SPIGOT-3379: Generalise canPickupItems to other entities.
Dieser Commit ist enthalten in:
Ursprung
de76085596
Commit
d7cd7275f2
@ -16,6 +16,15 @@
|
||||
public abstract class EntityInsentient extends EntityLiving {
|
||||
|
||||
private static final DataWatcherObject<Byte> a = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.a);
|
||||
@@ -27,7 +36,7 @@
|
||||
public float[] dropChanceHand;
|
||||
private final NonNullList<ItemStack> by;
|
||||
public float[] dropChanceArmor;
|
||||
- public boolean canPickUpLoot;
|
||||
+ // public boolean canPickUpLoot; // CraftBukkit - moved up to EntityLiving
|
||||
public boolean persistent;
|
||||
private final Map<PathType, Float> bB;
|
||||
private MinecraftKey bC;
|
||||
@@ -57,6 +66,9 @@
|
||||
this.r();
|
||||
}
|
||||
|
@ -88,7 +88,7 @@
|
||||
+ if (this.pickupDelay <= 0 && canHold > 0) {
|
||||
+ itemstack.setCount(canHold);
|
||||
+ PlayerPickupItemEvent event = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
|
||||
+ // event.setCancelled(!entityhuman.canPickUpLoot); TODO
|
||||
+ event.setCancelled(!entityhuman.canPickUpLoot);
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+ itemstack.setCount(canHold + remaining);
|
||||
+
|
||||
|
@ -25,7 +25,7 @@
|
||||
public abstract class EntityLiving extends Entity {
|
||||
|
||||
private static final Logger a = LogManager.getLogger();
|
||||
@@ -88,6 +106,14 @@
|
||||
@@ -88,6 +106,15 @@
|
||||
private BlockPosition bF;
|
||||
private DamageSource bG;
|
||||
private long bH;
|
||||
@ -36,11 +36,12 @@
|
||||
+ ArrayList<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
|
||||
+ public org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes;
|
||||
+ public boolean collides = true;
|
||||
+ public boolean canPickUpLoot;
|
||||
+ // CraftBukkit end
|
||||
|
||||
public void killEntity() {
|
||||
this.damageEntity(DamageSource.OUT_OF_WORLD, Float.MAX_VALUE);
|
||||
@@ -102,7 +128,8 @@
|
||||
@@ -102,7 +129,8 @@
|
||||
this.updateEffects = true;
|
||||
this.activeItem = ItemStack.a;
|
||||
this.initAttributes();
|
||||
@ -50,7 +51,7 @@
|
||||
this.i = true;
|
||||
this.aM = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
|
||||
this.setPosition(this.locX, this.locY, this.locZ);
|
||||
@@ -140,7 +167,13 @@
|
||||
@@ -140,7 +168,13 @@
|
||||
double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D);
|
||||
int i = (int) (150.0D * d1);
|
||||
|
||||
@ -65,7 +66,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,7 +235,11 @@
|
||||
@@ -202,7 +236,11 @@
|
||||
this.stopRiding();
|
||||
}
|
||||
} else {
|
||||
@ -78,7 +79,7 @@
|
||||
}
|
||||
|
||||
if (!this.world.isClientSide) {
|
||||
@@ -259,6 +296,18 @@
|
||||
@@ -259,6 +297,18 @@
|
||||
this.world.methodProfiler.b();
|
||||
}
|
||||
|
||||
@ -97,7 +98,7 @@
|
||||
protected void b(BlockPosition blockposition) {
|
||||
int i = EnchantmentManager.a(Enchantments.j, this);
|
||||
|
||||
@@ -274,19 +323,19 @@
|
||||
@@ -274,19 +324,19 @@
|
||||
|
||||
protected void bO() {
|
||||
++this.deathTicks;
|
||||
@ -126,7 +127,7 @@
|
||||
|
||||
this.die();
|
||||
|
||||
@@ -442,6 +491,17 @@
|
||||
@@ -442,6 +492,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -144,7 +145,7 @@
|
||||
if (nbttagcompound.hasKeyOfType("Health", 99)) {
|
||||
this.setHealth(nbttagcompound.getFloat("Health"));
|
||||
}
|
||||
@@ -464,9 +524,15 @@
|
||||
@@ -464,9 +525,15 @@
|
||||
|
||||
}
|
||||
|
||||
@ -160,7 +161,7 @@
|
||||
try {
|
||||
while (iterator.hasNext()) {
|
||||
MobEffectList mobeffectlist = (MobEffectList) iterator.next();
|
||||
@@ -484,6 +550,17 @@
|
||||
@@ -484,6 +551,17 @@
|
||||
} catch (ConcurrentModificationException concurrentmodificationexception) {
|
||||
;
|
||||
}
|
||||
@ -178,7 +179,7 @@
|
||||
|
||||
if (this.updateEffects) {
|
||||
if (!this.world.isClientSide) {
|
||||
@@ -585,6 +662,12 @@
|
||||
@@ -585,6 +663,12 @@
|
||||
}
|
||||
|
||||
public void addEffect(MobEffect mobeffect) {
|
||||
@ -191,7 +192,7 @@
|
||||
if (this.d(mobeffect)) {
|
||||
MobEffect mobeffect1 = (MobEffect) this.effects.get(mobeffect.getMobEffect());
|
||||
|
||||
@@ -617,6 +700,12 @@
|
||||
@@ -617,6 +701,12 @@
|
||||
|
||||
@Nullable
|
||||
public MobEffect c(@Nullable MobEffectList mobeffectlist) {
|
||||
@ -204,7 +205,7 @@
|
||||
return (MobEffect) this.effects.remove(mobeffectlist);
|
||||
}
|
||||
|
||||
@@ -656,20 +745,52 @@
|
||||
@@ -656,20 +746,52 @@
|
||||
|
||||
}
|
||||
|
||||
@ -258,7 +259,7 @@
|
||||
this.datawatcher.set(EntityLiving.HEALTH, Float.valueOf(MathHelper.a(f, 0.0F, this.getMaxHealth())));
|
||||
}
|
||||
|
||||
@@ -687,14 +808,16 @@
|
||||
@@ -687,14 +809,16 @@
|
||||
} else {
|
||||
float f1 = f;
|
||||
|
||||
@ -278,7 +279,7 @@
|
||||
this.damageShield(f);
|
||||
f = 0.0F;
|
||||
if (!damagesource.a()) {
|
||||
@@ -713,20 +836,39 @@
|
||||
@@ -713,20 +837,39 @@
|
||||
|
||||
if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) {
|
||||
if (f <= this.lastDamage) {
|
||||
@ -320,7 +321,7 @@
|
||||
this.aA = 0.0F;
|
||||
Entity entity1 = damagesource.getEntity();
|
||||
|
||||
@@ -833,18 +975,26 @@
|
||||
@@ -833,18 +976,26 @@
|
||||
EnumHand[] aenumhand = EnumHand.values();
|
||||
int i = aenumhand.length;
|
||||
|
||||
@ -350,7 +351,7 @@
|
||||
if (this instanceof EntityPlayer) {
|
||||
EntityPlayer entityplayer = (EntityPlayer) this;
|
||||
|
||||
@@ -859,7 +1009,7 @@
|
||||
@@ -859,7 +1010,7 @@
|
||||
this.world.broadcastEntityEffect(this, (byte) 35);
|
||||
}
|
||||
|
||||
@ -359,7 +360,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -944,6 +1094,12 @@
|
||||
@@ -944,6 +1095,12 @@
|
||||
boolean flag = this.lastDamageByPlayerTime > 0;
|
||||
|
||||
this.a(flag, i, damagesource);
|
||||
@ -372,7 +373,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1033,8 +1189,13 @@
|
||||
@@ -1033,8 +1190,13 @@
|
||||
int i = MathHelper.f((f - 3.0F - f2) * f1);
|
||||
|
||||
if (i > 0) {
|
||||
@ -387,7 +388,7 @@
|
||||
int j = MathHelper.floor(this.locX);
|
||||
int k = MathHelper.floor(this.locY - 0.20000000298023224D);
|
||||
int l = MathHelper.floor(this.locZ);
|
||||
@@ -1061,7 +1222,7 @@
|
||||
@@ -1061,7 +1223,7 @@
|
||||
|
||||
protected float applyArmorModifier(DamageSource damagesource, float f) {
|
||||
if (!damagesource.ignoresArmor()) {
|
||||
@ -396,7 +397,7 @@
|
||||
f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.getAttributeInstance(GenericAttributes.i).getValue());
|
||||
}
|
||||
|
||||
@@ -1074,7 +1235,8 @@
|
||||
@@ -1074,7 +1236,8 @@
|
||||
} else {
|
||||
int i;
|
||||
|
||||
@ -406,7 +407,7 @@
|
||||
i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
|
||||
int j = 25 - i;
|
||||
float f1 = f * (float) j;
|
||||
@@ -1095,22 +1257,142 @@
|
||||
@@ -1095,22 +1258,142 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -559,7 +560,7 @@
|
||||
}
|
||||
|
||||
public CombatTracker getCombatTracker() {
|
||||
@@ -1177,6 +1459,7 @@
|
||||
@@ -1177,6 +1460,7 @@
|
||||
public AttributeMapBase getAttributeMap() {
|
||||
if (this.attributeMap == null) {
|
||||
this.attributeMap = new AttributeMapServer();
|
||||
@ -567,7 +568,7 @@
|
||||
}
|
||||
|
||||
return this.attributeMap;
|
||||
@@ -1469,6 +1752,7 @@
|
||||
@@ -1469,6 +1753,7 @@
|
||||
}
|
||||
|
||||
if (this.onGround && !this.world.isClientSide) {
|
||||
@ -575,7 +576,7 @@
|
||||
this.setFlag(7, false);
|
||||
}
|
||||
} else {
|
||||
@@ -1838,6 +2122,7 @@
|
||||
@@ -1838,6 +2123,7 @@
|
||||
}
|
||||
|
||||
if (!this.world.isClientSide) {
|
||||
@ -583,7 +584,7 @@
|
||||
this.setFlag(7, flag);
|
||||
}
|
||||
|
||||
@@ -1931,11 +2216,11 @@
|
||||
@@ -1931,11 +2217,11 @@
|
||||
}
|
||||
|
||||
public boolean isInteractable() {
|
||||
@ -597,7 +598,7 @@
|
||||
}
|
||||
|
||||
protected void ax() {
|
||||
@@ -2072,7 +2357,27 @@
|
||||
@@ -2072,7 +2358,27 @@
|
||||
protected void v() {
|
||||
if (!this.activeItem.isEmpty() && this.isHandRaised()) {
|
||||
this.b(this.activeItem, 16);
|
||||
@ -626,7 +627,7 @@
|
||||
this.cN();
|
||||
}
|
||||
|
||||
@@ -2151,10 +2456,18 @@
|
||||
@@ -2151,10 +2457,18 @@
|
||||
}
|
||||
|
||||
if (flag1) {
|
||||
|
@ -435,13 +435,11 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
|
||||
}
|
||||
|
||||
public void setCanPickupItems(boolean pickup) {
|
||||
if (getHandle() instanceof EntityInsentient) {
|
||||
((EntityInsentient) getHandle()).canPickUpLoot = pickup;
|
||||
}
|
||||
getHandle().canPickUpLoot = pickup;
|
||||
}
|
||||
|
||||
public boolean getCanPickupItems() {
|
||||
return getHandle() instanceof EntityInsentient && ((EntityInsentient) getHandle()).canPickUpLoot;
|
||||
return getHandle().canPickUpLoot;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren