3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-25 07:40:06 +01:00
Paper/nms-patches/TileEntityBeacon.patch

154 Zeilen
4.8 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/TileEntityBeacon.java
+++ b/net/minecraft/server/TileEntityBeacon.java
2016-07-23 02:55:43 +02:00
@@ -9,19 +9,58 @@
2016-02-29 22:32:46 +01:00
import java.util.Set;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
2016-07-18 09:40:07 +02:00
+import org.bukkit.craftbukkit.potion.CraftPotionUtil;
+import org.bukkit.entity.HumanEntity;
2016-07-18 09:40:07 +02:00
+import org.bukkit.potion.PotionEffect;
+// CraftBukkit end
+
2016-02-29 22:32:46 +01:00
public class TileEntityBeacon extends TileEntityContainer implements ITickable, IWorldInventory {
2016-02-29 22:32:46 +01:00
public static final MobEffectList[][] a = new MobEffectList[][] { { MobEffects.FASTER_MOVEMENT, MobEffects.FASTER_DIG}, { MobEffects.RESISTANCE, MobEffects.JUMP}, { MobEffects.INCREASE_DAMAGE}, { MobEffects.REGENERATION}};
2016-07-18 09:40:07 +02:00
private static final Set<MobEffectList> f = Sets.newHashSet();
private final List<TileEntityBeacon.BeaconColorTracker> g = Lists.newArrayList();
private boolean j;
- private int k = -1;
+ public int k = -1; // PAIL: private -> public
@Nullable
2016-07-23 02:55:43 +02:00
- private MobEffectList l;
+ public MobEffectList l; // PAIL: private -> public
2016-07-18 09:40:07 +02:00
@Nullable
2016-07-23 02:55:43 +02:00
- private MobEffectList m;
+ public MobEffectList m; // PAIL: private -> public
private ItemStack inventorySlot;
2016-02-29 22:32:46 +01:00
private String o;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
+
+ public ItemStack[] getContents() {
+ return new ItemStack[] { this.inventorySlot };
+ }
+
+ public void onOpen(CraftHumanEntity who) {
+ transaction.add(who);
+ }
+
+ public void onClose(CraftHumanEntity who) {
+ transaction.remove(who);
+ }
+
+ public List<HumanEntity> getViewers() {
+ return transaction;
+ }
+
+ public void setMaxStackSize(int size) {
+ maxStack = size;
+ }
2016-07-18 09:40:07 +02:00
+
+ public PotionEffect getPrimaryEffect() {
2016-07-23 02:55:43 +02:00
+ return (this.l != null) ? CraftPotionUtil.toBukkit(new MobEffect(this.l, getLevel(), getAmplification(), true, true)) : null;
2016-07-18 09:40:07 +02:00
+ }
+
+ public PotionEffect getSecondaryEffect() {
2016-07-23 02:55:43 +02:00
+ return (hasSecondaryEffect()) ? CraftPotionUtil.toBukkit(new MobEffect(this.m, getLevel(), getAmplification(), true, true)) : null;
2016-07-18 09:40:07 +02:00
+ }
+ // CraftBukkit end
public TileEntityBeacon() {}
2016-07-23 02:55:43 +02:00
@@ -40,41 +79,79 @@
2016-07-18 09:40:07 +02:00
}
- private void E() {
- if (this.j && this.k > 0 && !this.world.isClientSide && this.l != null) {
- double d0 = (double) (this.k * 10 + 10);
+ // CraftBukkit start - split into components
+ private byte getAmplification() {
+ {
byte b0 = 0;
if (this.k >= 4 && this.l == this.m) {
b0 = 1;
}
+ return b0;
+ }
+ }
+
+ private int getLevel() {
+ {
int i = (9 + this.k * 2) * 20;
+ return i;
+ }
+ }
+
+ public List getHumansInRange() {
+ {
+ double d0 = (double) (this.k * 10 + 10);
+
int j = this.position.getX();
int k = this.position.getY();
int l = this.position.getZ();
AxisAlignedBB axisalignedbb = (new AxisAlignedBB((double) j, (double) k, (double) l, (double) (j + 1), (double) (k + 1), (double) (l + 1))).g(d0).a(0.0D, (double) this.world.getHeight(), 0.0D);
List list = this.world.a(EntityHuman.class, axisalignedbb);
+
+ return list;
+ }
+ }
+
+ private void applyEffect(List list, MobEffectList effects, int i, int b0) {
+ {
Iterator iterator = list.iterator();
EntityHuman entityhuman;
while (iterator.hasNext()) {
entityhuman = (EntityHuman) iterator.next();
- entityhuman.addEffect(new MobEffect(this.l, i, b0, true, true));
+ entityhuman.addEffect(new MobEffect(effects, i, b0, true, true));
}
+ }
+ }
+ private boolean hasSecondaryEffect() {
+ {
if (this.k >= 4 && this.l != this.m && this.m != null) {
- iterator = list.iterator();
+ return true;
+ }
+
+ return false;
+ }
+ }
+
+ private void E() {
+ if (this.j && this.k > 0 && !this.world.isClientSide && this.l != null) {
+ byte b0 = getAmplification();
+
+ int i = getLevel();
+ List list = getHumansInRange();
+
+ applyEffect(list, this.l, i, b0);
- while (iterator.hasNext()) {
- entityhuman = (EntityHuman) iterator.next();
- entityhuman.addEffect(new MobEffect(this.m, i, 0, true, true));
- }
+ if (hasSecondaryEffect()) {
+ applyEffect(list, this.m, i, 0);
}
}
}
+ // CraftBukkit end
private void F() {
int i = this.k;