792
paper-server/nms-patches/net/minecraft/world/entity/Entity.patch
Normal file
792
paper-server/nms-patches/net/minecraft/world/entity/Entity.patch
Normal file
@@ -0,0 +1,792 @@
|
||||
--- a/net/minecraft/server/Entity.java
|
||||
+++ b/net/minecraft/server/Entity.java
|
||||
@@ -21,8 +21,58 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.Server;
|
||||
+import org.bukkit.block.BlockFace;
|
||||
+import org.bukkit.command.CommandSender;
|
||||
+import org.bukkit.craftbukkit.event.CraftPortalEvent;
|
||||
+import org.bukkit.entity.Hanging;
|
||||
+import org.bukkit.entity.LivingEntity;
|
||||
+import org.bukkit.entity.Vehicle;
|
||||
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
+import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
+import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
|
||||
+import org.bukkit.event.vehicle.VehicleEnterEvent;
|
||||
+import org.bukkit.event.vehicle.VehicleExitEvent;
|
||||
+import org.bukkit.craftbukkit.CraftWorld;
|
||||
+import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.entity.Pose;
|
||||
+import org.bukkit.event.entity.EntityAirChangeEvent;
|
||||
+import org.bukkit.event.entity.EntityCombustEvent;
|
||||
+import org.bukkit.event.entity.EntityDropItemEvent;
|
||||
+import org.bukkit.event.entity.EntityPortalEvent;
|
||||
+import org.bukkit.event.entity.EntityPoseChangeEvent;
|
||||
+import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
+import org.bukkit.plugin.PluginManager;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class Entity implements INamableTileEntity, ICommandListener {
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private static final int CURRENT_LEVEL = 2;
|
||||
+ static boolean isLevelAtLeast(NBTTagCompound tag, int level) {
|
||||
+ return tag.hasKey("Bukkit.updateLevel") && tag.getInt("Bukkit.updateLevel") >= level;
|
||||
+ }
|
||||
+
|
||||
+ private CraftEntity bukkitEntity;
|
||||
+
|
||||
+ public CraftEntity getBukkitEntity() {
|
||||
+ if (bukkitEntity == null) {
|
||||
+ bukkitEntity = CraftEntity.getEntity(world.getServer(), this);
|
||||
+ }
|
||||
+ return bukkitEntity;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
|
||||
+ return getBukkitEntity();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
protected static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final AtomicInteger entityCount = new AtomicInteger();
|
||||
private static final List<ItemStack> c = Collections.emptyList();
|
||||
@@ -106,6 +156,21 @@
|
||||
private long aB;
|
||||
private EntitySize size;
|
||||
private float headHeight;
|
||||
+ // CraftBukkit start
|
||||
+ public boolean persist = true;
|
||||
+ public boolean valid;
|
||||
+ public org.bukkit.projectiles.ProjectileSource projectileSource; // For projectiles only
|
||||
+ public boolean forceExplosionKnockback; // SPIGOT-949
|
||||
+ public boolean persistentInvisibility = false;
|
||||
+
|
||||
+ public float getBukkitYaw() {
|
||||
+ return this.yaw;
|
||||
+ }
|
||||
+
|
||||
+ public boolean isChunkLoaded() {
|
||||
+ return world.isChunkLoaded((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
public Entity(EntityTypes<?> entitytypes, World world) {
|
||||
this.id = Entity.entityCount.incrementAndGet();
|
||||
@@ -212,6 +277,12 @@
|
||||
}
|
||||
|
||||
public void setPose(EntityPose entitypose) {
|
||||
+ // CraftBukkit start
|
||||
+ if (entitypose == this.getPose()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ this.world.getServer().getPluginManager().callEvent(new EntityPoseChangeEvent(this.getBukkitEntity(), Pose.values()[entitypose.ordinal()]));
|
||||
+ // CraftBukkit end
|
||||
this.datawatcher.set(Entity.POSE, entitypose);
|
||||
}
|
||||
|
||||
@@ -228,6 +299,33 @@
|
||||
}
|
||||
|
||||
protected void setYawPitch(float f, float f1) {
|
||||
+ // CraftBukkit start - yaw was sometimes set to NaN, so we need to set it back to 0
|
||||
+ if (Float.isNaN(f)) {
|
||||
+ f = 0;
|
||||
+ }
|
||||
+
|
||||
+ if (f == Float.POSITIVE_INFINITY || f == Float.NEGATIVE_INFINITY) {
|
||||
+ if (this instanceof EntityPlayer) {
|
||||
+ this.world.getServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid yaw");
|
||||
+ ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite yaw (Hacking?)");
|
||||
+ }
|
||||
+ f = 0;
|
||||
+ }
|
||||
+
|
||||
+ // pitch was sometimes set to NaN, so we need to set it back to 0
|
||||
+ if (Float.isNaN(f1)) {
|
||||
+ f1 = 0;
|
||||
+ }
|
||||
+
|
||||
+ if (f1 == Float.POSITIVE_INFINITY || f1 == Float.NEGATIVE_INFINITY) {
|
||||
+ if (this instanceof EntityPlayer) {
|
||||
+ this.world.getServer().getLogger().warning(this.getName() + " was caught trying to crash the server with an invalid pitch");
|
||||
+ ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Infinite pitch (Hacking?)");
|
||||
+ }
|
||||
+ f1 = 0;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.yaw = f % 360.0F;
|
||||
this.pitch = f1 % 360.0F;
|
||||
}
|
||||
@@ -235,6 +333,7 @@
|
||||
public void setPosition(double d0, double d1, double d2) {
|
||||
this.setPositionRaw(d0, d1, d2);
|
||||
this.a(this.size.a(d0, d1, d2));
|
||||
+ if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit
|
||||
}
|
||||
|
||||
protected void af() {
|
||||
@@ -249,6 +348,15 @@
|
||||
this.entityBaseTick();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void postTick() {
|
||||
+ // No clean way to break out of ticking once the entity has been copied to a new world, so instead we move the portalling later in the tick cycle
|
||||
+ if (!(this instanceof EntityPlayer)) {
|
||||
+ this.doPortalTick();
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void entityBaseTick() {
|
||||
this.world.getMethodProfiler().enter("entityBaseTick");
|
||||
if (this.isPassenger() && this.getVehicle().dead) {
|
||||
@@ -262,7 +370,7 @@
|
||||
this.z = this.A;
|
||||
this.lastPitch = this.pitch;
|
||||
this.lastYaw = this.yaw;
|
||||
- this.doPortalTick();
|
||||
+ if (this instanceof EntityPlayer) this.doPortalTick(); // CraftBukkit - // Moved up to postTick
|
||||
if (this.aO()) {
|
||||
this.aP();
|
||||
}
|
||||
@@ -325,12 +433,44 @@
|
||||
|
||||
protected void burnFromLava() {
|
||||
if (!this.isFireProof()) {
|
||||
- this.setOnFire(15);
|
||||
+ // CraftBukkit start - Fallen in lava TODO: this event spams!
|
||||
+ if (this instanceof EntityLiving && fireTicks <= 0) {
|
||||
+ // not on fire yet
|
||||
+ // TODO: shouldn't be sending null for the block
|
||||
+ org.bukkit.block.Block damager = null; // ((WorldServer) this.l).getWorld().getBlockAt(i, j, k);
|
||||
+ org.bukkit.entity.Entity damagee = this.getBukkitEntity();
|
||||
+ EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15);
|
||||
+ this.world.getServer().getPluginManager().callEvent(combustEvent);
|
||||
+
|
||||
+ if (!combustEvent.isCancelled()) {
|
||||
+ this.setOnFire(combustEvent.getDuration(), false);
|
||||
+ }
|
||||
+ } else {
|
||||
+ // This will be called every single tick the entity is in lava, so don't throw an event
|
||||
+ this.setOnFire(15, false);
|
||||
+ }
|
||||
+ // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
|
||||
this.damageEntity(DamageSource.LAVA, 4.0F);
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnFire(int i) {
|
||||
+ // CraftBukkit start
|
||||
+ this.setOnFire(i, true);
|
||||
+ }
|
||||
+
|
||||
+ public void setOnFire(int i, boolean callEvent) {
|
||||
+ if (callEvent) {
|
||||
+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), i);
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ i = event.getDuration();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
int j = i * 20;
|
||||
|
||||
if (this instanceof EntityLiving) {
|
||||
@@ -427,6 +567,28 @@
|
||||
block.a((IBlockAccess) this.world, this);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (positionChanged && getBukkitEntity() instanceof Vehicle) {
|
||||
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
|
||||
+ org.bukkit.block.Block bl = this.world.getWorld().getBlockAt(MathHelper.floor(this.locX()), MathHelper.floor(this.locY()), MathHelper.floor(this.locZ()));
|
||||
+
|
||||
+ if (vec3d.x > vec3d1.x) {
|
||||
+ bl = bl.getRelative(BlockFace.EAST);
|
||||
+ } else if (vec3d.x < vec3d1.x) {
|
||||
+ bl = bl.getRelative(BlockFace.WEST);
|
||||
+ } else if (vec3d.z > vec3d1.z) {
|
||||
+ bl = bl.getRelative(BlockFace.SOUTH);
|
||||
+ } else if (vec3d.z < vec3d1.z) {
|
||||
+ bl = bl.getRelative(BlockFace.NORTH);
|
||||
+ }
|
||||
+
|
||||
+ if (!bl.getType().isAir()) {
|
||||
+ VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, bl);
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (this.onGround && !this.bv()) {
|
||||
block.stepOn(this.world, blockposition, this);
|
||||
}
|
||||
@@ -700,6 +862,7 @@
|
||||
AxisAlignedBB axisalignedbb = this.getBoundingBox();
|
||||
|
||||
this.setPositionRaw((axisalignedbb.minX + axisalignedbb.maxX) / 2.0D, axisalignedbb.minY, (axisalignedbb.minZ + axisalignedbb.maxZ) / 2.0D);
|
||||
+ if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit
|
||||
}
|
||||
|
||||
protected SoundEffect getSoundSwim() {
|
||||
@@ -1025,6 +1188,13 @@
|
||||
}
|
||||
|
||||
public void spawnIn(World world) {
|
||||
+ // CraftBukkit start
|
||||
+ if (world == null) {
|
||||
+ die();
|
||||
+ this.world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle();
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
@@ -1044,6 +1214,7 @@
|
||||
this.lastY = d1;
|
||||
this.lastZ = d4;
|
||||
this.setPosition(d3, d1, d4);
|
||||
+ world.getChunkAt((int) Math.floor(this.locX()) >> 4, (int) Math.floor(this.locZ()) >> 4); // CraftBukkit
|
||||
}
|
||||
|
||||
public void d(Vec3D vec3d) {
|
||||
@@ -1218,6 +1389,12 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - collidable API
|
||||
+ public boolean canCollideWith(Entity entity) {
|
||||
+ return isCollidable();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void a(Entity entity, int i, DamageSource damagesource) {
|
||||
if (entity instanceof EntityPlayer) {
|
||||
CriterionTriggers.c.a((EntityPlayer) entity, this, damagesource);
|
||||
@@ -1228,7 +1405,7 @@
|
||||
public boolean a_(NBTTagCompound nbttagcompound) {
|
||||
String s = this.getSaveID();
|
||||
|
||||
- if (!this.dead && s != null) {
|
||||
+ if (this.persist && !this.dead && s != null) { // CraftBukkit - persist flag
|
||||
nbttagcompound.setString("id", s);
|
||||
this.save(nbttagcompound);
|
||||
return true;
|
||||
@@ -1252,6 +1429,18 @@
|
||||
Vec3D vec3d = this.getMot();
|
||||
|
||||
nbttagcompound.set("Motion", this.a(vec3d.x, vec3d.y, vec3d.z));
|
||||
+
|
||||
+ // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero
|
||||
+ // TODO: make sure this is the best way to address this.
|
||||
+ if (Float.isNaN(this.yaw)) {
|
||||
+ this.yaw = 0;
|
||||
+ }
|
||||
+
|
||||
+ if (Float.isNaN(this.pitch)) {
|
||||
+ this.pitch = 0;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
nbttagcompound.set("Rotation", this.a(this.yaw, this.pitch));
|
||||
nbttagcompound.setFloat("FallDistance", this.fallDistance);
|
||||
nbttagcompound.setShort("Fire", (short) this.fireTicks);
|
||||
@@ -1260,6 +1449,18 @@
|
||||
nbttagcompound.setBoolean("Invulnerable", this.invulnerable);
|
||||
nbttagcompound.setInt("PortalCooldown", this.portalCooldown);
|
||||
nbttagcompound.a("UUID", this.getUniqueID());
|
||||
+ // CraftBukkit start
|
||||
+ // PAIL: Check above UUID reads 1.8 properly, ie: UUIDMost / UUIDLeast
|
||||
+ nbttagcompound.setLong("WorldUUIDLeast", ((WorldServer) this.world).getWorld().getUID().getLeastSignificantBits());
|
||||
+ nbttagcompound.setLong("WorldUUIDMost", ((WorldServer) this.world).getWorld().getUID().getMostSignificantBits());
|
||||
+ nbttagcompound.setInt("Bukkit.updateLevel", CURRENT_LEVEL);
|
||||
+ if (!this.persist) {
|
||||
+ nbttagcompound.setBoolean("Bukkit.persist", this.persist);
|
||||
+ }
|
||||
+ if (this.persistentInvisibility) {
|
||||
+ nbttagcompound.setBoolean("Bukkit.invisible", this.persistentInvisibility);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
IChatBaseComponent ichatbasecomponent = this.getCustomName();
|
||||
|
||||
if (ichatbasecomponent != null) {
|
||||
@@ -1317,6 +1518,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - stores eventually existing bukkit values
|
||||
+ if (this.bukkitEntity != null) {
|
||||
+ this.bukkitEntity.storeBukkitValues(nbttagcompound);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return nbttagcompound;
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.a(throwable, "Saving entity NBT");
|
||||
@@ -1394,6 +1600,49 @@
|
||||
} else {
|
||||
throw new IllegalStateException("Entity has invalid position");
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ if (this instanceof EntityLiving) {
|
||||
+ EntityLiving entity = (EntityLiving) this;
|
||||
+
|
||||
+ // Reset the persistence for tamed animals
|
||||
+ if (entity instanceof EntityTameableAnimal && !isLevelAtLeast(nbttagcompound, 2) && !nbttagcompound.getBoolean("PersistenceRequired")) {
|
||||
+ EntityInsentient entityinsentient = (EntityInsentient) entity;
|
||||
+ entityinsentient.persistent = !entityinsentient.isTypeNotPersistent(0);
|
||||
+ }
|
||||
+ }
|
||||
+ this.persist = !nbttagcompound.hasKey("Bukkit.persist") || nbttagcompound.getBoolean("Bukkit.persist");
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ // CraftBukkit start - Reset world
|
||||
+ if (this instanceof EntityPlayer) {
|
||||
+ Server server = Bukkit.getServer();
|
||||
+ org.bukkit.World bworld = null;
|
||||
+
|
||||
+ // TODO: Remove World related checks, replaced with WorldUID
|
||||
+ String worldName = nbttagcompound.getString("world");
|
||||
+
|
||||
+ if (nbttagcompound.hasKey("WorldUUIDMost") && nbttagcompound.hasKey("WorldUUIDLeast")) {
|
||||
+ UUID uid = new UUID(nbttagcompound.getLong("WorldUUIDMost"), nbttagcompound.getLong("WorldUUIDLeast"));
|
||||
+ bworld = server.getWorld(uid);
|
||||
+ } else {
|
||||
+ bworld = server.getWorld(worldName);
|
||||
+ }
|
||||
+
|
||||
+ if (bworld == null) {
|
||||
+ bworld = ((org.bukkit.craftbukkit.CraftServer) server).getServer().getWorldServer(World.OVERWORLD).getWorld();
|
||||
+ }
|
||||
+
|
||||
+ spawnIn(bworld == null ? null : ((CraftWorld) bworld).getHandle());
|
||||
+ }
|
||||
+ this.getBukkitEntity().readBukkitValues(nbttagcompound);
|
||||
+ if (nbttagcompound.hasKey("Bukkit.invisible")) {
|
||||
+ boolean bukkitInvisible = nbttagcompound.getBoolean("Bukkit.invisible");
|
||||
+ this.setInvisible(bukkitInvisible);
|
||||
+ this.persistentInvisibility = bukkitInvisible;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
} catch (Throwable throwable) {
|
||||
CrashReport crashreport = CrashReport.a(throwable, "Loading entity NBT");
|
||||
CrashReportSystemDetails crashreportsystemdetails = crashreport.a("Entity being loaded");
|
||||
@@ -1469,9 +1718,22 @@
|
||||
} else if (this.world.isClientSide) {
|
||||
return null;
|
||||
} else {
|
||||
+ // CraftBukkit start - Capture drops for death event
|
||||
+ if (this instanceof EntityLiving && !((EntityLiving) this).forceDrops) {
|
||||
+ ((EntityLiving) this).drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack));
|
||||
+ return null;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
EntityItem entityitem = new EntityItem(this.world, this.locX(), this.locY() + (double) f, this.locZ(), itemstack);
|
||||
|
||||
entityitem.defaultPickupDelay();
|
||||
+ // CraftBukkit start
|
||||
+ EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
|
||||
+ Bukkit.getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.world.addEntity(entityitem);
|
||||
return entityitem;
|
||||
}
|
||||
@@ -1555,7 +1817,7 @@
|
||||
|
||||
this.setPose(EntityPose.STANDING);
|
||||
this.vehicle = entity;
|
||||
- this.vehicle.addPassenger(this);
|
||||
+ if (!this.vehicle.addPassenger(this)) this.vehicle = null; // CraftBukkit
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1580,7 +1842,7 @@
|
||||
Entity entity = this.vehicle;
|
||||
|
||||
this.vehicle = null;
|
||||
- entity.removePassenger(this);
|
||||
+ if (!entity.removePassenger(this)) this.vehicle = entity; // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1589,10 +1851,31 @@
|
||||
this.bf();
|
||||
}
|
||||
|
||||
- protected void addPassenger(Entity entity) {
|
||||
+ protected boolean addPassenger(Entity entity) { // CraftBukkit
|
||||
if (entity.getVehicle() != this) {
|
||||
throw new IllegalStateException("Use x.startRiding(y), not y.addPassenger(x)");
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ com.google.common.base.Preconditions.checkState(!entity.passengers.contains(this), "Circular entity riding! %s %s", this, entity);
|
||||
+
|
||||
+ CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
|
||||
+ Entity orig = craft == null ? null : craft.getHandle();
|
||||
+ if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
|
||||
+ VehicleEnterEvent event = new VehicleEnterEvent(
|
||||
+ (Vehicle) getBukkitEntity(),
|
||||
+ entity.getBukkitEntity()
|
||||
+ );
|
||||
+ // Suppress during worldgen
|
||||
+ if (this.valid) {
|
||||
+ Bukkit.getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+ CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle();
|
||||
+ Entity n = craftn == null ? null : craftn.getHandle();
|
||||
+ if (event.isCancelled() || n != orig) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (!this.world.isClientSide && entity instanceof EntityHuman && !(this.getRidingPassenger() instanceof EntityHuman)) {
|
||||
this.passengers.add(0, entity);
|
||||
} else {
|
||||
@@ -1600,15 +1883,36 @@
|
||||
}
|
||||
|
||||
}
|
||||
+ return true; // CraftBukkit
|
||||
}
|
||||
|
||||
- protected void removePassenger(Entity entity) {
|
||||
+ protected boolean removePassenger(Entity entity) { // CraftBukkit
|
||||
if (entity.getVehicle() == this) {
|
||||
throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ CraftEntity craft = (CraftEntity) entity.getBukkitEntity().getVehicle();
|
||||
+ Entity orig = craft == null ? null : craft.getHandle();
|
||||
+ if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
|
||||
+ VehicleExitEvent event = new VehicleExitEvent(
|
||||
+ (Vehicle) getBukkitEntity(),
|
||||
+ (LivingEntity) entity.getBukkitEntity()
|
||||
+ );
|
||||
+ // Suppress during worldgen
|
||||
+ if (this.valid) {
|
||||
+ Bukkit.getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+ CraftEntity craftn = (CraftEntity) entity.getBukkitEntity().getVehicle();
|
||||
+ Entity n = craftn == null ? null : craftn.getHandle();
|
||||
+ if (event.isCancelled() || n != orig) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.passengers.remove(entity);
|
||||
entity.j = 60;
|
||||
}
|
||||
+ return true; // CraftBukkit
|
||||
}
|
||||
|
||||
protected boolean q(Entity entity) {
|
||||
@@ -1646,14 +1950,20 @@
|
||||
|
||||
if (this.inPortal) {
|
||||
MinecraftServer minecraftserver = worldserver.getMinecraftServer();
|
||||
- ResourceKey<World> resourcekey = this.world.getDimensionKey() == World.THE_NETHER ? World.OVERWORLD : World.THE_NETHER;
|
||||
+ ResourceKey<World> resourcekey = this.world.getTypeKey() == DimensionManager.THE_NETHER ? World.OVERWORLD : World.THE_NETHER; // CraftBukkit
|
||||
WorldServer worldserver1 = minecraftserver.getWorldServer(resourcekey);
|
||||
|
||||
- if (worldserver1 != null && minecraftserver.getAllowNether() && !this.isPassenger() && this.portalTicks++ >= i) {
|
||||
+ if (true && !this.isPassenger() && this.portalTicks++ >= i) { // CraftBukkit
|
||||
this.world.getMethodProfiler().enter("portal");
|
||||
this.portalTicks = i;
|
||||
this.resetPortalCooldown();
|
||||
- this.b(worldserver1);
|
||||
+ // CraftBukkit start
|
||||
+ if (this instanceof EntityPlayer) {
|
||||
+ ((EntityPlayer) this).b(worldserver1, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL);
|
||||
+ } else {
|
||||
+ this.b(worldserver1);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.world.getMethodProfiler().exit();
|
||||
}
|
||||
|
||||
@@ -1753,6 +2063,13 @@
|
||||
}
|
||||
|
||||
public void setSwimming(boolean flag) {
|
||||
+ // CraftBukkit start
|
||||
+ if (this.isSwimming() != flag && this instanceof EntityLiving) {
|
||||
+ if (CraftEventFactory.callToggleSwimEvent((EntityLiving) this, flag).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.setFlag(4, flag);
|
||||
}
|
||||
|
||||
@@ -1785,8 +2102,12 @@
|
||||
return this.getScoreboardTeam() != null ? this.getScoreboardTeam().isAlly(scoreboardteambase) : false;
|
||||
}
|
||||
|
||||
+ // CraftBukkit - start
|
||||
public void setInvisible(boolean flag) {
|
||||
- this.setFlag(5, flag);
|
||||
+ if (!this.persistentInvisibility) { // Prevent Minecraft from removing our invisibility flag
|
||||
+ this.setFlag(5, flag);
|
||||
+ }
|
||||
+ // CraftBukkit - end
|
||||
}
|
||||
|
||||
public boolean getFlag(int i) {
|
||||
@@ -1813,16 +2134,56 @@
|
||||
}
|
||||
|
||||
public void setAirTicks(int i) {
|
||||
- this.datawatcher.set(Entity.AIR_TICKS, i);
|
||||
+ // CraftBukkit start
|
||||
+ EntityAirChangeEvent event = new EntityAirChangeEvent(this.getBukkitEntity(), i);
|
||||
+ // Suppress during worldgen
|
||||
+ if (this.valid) {
|
||||
+ event.getEntity().getServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ this.datawatcher.set(Entity.AIR_TICKS, event.getAmount());
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) {
|
||||
this.setFireTicks(this.fireTicks + 1);
|
||||
+ // CraftBukkit start
|
||||
+ final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity();
|
||||
+ final org.bukkit.entity.Entity stormBukkitEntity = entitylightning.getBukkitEntity();
|
||||
+ final PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (this.fireTicks == 0) {
|
||||
- this.setOnFire(8);
|
||||
+ // CraftBukkit start - Call a combust event when lightning strikes
|
||||
+ EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8);
|
||||
+ pluginManager.callEvent(entityCombustEvent);
|
||||
+ if (!entityCombustEvent.isCancelled()) {
|
||||
+ this.setOnFire(entityCombustEvent.getDuration(), false);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ if (thisBukkitEntity instanceof Hanging) {
|
||||
+ HangingBreakByEntityEvent hangingEvent = new HangingBreakByEntityEvent((Hanging) thisBukkitEntity, stormBukkitEntity);
|
||||
+ pluginManager.callEvent(hangingEvent);
|
||||
+
|
||||
+ if (hangingEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
}
|
||||
|
||||
- this.damageEntity(DamageSource.LIGHTNING, 5.0F);
|
||||
+ if (this.isFireProof()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ CraftEventFactory.entityDamage = entitylightning;
|
||||
+ if (!this.damageEntity(DamageSource.LIGHTNING, 5.0F)) {
|
||||
+ CraftEventFactory.entityDamage = null;
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void k(boolean flag) {
|
||||
@@ -1972,15 +2333,32 @@
|
||||
|
||||
@Nullable
|
||||
public Entity b(WorldServer worldserver) {
|
||||
+ // CraftBukkit start
|
||||
+ return teleportTo(worldserver, null);
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public Entity teleportTo(WorldServer worldserver, BlockPosition location) {
|
||||
+ // CraftBukkit end
|
||||
if (this.world instanceof WorldServer && !this.dead) {
|
||||
this.world.getMethodProfiler().enter("changeDimension");
|
||||
- this.decouple();
|
||||
+ // CraftBukkit start
|
||||
+ // this.decouple();
|
||||
+ if (worldserver == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.world.getMethodProfiler().enter("reposition");
|
||||
- ShapeDetectorShape shapedetectorshape = this.a(worldserver);
|
||||
+ ShapeDetectorShape shapedetectorshape = (location == null) ? this.a(worldserver) : new ShapeDetectorShape(new Vec3D(location.getX(), location.getY(), location.getZ()), Vec3D.ORIGIN, this.yaw, this.pitch, worldserver, null); // CraftBukkit
|
||||
|
||||
if (shapedetectorshape == null) {
|
||||
return null;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ worldserver = shapedetectorshape.world;
|
||||
+ this.decouple();
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.world.getMethodProfiler().exitEnter("reloading");
|
||||
Entity entity = this.getEntityType().a((World) worldserver);
|
||||
|
||||
@@ -1989,9 +2367,17 @@
|
||||
entity.setPositionRotation(shapedetectorshape.position.x, shapedetectorshape.position.y, shapedetectorshape.position.z, shapedetectorshape.yaw, entity.pitch);
|
||||
entity.setMot(shapedetectorshape.velocity);
|
||||
worldserver.addEntityTeleport(entity);
|
||||
- if (worldserver.getDimensionKey() == World.THE_END) {
|
||||
- WorldServer.a(worldserver);
|
||||
+ if (worldserver.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit
|
||||
+ WorldServer.a(worldserver, this); // CraftBukkit
|
||||
}
|
||||
+ // CraftBukkit start - Forward the CraftEntity to the new entity
|
||||
+ this.getBukkitEntity().setHandle(entity);
|
||||
+ entity.bukkitEntity = this.getBukkitEntity();
|
||||
+
|
||||
+ if (this instanceof EntityInsentient) {
|
||||
+ ((EntityInsentient) this).unleash(true, false); // Unleash to prevent duping of leads.
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
this.bN();
|
||||
@@ -2012,13 +2398,18 @@
|
||||
|
||||
@Nullable
|
||||
protected ShapeDetectorShape a(WorldServer worldserver) {
|
||||
- boolean flag = this.world.getDimensionKey() == World.THE_END && worldserver.getDimensionKey() == World.OVERWORLD;
|
||||
- boolean flag1 = worldserver.getDimensionKey() == World.THE_END;
|
||||
+ // CraftBukkit start
|
||||
+ if (worldserver == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ boolean flag = this.world.getTypeKey() == DimensionManager.THE_END && worldserver.getTypeKey() == DimensionManager.OVERWORLD; // fromEndToOverworld
|
||||
+ boolean flag1 = worldserver.getTypeKey() == DimensionManager.THE_END; // targetIsEnd
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (!flag && !flag1) {
|
||||
- boolean flag2 = worldserver.getDimensionKey() == World.THE_NETHER;
|
||||
+ boolean flag2 = worldserver.getTypeKey() == DimensionManager.THE_NETHER; // CraftBukkit
|
||||
|
||||
- if (this.world.getDimensionKey() != World.THE_NETHER && !flag2) {
|
||||
+ if (this.world.getTypeKey() != DimensionManager.THE_NETHER && !flag2) {
|
||||
return null;
|
||||
} else {
|
||||
WorldBorder worldborder = worldserver.getWorldBorder();
|
||||
@@ -2028,8 +2419,16 @@
|
||||
double d3 = Math.min(2.9999872E7D, worldborder.h() - 16.0D);
|
||||
double d4 = DimensionManager.a(this.world.getDimensionManager(), worldserver.getDimensionManager());
|
||||
BlockPosition blockposition = new BlockPosition(MathHelper.a(this.locX() * d4, d0, d2), this.locY(), MathHelper.a(this.locZ() * d4, d1, d3));
|
||||
+ // CraftBukkit start
|
||||
+ CraftPortalEvent event = callPortalEvent(this, worldserver, blockposition, PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16);
|
||||
+ if (event == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ final WorldServer worldserverFinal = worldserver = ((CraftWorld) event.getTo().getWorld()).getHandle();
|
||||
+ blockposition = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
|
||||
|
||||
- return (ShapeDetectorShape) this.findOrCreatePortal(worldserver, blockposition, flag2).map((blockutil_rectangle) -> {
|
||||
+ return (ShapeDetectorShape) this.findOrCreatePortal(worldserver, blockposition, flag2, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius()).map((blockutil_rectangle) -> {
|
||||
+ // CraftBukkit end
|
||||
IBlockData iblockdata = this.world.getType(this.ac);
|
||||
EnumDirection.EnumAxis enumdirection_enumaxis;
|
||||
Vec3D vec3d;
|
||||
@@ -2046,8 +2445,8 @@
|
||||
vec3d = new Vec3D(0.5D, 0.0D, 0.0D);
|
||||
}
|
||||
|
||||
- return BlockPortalShape.a(worldserver, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.a(this.getPose()), this.getMot(), this.yaw, this.pitch);
|
||||
- }).orElse((Object) null);
|
||||
+ return BlockPortalShape.a(worldserverFinal, blockutil_rectangle, enumdirection_enumaxis, vec3d, this.a(this.getPose()), this.getMot(), this.yaw, this.pitch, event); // CraftBukkit
|
||||
+ }).orElse(null); // CraftBuukkit - decompile error
|
||||
}
|
||||
} else {
|
||||
BlockPosition blockposition1;
|
||||
@@ -2057,8 +2456,15 @@
|
||||
} else {
|
||||
blockposition1 = worldserver.getHighestBlockYAt(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSpawn());
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ CraftPortalEvent event = callPortalEvent(this, worldserver, blockposition1, PlayerTeleportEvent.TeleportCause.END_PORTAL, 0, 0);
|
||||
+ if (event == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ blockposition1 = new BlockPosition(event.getTo().getX(), event.getTo().getY(), event.getTo().getZ());
|
||||
|
||||
- return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getMot(), this.yaw, this.pitch);
|
||||
+ return new ShapeDetectorShape(new Vec3D((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY(), (double) blockposition1.getZ() + 0.5D), this.getMot(), this.yaw, this.pitch, ((CraftWorld) event.getTo().getWorld()).getHandle(), event);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2066,8 +2472,23 @@
|
||||
return BlockPortalShape.a(blockutil_rectangle, enumdirection_enumaxis, this.getPositionVector(), this.a(this.getPose()));
|
||||
}
|
||||
|
||||
- protected Optional<BlockUtil.Rectangle> findOrCreatePortal(WorldServer worldserver, BlockPosition blockposition, boolean flag) {
|
||||
- return worldserver.getTravelAgent().findPortal(blockposition, flag);
|
||||
+ // CraftBukkit start
|
||||
+ protected CraftPortalEvent callPortalEvent(Entity entity, WorldServer exitWorldServer, BlockPosition exitPosition, PlayerTeleportEvent.TeleportCause cause, int searchRadius, int creationRadius) {
|
||||
+ org.bukkit.entity.Entity bukkitEntity = entity.getBukkitEntity();
|
||||
+ Location enter = bukkitEntity.getLocation();
|
||||
+ Location exit = new Location(exitWorldServer.getWorld(), exitPosition.getX(), exitPosition.getY(), exitPosition.getZ());
|
||||
+
|
||||
+ EntityPortalEvent event = new EntityPortalEvent(bukkitEntity, enter, exit, searchRadius);
|
||||
+ event.getEntity().getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled() || event.getTo() == null || event.getTo().getWorld() == null || !entity.isAlive()) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ return new CraftPortalEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ protected Optional<BlockUtil.Rectangle> findOrCreatePortal(WorldServer worldserver, BlockPosition blockposition, boolean flag, int searchRadius, boolean canCreatePortal, int createRadius) {
|
||||
+ return worldserver.getTravelAgent().findPortal(blockposition, searchRadius);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public boolean canPortal() {
|
||||
@@ -2253,7 +2674,26 @@
|
||||
}
|
||||
|
||||
public void a(AxisAlignedBB axisalignedbb) {
|
||||
- this.boundingBox = axisalignedbb;
|
||||
+ // CraftBukkit start - block invalid bounding boxes
|
||||
+ double minX = axisalignedbb.minX,
|
||||
+ minY = axisalignedbb.minY,
|
||||
+ minZ = axisalignedbb.minZ,
|
||||
+ maxX = axisalignedbb.maxX,
|
||||
+ maxY = axisalignedbb.maxY,
|
||||
+ maxZ = axisalignedbb.maxZ;
|
||||
+ double len = axisalignedbb.maxX - axisalignedbb.minX;
|
||||
+ if (len < 0) maxX = minX;
|
||||
+ if (len > 64) maxX = minX + 64.0;
|
||||
+
|
||||
+ len = axisalignedbb.maxY - axisalignedbb.minY;
|
||||
+ if (len < 0) maxY = minY;
|
||||
+ if (len > 64) maxY = minY + 64.0;
|
||||
+
|
||||
+ len = axisalignedbb.maxZ - axisalignedbb.minZ;
|
||||
+ if (len < 0) maxZ = minZ;
|
||||
+ if (len > 64) maxZ = minZ + 64.0;
|
||||
+ this.boundingBox = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
protected float getHeadHeight(EntityPose entitypose, EntitySize entitysize) {
|
||||
@@ -0,0 +1,35 @@
|
||||
--- a/net/minecraft/server/EntityAgeable.java
|
||||
+++ b/net/minecraft/server/EntityAgeable.java
|
||||
@@ -8,6 +8,7 @@
|
||||
protected int b;
|
||||
protected int c;
|
||||
protected int d;
|
||||
+ public boolean ageLocked; // CraftBukkit
|
||||
|
||||
protected EntityAgeable(EntityTypes<? extends EntityAgeable> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -91,6 +92,7 @@
|
||||
super.saveData(nbttagcompound);
|
||||
nbttagcompound.setInt("Age", this.getAge());
|
||||
nbttagcompound.setInt("ForcedAge", this.c);
|
||||
+ nbttagcompound.setBoolean("AgeLocked", this.ageLocked); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,6 +100,7 @@
|
||||
super.loadData(nbttagcompound);
|
||||
this.setAgeRaw(nbttagcompound.getInt("Age"));
|
||||
this.c = nbttagcompound.getInt("ForcedAge");
|
||||
+ this.ageLocked = nbttagcompound.getBoolean("AgeLocked"); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -112,7 +115,7 @@
|
||||
@Override
|
||||
public void movementTick() {
|
||||
super.movementTick();
|
||||
- if (this.world.isClientSide) {
|
||||
+ if (this.world.isClientSide || ageLocked) { // CraftBukkit
|
||||
if (this.d > 0) {
|
||||
if (this.d % 4 == 0) {
|
||||
this.world.addParticle(Particles.HAPPY_VILLAGER, this.d(1.0D), this.cF() + 0.5D, this.g(1.0D), 0.0D, 0.0D, 0.0D);
|
||||
@@ -0,0 +1,72 @@
|
||||
--- a/net/minecraft/server/EntityAreaEffectCloud.java
|
||||
+++ b/net/minecraft/server/EntityAreaEffectCloud.java
|
||||
@@ -14,6 +14,11 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||
+import org.bukkit.entity.LivingEntity;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityAreaEffectCloud extends Entity {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -105,6 +110,22 @@
|
||||
|
||||
}
|
||||
|
||||
+ // CraftBukkit start accessor methods
|
||||
+ public void refreshEffects() {
|
||||
+ if (!this.hasColor) {
|
||||
+ this.getDataWatcher().set(EntityAreaEffectCloud.COLOR, PotionUtil.a((Collection) PotionUtil.a(this.potionRegistry, (Collection) this.effects))); // PAIL: rename
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public String getType() {
|
||||
+ return ((MinecraftKey) IRegistry.POTION.getKey(this.potionRegistry)).toString();
|
||||
+ }
|
||||
+
|
||||
+ public void setType(String string) {
|
||||
+ a(IRegistry.POTION.get(new MinecraftKey(string)));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public int getColor() {
|
||||
return (Integer) this.getDataWatcher().get(EntityAreaEffectCloud.COLOR);
|
||||
}
|
||||
@@ -249,6 +270,7 @@
|
||||
if (!list1.isEmpty()) {
|
||||
Iterator iterator2 = list1.iterator();
|
||||
|
||||
+ List<LivingEntity> entities = new java.util.ArrayList<LivingEntity>(); // CraftBukkit
|
||||
while (iterator2.hasNext()) {
|
||||
EntityLiving entityliving = (EntityLiving) iterator2.next();
|
||||
|
||||
@@ -258,6 +280,17 @@
|
||||
double d2 = d0 * d0 + d1 * d1;
|
||||
|
||||
if (d2 <= (double) (f * f)) {
|
||||
+ // CraftBukkit start
|
||||
+ entities.add((LivingEntity) entityliving.getBukkitEntity());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ org.bukkit.event.entity.AreaEffectCloudApplyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callAreaEffectCloudApplyEvent(this, entities);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ for (LivingEntity entity : event.getAffectedEntities()) {
|
||||
+ if (entity instanceof CraftLivingEntity) {
|
||||
+ EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle();
|
||||
+ // CraftBukkit end
|
||||
this.affectedEntities.put(entityliving, this.ticksLived + this.reapplicationDelay);
|
||||
Iterator iterator3 = list.iterator();
|
||||
|
||||
@@ -267,7 +300,7 @@
|
||||
if (mobeffect1.getMobEffect().isInstant()) {
|
||||
mobeffect1.getMobEffect().applyInstantEffect(this, this.getSource(), entityliving, mobeffect1.getAmplifier(), 0.5D);
|
||||
} else {
|
||||
- entityliving.addEffect(new MobEffect(mobeffect1));
|
||||
+ entityliving.addEffect(new MobEffect(mobeffect1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
--- a/net/minecraft/server/EntityCreature.java
|
||||
+++ b/net/minecraft/server/EntityCreature.java
|
||||
@@ -1,5 +1,9 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityUnleashEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class EntityCreature extends EntityInsentient {
|
||||
|
||||
protected EntityCreature(EntityTypes<? extends EntityCreature> entitytypes, World world) {
|
||||
@@ -34,6 +38,7 @@
|
||||
|
||||
if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isSitting()) {
|
||||
if (f > 10.0F) {
|
||||
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
|
||||
this.unleash(true, true);
|
||||
}
|
||||
|
||||
@@ -42,6 +47,7 @@
|
||||
|
||||
this.x(f);
|
||||
if (f > 10.0F) {
|
||||
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
|
||||
this.unleash(true, true);
|
||||
this.goalSelector.a(PathfinderGoal.Type.MOVE);
|
||||
} else if (f > 6.0F) {
|
||||
@@ -0,0 +1,95 @@
|
||||
--- a/net/minecraft/server/EntityExperienceOrb.java
|
||||
+++ b/net/minecraft/server/EntityExperienceOrb.java
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
import java.util.Map.Entry;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityExperienceOrb extends Entity {
|
||||
|
||||
public int b;
|
||||
@@ -36,6 +42,7 @@
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
+ EntityHuman prevTarget = this.targetPlayer;// CraftBukkit - store old target
|
||||
if (this.d > 0) {
|
||||
--this.d;
|
||||
}
|
||||
@@ -72,7 +79,22 @@
|
||||
this.targetPlayer = null;
|
||||
}
|
||||
|
||||
- if (this.targetPlayer != null) {
|
||||
+ // CraftBukkit start
|
||||
+ boolean cancelled = false;
|
||||
+ if (this.targetPlayer != prevTarget) {
|
||||
+ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this, targetPlayer, (targetPlayer != null) ? EntityTargetEvent.TargetReason.CLOSEST_PLAYER : EntityTargetEvent.TargetReason.FORGOT_TARGET);
|
||||
+ EntityLiving target = (event.getTarget() == null) ? null : ((org.bukkit.craftbukkit.entity.CraftLivingEntity) event.getTarget()).getHandle();
|
||||
+ cancelled = event.isCancelled();
|
||||
+
|
||||
+ if (cancelled) {
|
||||
+ targetPlayer = prevTarget;
|
||||
+ } else {
|
||||
+ targetPlayer = (target instanceof EntityHuman) ? (EntityHuman) target : null;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (this.targetPlayer != null && !cancelled) {
|
||||
+ // CraftBukkit end
|
||||
Vec3D vec3d = new Vec3D(this.targetPlayer.locX() - this.locX(), this.targetPlayer.locY() + (double) this.targetPlayer.getHeadHeight() / 2.0D - this.locY(), this.targetPlayer.locZ() - this.locZ());
|
||||
double d1 = vec3d.g();
|
||||
|
||||
@@ -155,13 +177,19 @@
|
||||
if (!itemstack.isEmpty() && itemstack.f()) {
|
||||
int i = Math.min(this.c(this.value), itemstack.getDamage());
|
||||
|
||||
- this.value -= this.b(i);
|
||||
- itemstack.setDamage(itemstack.getDamage() - i);
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.player.PlayerItemMendEvent event = CraftEventFactory.callPlayerItemMendEvent(entityhuman, this, itemstack, i);
|
||||
+ i = event.getRepairAmount();
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.value -= this.b(i);
|
||||
+ itemstack.setDamage(itemstack.getDamage() - i);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
if (this.value > 0) {
|
||||
- entityhuman.giveExp(this.value);
|
||||
+ entityhuman.giveExp(CraftEventFactory.callPlayerExpChangeEvent(entityhuman, this.value).getAmount()); // CraftBukkit - this.value -> event.getAmount()
|
||||
}
|
||||
|
||||
this.die();
|
||||
@@ -183,6 +211,24 @@
|
||||
}
|
||||
|
||||
public static int getOrbValue(int i) {
|
||||
+ // CraftBukkit start
|
||||
+ if (i > 162670129) return i - 100000;
|
||||
+ if (i > 81335063) return 81335063;
|
||||
+ if (i > 40667527) return 40667527;
|
||||
+ if (i > 20333759) return 20333759;
|
||||
+ if (i > 10166857) return 10166857;
|
||||
+ if (i > 5083423) return 5083423;
|
||||
+ if (i > 2541701) return 2541701;
|
||||
+ if (i > 1270849) return 1270849;
|
||||
+ if (i > 635413) return 635413;
|
||||
+ if (i > 317701) return 317701;
|
||||
+ if (i > 158849) return 158849;
|
||||
+ if (i > 79423) return 79423;
|
||||
+ if (i > 39709) return 39709;
|
||||
+ if (i > 19853) return 19853;
|
||||
+ if (i > 9923) return 9923;
|
||||
+ if (i > 4957) return 4957;
|
||||
+ // CraftBukkit end
|
||||
return i >= 2477 ? 2477 : (i >= 1237 ? 1237 : (i >= 617 ? 617 : (i >= 307 ? 307 : (i >= 149 ? 149 : (i >= 73 ? 73 : (i >= 37 ? 37 : (i >= 17 ? 17 : (i >= 7 ? 7 : (i >= 3 ? 3 : 1)))))))));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,331 @@
|
||||
--- a/net/minecraft/server/EntityInsentient.java
|
||||
+++ b/net/minecraft/server/EntityInsentient.java
|
||||
@@ -10,6 +10,18 @@
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
+import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
+import org.bukkit.event.entity.EntityTransformEvent;
|
||||
+import org.bukkit.event.entity.EntityUnleashEvent;
|
||||
+import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class EntityInsentient extends EntityLiving {
|
||||
|
||||
private static final DataWatcherObject<Byte> b = DataWatcher.a(EntityInsentient.class, DataWatcherRegistry.a);
|
||||
@@ -28,7 +40,7 @@
|
||||
public final float[] dropChanceHand;
|
||||
private final NonNullList<ItemStack> bq;
|
||||
public final float[] dropChanceArmor;
|
||||
- private boolean canPickUpLoot;
|
||||
+ // private boolean canPickUpLoot; // CraftBukkit - moved up to EntityLiving
|
||||
public boolean persistent;
|
||||
private final Map<PathType, Float> bt;
|
||||
public MinecraftKey lootTableKey;
|
||||
@@ -41,6 +53,8 @@
|
||||
private BlockPosition bz;
|
||||
private float bA;
|
||||
|
||||
+ public boolean aware = true; // CraftBukkit
|
||||
+
|
||||
protected EntityInsentient(EntityTypes<? extends EntityInsentient> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
this.bp = NonNullList.a(2, ItemStack.b);
|
||||
@@ -64,6 +78,9 @@
|
||||
this.initPathfinder();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - default persistance to type's persistance value
|
||||
+ this.persistent = !isTypeNotPersistent(0);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
protected void initPathfinder() {}
|
||||
@@ -144,7 +161,38 @@
|
||||
}
|
||||
|
||||
public void setGoalTarget(@Nullable EntityLiving entityliving) {
|
||||
+ // CraftBukkit start - fire event
|
||||
+ setGoalTarget(entityliving, EntityTargetEvent.TargetReason.UNKNOWN, true);
|
||||
+ }
|
||||
+
|
||||
+ public boolean setGoalTarget(EntityLiving entityliving, EntityTargetEvent.TargetReason reason, boolean fireEvent) {
|
||||
+ if (getGoalTarget() == entityliving) return false;
|
||||
+ if (fireEvent) {
|
||||
+ if (reason == EntityTargetEvent.TargetReason.UNKNOWN && getGoalTarget() != null && entityliving == null) {
|
||||
+ reason = getGoalTarget().isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
|
||||
+ }
|
||||
+ if (reason == EntityTargetEvent.TargetReason.UNKNOWN) {
|
||||
+ world.getServer().getLogger().log(java.util.logging.Level.WARNING, "Unknown target reason, please report on the issue tracker", new Exception());
|
||||
+ }
|
||||
+ CraftLivingEntity ctarget = null;
|
||||
+ if (entityliving != null) {
|
||||
+ ctarget = (CraftLivingEntity) entityliving.getBukkitEntity();
|
||||
+ }
|
||||
+ EntityTargetLivingEntityEvent event = new EntityTargetLivingEntityEvent(this.getBukkitEntity(), ctarget, reason);
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (event.getTarget() != null) {
|
||||
+ entityliving = ((CraftLivingEntity) event.getTarget()).getHandle();
|
||||
+ } else {
|
||||
+ entityliving = null;
|
||||
+ }
|
||||
+ }
|
||||
this.goalTarget = entityliving;
|
||||
+ return true;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -361,16 +409,26 @@
|
||||
nbttagcompound.setBoolean("NoAI", this.isNoAI());
|
||||
}
|
||||
|
||||
+ nbttagcompound.setBoolean("Bukkit.Aware", this.aware); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadData(NBTTagCompound nbttagcompound) {
|
||||
super.loadData(nbttagcompound);
|
||||
+
|
||||
+ // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it
|
||||
if (nbttagcompound.hasKeyOfType("CanPickUpLoot", 1)) {
|
||||
- this.setCanPickupLoot(nbttagcompound.getBoolean("CanPickUpLoot"));
|
||||
+ boolean data = nbttagcompound.getBoolean("CanPickUpLoot");
|
||||
+ if (isLevelAtLeast(nbttagcompound, 1) || data) {
|
||||
+ this.setCanPickupLoot(data);
|
||||
+ }
|
||||
}
|
||||
|
||||
- this.persistent = nbttagcompound.getBoolean("PersistenceRequired");
|
||||
+ boolean data = nbttagcompound.getBoolean("PersistenceRequired");
|
||||
+ if (isLevelAtLeast(nbttagcompound, 1) || data) {
|
||||
+ this.persistent = data;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
NBTTagList nbttaglist;
|
||||
int i;
|
||||
|
||||
@@ -417,6 +475,11 @@
|
||||
}
|
||||
|
||||
this.setNoAI(nbttagcompound.getBoolean("NoAI"));
|
||||
+ // CraftBukkit start
|
||||
+ if (nbttagcompound.hasKey("Bukkit.Aware")) {
|
||||
+ this.aware = nbttagcompound.getBoolean("Bukkit.Aware");
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -424,6 +487,11 @@
|
||||
super.a(damagesource, flag);
|
||||
this.lootTableKey = null;
|
||||
}
|
||||
+ // CraftBukkit - start
|
||||
+ public MinecraftKey getLootTable() {
|
||||
+ return getDefaultLootTable();
|
||||
+ }
|
||||
+ // CraftBukkit - end
|
||||
|
||||
@Override
|
||||
protected LootTableInfo.Builder a(boolean flag, DamageSource damagesource) {
|
||||
@@ -480,7 +548,7 @@
|
||||
protected void b(EntityItem entityitem) {
|
||||
ItemStack itemstack = entityitem.getItemStack();
|
||||
|
||||
- if (this.g(itemstack)) {
|
||||
+ if (this.g(itemstack, entityitem)) { // CraftBukkit - add item
|
||||
this.a(entityitem);
|
||||
this.receive(entityitem, itemstack.getCount());
|
||||
entityitem.die();
|
||||
@@ -489,15 +557,29 @@
|
||||
}
|
||||
|
||||
public boolean g(ItemStack itemstack) {
|
||||
+ // CraftBukkit start - add item
|
||||
+ return this.g(itemstack, null);
|
||||
+ }
|
||||
+
|
||||
+ public boolean g(ItemStack itemstack, EntityItem entityitem) {
|
||||
+ // CraftBukkit end
|
||||
EnumItemSlot enumitemslot = j(itemstack);
|
||||
ItemStack itemstack1 = this.getEquipment(enumitemslot);
|
||||
boolean flag = this.a(itemstack, itemstack1);
|
||||
|
||||
- if (flag && this.canPickup(itemstack)) {
|
||||
+ // CraftBukkit start
|
||||
+ boolean canPickup = flag && this.canPickup(itemstack);
|
||||
+ if (entityitem != null) {
|
||||
+ canPickup = !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !canPickup).isCancelled();
|
||||
+ }
|
||||
+ if (canPickup) {
|
||||
+ // CraftBukkit end
|
||||
double d0 = (double) this.e(enumitemslot);
|
||||
|
||||
if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.a(itemstack1);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
}
|
||||
|
||||
this.b(enumitemslot, itemstack);
|
||||
@@ -610,18 +692,18 @@
|
||||
EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D);
|
||||
|
||||
if (entityhuman != null) {
|
||||
- double d0 = entityhuman.h(this);
|
||||
+ double d0 = entityhuman.h((Entity) this); // CraftBukkit - decompile error
|
||||
int i = this.getEntityType().e().f();
|
||||
int j = i * i;
|
||||
|
||||
- if (d0 > (double) j && this.isTypeNotPersistent(d0)) {
|
||||
+ if (d0 > (double) j) { // CraftBukkit - remove isTypeNotPersistent() check
|
||||
this.die();
|
||||
}
|
||||
|
||||
int k = this.getEntityType().e().g();
|
||||
int l = k * k;
|
||||
|
||||
- if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > (double) l && this.isTypeNotPersistent(d0)) {
|
||||
+ if (this.ticksFarFromPlayer > 600 && this.random.nextInt(800) == 0 && d0 > (double) l) { // CraftBukkit - remove isTypeNotPersistent() check
|
||||
this.die();
|
||||
} else if (d0 < (double) l) {
|
||||
this.ticksFarFromPlayer = 0;
|
||||
@@ -636,6 +718,7 @@
|
||||
@Override
|
||||
protected final void doTick() {
|
||||
++this.ticksFarFromPlayer;
|
||||
+ if (!this.aware) return; // CraftBukkit
|
||||
this.world.getMethodProfiler().enter("sensing");
|
||||
this.bo.a();
|
||||
this.world.getMethodProfiler().exit();
|
||||
@@ -1024,6 +1107,12 @@
|
||||
if (!this.isAlive()) {
|
||||
return EnumInteractionResult.PASS;
|
||||
} else if (this.getLeashHolder() == entityhuman) {
|
||||
+ // CraftBukkit start - fire PlayerUnleashEntityEvent
|
||||
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(this, entityhuman).isCancelled()) {
|
||||
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.unleash(true, !entityhuman.abilities.canInstantlyBuild);
|
||||
return EnumInteractionResult.a(this.world.isClientSide);
|
||||
} else {
|
||||
@@ -1042,6 +1131,12 @@
|
||||
ItemStack itemstack = entityhuman.b(enumhand);
|
||||
|
||||
if (itemstack.getItem() == Items.LEAD && this.a(entityhuman)) {
|
||||
+ // CraftBukkit start - fire PlayerLeashEntityEvent
|
||||
+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, entityhuman, entityhuman).isCancelled()) {
|
||||
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(this, this.getLeashHolder()));
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.setLeashHolder(entityhuman, true);
|
||||
itemstack.subtract(1);
|
||||
return EnumInteractionResult.a(this.world.isClientSide);
|
||||
@@ -1057,7 +1152,7 @@
|
||||
if (itemstack.getItem() instanceof ItemMonsterEgg) {
|
||||
if (this.world instanceof WorldServer) {
|
||||
ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem();
|
||||
- Optional<EntityInsentient> optional = itemmonsteregg.a(entityhuman, this, this.getEntityType(), (WorldServer) this.world, this.getPositionVector(), itemstack);
|
||||
+ Optional<EntityInsentient> optional = itemmonsteregg.a(entityhuman, this, (EntityTypes<? extends EntityInsentient>) this.getEntityType(), (WorldServer) this.world, this.getPositionVector(), itemstack); // CraftBukkit - decompile error
|
||||
|
||||
optional.ifPresent((entityinsentient) -> {
|
||||
this.a(entityhuman, entityinsentient);
|
||||
@@ -1103,12 +1198,19 @@
|
||||
return this.bA != -1.0F;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@Nullable
|
||||
public <T extends EntityInsentient> T a(EntityTypes<T> entitytypes, boolean flag) {
|
||||
+ return this.a(entitytypes, flag, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public <T extends EntityInsentient> T a(EntityTypes<T> entitytypes, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
+ // CraftBukkit end
|
||||
if (this.dead) {
|
||||
return null;
|
||||
} else {
|
||||
- T t0 = (EntityInsentient) entitytypes.a(this.world);
|
||||
+ T t0 = entitytypes.a(this.world); // CraftBukkit - decompile error
|
||||
|
||||
t0.u(this);
|
||||
t0.setBaby(this.isBaby());
|
||||
@@ -1140,7 +1242,12 @@
|
||||
}
|
||||
}
|
||||
|
||||
- this.world.addEntity(t0);
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callEntityTransformEvent(this, t0, transformReason).isCancelled()) {
|
||||
+ return null;
|
||||
+ }
|
||||
+ this.world.addEntity(t0, spawnReason);
|
||||
+ // CraftBukkit end
|
||||
if (this.isPassenger()) {
|
||||
Entity entity = this.getVehicle();
|
||||
|
||||
@@ -1160,6 +1267,7 @@
|
||||
|
||||
if (this.leashHolder != null) {
|
||||
if (!this.isAlive() || !this.leashHolder.isAlive()) {
|
||||
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit
|
||||
this.unleash(true, true);
|
||||
}
|
||||
|
||||
@@ -1176,7 +1284,9 @@
|
||||
this.leashHolder = null;
|
||||
this.by = null;
|
||||
if (!this.world.isClientSide && flag1) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.a((IMaterial) Items.LEAD);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
}
|
||||
|
||||
if (!this.world.isClientSide && flag && this.world instanceof WorldServer) {
|
||||
@@ -1226,6 +1336,7 @@
|
||||
boolean flag1 = super.a(entity, flag);
|
||||
|
||||
if (flag1 && this.isLeashed()) {
|
||||
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
|
||||
this.unleash(true, true);
|
||||
}
|
||||
|
||||
@@ -1358,7 +1469,14 @@
|
||||
int i = EnchantmentManager.getFireAspectEnchantmentLevel(this);
|
||||
|
||||
if (i > 0) {
|
||||
- entity.setOnFire(i * 4);
|
||||
+ // CraftBukkit start - Call a combust event when somebody hits with a fire enchanted item
|
||||
+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), i * 4);
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
|
||||
+
|
||||
+ if (!combustEvent.isCancelled()) {
|
||||
+ entity.setOnFire(combustEvent.getDuration(), false);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
boolean flag = entity.damageEntity(DamageSource.mobAttack(this), f);
|
||||
@@ -1420,6 +1538,7 @@
|
||||
@Override
|
||||
protected void bN() {
|
||||
super.bN();
|
||||
+ this.world.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
|
||||
this.unleash(true, false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
--- a/net/minecraft/server/EntityLightning.java
|
||||
+++ b/net/minecraft/server/EntityLightning.java
|
||||
@@ -5,6 +5,8 @@
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
+
|
||||
public class EntityLightning extends Entity {
|
||||
|
||||
private int lifeTicks;
|
||||
@@ -45,7 +47,24 @@
|
||||
this.a(4);
|
||||
}
|
||||
|
||||
- this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
|
||||
+ // CraftBukkit start - Use relative location for far away sounds
|
||||
+ // this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
|
||||
+ float pitch = 0.8F + this.random.nextFloat() * 0.2F;
|
||||
+ int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16;
|
||||
+ for (EntityPlayer player : (List<EntityPlayer>) (List) this.world.getPlayers()) {
|
||||
+ double deltaX = this.locX() - player.locX();
|
||||
+ double deltaZ = this.locZ() - player.locZ();
|
||||
+ double distanceSquared = deltaX * deltaX + deltaZ * deltaZ;
|
||||
+ if (distanceSquared > viewDistance * viewDistance) {
|
||||
+ double deltaLength = Math.sqrt(distanceSquared);
|
||||
+ double relativeX = player.locX() + (deltaX / deltaLength) * viewDistance;
|
||||
+ double relativeZ = player.locZ() + (deltaZ / deltaLength) * viewDistance;
|
||||
+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, relativeX, this.locY(), relativeZ, 10000.0F, pitch));
|
||||
+ } else {
|
||||
+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(SoundEffects.ENTITY_LIGHTNING_BOLT_THUNDER, SoundCategory.WEATHER, this.locX(), this.locY(), this.locZ(), 10000.0F, pitch));
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_LIGHTNING_BOLT_IMPACT, SoundCategory.WEATHER, 2.0F, 0.5F + this.random.nextFloat() * 0.2F);
|
||||
}
|
||||
|
||||
@@ -61,7 +80,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (this.lifeTicks >= 0) {
|
||||
+ if (this.lifeTicks >= 0 && !this.isEffect) { // CraftBukkit - add !this.isEffect
|
||||
if (!(this.world instanceof WorldServer)) {
|
||||
this.world.c(2);
|
||||
} else if (!this.isEffect) {
|
||||
@@ -89,7 +108,11 @@
|
||||
IBlockData iblockdata = BlockFireAbstract.a((IBlockAccess) this.world, blockposition);
|
||||
|
||||
if (this.world.getType(blockposition).isAir() && iblockdata.canPlace(this.world, blockposition)) {
|
||||
- this.world.setTypeUpdate(blockposition, iblockdata);
|
||||
+ // CraftBukkit start - add "!isEffect"
|
||||
+ if (!isEffect && !CraftEventFactory.callBlockIgniteEvent(world, blockposition, this).isCancelled()) {
|
||||
+ this.world.setTypeUpdate(blockposition, iblockdata);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
@@ -97,7 +120,11 @@
|
||||
|
||||
iblockdata = BlockFireAbstract.a((IBlockAccess) this.world, blockposition1);
|
||||
if (this.world.getType(blockposition1).isAir() && iblockdata.canPlace(this.world, blockposition1)) {
|
||||
- this.world.setTypeUpdate(blockposition1, iblockdata);
|
||||
+ // CraftBukkit start - add "!isEffect"
|
||||
+ if (!isEffect && !CraftEventFactory.callBlockIgniteEvent(world, blockposition1, this).isCancelled()) {
|
||||
+ this.world.setTypeUpdate(blockposition1, iblockdata);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,941 @@
|
||||
--- a/net/minecraft/server/EntityLiving.java
|
||||
+++ b/net/minecraft/server/EntityLiving.java
|
||||
@@ -21,6 +21,27 @@
|
||||
import javax.annotation.Nullable;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.HashSet;
|
||||
+import java.util.Set;
|
||||
+import com.google.common.base.Function;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.attribute.CraftAttributeMap;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.entity.LivingEntity;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.entity.ArrowBodyCountChangeEvent;
|
||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
||||
+import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
|
||||
+import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
+import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
+import org.bukkit.event.entity.EntityResurrectEvent;
|
||||
+import org.bukkit.event.entity.EntityTeleportEvent;
|
||||
+import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class EntityLiving extends Entity {
|
||||
|
||||
private static final UUID b = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
|
||||
@@ -106,6 +127,21 @@
|
||||
private float bB;
|
||||
private float bC;
|
||||
protected BehaviorController<?> bg;
|
||||
+ // CraftBukkit start
|
||||
+ public int expToDrop;
|
||||
+ public int maxAirTicks = 300;
|
||||
+ boolean forceDrops;
|
||||
+ ArrayList<org.bukkit.inventory.ItemStack> drops = new ArrayList<org.bukkit.inventory.ItemStack>();
|
||||
+ public final org.bukkit.craftbukkit.attribute.CraftAttributeMap craftAttributes;
|
||||
+ public boolean collides = true;
|
||||
+ public Set<UUID> collidableExemptions = new HashSet<>();
|
||||
+ public boolean canPickUpLoot;
|
||||
+
|
||||
+ @Override
|
||||
+ public float getBukkitYaw() {
|
||||
+ return getHeadRotation();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
protected EntityLiving(EntityTypes<? extends EntityLiving> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -117,7 +153,9 @@
|
||||
this.activeItem = ItemStack.b;
|
||||
this.by = Optional.empty();
|
||||
this.attributeMap = new AttributeMapBase(AttributeDefaults.a(entitytypes));
|
||||
- this.setHealth(this.getMaxHealth());
|
||||
+ this.craftAttributes = new CraftAttributeMap(attributeMap); // CraftBukkit
|
||||
+ // CraftBukkit - setHealth(getMaxHealth()) inlined and simplified to skip the instanceof check for EntityPlayer, as getBukkitEntity() is not initialized in constructor
|
||||
+ this.datawatcher.set(EntityLiving.HEALTH, (float) this.getAttributeInstance(GenericAttributes.MAX_HEALTH).getValue());
|
||||
this.i = true;
|
||||
this.az = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
|
||||
this.af();
|
||||
@@ -184,7 +222,13 @@
|
||||
double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D);
|
||||
int i = (int) (150.0D * d1);
|
||||
|
||||
- ((WorldServer) this.world).a(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D);
|
||||
+ // CraftBukkit start - visiblity api
|
||||
+ if (this instanceof EntityPlayer) {
|
||||
+ ((WorldServer) this.world).sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false);
|
||||
+ } else {
|
||||
+ ((WorldServer) this.world).a(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.locX(), this.locY(), this.locZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,7 +450,7 @@
|
||||
|
||||
protected void cU() {
|
||||
++this.deathTicks;
|
||||
- if (this.deathTicks == 20) {
|
||||
+ if (this.deathTicks >= 20 && !this.dead) { // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead)
|
||||
this.die();
|
||||
|
||||
for (int i = 0; i < 20; ++i) {
|
||||
@@ -497,7 +541,13 @@
|
||||
}
|
||||
|
||||
protected void playEquipSound(ItemStack itemstack) {
|
||||
- if (!itemstack.isEmpty()) {
|
||||
+ // CraftBukkit start
|
||||
+ this.playEquipSound(itemstack, false);
|
||||
+ }
|
||||
+
|
||||
+ protected void playEquipSound(ItemStack itemstack, boolean silent) {
|
||||
+ if (!itemstack.isEmpty() && !silent) {
|
||||
+ // CraftBukkit end
|
||||
SoundEffect soundeffect = SoundEffects.ITEM_ARMOR_EQUIP_GENERIC;
|
||||
Item item = itemstack.getItem();
|
||||
|
||||
@@ -567,6 +617,17 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (nbttagcompound.hasKey("Bukkit.MaxHealth")) {
|
||||
+ NBTBase nbtbase = nbttagcompound.get("Bukkit.MaxHealth");
|
||||
+ if (nbtbase.getTypeId() == 5) {
|
||||
+ this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(((NBTTagFloat) nbtbase).asDouble());
|
||||
+ } else if (nbtbase.getTypeId() == 3) {
|
||||
+ this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(((NBTTagInt) nbtbase).asDouble());
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (nbttagcompound.hasKeyOfType("Health", 99)) {
|
||||
this.setHealth(nbttagcompound.getFloat("Health"));
|
||||
}
|
||||
@@ -604,9 +665,32 @@
|
||||
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private boolean isTickingEffects = false;
|
||||
+ private List<ProcessableEffect> effectsToProcess = Lists.newArrayList();
|
||||
+
|
||||
+ private static class ProcessableEffect {
|
||||
+
|
||||
+ private MobEffectList type;
|
||||
+ private MobEffect effect;
|
||||
+ private final EntityPotionEffectEvent.Cause cause;
|
||||
+
|
||||
+ private ProcessableEffect(MobEffect effect, EntityPotionEffectEvent.Cause cause) {
|
||||
+ this.effect = effect;
|
||||
+ this.cause = cause;
|
||||
+ }
|
||||
+
|
||||
+ private ProcessableEffect(MobEffectList type, EntityPotionEffectEvent.Cause cause) {
|
||||
+ this.type = type;
|
||||
+ this.cause = cause;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
protected void tickPotionEffects() {
|
||||
Iterator iterator = this.effects.keySet().iterator();
|
||||
|
||||
+ isTickingEffects = true; // CraftBukkit
|
||||
try {
|
||||
while (iterator.hasNext()) {
|
||||
MobEffectList mobeffectlist = (MobEffectList) iterator.next();
|
||||
@@ -616,6 +700,12 @@
|
||||
this.a(mobeffect, true);
|
||||
})) {
|
||||
if (!this.world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, mobeffect, null, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.EXPIRATION);
|
||||
+ if (event.isCancelled()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
iterator.remove();
|
||||
this.b(mobeffect);
|
||||
}
|
||||
@@ -626,6 +716,17 @@
|
||||
} catch (ConcurrentModificationException concurrentmodificationexception) {
|
||||
;
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ isTickingEffects = false;
|
||||
+ for (ProcessableEffect e : effectsToProcess) {
|
||||
+ if (e.effect != null) {
|
||||
+ addEffect(e.effect, e.cause);
|
||||
+ } else {
|
||||
+ removeEffect(e.type, e.cause);
|
||||
+ }
|
||||
+ }
|
||||
+ effectsToProcess.clear();
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (this.updateEffects) {
|
||||
if (!this.world.isClientSide) {
|
||||
@@ -735,7 +836,13 @@
|
||||
this.datawatcher.set(EntityLiving.f, 0);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
public boolean removeAllEffects() {
|
||||
+ return removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
+ public boolean removeAllEffects(EntityPotionEffectEvent.Cause cause) {
|
||||
+ // CraftBukkit end
|
||||
if (this.world.isClientSide) {
|
||||
return false;
|
||||
} else {
|
||||
@@ -744,7 +851,14 @@
|
||||
boolean flag;
|
||||
|
||||
for (flag = false; iterator.hasNext(); flag = true) {
|
||||
- this.b((MobEffect) iterator.next());
|
||||
+ // CraftBukkit start
|
||||
+ MobEffect effect = (MobEffect) iterator.next();
|
||||
+ EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, effect, null, cause, EntityPotionEffectEvent.Action.CLEARED);
|
||||
+ if (event.isCancelled()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ this.b(effect);
|
||||
+ // CraftBukkit end
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
@@ -769,18 +883,44 @@
|
||||
return (MobEffect) this.effects.get(mobeffectlist);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
public boolean addEffect(MobEffect mobeffect) {
|
||||
+ return addEffect(mobeffect, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
+ public boolean addEffect(MobEffect mobeffect, EntityPotionEffectEvent.Cause cause) {
|
||||
+ if (isTickingEffects) {
|
||||
+ effectsToProcess.add(new ProcessableEffect(mobeffect, cause));
|
||||
+ return true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (!this.d(mobeffect)) {
|
||||
return false;
|
||||
} else {
|
||||
MobEffect mobeffect1 = (MobEffect) this.effects.get(mobeffect.getMobEffect());
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ boolean override = false;
|
||||
+ if (mobeffect1 != null) {
|
||||
+ override = new MobEffect(mobeffect1).b(mobeffect);
|
||||
+ }
|
||||
+
|
||||
+ EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, mobeffect1, mobeffect, cause, override);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (mobeffect1 == null) {
|
||||
this.effects.put(mobeffect.getMobEffect(), mobeffect);
|
||||
this.a(mobeffect);
|
||||
return true;
|
||||
- } else if (mobeffect1.b(mobeffect)) {
|
||||
+ // CraftBukkit start
|
||||
+ } else if (event.isOverride()) {
|
||||
+ mobeffect1.b(mobeffect);
|
||||
this.a(mobeffect1, true);
|
||||
+ // CraftBukkit end
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -804,13 +944,39 @@
|
||||
return this.getMonsterType() == EnumMonsterType.UNDEAD;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@Nullable
|
||||
public MobEffect c(@Nullable MobEffectList mobeffectlist) {
|
||||
+ return c(mobeffectlist, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public MobEffect c(@Nullable MobEffectList mobeffectlist, EntityPotionEffectEvent.Cause cause) {
|
||||
+ if (isTickingEffects) {
|
||||
+ effectsToProcess.add(new ProcessableEffect(mobeffectlist, cause));
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ MobEffect effect = this.effects.get(mobeffectlist);
|
||||
+ if (effect == null) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, effect, null, cause);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
return (MobEffect) this.effects.remove(mobeffectlist);
|
||||
}
|
||||
|
||||
public boolean removeEffect(MobEffectList mobeffectlist) {
|
||||
- MobEffect mobeffect = this.c(mobeffectlist);
|
||||
+ return removeEffect(mobeffectlist, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.UNKNOWN);
|
||||
+ }
|
||||
+
|
||||
+ public boolean removeEffect(MobEffectList mobeffectlist, EntityPotionEffectEvent.Cause cause) {
|
||||
+ MobEffect mobeffect = this.c(mobeffectlist, cause);
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (mobeffect != null) {
|
||||
this.b(mobeffect);
|
||||
@@ -847,20 +1013,55 @@
|
||||
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Delegate so we can handle providing a reason for health being regained
|
||||
public void heal(float f) {
|
||||
+ heal(f, EntityRegainHealthEvent.RegainReason.CUSTOM);
|
||||
+ }
|
||||
+
|
||||
+ public void heal(float f, EntityRegainHealthEvent.RegainReason regainReason) {
|
||||
float f1 = this.getHealth();
|
||||
|
||||
if (f1 > 0.0F) {
|
||||
- this.setHealth(f1 + f);
|
||||
+ EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), f, regainReason);
|
||||
+ // Suppress during worldgen
|
||||
+ if (this.valid) {
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.setHealth((float) (this.getHealth() + event.getAmount()));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public float getHealth() {
|
||||
+ // CraftBukkit start - Use unscaled health
|
||||
+ if (this instanceof EntityPlayer) {
|
||||
+ return (float) ((EntityPlayer) this).getBukkitEntity().getHealth();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return (Float) this.datawatcher.get(EntityLiving.HEALTH);
|
||||
}
|
||||
|
||||
public void setHealth(float f) {
|
||||
+ // CraftBukkit start - Handle scaled health
|
||||
+ if (this instanceof EntityPlayer) {
|
||||
+ org.bukkit.craftbukkit.entity.CraftPlayer player = ((EntityPlayer) this).getBukkitEntity();
|
||||
+ // Squeeze
|
||||
+ if (f < 0.0F) {
|
||||
+ player.setRealHealth(0.0D);
|
||||
+ } else if (f > player.getMaxHealth()) {
|
||||
+ player.setRealHealth(player.getMaxHealth());
|
||||
+ } else {
|
||||
+ player.setRealHealth(f);
|
||||
+ }
|
||||
+
|
||||
+ player.updateScaledHealth(false);
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.datawatcher.set(EntityLiving.HEALTH, MathHelper.a(f, 0.0F, this.getMaxHealth()));
|
||||
}
|
||||
|
||||
@@ -874,7 +1075,7 @@
|
||||
return false;
|
||||
} else if (this.world.isClientSide) {
|
||||
return false;
|
||||
- } else if (this.dl()) {
|
||||
+ } else if (this.dead || this.killed || this.getHealth() <= 0.0F) { // CraftBukkit - Don't allow entities that got set to dead/killed elsewhere to get damaged and die
|
||||
return false;
|
||||
} else if (damagesource.isFire() && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
|
||||
return false;
|
||||
@@ -886,17 +1087,19 @@
|
||||
this.ticksFarFromPlayer = 0;
|
||||
float f1 = f;
|
||||
|
||||
- if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
|
||||
+ // CraftBukkit - Moved into damageEntity0(DamageSource, float)
|
||||
+ if (false && (damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
|
||||
this.getEquipment(EnumItemSlot.HEAD).damage((int) (f * 4.0F + this.random.nextFloat() * f * 2.0F), this, (entityliving) -> {
|
||||
entityliving.broadcastItemBreak(EnumItemSlot.HEAD);
|
||||
});
|
||||
f *= 0.75F;
|
||||
}
|
||||
|
||||
- boolean flag = false;
|
||||
+ boolean flag = f > 0.0F && this.applyBlockingModifier(damagesource); // Copied from below
|
||||
float f2 = 0.0F;
|
||||
|
||||
- if (f > 0.0F && this.applyBlockingModifier(damagesource)) {
|
||||
+ // CraftBukkit - Moved into damageEntity0(DamageSource, float)
|
||||
+ if (false && f > 0.0F && this.applyBlockingModifier(damagesource)) {
|
||||
this.damageShield(f);
|
||||
f2 = f;
|
||||
f = 0.0F;
|
||||
@@ -914,22 +1117,41 @@
|
||||
this.av = 1.5F;
|
||||
boolean flag1 = true;
|
||||
|
||||
- if ((float) this.noDamageTicks > 10.0F) {
|
||||
+ if ((float) this.noDamageTicks > (float) this.maxNoDamageTicks / 2.0F) { // CraftBukkit - restore use of maxNoDamageTicks
|
||||
if (f <= this.lastDamage) {
|
||||
+ this.forceExplosionKnockback = true; // CraftBukkit - SPIGOT-949 - for vanilla consistency, cooldown does not prevent explosion knockback
|
||||
return false;
|
||||
}
|
||||
|
||||
- this.damageEntity0(damagesource, f - this.lastDamage);
|
||||
+ // CraftBukkit start
|
||||
+ if (!this.damageEntity0(damagesource, f - this.lastDamage)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.lastDamage = f;
|
||||
flag1 = false;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ if (!this.damageEntity0(damagesource, f)) {
|
||||
+ return false;
|
||||
+ }
|
||||
this.lastDamage = f;
|
||||
- this.noDamageTicks = 20;
|
||||
- this.damageEntity0(damagesource, f);
|
||||
+ this.noDamageTicks = this.maxNoDamageTicks; // CraftBukkit - restore use of maxNoDamageTicks
|
||||
+ // this.damageEntity0(damagesource, f);
|
||||
+ // CraftBukkit end
|
||||
this.hurtDuration = 10;
|
||||
this.hurtTicks = this.hurtDuration;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (this instanceof EntityAnimal) {
|
||||
+ ((EntityAnimal) this).resetLove();
|
||||
+ if (this instanceof EntityTameableAnimal) {
|
||||
+ ((EntityTameableAnimal) this).setWillSit(false);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.ap = 0.0F;
|
||||
Entity entity1 = damagesource.getEntity();
|
||||
|
||||
@@ -1050,19 +1272,29 @@
|
||||
EnumHand[] aenumhand = EnumHand.values();
|
||||
int i = aenumhand.length;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ ItemStack itemstack1 = ItemStack.b;
|
||||
for (int j = 0; j < i; ++j) {
|
||||
EnumHand enumhand = aenumhand[j];
|
||||
- ItemStack itemstack1 = this.b(enumhand);
|
||||
+ itemstack1 = this.b(enumhand);
|
||||
|
||||
if (itemstack1.getItem() == Items.TOTEM_OF_UNDYING) {
|
||||
itemstack = itemstack1.cloneItemStack();
|
||||
- itemstack1.subtract(1);
|
||||
+ // itemstack1.subtract(1); // CraftBukkit
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- if (itemstack != null) {
|
||||
- if (this instanceof EntityPlayer) {
|
||||
+ EntityResurrectEvent event = new EntityResurrectEvent((LivingEntity) this.getBukkitEntity());
|
||||
+ event.setCancelled(itemstack == null);
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
+ if (!itemstack1.isEmpty()) {
|
||||
+ itemstack1.subtract(1);
|
||||
+ }
|
||||
+ if (itemstack != null && this instanceof EntityPlayer) {
|
||||
+ // CraftBukkit end
|
||||
EntityPlayer entityplayer = (EntityPlayer) this;
|
||||
|
||||
entityplayer.b(StatisticList.ITEM_USED.b(Items.TOTEM_OF_UNDYING));
|
||||
@@ -1070,14 +1302,16 @@
|
||||
}
|
||||
|
||||
this.setHealth(1.0F);
|
||||
- this.removeAllEffects();
|
||||
- this.addEffect(new MobEffect(MobEffects.REGENERATION, 900, 1));
|
||||
- this.addEffect(new MobEffect(MobEffects.ABSORBTION, 100, 1));
|
||||
- this.addEffect(new MobEffect(MobEffects.FIRE_RESISTANCE, 800, 0));
|
||||
+ // CraftBukkit start
|
||||
+ this.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM);
|
||||
+ this.addEffect(new MobEffect(MobEffects.REGENERATION, 900, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM);
|
||||
+ this.addEffect(new MobEffect(MobEffects.ABSORBTION, 100, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM);
|
||||
+ this.addEffect(new MobEffect(MobEffects.FIRE_RESISTANCE, 800, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM);
|
||||
+ // CraftBukkit end
|
||||
this.world.broadcastEntityEffect(this, (byte) 35);
|
||||
}
|
||||
|
||||
- return itemstack != null;
|
||||
+ return !event.isCancelled();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1175,6 +1409,13 @@
|
||||
if (!flag) {
|
||||
EntityItem entityitem = new EntityItem(this.world, this.locX(), this.locY(), this.locZ(), new ItemStack(Items.bt));
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
|
||||
+ CraftEventFactory.callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.world.addEntity(entityitem);
|
||||
}
|
||||
}
|
||||
@@ -1194,28 +1435,46 @@
|
||||
|
||||
boolean flag = this.lastDamageByPlayerTime > 0;
|
||||
|
||||
+ this.dropInventory(); // CraftBukkit - from below
|
||||
if (this.cW() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
|
||||
this.a(damagesource, flag);
|
||||
this.dropDeathLoot(damagesource, i, flag);
|
||||
}
|
||||
+ // CraftBukkit start - Call death event
|
||||
+ CraftEventFactory.callEntityDeathEvent(this, this.drops);
|
||||
+ this.drops = new ArrayList<>();
|
||||
+ // CraftBukkit end
|
||||
|
||||
- this.dropInventory();
|
||||
+ // this.dropInventory();// CraftBukkit - moved up
|
||||
this.dropExperience();
|
||||
}
|
||||
|
||||
protected void dropInventory() {}
|
||||
|
||||
- protected void dropExperience() {
|
||||
+ // CraftBukkit start
|
||||
+ public int getExpReward() {
|
||||
if (!this.world.isClientSide && (this.alwaysGivesExp() || this.lastDamageByPlayerTime > 0 && this.isDropExperience() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT))) {
|
||||
int i = this.getExpValue(this.killer);
|
||||
+ return i;
|
||||
+ } else {
|
||||
+ return 0;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
+ protected void dropExperience() {
|
||||
+ // CraftBukkit start - Update getExpReward() above if the removed if() changes!
|
||||
+ if (true) {
|
||||
+ int i = this.expToDrop;
|
||||
while (i > 0) {
|
||||
int j = EntityExperienceOrb.getOrbValue(i);
|
||||
|
||||
i -= j;
|
||||
this.world.addEntity(new EntityExperienceOrb(this.world, this.locX(), this.locY(), this.locZ(), j));
|
||||
}
|
||||
+ this.expToDrop = 0;
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
}
|
||||
|
||||
@@ -1336,9 +1595,14 @@
|
||||
int i = this.e(f, f1);
|
||||
|
||||
if (i > 0) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!this.damageEntity(DamageSource.FALL, (float) i)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.playSound(this.getSoundFall(i), 1.0F, 1.0F);
|
||||
this.playBlockStepSound();
|
||||
- this.damageEntity(DamageSource.FALL, (float) i);
|
||||
+ // this.damageEntity(DamageSource.FALL, (float) i); // CraftBukkit - moved up
|
||||
return true;
|
||||
} else {
|
||||
return flag;
|
||||
@@ -1378,7 +1642,7 @@
|
||||
|
||||
protected float applyArmorModifier(DamageSource damagesource, float f) {
|
||||
if (!damagesource.ignoresArmor()) {
|
||||
- this.damageArmor(damagesource, f);
|
||||
+ // this.damageArmor(damagesource, f); // CraftBukkit - Moved into damageEntity0(DamageSource, float)
|
||||
f = CombatMath.a(f, (float) this.getArmorStrength(), (float) this.b(GenericAttributes.ARMOR_TOUGHNESS));
|
||||
}
|
||||
|
||||
@@ -1391,7 +1655,8 @@
|
||||
} else {
|
||||
int i;
|
||||
|
||||
- if (this.hasEffect(MobEffects.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) {
|
||||
+ // CraftBukkit - Moved to damageEntity0(DamageSource, float)
|
||||
+ if (false && this.hasEffect(MobEffects.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) {
|
||||
i = (this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
|
||||
int j = 25 - i;
|
||||
float f1 = f * (float) j;
|
||||
@@ -1422,28 +1687,173 @@
|
||||
}
|
||||
}
|
||||
|
||||
- protected void damageEntity0(DamageSource damagesource, float f) {
|
||||
- if (!this.isInvulnerable(damagesource)) {
|
||||
- f = this.applyArmorModifier(damagesource, f);
|
||||
- f = this.applyMagicModifier(damagesource, f);
|
||||
- float f1 = f;
|
||||
+ // CraftBukkit start
|
||||
+ protected boolean damageEntity0(final DamageSource damagesource, float f) { // void -> boolean, add final
|
||||
+ if (!this.isInvulnerable(damagesource)) {
|
||||
+ final boolean human = this instanceof EntityHuman;
|
||||
+ float originalDamage = f;
|
||||
+ Function<Double, Double> hardHat = new Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
+ if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && !EntityLiving.this.getEquipment(EnumItemSlot.HEAD).isEmpty()) {
|
||||
+ return -(f - (f * 0.75F));
|
||||
+
|
||||
+ }
|
||||
+ return -0.0;
|
||||
+ }
|
||||
+ };
|
||||
+ float hardHatModifier = hardHat.apply((double) f).floatValue();
|
||||
+ f += hardHatModifier;
|
||||
+
|
||||
+ Function<Double, Double> blocking = new Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
+ return -((EntityLiving.this.applyBlockingModifier(damagesource)) ? f : 0.0);
|
||||
+ }
|
||||
+ };
|
||||
+ float blockingModifier = blocking.apply((double) f).floatValue();
|
||||
+ f += blockingModifier;
|
||||
+
|
||||
+ Function<Double, Double> armor = new Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
+ return -(f - EntityLiving.this.applyArmorModifier(damagesource, f.floatValue()));
|
||||
+ }
|
||||
+ };
|
||||
+ float armorModifier = armor.apply((double) f).floatValue();
|
||||
+ f += armorModifier;
|
||||
+
|
||||
+ Function<Double, Double> resistance = new Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
+ if (!damagesource.isStarvation() && EntityLiving.this.hasEffect(MobEffects.RESISTANCE) && damagesource != DamageSource.OUT_OF_WORLD) {
|
||||
+ int i = (EntityLiving.this.getEffect(MobEffects.RESISTANCE).getAmplifier() + 1) * 5;
|
||||
+ int j = 25 - i;
|
||||
+ float f1 = f.floatValue() * (float) j;
|
||||
+ return -(f - (f1 / 25.0F));
|
||||
+ }
|
||||
+ return -0.0;
|
||||
+ }
|
||||
+ };
|
||||
+ float resistanceModifier = resistance.apply((double) f).floatValue();
|
||||
+ f += resistanceModifier;
|
||||
+
|
||||
+ Function<Double, Double> magic = new Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
+ return -(f - EntityLiving.this.applyMagicModifier(damagesource, f.floatValue()));
|
||||
+ }
|
||||
+ };
|
||||
+ float magicModifier = magic.apply((double) f).floatValue();
|
||||
+ f += magicModifier;
|
||||
+
|
||||
+ Function<Double, Double> absorption = new Function<Double, Double>() {
|
||||
+ @Override
|
||||
+ public Double apply(Double f) {
|
||||
+ return -(Math.max(f - Math.max(f - EntityLiving.this.getAbsorptionHearts(), 0.0F), 0.0F));
|
||||
+ }
|
||||
+ };
|
||||
+ float absorptionModifier = absorption.apply((double) f).floatValue();
|
||||
+
|
||||
+ EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption);
|
||||
+ if (damagesource.getEntity() instanceof EntityHuman) {
|
||||
+ ((EntityHuman) damagesource.getEntity()).resetAttackCooldown(); // Moved from EntityHuman in order to make the cooldown reset get called after the damage event is fired
|
||||
+ }
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ f = (float) event.getFinalDamage();
|
||||
+
|
||||
+ // Resistance
|
||||
+ if (event.getDamage(DamageModifier.RESISTANCE) < 0) {
|
||||
+ float f3 = (float) -event.getDamage(DamageModifier.RESISTANCE);
|
||||
+ if (f3 > 0.0F && f3 < 3.4028235E37F) {
|
||||
+ if (this instanceof EntityPlayer) {
|
||||
+ ((EntityPlayer) this).a(StatisticList.DAMAGE_RESISTED, Math.round(f3 * 10.0F));
|
||||
+ } else if (damagesource.getEntity() instanceof EntityPlayer) {
|
||||
+ ((EntityPlayer) damagesource.getEntity()).a(StatisticList.DAMAGE_DEALT_RESISTED, Math.round(f3 * 10.0F));
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // Apply damage to helmet
|
||||
+ if ((damagesource == DamageSource.ANVIL || damagesource == DamageSource.FALLING_BLOCK) && this.getEquipment(EnumItemSlot.HEAD) != null) {
|
||||
+ this.getEquipment(EnumItemSlot.HEAD).damage((int) (event.getDamage() * 4.0F + this.random.nextFloat() * event.getDamage() * 2.0F), this, (entityliving) -> {
|
||||
+ entityliving.broadcastItemBreak(EnumItemSlot.HEAD);
|
||||
+ });
|
||||
+ }
|
||||
+
|
||||
+ // Apply damage to armor
|
||||
+ if (!damagesource.ignoresArmor()) {
|
||||
+ float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT));
|
||||
+ this.damageArmor(damagesource, armorDamage);
|
||||
+ }
|
||||
|
||||
- f = Math.max(f - this.getAbsorptionHearts(), 0.0F);
|
||||
- this.setAbsorptionHearts(this.getAbsorptionHearts() - (f1 - f));
|
||||
- float f2 = f1 - f;
|
||||
+ // Apply blocking code // PAIL: steal from above
|
||||
+ if (event.getDamage(DamageModifier.BLOCKING) < 0) {
|
||||
+ this.world.broadcastEntityEffect(this, (byte) 29); // SPIGOT-4635 - shield damage sound
|
||||
+ this.damageShield((float) -event.getDamage(DamageModifier.BLOCKING));
|
||||
+ Entity entity = damagesource.j();
|
||||
|
||||
+ if (entity instanceof EntityLiving) {
|
||||
+ this.shieldBlock((EntityLiving) entity);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ absorptionModifier = (float) -event.getDamage(DamageModifier.ABSORPTION);
|
||||
+ this.setAbsorptionHearts(Math.max(this.getAbsorptionHearts() - absorptionModifier, 0.0F));
|
||||
+ float f2 = absorptionModifier;
|
||||
+
|
||||
+ if (f2 > 0.0F && f2 < 3.4028235E37F && this instanceof EntityHuman) {
|
||||
+ ((EntityHuman) this).a(StatisticList.DAMAGE_ABSORBED, Math.round(f2 * 10.0F));
|
||||
+ }
|
||||
if (f2 > 0.0F && f2 < 3.4028235E37F && damagesource.getEntity() instanceof EntityPlayer) {
|
||||
((EntityPlayer) damagesource.getEntity()).a(StatisticList.DAMAGE_DEALT_ABSORBED, Math.round(f2 * 10.0F));
|
||||
}
|
||||
|
||||
- if (f != 0.0F) {
|
||||
+ if (f > 0 || !human) {
|
||||
+ if (human) {
|
||||
+ // PAIL: Be sure to drag all this code from the EntityHuman subclass each update.
|
||||
+ ((EntityHuman) this).applyExhaustion(damagesource.getExhaustionCost(), org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.DAMAGED); // CraftBukkit - EntityExhaustionEvent
|
||||
+ if (f < 3.4028235E37F) {
|
||||
+ ((EntityHuman) this).a(StatisticList.DAMAGE_TAKEN, Math.round(f * 10.0F));
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
float f3 = this.getHealth();
|
||||
|
||||
this.setHealth(f3 - f);
|
||||
this.getCombatTracker().trackDamage(damagesource, f3, f);
|
||||
- this.setAbsorptionHearts(this.getAbsorptionHearts() - f);
|
||||
+ // CraftBukkit start
|
||||
+ if (!human) {
|
||||
+ this.setAbsorptionHearts(this.getAbsorptionHearts() - f);
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+ } else {
|
||||
+ // Duplicate triggers if blocking
|
||||
+ if (event.getDamage(DamageModifier.BLOCKING) < 0) {
|
||||
+ if (this instanceof EntityPlayer) {
|
||||
+ CriterionTriggers.h.a((EntityPlayer) this, damagesource, f, originalDamage, true);
|
||||
+ f2 = (float) -event.getDamage(DamageModifier.BLOCKING);
|
||||
+ if (f2 > 0.0F && f2 < 3.4028235E37F) {
|
||||
+ ((EntityPlayer) this).a(StatisticList.DAMAGE_BLOCKED_BY_SHIELD, Math.round(originalDamage * 10.0F));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (damagesource.getEntity() instanceof EntityPlayer) {
|
||||
+ CriterionTriggers.g.a((EntityPlayer) damagesource.getEntity(), this, damagesource, f, originalDamage, true);
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ } else {
|
||||
+ return originalDamage > 0;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
+ return false; // CraftBukkit
|
||||
}
|
||||
|
||||
public CombatTracker getCombatTracker() {
|
||||
@@ -1464,9 +1874,19 @@
|
||||
}
|
||||
|
||||
public final void setArrowCount(int i) {
|
||||
- this.datawatcher.set(EntityLiving.ARROWS_IN_BODY, i);
|
||||
+ // CraftBukkit start
|
||||
+ setArrowCount(i, false);
|
||||
}
|
||||
|
||||
+ public final void setArrowCount(int i, boolean flag) {
|
||||
+ ArrowBodyCountChangeEvent event = CraftEventFactory.callArrowBodyCountChangeEvent(this, getArrowCount(), i, flag);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ this.datawatcher.set(EntityLiving.ARROWS_IN_BODY, event.getNewAmount());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public final int dz() {
|
||||
return (Integer) this.datawatcher.get(EntityLiving.bi);
|
||||
}
|
||||
@@ -1594,6 +2014,12 @@
|
||||
|
||||
public abstract ItemStack getEquipment(EnumItemSlot enumitemslot);
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) {
|
||||
+ this.setSlot(enumitemslot, itemstack);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public abstract void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack);
|
||||
|
||||
@@ -1816,6 +2242,7 @@
|
||||
}
|
||||
|
||||
if (this.onGround && !this.world.isClientSide) {
|
||||
+ if (getFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit
|
||||
this.setFlag(7, false);
|
||||
}
|
||||
} else {
|
||||
@@ -1957,7 +2384,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- this.p();
|
||||
+ this.updateEquipment(); // PAIL rename
|
||||
if (this.ticksLived % 20 == 0) {
|
||||
this.getCombatTracker().g();
|
||||
}
|
||||
@@ -2058,7 +2485,7 @@
|
||||
|
||||
}
|
||||
|
||||
- private void p() {
|
||||
+ public void updateEquipment() { // PAIL private->public; updateEquipment
|
||||
Map<EnumItemSlot, ItemStack> map = this.q();
|
||||
|
||||
if (map != null) {
|
||||
@@ -2321,6 +2748,7 @@
|
||||
}
|
||||
|
||||
if (!this.world.isClientSide) {
|
||||
+ if (flag != this.getFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, flag).isCancelled()) // CraftBukkit
|
||||
this.setFlag(7, flag);
|
||||
}
|
||||
|
||||
@@ -2441,6 +2869,7 @@
|
||||
}
|
||||
|
||||
public boolean hasLineOfSight(Entity entity) {
|
||||
+ if (this.world != entity.world) return false; // CraftBukkit - SPIGOT-5675, SPIGOT-5798, MC-149563
|
||||
Vec3D vec3d = new Vec3D(this.locX(), this.getHeadY(), this.locZ());
|
||||
Vec3D vec3d1 = new Vec3D(entity.locX(), entity.getHeadY(), entity.locZ());
|
||||
|
||||
@@ -2458,14 +2887,21 @@
|
||||
|
||||
@Override
|
||||
public boolean isInteractable() {
|
||||
- return !this.dead;
|
||||
+ return !this.dead && this.collides; // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
- return this.isAlive() && !this.isSpectator() && !this.isClimbing();
|
||||
+ return this.isAlive() && !this.isSpectator() && !this.isClimbing() && this.collides; // CraftBukkit
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - collidable API
|
||||
+ @Override
|
||||
+ public boolean canCollideWith(Entity entity) {
|
||||
+ return isCollidable() && this.collides != this.collidableExemptions.contains(entity.getUniqueID());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
protected void velocityChanged() {
|
||||
this.velocityChanged = this.random.nextDouble() >= this.b(GenericAttributes.KNOCKBACK_RESISTANCE);
|
||||
@@ -2658,7 +3094,25 @@
|
||||
} else {
|
||||
if (!this.activeItem.isEmpty() && this.isHandRaised()) {
|
||||
this.b(this.activeItem, 16);
|
||||
- ItemStack itemstack = this.activeItem.a(this.world, this);
|
||||
+ // CraftBukkit start - fire PlayerItemConsumeEvent
|
||||
+ ItemStack itemstack;
|
||||
+ if (this instanceof EntityPlayer) {
|
||||
+ org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.activeItem);
|
||||
+ PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ // Update client
|
||||
+ ((EntityPlayer) this).getBukkitEntity().updateInventory();
|
||||
+ ((EntityPlayer) this).getBukkitEntity().updateScaledHealth();
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ itemstack = (craftItem.equals(event.getItem())) ? this.activeItem.a(this.world, this) : CraftItemStack.asNMSCopy(event.getItem()).a(world, this);
|
||||
+ } else {
|
||||
+ itemstack = this.activeItem.a(this.world, this);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (itemstack != this.activeItem) {
|
||||
this.a(enumhand, itemstack);
|
||||
@@ -2750,10 +3204,18 @@
|
||||
}
|
||||
|
||||
if (flag2) {
|
||||
- this.enderTeleportTo(d0, d6, d2);
|
||||
- if (world.getCubes(this) && !world.containsLiquid(this.getBoundingBox())) {
|
||||
- flag1 = true;
|
||||
+ // CraftBukkit start - Teleport event
|
||||
+ // this.enderTeleportTo(d0, d6, d2);
|
||||
+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.world.getWorld(), d3, d4, d5), new Location(this.world.getWorld(), d0, d6, d2));
|
||||
+ this.world.getServer().getPluginManager().callEvent(teleport);
|
||||
+ if (!teleport.isCancelled()) {
|
||||
+ Location to = teleport.getTo();
|
||||
+ this.enderTeleportTo(to.getX(), to.getY(), to.getZ());
|
||||
+ if (world.getCubes(this) && !world.containsLiquid(this.getBoundingBox())) {
|
||||
+ flag1 = true;
|
||||
+ }
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2850,7 +3312,7 @@
|
||||
}
|
||||
|
||||
public void entityWakeup() {
|
||||
- Optional optional = this.getBedPosition();
|
||||
+ Optional<BlockPosition> optional = this.getBedPosition(); // CraftBukkit - decompile error
|
||||
World world = this.world;
|
||||
|
||||
this.world.getClass();
|
||||
@@ -2921,7 +3383,7 @@
|
||||
Pair<MobEffect, Float> pair = (Pair) iterator.next();
|
||||
|
||||
if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) {
|
||||
- entityliving.addEffect(new MobEffect((MobEffect) pair.getFirst()));
|
||||
+ entityliving.addEffect(new MobEffect((MobEffect) pair.getFirst()), EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
--- a/net/minecraft/server/EntityTypes.java
|
||||
+++ b/net/minecraft/server/EntityTypes.java
|
||||
@@ -12,7 +12,7 @@
|
||||
public class EntityTypes<T extends Entity> {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
- public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = a("area_effect_cloud", EntityTypes.Builder.a(EntityAreaEffectCloud::new, EnumCreatureType.MISC).c().a(6.0F, 0.5F).trackingRange(10).updateInterval(Integer.MAX_VALUE));
|
||||
+ public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = a("area_effect_cloud", EntityTypes.Builder.a(EntityAreaEffectCloud::new, EnumCreatureType.MISC).c().a(6.0F, 0.5F).trackingRange(10).updateInterval(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds
|
||||
public static final EntityTypes<EntityArmorStand> ARMOR_STAND = a("armor_stand", EntityTypes.Builder.a(EntityArmorStand::new, EnumCreatureType.MISC).a(0.5F, 1.975F).trackingRange(10));
|
||||
public static final EntityTypes<EntityTippedArrow> ARROW = a("arrow", EntityTypes.Builder.a(EntityTippedArrow::new, EnumCreatureType.MISC).a(0.5F, 0.5F).trackingRange(4).updateInterval(20));
|
||||
public static final EntityTypes<EntityBat> BAT = a("bat", EntityTypes.Builder.a(EntityBat::new, EnumCreatureType.AMBIENT).a(0.5F, 0.9F).trackingRange(5));
|
||||
@@ -137,7 +137,7 @@
|
||||
private MinecraftKey bq;
|
||||
private final EntitySize br;
|
||||
|
||||
- private static <T extends Entity> EntityTypes<T> a(String s, EntityTypes.Builder<T> entitytypes_builder) {
|
||||
+ private static <T extends Entity> EntityTypes<T> a(String s, EntityTypes.Builder entitytypes_builder) { // CraftBukkit - decompile error
|
||||
return (EntityTypes) IRegistry.a((IRegistry) IRegistry.ENTITY_TYPE, s, (Object) entitytypes_builder.a(s));
|
||||
}
|
||||
|
||||
@@ -169,10 +169,18 @@
|
||||
|
||||
@Nullable
|
||||
public T spawnCreature(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) {
|
||||
+ // CraftBukkit start
|
||||
+ return this.spawnCreature(worldserver, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ public T spawnCreature(WorldServer worldserver, @Nullable NBTTagCompound nbttagcompound, @Nullable IChatBaseComponent ichatbasecomponent, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
|
||||
T t0 = this.createCreature(worldserver, nbttagcompound, ichatbasecomponent, entityhuman, blockposition, enummobspawn, flag, flag1);
|
||||
|
||||
if (t0 != null) {
|
||||
- worldserver.addAllEntities(t0);
|
||||
+ worldserver.addAllEntities(t0, spawnReason);
|
||||
+ return !t0.dead ? t0 : null; // Don't return an entity when CreatureSpawnEvent is canceled
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
return t0;
|
||||
@@ -208,7 +216,7 @@
|
||||
t0.setCustomName(ichatbasecomponent);
|
||||
}
|
||||
|
||||
- a((World) worldserver, entityhuman, t0, nbttagcompound);
|
||||
+ try { a((World) worldserver, entityhuman, t0, nbttagcompound); } catch (Throwable t) { LOGGER.warn("Error loading spawn egg NBT", t); } // CraftBukkit - SPIGOT-5665
|
||||
return t0;
|
||||
}
|
||||
}
|
||||
@@ -351,7 +359,7 @@
|
||||
}
|
||||
|
||||
return entity;
|
||||
- }).orElse((Object) null);
|
||||
+ }).orElse(null); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
private static Optional<Entity> b(NBTTagCompound nbttagcompound, World world) {
|
||||
@@ -403,7 +411,7 @@
|
||||
this.g = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC;
|
||||
}
|
||||
|
||||
- public static <T extends Entity> EntityTypes.Builder<T> a(EntityTypes.b<T> entitytypes_b, EnumCreatureType enumcreaturetype) {
|
||||
+ public static <T extends Entity> EntityTypes.Builder<T> a(EntityTypes.b entitytypes_b, EnumCreatureType enumcreaturetype) { // CraftBukkit - decompile error
|
||||
return new EntityTypes.Builder<>(entitytypes_b, enumcreaturetype);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/server/IEntityAngerable.java
|
||||
+++ b/net/minecraft/server/IEntityAngerable.java
|
||||
@@ -98,7 +98,7 @@
|
||||
default void pacify() {
|
||||
this.setLastDamager((EntityLiving) null);
|
||||
this.setAngerTarget((UUID) null);
|
||||
- this.setGoalTarget((EntityLiving) null);
|
||||
+ this.setGoalTarget((EntityLiving) null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit
|
||||
this.setAnger(0);
|
||||
}
|
||||
|
||||
@@ -108,6 +108,8 @@
|
||||
|
||||
void setGoalTarget(@Nullable EntityLiving entityliving);
|
||||
|
||||
+ boolean setGoalTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent); // CraftBukkit
|
||||
+
|
||||
@Nullable
|
||||
EntityLiving getGoalTarget();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/IEntitySelector.java
|
||||
+++ b/net/minecraft/server/IEntitySelector.java
|
||||
@@ -37,7 +37,7 @@
|
||||
ScoreboardTeamBase.EnumTeamPush scoreboardteambase_enumteampush = scoreboardteambase == null ? ScoreboardTeamBase.EnumTeamPush.ALWAYS : scoreboardteambase.getCollisionRule();
|
||||
|
||||
return (Predicate) (scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.NEVER ? Predicates.alwaysFalse() : IEntitySelector.g.and((entity1) -> {
|
||||
- if (!entity1.isCollidable()) {
|
||||
+ if (!entity1.canCollideWith(entity) || !entity.canCollideWith(entity1)) { // CraftBukkit - collidable API
|
||||
return false;
|
||||
} else if (entity.world.isClientSide && (!(entity1 instanceof EntityHuman) || !((EntityHuman) entity1).ez())) {
|
||||
return false;
|
||||
@@ -0,0 +1,18 @@
|
||||
--- a/net/minecraft/server/SaddleStorage.java
|
||||
+++ b/net/minecraft/server/SaddleStorage.java
|
||||
@@ -35,6 +35,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit add setBoostTicks(int)
|
||||
+ public void setBoostTicks(int ticks) {
|
||||
+ this.boosting = true;
|
||||
+ this.currentBoostTicks = 0;
|
||||
+ this.boostTicks = ticks;
|
||||
+ this.dataWatcher.set(this.dataWatcherBoostTicks, this.boostTicks);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setBoolean("Saddle", this.hasSaddle());
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/AttributeRanged.java
|
||||
+++ b/net/minecraft/server/AttributeRanged.java
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
@Override
|
||||
public double a(double d0) {
|
||||
+ if (d0 != d0) return getDefault(); // CraftBukkit
|
||||
+
|
||||
d0 = MathHelper.a(d0, this.a, this.maximum);
|
||||
return d0;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
--- a/net/minecraft/server/BehaviorAttackTargetForget.java
|
||||
+++ b/net/minecraft/server/BehaviorAttackTargetForget.java
|
||||
@@ -4,6 +4,12 @@
|
||||
import java.util.Optional;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BehaviorAttackTargetForget<E extends EntityInsentient> extends Behavior<E> {
|
||||
|
||||
private final Predicate<EntityLiving> b;
|
||||
@@ -54,6 +60,17 @@
|
||||
}
|
||||
|
||||
private void d(E e0) {
|
||||
+ // CraftBukkit start
|
||||
+ EntityLiving old = e0.getBehaviorController().getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null);
|
||||
+ EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(e0, null, (old != null && !old.isAlive()) ? EntityTargetEvent.TargetReason.TARGET_DIED : EntityTargetEvent.TargetReason.FORGOT_TARGET);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ if (event.getTarget() != null) {
|
||||
+ e0.getBehaviorController().setMemory(MemoryModuleType.ATTACK_TARGET, ((CraftLivingEntity) event.getTarget()).getHandle());
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
e0.getBehaviorController().removeMemory(MemoryModuleType.ATTACK_TARGET);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
--- a/net/minecraft/server/BehaviorAttackTargetSet.java
|
||||
+++ b/net/minecraft/server/BehaviorAttackTargetSet.java
|
||||
@@ -5,6 +5,12 @@
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BehaviorAttackTargetSet<E extends EntityInsentient> extends Behavior<E> {
|
||||
|
||||
private final Predicate<E> b;
|
||||
@@ -33,13 +39,21 @@
|
||||
}
|
||||
|
||||
protected void a(WorldServer worldserver, E e0, long i) {
|
||||
- ((Optional) this.c.apply(e0)).ifPresent((entityliving) -> {
|
||||
+ (this.c.apply(e0)).ifPresent((entityliving) -> { // CraftBukkit - decompile error
|
||||
this.a(e0, entityliving);
|
||||
});
|
||||
}
|
||||
|
||||
private void a(E e0, EntityLiving entityliving) {
|
||||
- e0.getBehaviorController().setMemory(MemoryModuleType.ATTACK_TARGET, (Object) entityliving);
|
||||
+ // CraftBukkit start
|
||||
+ EntityTargetEvent event = CraftEventFactory.callEntityTargetLivingEvent(e0, entityliving, (entityliving instanceof EntityPlayer) ? EntityTargetEvent.TargetReason.CLOSEST_PLAYER : EntityTargetEvent.TargetReason.CLOSEST_ENTITY);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ entityliving = (event.getTarget() != null) ? ((CraftLivingEntity) event.getTarget()).getHandle() : null;
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ e0.getBehaviorController().setMemory(MemoryModuleType.ATTACK_TARGET, entityliving); // CraftBukkit - decompile error
|
||||
e0.getBehaviorController().removeMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
--- a/net/minecraft/server/BehaviorCareer.java
|
||||
+++ b/net/minecraft/server/BehaviorCareer.java
|
||||
@@ -3,6 +3,12 @@
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import java.util.Optional;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.entity.CraftVillager;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.VillagerCareerChangeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BehaviorCareer extends Behavior<EntityVillager> {
|
||||
|
||||
public BehaviorCareer() {
|
||||
@@ -19,7 +25,7 @@
|
||||
GlobalPos globalpos = (GlobalPos) entityvillager.getBehaviorController().getMemory(MemoryModuleType.POTENTIAL_JOB_SITE).get();
|
||||
|
||||
entityvillager.getBehaviorController().removeMemory(MemoryModuleType.POTENTIAL_JOB_SITE);
|
||||
- entityvillager.getBehaviorController().setMemory(MemoryModuleType.JOB_SITE, (Object) globalpos);
|
||||
+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.JOB_SITE, globalpos); // CraftBukkit - decompile error
|
||||
worldserver.broadcastEntityEffect(entityvillager, (byte) 14);
|
||||
if (entityvillager.getVillagerData().getProfession() == VillagerProfession.NONE) {
|
||||
MinecraftServer minecraftserver = worldserver.getMinecraftServer();
|
||||
@@ -31,7 +37,14 @@
|
||||
return villagerprofession.b() == villageplacetype;
|
||||
}).findFirst();
|
||||
}).ifPresent((villagerprofession) -> {
|
||||
- entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(villagerprofession));
|
||||
+ // CraftBukkit start - Fire VillagerCareerChangeEvent where Villager gets employed
|
||||
+ VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.nmsToBukkitProfession(villagerprofession), VillagerCareerChangeEvent.ChangeReason.EMPLOYED);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(CraftVillager.bukkitToNmsProfession(event.getProfession())));
|
||||
+ // CraftBukkit end
|
||||
entityvillager.c(worldserver);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
--- a/net/minecraft/server/BehaviorFarm.java
|
||||
+++ b/net/minecraft/server/BehaviorFarm.java
|
||||
@@ -58,8 +58,8 @@
|
||||
|
||||
protected void a(WorldServer worldserver, EntityVillager entityvillager, long i) {
|
||||
if (i > this.c && this.farmBlock != null) {
|
||||
- entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(this.farmBlock)));
|
||||
- entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(new BehaviorTarget(this.farmBlock), 0.5F, 1)));
|
||||
+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(this.farmBlock))); // CraftBukkit - decompile error
|
||||
+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(new BehaviorTarget(this.farmBlock), 0.5F, 1))); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
}
|
||||
@@ -79,7 +79,11 @@
|
||||
Block block1 = worldserver.getType(this.farmBlock.down()).getBlock();
|
||||
|
||||
if (block instanceof BlockCrops && ((BlockCrops) block).isRipe(iblockdata)) {
|
||||
- worldserver.a(this.farmBlock, true, entityvillager);
|
||||
+ // CraftBukkit start
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.farmBlock, Blocks.AIR.getBlockData()).isCancelled()) {
|
||||
+ worldserver.a(this.farmBlock, true, entityvillager);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
if (iblockdata.isAir() && block1 instanceof BlockSoil && entityvillager.canPlant()) {
|
||||
@@ -90,19 +94,28 @@
|
||||
boolean flag = false;
|
||||
|
||||
if (!itemstack.isEmpty()) {
|
||||
+ // CraftBukkit start
|
||||
+ Block planted = null;
|
||||
if (itemstack.getItem() == Items.WHEAT_SEEDS) {
|
||||
- worldserver.setTypeAndData(this.farmBlock, Blocks.WHEAT.getBlockData(), 3);
|
||||
+ planted = Blocks.WHEAT;
|
||||
flag = true;
|
||||
} else if (itemstack.getItem() == Items.POTATO) {
|
||||
- worldserver.setTypeAndData(this.farmBlock, Blocks.POTATOES.getBlockData(), 3);
|
||||
+ planted = Blocks.POTATOES;
|
||||
flag = true;
|
||||
} else if (itemstack.getItem() == Items.CARROT) {
|
||||
- worldserver.setTypeAndData(this.farmBlock, Blocks.CARROTS.getBlockData(), 3);
|
||||
+ planted = Blocks.CARROTS;
|
||||
flag = true;
|
||||
} else if (itemstack.getItem() == Items.BEETROOT_SEEDS) {
|
||||
- worldserver.setTypeAndData(this.farmBlock, Blocks.BEETROOTS.getBlockData(), 3);
|
||||
+ planted = Blocks.BEETROOTS;
|
||||
flag = true;
|
||||
}
|
||||
+
|
||||
+ if (planted != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.farmBlock, planted.getBlockData()).isCancelled()) {
|
||||
+ worldserver.setTypeAndData(this.farmBlock, planted.getBlockData(), 3);
|
||||
+ } else {
|
||||
+ flag = false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
@@ -121,8 +134,8 @@
|
||||
this.farmBlock = this.a(worldserver);
|
||||
if (this.farmBlock != null) {
|
||||
this.c = i + 20L;
|
||||
- entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(new BehaviorTarget(this.farmBlock), 0.5F, 1)));
|
||||
- entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(this.farmBlock)));
|
||||
+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(new BehaviorTarget(this.farmBlock), 0.5F, 1))); // CraftBukkit - decompile error
|
||||
+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(this.farmBlock))); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
--- a/net/minecraft/server/BehaviorInteractDoor.java
|
||||
+++ b/net/minecraft/server/BehaviorInteractDoor.java
|
||||
@@ -52,6 +52,13 @@
|
||||
BlockDoor blockdoor = (BlockDoor) iblockdata.getBlock();
|
||||
|
||||
if (!blockdoor.h(iblockdata)) {
|
||||
+ // CraftBukkit start - entities opening doors
|
||||
+ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entityliving.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(entityliving.world, blockposition));
|
||||
+ entityliving.world.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
blockdoor.setDoor(worldserver, iblockdata, blockposition, true);
|
||||
}
|
||||
|
||||
@@ -65,6 +72,13 @@
|
||||
BlockDoor blockdoor1 = (BlockDoor) iblockdata1.getBlock();
|
||||
|
||||
if (!blockdoor1.h(iblockdata1)) {
|
||||
+ // CraftBukkit start - entities opening doors
|
||||
+ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entityliving.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(entityliving.world, blockposition));
|
||||
+ entityliving.world.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
blockdoor1.setDoor(worldserver, iblockdata1, blockposition1, true);
|
||||
this.c(worldserver, entityliving, blockposition1);
|
||||
}
|
||||
@@ -113,7 +127,7 @@
|
||||
private static boolean a(WorldServer worldserver, EntityLiving entityliving, BlockPosition blockposition) {
|
||||
BehaviorController<?> behaviorcontroller = entityliving.getBehaviorController();
|
||||
|
||||
- return !behaviorcontroller.hasMemory(MemoryModuleType.MOBS) ? false : ((List) behaviorcontroller.getMemory(MemoryModuleType.MOBS).get()).stream().filter((entityliving1) -> {
|
||||
+ return !behaviorcontroller.hasMemory(MemoryModuleType.MOBS) ? false : (behaviorcontroller.getMemory(MemoryModuleType.MOBS).get()).stream().filter((entityliving1) -> { // CraftBukkit - decompile error
|
||||
return entityliving1.getEntityType() == entityliving.getEntityType();
|
||||
}).filter((entityliving1) -> {
|
||||
return blockposition.a((IPosition) entityliving1.getPositionVector(), 2.0D);
|
||||
@@ -155,7 +169,7 @@
|
||||
if (behaviorcontroller.getMemory(MemoryModuleType.DOORS_TO_CLOSE).isPresent()) {
|
||||
((Set) behaviorcontroller.getMemory(MemoryModuleType.DOORS_TO_CLOSE).get()).add(globalpos);
|
||||
} else {
|
||||
- behaviorcontroller.setMemory(MemoryModuleType.DOORS_TO_CLOSE, (Object) Sets.newHashSet(new GlobalPos[]{globalpos}));
|
||||
+ behaviorcontroller.setMemory(MemoryModuleType.DOORS_TO_CLOSE, Sets.newHashSet(new GlobalPos[]{globalpos})); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
--- a/net/minecraft/server/BehaviorMakeLove.java
|
||||
+++ b/net/minecraft/server/BehaviorMakeLove.java
|
||||
@@ -93,6 +93,11 @@
|
||||
|
||||
private Optional<EntityVillager> b(WorldServer worldserver, EntityVillager entityvillager, EntityVillager entityvillager1) {
|
||||
EntityVillager entityvillager2 = entityvillager.createChild(worldserver, entityvillager1);
|
||||
+ // CraftBukkit start - call EntityBreedEvent
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityvillager2, entityvillager, entityvillager1, null, null, 0).isCancelled()) {
|
||||
+ return Optional.empty();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (entityvillager2 == null) {
|
||||
return Optional.empty();
|
||||
@@ -101,7 +106,7 @@
|
||||
entityvillager1.setAgeRaw(6000);
|
||||
entityvillager2.setAgeRaw(-24000);
|
||||
entityvillager2.setPositionRotation(entityvillager.locX(), entityvillager.locY(), entityvillager.locZ(), 0.0F, 0.0F);
|
||||
- worldserver.addAllEntities(entityvillager2);
|
||||
+ worldserver.addAllEntities(entityvillager2, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
|
||||
worldserver.broadcastEntityEffect(entityvillager2, (byte) 12);
|
||||
return Optional.of(entityvillager2);
|
||||
}
|
||||
@@ -110,6 +115,6 @@
|
||||
private void a(WorldServer worldserver, EntityVillager entityvillager, BlockPosition blockposition) {
|
||||
GlobalPos globalpos = GlobalPos.create(worldserver.getDimensionKey(), blockposition);
|
||||
|
||||
- entityvillager.getBehaviorController().setMemory(MemoryModuleType.HOME, (Object) globalpos);
|
||||
+ entityvillager.getBehaviorController().setMemory(MemoryModuleType.HOME, globalpos); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
--- a/net/minecraft/server/BehaviorProfession.java
|
||||
+++ b/net/minecraft/server/BehaviorProfession.java
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.entity.CraftVillager;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.VillagerCareerChangeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BehaviorProfession extends Behavior<EntityVillager> {
|
||||
|
||||
public BehaviorProfession() {
|
||||
@@ -15,7 +21,14 @@
|
||||
}
|
||||
|
||||
protected void a(WorldServer worldserver, EntityVillager entityvillager, long i) {
|
||||
- entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(VillagerProfession.NONE));
|
||||
+ // CraftBukkit start
|
||||
+ VillagerCareerChangeEvent event = CraftEventFactory.callVillagerCareerChangeEvent(entityvillager, CraftVillager.nmsToBukkitProfession(VillagerProfession.NONE), VillagerCareerChangeEvent.ChangeReason.EMPLOYED);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ entityvillager.setVillagerData(entityvillager.getVillagerData().withProfession(CraftVillager.bukkitToNmsProfession(event.getProfession())));
|
||||
+ // CraftBukkit end
|
||||
entityvillager.c(worldserver);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
--- a/net/minecraft/server/BehaviorUtil.java
|
||||
+++ b/net/minecraft/server/BehaviorUtil.java
|
||||
@@ -38,7 +38,7 @@
|
||||
}
|
||||
|
||||
public static void a(EntityLiving entityliving, EntityLiving entityliving1) {
|
||||
- entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorPositionEntity(entityliving1, true)));
|
||||
+ entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorPositionEntity(entityliving1, true))); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
private static void b(EntityLiving entityliving, EntityLiving entityliving1, float f) {
|
||||
@@ -51,18 +51,19 @@
|
||||
public static void a(EntityLiving entityliving, Entity entity, float f, int i) {
|
||||
MemoryTarget memorytarget = new MemoryTarget(new BehaviorPositionEntity(entity, false), f, i);
|
||||
|
||||
- entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorPositionEntity(entity, true)));
|
||||
- entityliving.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (Object) memorytarget);
|
||||
+ entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorPositionEntity(entity, true))); // CraftBukkit - decompile error
|
||||
+ entityliving.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, memorytarget); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public static void a(EntityLiving entityliving, BlockPosition blockposition, float f, int i) {
|
||||
MemoryTarget memorytarget = new MemoryTarget(new BehaviorTarget(blockposition), f, i);
|
||||
|
||||
- entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (Object) (new BehaviorTarget(blockposition)));
|
||||
- entityliving.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, (Object) memorytarget);
|
||||
+ entityliving.getBehaviorController().setMemory(MemoryModuleType.LOOK_TARGET, (new BehaviorTarget(blockposition))); // CraftBukkit - decompile error
|
||||
+ entityliving.getBehaviorController().setMemory(MemoryModuleType.WALK_TARGET, memorytarget); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public static void a(EntityLiving entityliving, ItemStack itemstack, Vec3D vec3d) {
|
||||
+ if (itemstack.isEmpty()) return; // CraftBukkit - SPIGOT-4940: no empty loot
|
||||
double d0 = entityliving.getHeadY() - 0.30000001192092896D;
|
||||
EntityItem entityitem = new EntityItem(entityliving.world, entityliving.locX(), d0, entityliving.locZ(), itemstack);
|
||||
float f = 0.3F;
|
||||
@@ -71,12 +72,19 @@
|
||||
vec3d1 = vec3d1.d().a(0.30000001192092896D);
|
||||
entityitem.setMot(vec3d1);
|
||||
entityitem.defaultPickupDelay();
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(entityliving.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
|
||||
+ entityitem.world.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
entityliving.world.addEntity(entityitem);
|
||||
}
|
||||
|
||||
public static SectionPosition a(WorldServer worldserver, SectionPosition sectionposition, int i) {
|
||||
int j = worldserver.b(sectionposition);
|
||||
- Stream stream = SectionPosition.a(sectionposition, i).filter((sectionposition1) -> {
|
||||
+ Stream<SectionPosition> stream = SectionPosition.a(sectionposition, i).filter((sectionposition1) -> { // CraftBukkit - decompile error
|
||||
return worldserver.b(sectionposition1) < j;
|
||||
});
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
--- a/net/minecraft/server/BehaviorWorkComposter.java
|
||||
+++ b/net/minecraft/server/BehaviorWorkComposter.java
|
||||
@@ -11,7 +11,7 @@
|
||||
public BehaviorWorkComposter() {}
|
||||
|
||||
@Override
|
||||
- protected void a(WorldServer worldserver, EntityVillager entityvillager) {
|
||||
+ protected void doWork(WorldServer worldserver, EntityVillager entityvillager) { // PAIL
|
||||
Optional<GlobalPos> optional = entityvillager.getBehaviorController().getMemory(MemoryModuleType.JOB_SITE);
|
||||
|
||||
if (optional.isPresent()) {
|
||||
@@ -30,7 +30,7 @@
|
||||
BlockPosition blockposition = globalpos.getBlockPosition();
|
||||
|
||||
if ((Integer) iblockdata.get(BlockComposter.a) == 8) {
|
||||
- iblockdata = BlockComposter.d(iblockdata, (World) worldserver, blockposition);
|
||||
+ iblockdata = BlockComposter.d(iblockdata, (World) worldserver, blockposition, entityvillager); // CraftBukkit
|
||||
}
|
||||
|
||||
int i = 20;
|
||||
@@ -55,7 +55,7 @@
|
||||
i -= k1;
|
||||
|
||||
for (int l1 = 0; l1 < k1; ++l1) {
|
||||
- iblockdata1 = BlockComposter.a(iblockdata1, worldserver, itemstack, blockposition);
|
||||
+ iblockdata1 = BlockComposter.a(iblockdata1, worldserver, itemstack, blockposition, entityvillager); // CraftBukkit
|
||||
if ((Integer) iblockdata1.get(BlockComposter.a) == 7) {
|
||||
this.a(worldserver, iblockdata, blockposition, iblockdata1);
|
||||
return;
|
||||
@@ -0,0 +1,15 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalBreakDoor.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalBreakDoor.java
|
||||
@@ -66,6 +66,12 @@
|
||||
}
|
||||
|
||||
if (this.a == this.f() && this.a(this.entity.world.getDifficulty())) {
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreakDoorEvent(this.entity, this.door).isCancelled()) {
|
||||
+ this.c();
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.entity.world.a(this.door, false);
|
||||
this.entity.world.triggerEffect(1021, this.door, 0);
|
||||
this.entity.world.triggerEffect(2001, this.door, Block.getCombinedId(this.entity.world.getType(this.door)));
|
||||
@@ -0,0 +1,33 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalEatTile.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalEatTile.java
|
||||
@@ -3,6 +3,10 @@
|
||||
import java.util.EnumSet;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PathfinderGoalEatTile extends PathfinderGoal {
|
||||
|
||||
private static final Predicate<IBlockData> a = BlockStatePredicate.a(Blocks.GRASS);
|
||||
@@ -55,7 +59,8 @@
|
||||
BlockPosition blockposition = this.b.getChunkCoordinates();
|
||||
|
||||
if (PathfinderGoalEatTile.a.test(this.c.getType(blockposition))) {
|
||||
- if (this.c.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) {
|
||||
+ // CraftBukkit
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, blockposition, Blocks.AIR.getBlockData(), !this.c.getGameRules().getBoolean(GameRules.MOB_GRIEFING)).isCancelled()) {
|
||||
this.c.b(blockposition, false);
|
||||
}
|
||||
|
||||
@@ -64,7 +69,8 @@
|
||||
BlockPosition blockposition1 = blockposition.down();
|
||||
|
||||
if (this.c.getType(blockposition1).a(Blocks.GRASS_BLOCK)) {
|
||||
- if (this.c.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) {
|
||||
+ // CraftBukkit
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.b, blockposition, Blocks.AIR.getBlockData(), !this.c.getGameRules().getBoolean(GameRules.MOB_GRIEFING)).isCancelled()) {
|
||||
this.c.triggerEffect(2001, blockposition1, Block.getCombinedId(Blocks.GRASS_BLOCK.getBlockData()));
|
||||
this.c.setTypeAndData(blockposition1, Blocks.DIRT.getBlockData(), 2);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalFollowOwner.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalFollowOwner.java
|
||||
@@ -2,6 +2,12 @@
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
+import org.bukkit.event.entity.EntityTeleportEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PathfinderGoalFollowOwner extends PathfinderGoal {
|
||||
|
||||
private final EntityTameableAnimal a;
|
||||
@@ -104,7 +110,18 @@
|
||||
} else if (!this.a(new BlockPosition(i, j, k))) {
|
||||
return false;
|
||||
} else {
|
||||
- this.a.setPositionRotation((double) i + 0.5D, (double) j, (double) k + 0.5D, this.a.yaw, this.a.pitch);
|
||||
+ // CraftBukkit start
|
||||
+ CraftEntity entity = this.a.getBukkitEntity();
|
||||
+ Location to = new Location(entity.getWorld(), (double) i + 0.5D, (double) j, (double) k + 0.5D, this.a.yaw, this.a.pitch);
|
||||
+ EntityTeleportEvent event = new EntityTeleportEvent(entity, entity.getLocation(), to);
|
||||
+ this.a.world.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ to = event.getTo();
|
||||
+
|
||||
+ this.a.setPositionRotation(to.getX(), to.getY(), to.getZ(), to.getYaw(), to.getPitch());
|
||||
+ // CraftBukkit end
|
||||
this.e.o();
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalPanic.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalPanic.java
|
||||
@@ -68,6 +68,12 @@
|
||||
|
||||
@Override
|
||||
public boolean b() {
|
||||
+ // CraftBukkit start - introduce a temporary timeout hack until this is fixed properly
|
||||
+ if ((this.a.ticksLived - this.a.hurtTimestamp) > 100) {
|
||||
+ this.a.setLastDamager((EntityLiving) null);
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return !this.a.getNavigation().m();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalRemoveBlock.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalRemoveBlock.java
|
||||
@@ -3,6 +3,11 @@
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.event.entity.EntityInteractEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
|
||||
|
||||
private final Block g;
|
||||
@@ -81,6 +86,14 @@
|
||||
}
|
||||
|
||||
if (this.i > 60) {
|
||||
+ // CraftBukkit start - Step on eggs
|
||||
+ EntityInteractEvent event = new EntityInteractEvent(this.entity.getBukkitEntity(), CraftBlock.at(world, blockposition1));
|
||||
+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.a(blockposition1, false);
|
||||
if (!world.isClientSide) {
|
||||
for (int i = 0; i < 20; ++i) {
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalSit.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalSit.java
|
||||
@@ -19,7 +19,7 @@
|
||||
@Override
|
||||
public boolean a() {
|
||||
if (!this.entity.isTamed()) {
|
||||
- return false;
|
||||
+ return this.entity.isWillSit() && this.entity.getGoalTarget() == null; // CraftBukkit - Allow sitting for wild animals
|
||||
} else if (this.entity.aH()) {
|
||||
return false;
|
||||
} else if (!this.entity.isOnGround()) {
|
||||
@@ -0,0 +1,12 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalTame.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalTame.java
|
||||
@@ -57,7 +57,8 @@
|
||||
int i = this.entity.getTemper();
|
||||
int j = this.entity.getMaxDomestication();
|
||||
|
||||
- if (j > 0 && this.entity.getRandom().nextInt(j) < i) {
|
||||
+ // CraftBukkit - fire EntityTameEvent
|
||||
+ if (j > 0 && this.entity.getRandom().nextInt(j) < i && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this.entity, ((org.bukkit.craftbukkit.entity.CraftHumanEntity) this.entity.getBukkitEntity().getPassenger()).getHandle()).isCancelled()) {
|
||||
this.entity.i((EntityHuman) entity);
|
||||
return;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalTempt.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalTempt.java
|
||||
@@ -2,6 +2,13 @@
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
+import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class PathfinderGoalTempt extends PathfinderGoal {
|
||||
|
||||
private static final PathfinderTargetCondition c = (new PathfinderTargetCondition()).a(10.0D).a().b().d().c();
|
||||
@@ -12,7 +19,7 @@
|
||||
private double g;
|
||||
private double h;
|
||||
private double i;
|
||||
- protected EntityHuman target;
|
||||
+ protected EntityLiving target; // CraftBukkit
|
||||
private int j;
|
||||
private boolean k;
|
||||
private final RecipeItemStack l;
|
||||
@@ -40,7 +47,17 @@
|
||||
return false;
|
||||
} else {
|
||||
this.target = this.a.world.a(PathfinderGoalTempt.c, (EntityLiving) this.a);
|
||||
- return this.target == null ? false : this.a(this.target.getItemInMainHand()) || this.a(this.target.getItemInOffHand());
|
||||
+ // CraftBukkit start
|
||||
+ boolean tempt = this.target == null ? false : this.a(this.target.getItemInMainHand()) || this.a(this.target.getItemInOffHand());
|
||||
+ if (tempt) {
|
||||
+ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this.a, this.target, EntityTargetEvent.TargetReason.TEMPT);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ this.target = (event.getTarget() == null) ? null : ((CraftLivingEntity) event.getTarget()).getHandle();
|
||||
+ }
|
||||
+ return tempt;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalDefendVillage.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalDefendVillage.java
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
@Override
|
||||
public void c() {
|
||||
- this.a.setGoalTarget(this.b);
|
||||
+ this.a.setGoalTarget(this.b, org.bukkit.event.entity.EntityTargetEvent.TargetReason.DEFEND_VILLAGE, true); // CraftBukkit - reason
|
||||
super.c();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalHurtByTarget.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalHurtByTarget.java
|
||||
@@ -53,7 +53,7 @@
|
||||
|
||||
@Override
|
||||
public void c() {
|
||||
- this.e.setGoalTarget(this.e.getLastDamager());
|
||||
+ this.e.setGoalTarget(this.e.getLastDamager(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason
|
||||
this.g = this.e.getGoalTarget();
|
||||
this.c = this.e.da();
|
||||
this.h = 300;
|
||||
@@ -100,6 +100,6 @@
|
||||
}
|
||||
|
||||
protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) {
|
||||
- entityinsentient.setGoalTarget(entityliving);
|
||||
+ entityinsentient.setGoalTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit - reason
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalNearestAttackableTarget.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalNearestAttackableTarget.java
|
||||
@@ -52,7 +52,7 @@
|
||||
|
||||
@Override
|
||||
public void c() {
|
||||
- this.e.setGoalTarget(this.c);
|
||||
+ this.e.setGoalTarget(this.c, c instanceof EntityPlayer ? org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER : org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit - reason
|
||||
super.c();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalOwnerHurtByTarget.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalOwnerHurtByTarget.java
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
@Override
|
||||
public void c() {
|
||||
- this.e.setGoalTarget(this.b);
|
||||
+ this.e.setGoalTarget(this.b, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit - reason
|
||||
EntityLiving entityliving = this.a.getOwner();
|
||||
|
||||
if (entityliving != null) {
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalOwnerHurtTarget.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalOwnerHurtTarget.java
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
@Override
|
||||
public void c() {
|
||||
- this.e.setGoalTarget(this.b);
|
||||
+ this.e.setGoalTarget(this.b, org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit - reason
|
||||
EntityLiving entityliving = this.a.getOwner();
|
||||
|
||||
if (entityliving != null) {
|
||||
@@ -0,0 +1,29 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalTarget.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalTarget.java
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit
|
||||
+
|
||||
public abstract class PathfinderGoalTarget extends PathfinderGoal {
|
||||
|
||||
protected final EntityInsentient e;
|
||||
@@ -59,7 +61,7 @@
|
||||
if (entityliving instanceof EntityHuman && ((EntityHuman) entityliving).abilities.isInvulnerable) {
|
||||
return false;
|
||||
} else {
|
||||
- this.e.setGoalTarget(entityliving);
|
||||
+ this.e.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.CLOSEST_ENTITY, true); // CraftBukkit
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -80,7 +82,7 @@
|
||||
|
||||
@Override
|
||||
public void d() {
|
||||
- this.e.setGoalTarget((EntityLiving) null);
|
||||
+ this.e.setGoalTarget((EntityLiving) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit
|
||||
this.g = null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/VillageSiege.java
|
||||
+++ b/net/minecraft/server/VillageSiege.java
|
||||
@@ -108,7 +108,7 @@
|
||||
}
|
||||
|
||||
entityzombie.setPositionRotation(vec3d.x, vec3d.y, vec3d.z, worldserver.random.nextFloat() * 360.0F, 0.0F);
|
||||
- worldserver.addAllEntities(entityzombie);
|
||||
+ worldserver.addAllEntities(entityzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_INVASION); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
--- a/net/minecraft/server/EntityBat.java
|
||||
+++ b/net/minecraft/server/EntityBat.java
|
||||
@@ -5,6 +5,8 @@
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
+
|
||||
public class EntityBat extends EntityAmbient {
|
||||
|
||||
private static final DataWatcherObject<Byte> b = DataWatcher.a(EntityBat.class, DataWatcherRegistry.a);
|
||||
@@ -105,16 +107,24 @@
|
||||
}
|
||||
|
||||
if (this.world.a(EntityBat.c, (EntityLiving) this) != null) {
|
||||
+ // CraftBukkit Start - Call BatToggleSleepEvent
|
||||
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
|
||||
+ this.setAsleep(false);
|
||||
+ if (!flag) {
|
||||
+ this.world.a((EntityHuman) null, 1025, blockposition, 0);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit End
|
||||
+ }
|
||||
+ } else {
|
||||
+ // CraftBukkit Start - Call BatToggleSleepEvent
|
||||
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
|
||||
this.setAsleep(false);
|
||||
if (!flag) {
|
||||
this.world.a((EntityHuman) null, 1025, blockposition, 0);
|
||||
}
|
||||
}
|
||||
- } else {
|
||||
- this.setAsleep(false);
|
||||
- if (!flag) {
|
||||
- this.world.a((EntityHuman) null, 1025, blockposition, 0);
|
||||
- }
|
||||
+ // CraftBukkit End - Call BatToggleSleepEvent
|
||||
}
|
||||
} else {
|
||||
if (this.d != null && (!this.world.isEmpty(this.d) || this.d.getY() < 1)) {
|
||||
@@ -138,7 +148,11 @@
|
||||
this.aT = 0.5F;
|
||||
this.yaw += f1;
|
||||
if (this.random.nextInt(100) == 0 && this.world.getType(blockposition1).isOccluding(this.world, blockposition1)) {
|
||||
- this.setAsleep(true);
|
||||
+ // CraftBukkit Start - Call BatToggleSleepEvent
|
||||
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, false)) {
|
||||
+ this.setAsleep(true);
|
||||
+ }
|
||||
+ // CraftBukkit End
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +182,11 @@
|
||||
return false;
|
||||
} else {
|
||||
if (!this.world.isClientSide && this.isAsleep()) {
|
||||
- this.setAsleep(false);
|
||||
+ // CraftBukkit Start - Call BatToggleSleepEvent
|
||||
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
|
||||
+ this.setAsleep(false);
|
||||
+ }
|
||||
+ // CraftBukkit End - Call BatToggleSleepEvent
|
||||
}
|
||||
|
||||
return super.damageEntity(damagesource, f);
|
||||
@@ -0,0 +1,98 @@
|
||||
--- a/net/minecraft/server/EntityAnimal.java
|
||||
+++ b/net/minecraft/server/EntityAnimal.java
|
||||
@@ -4,10 +4,16 @@
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityEnterLoveModeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class EntityAnimal extends EntityAgeable {
|
||||
|
||||
public int loveTicks;
|
||||
public UUID breedCause;
|
||||
+ public ItemStack breedItem; // CraftBukkit - Add breedItem variable
|
||||
|
||||
protected EntityAnimal(EntityTypes<? extends EntityAnimal> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -44,6 +50,9 @@
|
||||
|
||||
}
|
||||
|
||||
+ /* CraftBukkit start
|
||||
+ // Function disabled as it has no special function anymore after
|
||||
+ // setSitting is disabled.
|
||||
@Override
|
||||
public boolean damageEntity(DamageSource damagesource, float f) {
|
||||
if (this.isInvulnerable(damagesource)) {
|
||||
@@ -53,6 +62,7 @@
|
||||
return super.damageEntity(damagesource, f);
|
||||
}
|
||||
}
|
||||
+ // CraftBukkit end */
|
||||
|
||||
@Override
|
||||
public float a(BlockPosition blockposition, IWorldReader iworldreader) {
|
||||
@@ -143,10 +153,17 @@
|
||||
}
|
||||
|
||||
public void g(@Nullable EntityHuman entityhuman) {
|
||||
- this.loveTicks = 600;
|
||||
+ // CraftBukkit start
|
||||
+ EntityEnterLoveModeEvent entityEnterLoveModeEvent = CraftEventFactory.callEntityEnterLoveModeEvent(entityhuman, this, 600);
|
||||
+ if (entityEnterLoveModeEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ this.loveTicks = entityEnterLoveModeEvent.getTicksInLove();
|
||||
+ // CraftBukkit end
|
||||
if (entityhuman != null) {
|
||||
this.breedCause = entityhuman.getUniqueID();
|
||||
}
|
||||
+ this.breedItem = entityhuman.inventory.getItemInHand(); // CraftBukkit
|
||||
|
||||
this.world.broadcastEntityEffect(this, (byte) 18);
|
||||
}
|
||||
@@ -186,11 +203,24 @@
|
||||
EntityAgeable entityageable = this.createChild(worldserver, entityanimal);
|
||||
|
||||
if (entityageable != null) {
|
||||
+ // CraftBukkit start - set persistence for tame animals
|
||||
+ if (entityageable instanceof EntityTameableAnimal && ((EntityTameableAnimal) entityageable).isTamed()) {
|
||||
+ entityageable.persistent = true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
EntityPlayer entityplayer = this.getBreedCause();
|
||||
|
||||
if (entityplayer == null && entityanimal.getBreedCause() != null) {
|
||||
entityplayer = entityanimal.getBreedCause();
|
||||
}
|
||||
+ // CraftBukkit start - call EntityBreedEvent
|
||||
+ int experience = this.getRandom().nextInt(7) + 1;
|
||||
+ org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityageable, this, entityanimal, entityplayer, this.breedItem, experience);
|
||||
+ if (entityBreedEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ experience = entityBreedEvent.getExperience();
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (entityplayer != null) {
|
||||
entityplayer.a(StatisticList.ANIMALS_BRED);
|
||||
@@ -203,10 +233,14 @@
|
||||
entityanimal.resetLove();
|
||||
entityageable.setBaby(true);
|
||||
entityageable.setPositionRotation(this.locX(), this.locY(), this.locZ(), 0.0F, 0.0F);
|
||||
- worldserver.addAllEntities(entityageable);
|
||||
+ worldserver.addAllEntities(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
|
||||
worldserver.broadcastEntityEffect(this, (byte) 18);
|
||||
if (worldserver.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
|
||||
- worldserver.addEntity(new EntityExperienceOrb(worldserver, this.locX(), this.locY(), this.locZ(), this.getRandom().nextInt(7) + 1));
|
||||
+ // CraftBukkit start - use event experience
|
||||
+ if (experience > 0) {
|
||||
+ worldserver.addEntity(new EntityExperienceOrb(worldserver, this.locX(), this.locY(), this.locZ(), experience));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
--- a/net/minecraft/server/EntityBee.java
|
||||
+++ b/net/minecraft/server/EntityBee.java
|
||||
@@ -137,7 +137,7 @@
|
||||
}
|
||||
|
||||
if (b0 > 0) {
|
||||
- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0));
|
||||
+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -512,11 +512,15 @@
|
||||
} else {
|
||||
Entity entity = damagesource.getEntity();
|
||||
|
||||
- if (!this.world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ boolean result = super.damageEntity(damagesource, f);
|
||||
+
|
||||
+ if (result && !this.world.isClientSide) {
|
||||
this.bC.l();
|
||||
}
|
||||
|
||||
- return super.damageEntity(damagesource, f);
|
||||
+ return result;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,7 +541,7 @@
|
||||
class d extends EntityBee.a {
|
||||
|
||||
private d() {
|
||||
- super(null);
|
||||
+ super(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -597,7 +601,7 @@
|
||||
class g extends EntityBee.a {
|
||||
|
||||
private g() {
|
||||
- super(null);
|
||||
+ super(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -646,7 +650,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (flag) {
|
||||
+ if (flag && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityBee.this, blockposition, iblockdata.set(blockstateinteger, (Integer) iblockdata.get(blockstateinteger) + 1)).isCancelled()) { // Spigot
|
||||
EntityBee.this.world.triggerEffect(2005, blockposition, 0);
|
||||
EntityBee.this.world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(blockstateinteger, (Integer) iblockdata.get(blockstateinteger) + 1));
|
||||
EntityBee.this.fi();
|
||||
@@ -661,7 +665,7 @@
|
||||
class i extends EntityBee.a {
|
||||
|
||||
private i() {
|
||||
- super(null);
|
||||
+ super(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -725,7 +729,7 @@
|
||||
private int h = 0;
|
||||
|
||||
k() {
|
||||
- super(null);
|
||||
+ super(); // CraftBukkit - decompile error
|
||||
this.a(EnumSet.of(PathfinderGoal.Type.MOVE));
|
||||
}
|
||||
|
||||
@@ -909,7 +913,7 @@
|
||||
private int c;
|
||||
|
||||
f() {
|
||||
- super(null);
|
||||
+ super(); // CraftBukkit - decompile error
|
||||
this.c = EntityBee.this.world.random.nextInt(10);
|
||||
this.a(EnumSet.of(PathfinderGoal.Type.MOVE));
|
||||
}
|
||||
@@ -967,7 +971,7 @@
|
||||
private int f;
|
||||
|
||||
e() {
|
||||
- super(null);
|
||||
+ super(); // CraftBukkit - decompile error
|
||||
this.c = EntityBee.this.world.random.nextInt(10);
|
||||
this.d = Lists.newArrayList();
|
||||
this.e = null;
|
||||
@@ -1187,7 +1191,7 @@
|
||||
@Override
|
||||
protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) {
|
||||
if (entityinsentient instanceof EntityBee && this.e.hasLineOfSight(entityliving)) {
|
||||
- entityinsentient.setGoalTarget(entityliving);
|
||||
+ entityinsentient.setGoalTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
--- a/net/minecraft/server/EntityCat.java
|
||||
+++ b/net/minecraft/server/EntityCat.java
|
||||
@@ -15,7 +15,7 @@
|
||||
private static final DataWatcherObject<Boolean> bt = DataWatcher.a(EntityCat.class, DataWatcherRegistry.i);
|
||||
private static final DataWatcherObject<Boolean> bu = DataWatcher.a(EntityCat.class, DataWatcherRegistry.i);
|
||||
private static final DataWatcherObject<Integer> bv = DataWatcher.a(EntityCat.class, DataWatcherRegistry.b);
|
||||
- public static final Map<Integer, MinecraftKey> bq = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> {
|
||||
+ public static final Map<Integer, MinecraftKey> bq = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error
|
||||
hashmap.put(0, new MinecraftKey("textures/entity/cat/tabby.png"));
|
||||
hashmap.put(1, new MinecraftKey("textures/entity/cat/black.png"));
|
||||
hashmap.put(2, new MinecraftKey("textures/entity/cat/red.png"));
|
||||
@@ -341,7 +341,7 @@
|
||||
}
|
||||
} else if (this.k(itemstack)) {
|
||||
this.a(entityhuman, itemstack);
|
||||
- if (this.random.nextInt(3) == 0) {
|
||||
+ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { // CraftBukkit
|
||||
this.tame(entityhuman);
|
||||
this.setWillSit(true);
|
||||
this.world.broadcastEntityEffect(this, (byte) 7);
|
||||
@@ -499,7 +499,15 @@
|
||||
while (iterator.hasNext()) {
|
||||
ItemStack itemstack = (ItemStack) iterator.next();
|
||||
|
||||
- this.a.world.addEntity(new EntityItem(this.a.world, (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.a.aA * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.a.aA * 0.017453292F), itemstack));
|
||||
+ // CraftBukkit start
|
||||
+ EntityItem entityitem = new EntityItem(this.a.world, (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.a.aA * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.a.aA * 0.017453292F), itemstack);
|
||||
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.a.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
|
||||
+ entityitem.world.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ this.a.world.addEntity(entityitem);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -529,7 +537,7 @@
|
||||
static class PathfinderGoalTemptChance extends PathfinderGoalTempt {
|
||||
|
||||
@Nullable
|
||||
- private EntityHuman chosenTarget;
|
||||
+ private EntityLiving chosenTarget; // CraftBukkit
|
||||
private final EntityCat d;
|
||||
|
||||
public PathfinderGoalTemptChance(EntityCat entitycat, double d0, RecipeItemStack recipeitemstack, boolean flag) {
|
||||
@@ -564,9 +572,9 @@
|
||||
private final EntityCat i;
|
||||
|
||||
public a(EntityCat entitycat, Class<T> oclass, float f, double d0, double d1) {
|
||||
- Predicate predicate = IEntitySelector.e;
|
||||
+ // Predicate predicate = IEntitySelector.e; // CraftBukkit - decompile error
|
||||
|
||||
- super(entitycat, oclass, f, d0, d1, predicate::test);
|
||||
+ super(entitycat, oclass, f, d0, d1, IEntitySelector.e::test); // CraftBukkit - decompile error
|
||||
this.i = entitycat;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
--- a/net/minecraft/server/EntityChicken.java
|
||||
+++ b/net/minecraft/server/EntityChicken.java
|
||||
@@ -40,6 +40,11 @@
|
||||
|
||||
@Override
|
||||
public void movementTick() {
|
||||
+ // CraftBukkit start
|
||||
+ if (this.isChickenJockey()) {
|
||||
+ this.persistent = !this.isTypeNotPersistent(0);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
super.movementTick();
|
||||
this.br = this.bo;
|
||||
this.bq = this.bp;
|
||||
@@ -59,7 +64,9 @@
|
||||
this.bo += this.bs * 2.0F;
|
||||
if (!this.world.isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggLayTime <= 0) {
|
||||
this.playSound(SoundEffects.ENTITY_CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.a((IMaterial) Items.EGG);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
this.eggLayTime = this.random.nextInt(6000) + 6000;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
--- a/net/minecraft/server/EntityCow.java
|
||||
+++ b/net/minecraft/server/EntityCow.java
|
||||
@@ -1,5 +1,10 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityCow extends EntityAnimal {
|
||||
|
||||
public EntityCow(EntityTypes<? extends EntityCow> entitytypes, World world) {
|
||||
@@ -52,8 +57,16 @@
|
||||
ItemStack itemstack = entityhuman.b(enumhand);
|
||||
|
||||
if (itemstack.getItem() == Items.BUCKET && !this.isBaby()) {
|
||||
+ // CraftBukkit start - Got milk?
|
||||
+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.world, entityhuman, this.getChunkCoordinates(), this.getChunkCoordinates(), null, itemstack, Items.MILK_BUCKET);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
entityhuman.playSound(SoundEffects.ENTITY_COW_MILK, 1.0F, 1.0F);
|
||||
- ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, Items.MILK_BUCKET.createItemStack());
|
||||
+ ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
|
||||
|
||||
entityhuman.a(enumhand, itemstack1);
|
||||
return EnumInteractionResult.a(this.world.isClientSide);
|
||||
@@ -0,0 +1,51 @@
|
||||
--- a/net/minecraft/server/EntityDolphin.java
|
||||
+++ b/net/minecraft/server/EntityDolphin.java
|
||||
@@ -109,7 +109,7 @@
|
||||
this.goalSelector.a(8, new EntityDolphin.d());
|
||||
this.goalSelector.a(8, new PathfinderGoalFollowBoat(this));
|
||||
this.goalSelector.a(9, new PathfinderGoalAvoidTarget<>(this, EntityGuardian.class, 8.0F, 1.0D, 1.0D));
|
||||
- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityGuardian.class})).a());
|
||||
+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityGuardian.class})).a(new Class[0])); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public static AttributeProvider.Builder eM() {
|
||||
@@ -176,6 +176,12 @@
|
||||
ItemStack itemstack = entityitem.getItemStack();
|
||||
|
||||
if (this.canPickup(itemstack)) {
|
||||
+ // CraftBukkit start - call EntityPickupItemEvent
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, false).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ itemstack = entityitem.getItemStack(); // update ItemStack from event
|
||||
+ // CraftBukkit end
|
||||
this.a(entityitem);
|
||||
this.setSlot(EnumItemSlot.MAINHAND, itemstack);
|
||||
this.dropChanceHand[EnumItemSlot.MAINHAND.b()] = 2.0F;
|
||||
@@ -323,7 +329,7 @@
|
||||
|
||||
@Override
|
||||
public boolean a() {
|
||||
- return this.a.gotFish() && this.a.getAirTicks() >= 100;
|
||||
+ return this.a.gotFish() && this.a.getAirTicks() >= 100 && this.a.world.getWorld().canGenerateStructures(); // MC-151364, SPIGOT-5494: hangs if generate-structures=false
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -432,7 +438,7 @@
|
||||
|
||||
@Override
|
||||
public void c() {
|
||||
- this.c.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100));
|
||||
+ this.c.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -451,7 +457,7 @@
|
||||
}
|
||||
|
||||
if (this.c.isSwimming() && this.c.world.random.nextInt(6) == 0) {
|
||||
- this.c.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100));
|
||||
+ this.c.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
--- a/net/minecraft/server/EntityFish.java
|
||||
+++ b/net/minecraft/server/EntityFish.java
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
@Override
|
||||
public boolean isTypeNotPersistent(double d0) {
|
||||
- return !this.isFromBucket() && !this.hasCustomName();
|
||||
+ return true; // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,6 +52,7 @@
|
||||
|
||||
public void setFromBucket(boolean flag) {
|
||||
this.datawatcher.set(EntityFish.FROM_BUCKET, flag);
|
||||
+ this.persistent = this.isPersistent(); // CraftBukkit - SPIGOT-4106 update persistence
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,94 @@
|
||||
--- a/net/minecraft/server/EntityFox.java
|
||||
+++ b/net/minecraft/server/EntityFox.java
|
||||
@@ -264,8 +264,8 @@
|
||||
private List<UUID> fa() {
|
||||
List<UUID> list = Lists.newArrayList();
|
||||
|
||||
- list.add(((Optional) this.datawatcher.get(EntityFox.FIRST_TRUSTED_PLAYER)).orElse((Object) null));
|
||||
- list.add(((Optional) this.datawatcher.get(EntityFox.SECOND_TRUSTED_PLAYER)).orElse((Object) null));
|
||||
+ list.add((this.datawatcher.get(EntityFox.FIRST_TRUSTED_PLAYER)).orElse(null)); // CraftBukkit - decompile error
|
||||
+ list.add((this.datawatcher.get(EntityFox.SECOND_TRUSTED_PLAYER)).orElse(null)); // CraftBukkit - decompile error
|
||||
return list;
|
||||
}
|
||||
|
||||
@@ -401,7 +401,8 @@
|
||||
protected void b(EntityItem entityitem) {
|
||||
ItemStack itemstack = entityitem.getItemStack();
|
||||
|
||||
- if (this.canPickup(itemstack)) {
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, itemstack.getCount() - 1, !this.canPickup(itemstack)).isCancelled()) { // CraftBukkit - call EntityPickupItemEvent
|
||||
+ itemstack = entityitem.getItemStack(); // CraftBukkit - update ItemStack from event
|
||||
int i = itemstack.getCount();
|
||||
|
||||
if (i > 1) {
|
||||
@@ -923,6 +924,11 @@
|
||||
int i = (Integer) iblockdata.get(BlockSweetBerryBush.a);
|
||||
|
||||
iblockdata.set(BlockSweetBerryBush.a, 1);
|
||||
+ // CraftBukkit start - call EntityChangeBlockEvent
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityFox.this, this.e, iblockdata.set(BlockSweetBerryBush.a, 1)).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
int j = 1 + EntityFox.this.world.random.nextInt(2) + (i == 3 ? 1 : 0);
|
||||
ItemStack itemstack = EntityFox.this.getEquipment(EnumItemSlot.MAINHAND);
|
||||
|
||||
@@ -962,7 +968,7 @@
|
||||
private int f;
|
||||
|
||||
public r() {
|
||||
- super(null);
|
||||
+ super(); // CraftBukkit - decompile error
|
||||
this.a(EnumSet.of(PathfinderGoal.Type.MOVE, PathfinderGoal.Type.LOOK));
|
||||
}
|
||||
|
||||
@@ -1014,7 +1020,7 @@
|
||||
private int c;
|
||||
|
||||
public t() {
|
||||
- super(null);
|
||||
+ super(); // CraftBukkit - decompile error
|
||||
this.c = EntityFox.this.random.nextInt(140);
|
||||
this.a(EnumSet.of(PathfinderGoal.Type.MOVE, PathfinderGoal.Type.LOOK, PathfinderGoal.Type.JUMP));
|
||||
}
|
||||
@@ -1125,7 +1131,7 @@
|
||||
private EntityLiving k;
|
||||
private int l;
|
||||
|
||||
- public a(Class oclass, boolean flag, boolean flag1, Predicate predicate) {
|
||||
+ public a(Class oclass, boolean flag, boolean flag1, Predicate<EntityLiving> predicate) { // CraftBukkit - decompile error
|
||||
super(EntityFox.this, oclass, 10, flag, flag1, predicate);
|
||||
}
|
||||
|
||||
@@ -1205,6 +1211,14 @@
|
||||
if (entityplayer1 != null && entityplayer != entityplayer1) {
|
||||
entityfox.b(entityplayer1.getUniqueID());
|
||||
}
|
||||
+ // CraftBukkit start - call EntityBreedEvent
|
||||
+ int experience = this.animal.getRandom().nextInt(7) + 1;
|
||||
+ org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityfox, animal, partner, entityplayer, this.animal.breedItem, experience);
|
||||
+ if (entityBreedEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ experience = entityBreedEvent.getExperience();
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (entityplayer2 != null) {
|
||||
entityplayer2.a(StatisticList.ANIMALS_BRED);
|
||||
@@ -1217,10 +1231,14 @@
|
||||
this.partner.resetLove();
|
||||
entityfox.setAgeRaw(-24000);
|
||||
entityfox.setPositionRotation(this.animal.locX(), this.animal.locY(), this.animal.locZ(), 0.0F, 0.0F);
|
||||
- worldserver.addAllEntities(entityfox);
|
||||
+ worldserver.addAllEntities(entityfox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
|
||||
this.b.broadcastEntityEffect(this.animal, (byte) 18);
|
||||
if (this.b.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
|
||||
- this.b.addEntity(new EntityExperienceOrb(this.b, this.animal.locX(), this.animal.locY(), this.animal.locZ(), this.animal.getRandom().nextInt(7) + 1));
|
||||
+ // CraftBukkit start - use event experience
|
||||
+ if (experience > 0) {
|
||||
+ this.b.addEntity(new EntityExperienceOrb(this.b, this.animal.locX(), this.animal.locY(), this.animal.locZ(), experience));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/EntityIronGolem.java
|
||||
+++ b/net/minecraft/server/EntityIronGolem.java
|
||||
@@ -58,7 +58,7 @@
|
||||
@Override
|
||||
protected void C(Entity entity) {
|
||||
if (entity instanceof IMonster && !(entity instanceof EntityCreeper) && this.getRandom().nextInt(20) == 0) {
|
||||
- this.setGoalTarget((EntityLiving) entity);
|
||||
+ this.setGoalTarget((EntityLiving) entity, org.bukkit.event.entity.EntityTargetLivingEntityEvent.TargetReason.COLLISION, true); // CraftBukkit - set reason
|
||||
}
|
||||
|
||||
super.C(entity);
|
||||
@@ -0,0 +1,51 @@
|
||||
--- a/net/minecraft/server/EntityMushroomCow.java
|
||||
+++ b/net/minecraft/server/EntityMushroomCow.java
|
||||
@@ -5,6 +5,11 @@
|
||||
import java.util.UUID;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityTransformEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityMushroomCow extends EntityCow implements IShearable {
|
||||
|
||||
private static final DataWatcherObject<String> bo = DataWatcher.a(EntityMushroomCow.class, DataWatcherRegistry.d);
|
||||
@@ -75,6 +80,11 @@
|
||||
this.playSound(soundeffect, 1.0F, 1.0F);
|
||||
return EnumInteractionResult.a(this.world.isClientSide);
|
||||
} else if (itemstack.getItem() == Items.SHEARS && this.canShear()) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.shear(SoundCategory.PLAYERS);
|
||||
if (!this.world.isClientSide) {
|
||||
itemstack.damage(1, entityhuman, (entityhuman1) -> {
|
||||
@@ -121,7 +131,7 @@
|
||||
this.world.playSound((EntityHuman) null, (Entity) this, SoundEffects.ENTITY_MOOSHROOM_SHEAR, soundcategory, 1.0F, 1.0F);
|
||||
if (!this.world.s_()) {
|
||||
((WorldServer) this.world).a(Particles.EXPLOSION, this.locX(), this.e(0.5D), this.locZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
|
||||
- this.die();
|
||||
+ // this.die(); // CraftBukkit - moved down
|
||||
EntityCow entitycow = (EntityCow) EntityTypes.COW.a(this.world);
|
||||
|
||||
entitycow.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.yaw, this.pitch);
|
||||
@@ -137,7 +147,14 @@
|
||||
}
|
||||
|
||||
entitycow.setInvulnerable(this.isInvulnerable());
|
||||
- this.world.addEntity(entitycow);
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ this.world.addEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED);
|
||||
+
|
||||
+ this.die(); // CraftBukkit - from above
|
||||
+ // CraftBukkit end
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
this.world.addEntity(new EntityItem(this.world, this.locX(), this.e(1.0D), this.locZ(), new ItemStack(this.getVariant().d.getBlock())));
|
||||
@@ -0,0 +1,33 @@
|
||||
--- a/net/minecraft/server/EntityOcelot.java
|
||||
+++ b/net/minecraft/server/EntityOcelot.java
|
||||
@@ -81,7 +81,7 @@
|
||||
|
||||
@Override
|
||||
public boolean isTypeNotPersistent(double d0) {
|
||||
- return !this.isTrusting() && this.ticksLived > 2400;
|
||||
+ return !this.isTrusting() /*&& this.ticksLived > 2400*/; // CraftBukkit
|
||||
}
|
||||
|
||||
public static AttributeProvider.Builder eK() {
|
||||
@@ -135,7 +135,8 @@
|
||||
if ((this.br == null || this.br.h()) && !this.isTrusting() && this.k(itemstack) && entityhuman.h((Entity) this) < 9.0D) {
|
||||
this.a(entityhuman, itemstack);
|
||||
if (!this.world.isClientSide) {
|
||||
- if (this.random.nextInt(3) == 0) {
|
||||
+ // CraftBukkit - added event call and isCancelled check
|
||||
+ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) {
|
||||
this.setTrusting(true);
|
||||
this.u(true);
|
||||
this.world.broadcastEntityEffect(this, (byte) 41);
|
||||
@@ -243,9 +244,9 @@
|
||||
private final EntityOcelot i;
|
||||
|
||||
public a(EntityOcelot entityocelot, Class<T> oclass, float f, double d0, double d1) {
|
||||
- Predicate predicate = IEntitySelector.e;
|
||||
+ // Predicate predicate = IEntitySelector.e; // CraftBukkit - decompile error
|
||||
|
||||
- super(entityocelot, oclass, f, d0, d1, predicate::test);
|
||||
+ super(entityocelot, oclass, f, d0, d1, IEntitySelector.e::test); // CraftBukkit - decompile error
|
||||
this.i = entityocelot;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
--- a/net/minecraft/server/EntityPanda.java
|
||||
+++ b/net/minecraft/server/EntityPanda.java
|
||||
@@ -9,6 +9,8 @@
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit
|
||||
+
|
||||
public class EntityPanda extends EntityAnimal {
|
||||
|
||||
private static final DataWatcherObject<Integer> bp = DataWatcher.a(EntityPanda.class, DataWatcherRegistry.b);
|
||||
@@ -445,7 +447,7 @@
|
||||
|
||||
@Override
|
||||
protected void b(EntityItem entityitem) {
|
||||
- if (this.getEquipment(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PICKUP_PREDICATE.test(entityitem)) {
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !(this.getEquipment(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PICKUP_PREDICATE.test(entityitem))).isCancelled()) { // CraftBukkit
|
||||
this.a(entityitem);
|
||||
ItemStack itemstack = entityitem.getItemStack();
|
||||
|
||||
@@ -666,7 +668,7 @@
|
||||
@Override
|
||||
protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) {
|
||||
if (entityinsentient instanceof EntityPanda && ((EntityPanda) entityinsentient).isAggressive()) {
|
||||
- entityinsentient.setGoalTarget(entityliving);
|
||||
+ entityinsentient.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -770,9 +772,9 @@
|
||||
private final EntityPanda i;
|
||||
|
||||
public c(EntityPanda entitypanda, Class<T> oclass, float f, double d0, double d1) {
|
||||
- Predicate predicate = IEntitySelector.g;
|
||||
+ // Predicate predicate = IEntitySelector.g; // CraftBukkit - decompile error
|
||||
|
||||
- super(entitypanda, oclass, f, d0, d1, predicate::test);
|
||||
+ super(entitypanda, oclass, f, d0, d1, IEntitySelector.g::test); // CraftBukkit - decompile error
|
||||
this.i = entitypanda;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
--- a/net/minecraft/server/EntityParrot.java
|
||||
+++ b/net/minecraft/server/EntityParrot.java
|
||||
@@ -20,7 +20,7 @@
|
||||
};
|
||||
private static final Item bw = Items.COOKIE;
|
||||
private static final Set<Item> bx = Sets.newHashSet(new Item[]{Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS});
|
||||
- private static final Map<EntityTypes<?>, SoundEffect> by = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> {
|
||||
+ private static final Map<EntityTypes<?>, SoundEffect> by = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error
|
||||
hashmap.put(EntityTypes.BLAZE, SoundEffects.ENTITY_PARROT_IMITATE_BLAZE);
|
||||
hashmap.put(EntityTypes.CAVE_SPIDER, SoundEffects.ENTITY_PARROT_IMITATE_SPIDER);
|
||||
hashmap.put(EntityTypes.CREEPER, SoundEffects.ENTITY_PARROT_IMITATE_CREEPER);
|
||||
@@ -187,7 +187,7 @@
|
||||
}
|
||||
|
||||
if (!this.world.isClientSide) {
|
||||
- if (this.random.nextInt(10) == 0) {
|
||||
+ if (this.random.nextInt(10) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { // CraftBukkit
|
||||
this.tame(entityhuman);
|
||||
this.world.broadcastEntityEffect(this, (byte) 7);
|
||||
} else {
|
||||
@@ -201,7 +201,7 @@
|
||||
itemstack.subtract(1);
|
||||
}
|
||||
|
||||
- this.addEffect(new MobEffect(MobEffects.POISON, 900));
|
||||
+ this.addEffect(new MobEffect(MobEffects.POISON, 900), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit
|
||||
if (entityhuman.isCreative() || !this.isInvulnerable()) {
|
||||
this.damageEntity(DamageSource.playerAttack(entityhuman), Float.MAX_VALUE);
|
||||
}
|
||||
@@ -315,7 +315,7 @@
|
||||
|
||||
@Override
|
||||
public boolean isCollidable() {
|
||||
- return true;
|
||||
+ return super.isCollidable(); // CraftBukkit - collidable API
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -330,7 +330,7 @@
|
||||
if (this.isInvulnerable(damagesource)) {
|
||||
return false;
|
||||
} else {
|
||||
- this.setWillSit(false);
|
||||
+ // this.setWillSit(false); // CraftBukkit - moved into EntityLiving.damageEntity(DamageSource, float)
|
||||
return super.damageEntity(damagesource, f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
--- a/net/minecraft/server/EntityPig.java
|
||||
+++ b/net/minecraft/server/EntityPig.java
|
||||
@@ -3,6 +3,10 @@
|
||||
import com.google.common.collect.UnmodifiableIterator;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityPig extends EntityAnimal implements ISteerable, ISaddleable {
|
||||
|
||||
private static final DataWatcherObject<Boolean> bo = DataWatcher.a(EntityPig.class, DataWatcherRegistry.i);
|
||||
@@ -204,7 +208,13 @@
|
||||
}
|
||||
|
||||
entitypigzombie.setPersistent();
|
||||
- worldserver.addEntity(entitypigzombie);
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit - added a reason for spawning this creature
|
||||
+ worldserver.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
|
||||
+ // CraftBukkit end
|
||||
this.die();
|
||||
} else {
|
||||
super.onLightningStrike(worldserver, entitylightning);
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/server/EntityPufferFish.java
|
||||
+++ b/net/minecraft/server/EntityPufferFish.java
|
||||
@@ -114,7 +114,7 @@
|
||||
int i = this.getPuffState();
|
||||
|
||||
if (entityinsentient.damageEntity(DamageSource.mobAttack(this), (float) (1 + i))) {
|
||||
- entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0));
|
||||
+ entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
this.playSound(SoundEffects.ENTITY_PUFFER_FISH_STING, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.j, 0.0F));
|
||||
}
|
||||
|
||||
- entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0));
|
||||
+ entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
--- a/net/minecraft/server/EntityRabbit.java
|
||||
+++ b/net/minecraft/server/EntityRabbit.java
|
||||
@@ -17,8 +17,14 @@
|
||||
super(entitytypes, world);
|
||||
this.bi = new EntityRabbit.ControllerJumpRabbit(this);
|
||||
this.moveController = new EntityRabbit.ControllerMoveRabbit(this);
|
||||
+ this.initializePathFinderGoals(); // CraftBukkit - moved code
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start - code from constructor
|
||||
+ public void initializePathFinderGoals(){
|
||||
this.i(0.0D);
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
@Override
|
||||
public void initPathfinder() {
|
||||
@@ -285,7 +291,7 @@
|
||||
if (i == 99) {
|
||||
this.getAttributeInstance(GenericAttributes.ARMOR).setValue(8.0D);
|
||||
this.goalSelector.a(4, new EntityRabbit.PathfinderGoalKillerRabbitMeleeAttack(this));
|
||||
- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a());
|
||||
+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error
|
||||
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
|
||||
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityWolf.class, true));
|
||||
if (!this.hasCustomName()) {
|
||||
@@ -401,9 +407,23 @@
|
||||
Integer integer = (Integer) iblockdata.get(BlockCarrots.AGE);
|
||||
|
||||
if (integer == 0) {
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.entity, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 2);
|
||||
world.a(blockposition, true, this.entity);
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(
|
||||
+ this.entity,
|
||||
+ blockposition,
|
||||
+ iblockdata.set(BlockCarrots.AGE, integer - 1)
|
||||
+ ).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCarrots.AGE, integer - 1), 2);
|
||||
world.triggerEffect(2001, blockposition, Block.getCombinedId(iblockdata));
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
--- a/net/minecraft/server/EntitySheep.java
|
||||
+++ b/net/minecraft/server/EntitySheep.java
|
||||
@@ -8,10 +8,16 @@
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.SheepRegrowWoolEvent;
|
||||
+import org.bukkit.inventory.InventoryView;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntitySheep extends EntityAnimal implements IShearable {
|
||||
|
||||
private static final DataWatcherObject<Byte> bo = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a);
|
||||
- private static final Map<EnumColor, IMaterial> bp = (Map) SystemUtils.a((Object) Maps.newEnumMap(EnumColor.class), (enummap) -> {
|
||||
+ private static final Map<EnumColor, IMaterial> bp = (Map) SystemUtils.a(Maps.newEnumMap(EnumColor.class), (enummap) -> { // CraftBukkit - decompile error
|
||||
enummap.put(EnumColor.WHITE, Blocks.WHITE_WOOL);
|
||||
enummap.put(EnumColor.ORANGE, Blocks.ORANGE_WOOL);
|
||||
enummap.put(EnumColor.MAGENTA, Blocks.MAGENTA_WOOL);
|
||||
@@ -138,6 +144,11 @@
|
||||
|
||||
if (itemstack.getItem() == Items.SHEARS) {
|
||||
if (!this.world.isClientSide && this.canShear()) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.shear(SoundCategory.PLAYERS);
|
||||
itemstack.damage(1, entityhuman, (entityhuman1) -> {
|
||||
entityhuman1.broadcastItemBreak(enumhand);
|
||||
@@ -158,7 +169,9 @@
|
||||
int i = 1 + this.random.nextInt(3);
|
||||
|
||||
for (int j = 0; j < i; ++j) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
EntityItem entityitem = this.a((IMaterial) EntitySheep.bp.get(this.getColor()), 1);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
|
||||
if (entityitem != null) {
|
||||
entityitem.setMot(entityitem.getMot().add((double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (this.random.nextFloat() * 0.05F), (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F)));
|
||||
@@ -248,6 +261,12 @@
|
||||
|
||||
@Override
|
||||
public void blockEaten() {
|
||||
+ // CraftBukkit start
|
||||
+ SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity());
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) return;
|
||||
+ // CraftBukkit end
|
||||
this.setSheared(false);
|
||||
if (this.isBaby()) {
|
||||
this.setAge(60);
|
||||
@@ -266,7 +285,7 @@
|
||||
EnumColor enumcolor = ((EntitySheep) entityanimal).getColor();
|
||||
EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor();
|
||||
InventoryCrafting inventorycrafting = a(enumcolor, enumcolor1);
|
||||
- Optional optional = this.world.getCraftingManager().craft(Recipes.CRAFTING, inventorycrafting, this.world).map((recipecrafting) -> {
|
||||
+ Optional<Item> optional = this.world.getCraftingManager().craft(Recipes.CRAFTING, inventorycrafting, this.world).map((recipecrafting) -> { // Eclipse fail
|
||||
return recipecrafting.a(inventorycrafting);
|
||||
}).map(ItemStack::getItem);
|
||||
|
||||
@@ -284,10 +303,18 @@
|
||||
public boolean canUse(EntityHuman entityhuman) {
|
||||
return false;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public InventoryView getBukkitView() {
|
||||
+ return null; // TODO: O.O
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}, 2, 1);
|
||||
|
||||
inventorycrafting.setItem(0, new ItemStack(ItemDye.a(enumcolor)));
|
||||
inventorycrafting.setItem(1, new ItemStack(ItemDye.a(enumcolor1)));
|
||||
+ inventorycrafting.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event
|
||||
return inventorycrafting;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
--- a/net/minecraft/server/EntitySnowman.java
|
||||
+++ b/net/minecraft/server/EntitySnowman.java
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntitySnowman extends EntityGolem implements IShearable, IRangedEntity {
|
||||
|
||||
private static final DataWatcherObject<Byte> b = DataWatcher.a(EntitySnowman.class, DataWatcherRegistry.a);
|
||||
@@ -60,7 +64,7 @@
|
||||
int k = MathHelper.floor(this.locZ());
|
||||
|
||||
if (this.world.getBiome(new BlockPosition(i, 0, k)).getAdjustedTemperature(new BlockPosition(i, j, k)) > 1.0F) {
|
||||
- this.damageEntity(DamageSource.BURN, 1.0F);
|
||||
+ this.damageEntity(CraftEventFactory.MELTING, 1.0F); // CraftBukkit - DamageSource.BURN -> CraftEventFactory.MELTING
|
||||
}
|
||||
|
||||
if (!this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) {
|
||||
@@ -76,7 +80,7 @@
|
||||
BlockPosition blockposition = new BlockPosition(i, j, k);
|
||||
|
||||
if (this.world.getType(blockposition).isAir() && this.world.getBiome(blockposition).getAdjustedTemperature(blockposition) < 0.8F && iblockdata.canPlace(this.world, blockposition)) {
|
||||
- this.world.setTypeUpdate(blockposition, iblockdata);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.world, blockposition, iblockdata, this); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,6 +111,11 @@
|
||||
ItemStack itemstack = entityhuman.b(enumhand);
|
||||
|
||||
if (itemstack.getItem() == Items.SHEARS && this.canShear()) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.shear(SoundCategory.PLAYERS);
|
||||
if (!this.world.isClientSide) {
|
||||
itemstack.damage(1, entityhuman, (entityhuman1) -> {
|
||||
@@ -0,0 +1,44 @@
|
||||
--- a/net/minecraft/server/EntityTurtle.java
|
||||
+++ b/net/minecraft/server/EntityTurtle.java
|
||||
@@ -252,7 +252,9 @@
|
||||
protected void m() {
|
||||
super.m();
|
||||
if (!this.isBaby() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.a((IMaterial) Items.SCUTE, 1);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -279,7 +281,9 @@
|
||||
|
||||
@Override
|
||||
public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) {
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = entitylightning; // CraftBukkit
|
||||
this.damageEntity(DamageSource.LIGHTNING, Float.MAX_VALUE);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = null; // CraftBukkit
|
||||
}
|
||||
|
||||
static class g extends NavigationGuardian {
|
||||
@@ -438,8 +442,12 @@
|
||||
} else if (this.g.bv > 200) {
|
||||
World world = this.g.world;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.g, this.e.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, this.g.random.nextInt(4) + 1)).isCancelled()) {
|
||||
world.playSound((EntityHuman) null, blockposition, SoundEffects.ENTITY_TURTLE_LAY_EGG, SoundCategory.BLOCKS, 0.3F, 0.9F + world.random.nextFloat() * 0.2F);
|
||||
world.setTypeAndData(this.e.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, this.g.random.nextInt(4) + 1), 3);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.g.setHasEgg(false);
|
||||
this.g.u(false);
|
||||
this.g.setLoveTicks(600);
|
||||
@@ -519,7 +527,7 @@
|
||||
--this.e;
|
||||
return false;
|
||||
} else {
|
||||
- this.d = this.b.world.a(EntityTurtle.i.a, (EntityLiving) this.b);
|
||||
+ this.d = this.b.world.a(this.a, (EntityLiving) this.b); // CraftBukkit - decompile error
|
||||
return this.d == null ? false : this.a(this.d.getItemInMainHand()) || this.a(this.d.getItemInOffHand());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
--- a/net/minecraft/server/EntityWolf.java
|
||||
+++ b/net/minecraft/server/EntityWolf.java
|
||||
@@ -4,6 +4,11 @@
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable {
|
||||
|
||||
private static final DataWatcherObject<Boolean> br = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.i);
|
||||
@@ -43,7 +48,7 @@
|
||||
this.goalSelector.a(10, new PathfinderGoalRandomLookaround(this));
|
||||
this.targetSelector.a(1, new PathfinderGoalOwnerHurtByTarget(this));
|
||||
this.targetSelector.a(2, new PathfinderGoalOwnerHurtTarget(this));
|
||||
- this.targetSelector.a(3, (new PathfinderGoalHurtByTarget(this, new Class[0])).a());
|
||||
+ this.targetSelector.a(3, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error
|
||||
this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, 10, true, false, this::a_));
|
||||
this.targetSelector.a(5, new PathfinderGoalRandomTargetNonTamed<>(this, EntityAnimal.class, false, EntityWolf.bq));
|
||||
this.targetSelector.a(6, new PathfinderGoalRandomTargetNonTamed<>(this, EntityTurtle.class, false, EntityTurtle.bo));
|
||||
@@ -55,6 +60,24 @@
|
||||
return EntityInsentient.p().a(GenericAttributes.MOVEMENT_SPEED, 0.30000001192092896D).a(GenericAttributes.MAX_HEALTH, 8.0D).a(GenericAttributes.ATTACK_DAMAGE, 2.0D);
|
||||
}
|
||||
|
||||
+ // CraftBukkit - add overriden version
|
||||
+ @Override
|
||||
+ public boolean setGoalTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fire) {
|
||||
+ if (!super.setGoalTarget(entityliving, reason, fire)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ entityliving = getGoalTarget();
|
||||
+ /* // PAIL
|
||||
+ if (entityliving == null) {
|
||||
+ this.setAngry(false);
|
||||
+ } else if (!this.isTamed()) {
|
||||
+ this.setAngry(true);
|
||||
+ }
|
||||
+ */
|
||||
+ return true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
protected void initDatawatcher() {
|
||||
super.initDatawatcher();
|
||||
@@ -201,7 +224,7 @@
|
||||
} else {
|
||||
Entity entity = damagesource.getEntity();
|
||||
|
||||
- this.setWillSit(false);
|
||||
+ // this.setWillSit(false); // CraftBukkit - moved into EntityLiving.damageEntity(DamageSource, float)
|
||||
if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) {
|
||||
f = (f + 1.0F) / 2.0F;
|
||||
}
|
||||
@@ -226,7 +249,7 @@
|
||||
super.setTamed(flag);
|
||||
if (flag) {
|
||||
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(20.0D);
|
||||
- this.setHealth(20.0F);
|
||||
+ this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth()
|
||||
} else {
|
||||
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(8.0D);
|
||||
}
|
||||
@@ -250,7 +273,7 @@
|
||||
itemstack.subtract(1);
|
||||
}
|
||||
|
||||
- this.heal((float) item.getFoodInfo().getNutrition());
|
||||
+ this.heal((float) item.getFoodInfo().getNutrition(), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -261,7 +284,7 @@
|
||||
this.setWillSit(!this.isWillSit());
|
||||
this.jumping = false;
|
||||
this.navigation.o();
|
||||
- this.setGoalTarget((EntityLiving) null);
|
||||
+ this.setGoalTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
@@ -283,7 +306,8 @@
|
||||
itemstack.subtract(1);
|
||||
}
|
||||
|
||||
- if (this.random.nextInt(3) == 0) {
|
||||
+ // CraftBukkit - added event call and isCancelled check.
|
||||
+ if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) {
|
||||
this.tame(entityhuman);
|
||||
this.navigation.o();
|
||||
this.setGoalTarget((EntityLiving) null);
|
||||
@@ -0,0 +1,94 @@
|
||||
--- a/net/minecraft/server/EntityHorseAbstract.java
|
||||
+++ b/net/minecraft/server/EntityHorseAbstract.java
|
||||
@@ -7,6 +7,8 @@
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; // CraftBukkit
|
||||
+
|
||||
public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, IJumpable, ISaddleable {
|
||||
|
||||
private static final Predicate<EntityLiving> bw = (entityliving) -> {
|
||||
@@ -34,6 +36,7 @@
|
||||
private float bK;
|
||||
protected boolean bu = true;
|
||||
protected int bv;
|
||||
+ public int maxDomestication = 100; // CraftBukkit - store max domestication value
|
||||
|
||||
protected EntityHorseAbstract(EntityTypes<? extends EntityHorseAbstract> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -218,7 +221,7 @@
|
||||
public void loadChest() {
|
||||
InventorySubcontainer inventorysubcontainer = this.inventoryChest;
|
||||
|
||||
- this.inventoryChest = new InventorySubcontainer(this.getChestSlots());
|
||||
+ this.inventoryChest = new InventorySubcontainer(this.getChestSlots(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit
|
||||
if (inventorysubcontainer != null) {
|
||||
inventorysubcontainer.b((IInventoryListener) this);
|
||||
int i = Math.min(inventorysubcontainer.getSize(), this.inventoryChest.getSize());
|
||||
@@ -334,7 +337,7 @@
|
||||
}
|
||||
|
||||
public int getMaxDomestication() {
|
||||
- return 100;
|
||||
+ return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -405,7 +408,7 @@
|
||||
}
|
||||
|
||||
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
|
||||
- this.heal(f);
|
||||
+ this.heal(f, RegainReason.EATING); // CraftBukkit
|
||||
flag = true;
|
||||
}
|
||||
|
||||
@@ -481,7 +484,7 @@
|
||||
super.movementTick();
|
||||
if (!this.world.isClientSide && this.isAlive()) {
|
||||
if (this.random.nextInt(900) == 0 && this.deathTicks == 0) {
|
||||
- this.heal(1.0F);
|
||||
+ this.heal(1.0F, RegainReason.REGEN); // CraftBukkit
|
||||
}
|
||||
|
||||
if (this.fl()) {
|
||||
@@ -718,6 +721,7 @@
|
||||
if (this.getOwnerUUID() != null) {
|
||||
nbttagcompound.a("Owner", this.getOwnerUUID());
|
||||
}
|
||||
+ nbttagcompound.setInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit
|
||||
|
||||
if (!this.inventoryChest.getItem(0).isEmpty()) {
|
||||
nbttagcompound.set("SaddleItem", this.inventoryChest.getItem(0).save(new NBTTagCompound()));
|
||||
@@ -745,6 +749,11 @@
|
||||
if (uuid != null) {
|
||||
this.setOwnerUUID(uuid);
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ if (nbttagcompound.hasKey("Bukkit.MaxDomestication")) {
|
||||
+ this.maxDomestication = nbttagcompound.getInt("Bukkit.MaxDomestication");
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (nbttagcompound.hasKeyOfType("SaddleItem", 10)) {
|
||||
ItemStack itemstack = ItemStack.a(nbttagcompound.getCompound("SaddleItem"));
|
||||
@@ -796,6 +805,18 @@
|
||||
|
||||
@Override
|
||||
public void b(int i) {
|
||||
+ // CraftBukkit start
|
||||
+ float power;
|
||||
+ if (i >= 90) {
|
||||
+ power = 1.0F;
|
||||
+ } else {
|
||||
+ power = 0.4F + 0.4F * (float) i / 90.0F;
|
||||
+ }
|
||||
+ org.bukkit.event.entity.HorseJumpEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callHorseJumpEvent(this, power);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.canSlide = true;
|
||||
this.eU();
|
||||
this.fn();
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/EntityLlamaTrader.java
|
||||
+++ b/net/minecraft/server/EntityLlamaTrader.java
|
||||
@@ -127,7 +127,7 @@
|
||||
|
||||
@Override
|
||||
public void c() {
|
||||
- this.e.setGoalTarget(this.c);
|
||||
+ this.e.setGoalTarget(this.c, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit
|
||||
Entity entity = this.b.getLeashHolder();
|
||||
|
||||
if (entity instanceof EntityVillagerTrader) {
|
||||
@@ -0,0 +1,28 @@
|
||||
--- a/net/minecraft/server/PathfinderGoalHorseTrap.java
|
||||
+++ b/net/minecraft/server/PathfinderGoalHorseTrap.java
|
||||
@@ -25,19 +25,20 @@
|
||||
|
||||
entitylightning.teleportAndSync(this.a.locX(), this.a.locY(), this.a.locZ());
|
||||
entitylightning.setEffect(true);
|
||||
- worldserver.addEntity(entitylightning);
|
||||
+ worldserver.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRAP); // CraftBukkit
|
||||
EntitySkeleton entityskeleton = this.a(difficultydamagescaler, this.a);
|
||||
|
||||
- entityskeleton.startRiding(this.a);
|
||||
- worldserver.addAllEntities(entityskeleton);
|
||||
+ if (entityskeleton != null) entityskeleton.startRiding(this.a); // CraftBukkit
|
||||
+ worldserver.addAllEntities(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP); // CraftBukkit
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
EntityHorseAbstract entityhorseabstract = this.a(difficultydamagescaler);
|
||||
+ if (entityhorseabstract == null) continue; // CraftBukkit
|
||||
EntitySkeleton entityskeleton1 = this.a(difficultydamagescaler, entityhorseabstract);
|
||||
|
||||
- entityskeleton1.startRiding(entityhorseabstract);
|
||||
+ if (entityskeleton1 != null) entityskeleton1.startRiding(entityhorseabstract); // CraftBukkit
|
||||
entityhorseabstract.i(this.a.getRandom().nextGaussian() * 0.5D, 0.0D, this.a.getRandom().nextGaussian() * 0.5D);
|
||||
- worldserver.addAllEntities(entityhorseabstract);
|
||||
+ worldserver.addAllEntities(entityhorseabstract, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
--- a/net/minecraft/server/EntityEnderCrystal.java
|
||||
+++ b/net/minecraft/server/EntityEnderCrystal.java
|
||||
@@ -3,6 +3,11 @@
|
||||
import java.util.Optional;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityEnderCrystal extends Entity {
|
||||
|
||||
private static final DataWatcherObject<Optional<BlockPosition>> c = DataWatcher.a(EntityEnderCrystal.class, DataWatcherRegistry.m);
|
||||
@@ -38,7 +43,11 @@
|
||||
BlockPosition blockposition = this.getChunkCoordinates();
|
||||
|
||||
if (((WorldServer) this.world).getDragonBattle() != null && this.world.getType(blockposition).isAir()) {
|
||||
- this.world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) this.world, blockposition));
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.callBlockIgniteEvent(this.world, blockposition, this).isCancelled()) {
|
||||
+ this.world.setTypeUpdate(blockposition, BlockFireAbstract.a((IBlockAccess) this.world, blockposition));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,9 +87,22 @@
|
||||
return false;
|
||||
} else {
|
||||
if (!this.dead && !this.world.isClientSide) {
|
||||
+ // CraftBukkit start - All non-living entities need this
|
||||
+ if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.die();
|
||||
if (!damagesource.isExplosion()) {
|
||||
- this.world.explode((Entity) null, this.locX(), this.locY(), this.locZ(), 6.0F, Explosion.Effect.DESTROY);
|
||||
+ // CraftBukkit start
|
||||
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 6.0F, false);
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ this.dead = false;
|
||||
+ return false;
|
||||
+ }
|
||||
+ this.world.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), Explosion.Effect.DESTROY);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
this.a(damagesource);
|
||||
@@ -0,0 +1,123 @@
|
||||
--- a/net/minecraft/server/EntityEnderDragon.java
|
||||
+++ b/net/minecraft/server/EntityEnderDragon.java
|
||||
@@ -7,6 +7,12 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
+import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityEnderDragon extends EntityInsentient implements IMonster {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -38,6 +44,7 @@
|
||||
private final PathPoint[] bJ = new PathPoint[24];
|
||||
private final int[] bK = new int[24];
|
||||
private final Path bL = new Path();
|
||||
+ private Explosion explosionSource = new Explosion(null, this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.Effect.DESTROY); // CraftBukkit - reusable source for CraftTNTPrimed.getSource()
|
||||
|
||||
public EntityEnderDragon(EntityTypes<? extends EntityEnderDragon> entitytypes, World world) {
|
||||
super(EntityTypes.ENDER_DRAGON, world);
|
||||
@@ -175,7 +182,7 @@
|
||||
|
||||
Vec3D vec3d1 = idragoncontroller.g();
|
||||
|
||||
- if (vec3d1 != null) {
|
||||
+ if (vec3d1 != null && idragoncontroller.getControllerPhase() != DragonControllerPhase.HOVER) { // CraftBukkit - Don't move when hovering
|
||||
d0 = vec3d1.x - this.locX();
|
||||
d1 = vec3d1.y - this.locY();
|
||||
d2 = vec3d1.z - this.locZ();
|
||||
@@ -313,7 +320,14 @@
|
||||
if (this.currentEnderCrystal.dead) {
|
||||
this.currentEnderCrystal = null;
|
||||
} else if (this.ticksLived % 10 == 0 && this.getHealth() < this.getMaxHealth()) {
|
||||
- this.setHealth(this.getHealth() + 1.0F);
|
||||
+ // CraftBukkit start
|
||||
+ EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), 1.0F, EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL);
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.setHealth((float) (this.getHealth() + event.getAmount()));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -388,6 +402,9 @@
|
||||
int j1 = MathHelper.floor(axisalignedbb.maxZ);
|
||||
boolean flag = false;
|
||||
boolean flag1 = false;
|
||||
+ // CraftBukkit start - Create a list to hold all the destroyed blocks
|
||||
+ List<org.bukkit.block.Block> destroyedBlocks = new java.util.ArrayList<org.bukkit.block.Block>();
|
||||
+ // CraftBukkit end
|
||||
|
||||
for (int k1 = i; k1 <= l; ++k1) {
|
||||
for (int l1 = j; l1 <= i1; ++l1) {
|
||||
@@ -398,7 +415,11 @@
|
||||
|
||||
if (!iblockdata.isAir() && iblockdata.getMaterial() != Material.FIRE) {
|
||||
if (this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) && !TagsBlock.DRAGON_IMMUNE.isTagged(block)) {
|
||||
- flag1 = this.world.a(blockposition, false) || flag1;
|
||||
+ // CraftBukkit start - Add blocks to list rather than destroying them
|
||||
+ // flag1 = this.world.a(blockposition, false) || flag1;
|
||||
+ flag1 = true;
|
||||
+ destroyedBlocks.add(CraftBlock.at(world, blockposition));
|
||||
+ // CraftBukkit end
|
||||
} else {
|
||||
flag = true;
|
||||
}
|
||||
@@ -407,6 +428,51 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Set off an EntityExplodeEvent for the dragon exploding all these blocks
|
||||
+ // SPIGOT-4882: don't fire event if nothing hit
|
||||
+ if (!flag1) {
|
||||
+ return flag;
|
||||
+ }
|
||||
+
|
||||
+ org.bukkit.entity.Entity bukkitEntity = this.getBukkitEntity();
|
||||
+ EntityExplodeEvent event = new EntityExplodeEvent(bukkitEntity, bukkitEntity.getLocation(), destroyedBlocks, 0F);
|
||||
+ bukkitEntity.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ // This flag literally means 'Dragon hit something hard' (Obsidian, White Stone or Bedrock) and will cause the dragon to slow down.
|
||||
+ // We should consider adding an event extension for it, or perhaps returning true if the event is cancelled.
|
||||
+ return flag;
|
||||
+ } else if (event.getYield() == 0F) {
|
||||
+ // Yield zero ==> no drops
|
||||
+ for (org.bukkit.block.Block block : event.blockList()) {
|
||||
+ this.world.a(new BlockPosition(block.getX(), block.getY(), block.getZ()), false);
|
||||
+ }
|
||||
+ } else {
|
||||
+ for (org.bukkit.block.Block block : event.blockList()) {
|
||||
+ org.bukkit.Material blockId = block.getType();
|
||||
+ if (blockId.isAir()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ CraftBlock craftBlock = ((CraftBlock) block);
|
||||
+ BlockPosition blockposition = craftBlock.getPosition();
|
||||
+
|
||||
+ Block nmsBlock = craftBlock.getNMS().getBlock();
|
||||
+ if (nmsBlock.a(explosionSource)) {
|
||||
+ TileEntity tileentity = nmsBlock.isTileEntity() ? this.world.getTileEntity(blockposition) : null;
|
||||
+ LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.world)).a(this.world.random).set(LootContextParameters.ORIGIN, Vec3D.a(blockposition)).set(LootContextParameters.TOOL, ItemStack.b).set(LootContextParameters.EXPLOSION_RADIUS, 1.0F / event.getYield()).setOptional(LootContextParameters.BLOCK_ENTITY, tileentity);
|
||||
+
|
||||
+ craftBlock.getNMS().a(loottableinfo_builder).forEach((itemstack) -> {
|
||||
+ Block.a(world, blockposition, itemstack);
|
||||
+ });
|
||||
+ craftBlock.getNMS().dropNaturally((WorldServer) world, blockposition, ItemStack.b);
|
||||
+ }
|
||||
+ nmsBlock.wasExploded(world, blockposition, explosionSource);
|
||||
+
|
||||
+ this.world.a(blockposition, false);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (flag1) {
|
||||
BlockPosition blockposition1 = new BlockPosition(i + this.random.nextInt(l - i + 1), j + this.random.nextInt(i1 - j + 1), k + this.random.nextInt(j1 - k + 1));
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
--- a/net/minecraft/server/DragonControllerManager.java
|
||||
+++ b/net/minecraft/server/DragonControllerManager.java
|
||||
@@ -3,6 +3,11 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.entity.CraftEnderDragon;
|
||||
+import org.bukkit.event.entity.EnderDragonChangePhaseEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class DragonControllerManager {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -21,6 +26,19 @@
|
||||
this.currentDragonController.e();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Call EnderDragonChangePhaseEvent
|
||||
+ EnderDragonChangePhaseEvent event = new EnderDragonChangePhaseEvent(
|
||||
+ (CraftEnderDragon) this.enderDragon.getBukkitEntity(),
|
||||
+ (this.currentDragonController == null) ? null : CraftEnderDragon.getBukkitPhase(this.currentDragonController.getControllerPhase()),
|
||||
+ CraftEnderDragon.getBukkitPhase(dragoncontrollerphase)
|
||||
+ );
|
||||
+ this.enderDragon.world.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ dragoncontrollerphase = CraftEnderDragon.getMinecraftPhase(event.getNewPhase());
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.currentDragonController = this.b(dragoncontrollerphase);
|
||||
if (!this.enderDragon.world.isClientSide) {
|
||||
this.enderDragon.getDataWatcher().set(EntityEnderDragon.PHASE, dragoncontrollerphase.b());
|
||||
@@ -42,6 +60,6 @@
|
||||
this.dragonControllers[i] = dragoncontrollerphase.a(this.enderDragon);
|
||||
}
|
||||
|
||||
- return this.dragonControllers[i];
|
||||
+ return (T) this.dragonControllers[i]; // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
--- a/net/minecraft/server/EntityWither.java
|
||||
+++ b/net/minecraft/server/EntityWither.java
|
||||
@@ -6,6 +6,13 @@
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
+import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityWither extends EntityMonster implements IRangedEntity {
|
||||
|
||||
private static final DataWatcherObject<Integer> b = DataWatcher.a(EntityWither.class, DataWatcherRegistry.b);
|
||||
@@ -188,16 +195,40 @@
|
||||
i = this.getInvul() - 1;
|
||||
if (i <= 0) {
|
||||
Explosion.Effect explosion_effect = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE;
|
||||
+ // CraftBukkit start
|
||||
+ // this.world.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), 7.0F, false, explosion_effect);
|
||||
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false);
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.world.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
- this.world.createExplosion(this, this.locX(), this.getHeadY(), this.locZ(), 7.0F, false, explosion_effect);
|
||||
if (!this.isSilent()) {
|
||||
- this.world.b(1023, this.getChunkCoordinates(), 0);
|
||||
+ // CraftBukkit start - Use relative location for far away sounds
|
||||
+ // this.world.b(1023, new BlockPosition(this), 0);
|
||||
+ int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16;
|
||||
+ for (EntityPlayer player : (List<EntityPlayer>) MinecraftServer.getServer().getPlayerList().players) {
|
||||
+ double deltaX = this.locX() - player.locX();
|
||||
+ double deltaZ = this.locZ() - player.locZ();
|
||||
+ double distanceSquared = deltaX * deltaX + deltaZ * deltaZ;
|
||||
+ if (distanceSquared > viewDistance * viewDistance) {
|
||||
+ double deltaLength = Math.sqrt(distanceSquared);
|
||||
+ double relativeX = player.locX() + (deltaX / deltaLength) * viewDistance;
|
||||
+ double relativeZ = player.locZ() + (deltaZ / deltaLength) * viewDistance;
|
||||
+ player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1023, new BlockPosition((int) relativeX, (int) this.locY(), (int) relativeZ), 0, true));
|
||||
+ } else {
|
||||
+ player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1023, this.getChunkCoordinates(), 0, true));
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
this.setInvul(i);
|
||||
if (this.ticksLived % 10 == 0) {
|
||||
- this.heal(10.0F);
|
||||
+ this.heal(10.0F, EntityRegainHealthEvent.RegainReason.WITHER_SPAWN); // CraftBukkit
|
||||
}
|
||||
|
||||
} else {
|
||||
@@ -249,9 +280,11 @@
|
||||
if (entityliving != this && entityliving.isAlive() && this.hasLineOfSight(entityliving)) {
|
||||
if (entityliving instanceof EntityHuman) {
|
||||
if (!((EntityHuman) entityliving).abilities.isInvulnerable) {
|
||||
+ if (CraftEventFactory.callEntityTargetLivingEvent(this, entityliving, EntityTargetEvent.TargetReason.CLOSEST_PLAYER).isCancelled()) continue; // CraftBukkit
|
||||
this.setHeadTarget(i, entityliving.getId());
|
||||
}
|
||||
} else {
|
||||
+ if (CraftEventFactory.callEntityTargetLivingEvent(this, entityliving, EntityTargetEvent.TargetReason.CLOSEST_ENTITY).isCancelled()) continue; // CraftBukkit
|
||||
this.setHeadTarget(i, entityliving.getId());
|
||||
}
|
||||
break;
|
||||
@@ -287,6 +320,11 @@
|
||||
IBlockData iblockdata = this.world.getType(blockposition);
|
||||
|
||||
if (c(iblockdata)) {
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
flag = this.world.a(blockposition, true, this) || flag;
|
||||
}
|
||||
}
|
||||
@@ -300,7 +338,7 @@
|
||||
}
|
||||
|
||||
if (this.ticksLived % 20 == 0) {
|
||||
- this.heal(1.0F);
|
||||
+ this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
|
||||
}
|
||||
|
||||
this.bossBattle.setProgress(this.getHealth() / this.getMaxHealth());
|
||||
@@ -0,0 +1,185 @@
|
||||
--- a/net/minecraft/server/EntityArmorStand.java
|
||||
+++ b/net/minecraft/server/EntityArmorStand.java
|
||||
@@ -5,6 +5,15 @@
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.inventory.EquipmentSlot;
|
||||
+import org.bukkit.craftbukkit.CraftEquipmentSlot;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.entity.ArmorStand;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityArmorStand extends EntityLiving {
|
||||
|
||||
private static final Vector3f bj = new Vector3f(0.0F, 0.0F, 0.0F);
|
||||
@@ -55,6 +64,13 @@
|
||||
this.setPosition(d0, d1, d2);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - SPIGOT-3607, SPIGOT-3637
|
||||
+ @Override
|
||||
+ public float getBukkitYaw() {
|
||||
+ return this.yaw;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public void updateSize() {
|
||||
double d0 = this.locX();
|
||||
@@ -110,13 +126,20 @@
|
||||
|
||||
@Override
|
||||
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
|
||||
+ // CraftBukkit start
|
||||
+ this.setSlot(enumitemslot, itemstack, false);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) {
|
||||
+ // CraftBukkit end
|
||||
switch (enumitemslot.a()) {
|
||||
case HAND:
|
||||
- this.playEquipSound(itemstack);
|
||||
+ this.playEquipSound(itemstack, silent); // CraftBukkit
|
||||
this.handItems.set(enumitemslot.b(), itemstack);
|
||||
break;
|
||||
case ARMOR:
|
||||
- this.playEquipSound(itemstack);
|
||||
+ this.playEquipSound(itemstack, silent); // CraftBukkit
|
||||
this.armorItems.set(enumitemslot.b(), itemstack);
|
||||
}
|
||||
|
||||
@@ -383,6 +406,21 @@
|
||||
return false;
|
||||
} else {
|
||||
ItemStack itemstack2;
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.inventory.ItemStack armorStandItem = CraftItemStack.asCraftMirror(itemstack1);
|
||||
+ org.bukkit.inventory.ItemStack playerHeldItem = CraftItemStack.asCraftMirror(itemstack);
|
||||
+
|
||||
+ Player player = (Player) entityhuman.getBukkitEntity();
|
||||
+ ArmorStand self = (ArmorStand) this.getBukkitEntity();
|
||||
+
|
||||
+ EquipmentSlot slot = CraftEquipmentSlot.getSlot(enumitemslot);
|
||||
+ PlayerArmorStandManipulateEvent armorStandManipulateEvent = new PlayerArmorStandManipulateEvent(player,self,playerHeldItem,armorStandItem,slot);
|
||||
+ this.world.getServer().getPluginManager().callEvent(armorStandManipulateEvent);
|
||||
+
|
||||
+ if (armorStandManipulateEvent.isCancelled()) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (entityhuman.abilities.canInstantlyBuild && itemstack1.isEmpty() && !itemstack.isEmpty()) {
|
||||
itemstack2 = itemstack.cloneItemStack();
|
||||
@@ -411,12 +449,22 @@
|
||||
public boolean damageEntity(DamageSource damagesource, float f) {
|
||||
if (!this.world.isClientSide && !this.dead) {
|
||||
if (DamageSource.OUT_OF_WORLD.equals(damagesource)) {
|
||||
- this.die();
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity()
|
||||
return false;
|
||||
- } else if (!this.isInvulnerable(damagesource) && !this.armorStandInvisible && !this.isMarker()) {
|
||||
+ } else if (!this.isInvulnerable(damagesource) && (true || !this.armorStandInvisible) && !this.isMarker()) { // CraftBukkit
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, true, this.armorStandInvisible)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (damagesource.isExplosion()) {
|
||||
this.g(damagesource);
|
||||
- this.die();
|
||||
+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity()
|
||||
return false;
|
||||
} else if (DamageSource.FIRE.equals(damagesource)) {
|
||||
if (this.isBurning()) {
|
||||
@@ -441,7 +489,7 @@
|
||||
} else if (damagesource.v()) {
|
||||
this.F();
|
||||
this.D();
|
||||
- this.die();
|
||||
+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity()
|
||||
return flag1;
|
||||
} else {
|
||||
long i = this.world.getTime();
|
||||
@@ -452,7 +500,7 @@
|
||||
} else {
|
||||
this.f(damagesource);
|
||||
this.D();
|
||||
- this.die();
|
||||
+ this.die(); // CraftBukkit - SPIGOT-4890: remain as this.die() since above damagesource method will call death event
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -479,7 +527,7 @@
|
||||
f1 -= f;
|
||||
if (f1 <= 0.5F) {
|
||||
this.g(damagesource);
|
||||
- this.die();
|
||||
+ this.killEntity(); // CraftBukkit - this.die() -> this.killEntity()
|
||||
} else {
|
||||
this.setHealth(f1);
|
||||
}
|
||||
@@ -487,13 +535,13 @@
|
||||
}
|
||||
|
||||
private void f(DamageSource damagesource) {
|
||||
- Block.a(this.world, this.getChunkCoordinates(), new ItemStack(Items.ARMOR_STAND));
|
||||
+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(new ItemStack(Items.ARMOR_STAND))); // CraftBukkit - add to drops
|
||||
this.g(damagesource);
|
||||
}
|
||||
|
||||
private void g(DamageSource damagesource) {
|
||||
this.F();
|
||||
- this.d(damagesource);
|
||||
+ // this.d(damagesource); // CraftBukkit - moved down
|
||||
|
||||
ItemStack itemstack;
|
||||
int i;
|
||||
@@ -501,7 +549,7 @@
|
||||
for (i = 0; i < this.handItems.size(); ++i) {
|
||||
itemstack = (ItemStack) this.handItems.get(i);
|
||||
if (!itemstack.isEmpty()) {
|
||||
- Block.a(this.world, this.getChunkCoordinates().up(), itemstack);
|
||||
+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops
|
||||
this.handItems.set(i, ItemStack.b);
|
||||
}
|
||||
}
|
||||
@@ -509,10 +557,11 @@
|
||||
for (i = 0; i < this.armorItems.size(); ++i) {
|
||||
itemstack = (ItemStack) this.armorItems.get(i);
|
||||
if (!itemstack.isEmpty()) {
|
||||
- Block.a(this.world, this.getChunkCoordinates().up(), itemstack);
|
||||
+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops
|
||||
this.armorItems.set(i, ItemStack.b);
|
||||
}
|
||||
}
|
||||
+ this.d(damagesource); // CraftBukkit - moved from above
|
||||
|
||||
}
|
||||
|
||||
@@ -613,8 +662,16 @@
|
||||
return this.isSmall();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ protected boolean isDropExperience() {
|
||||
+ return true; // MC-157395, SPIGOT-5193 even baby (small) armor stands should drop
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public void killEntity() {
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, drops); // CraftBukkit - call event
|
||||
this.die();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
--- a/net/minecraft/server/EntityHanging.java
|
||||
+++ b/net/minecraft/server/EntityHanging.java
|
||||
@@ -4,6 +4,12 @@
|
||||
import javax.annotation.Nullable;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.entity.Hanging;
|
||||
+import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
+import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class EntityHanging extends Entity {
|
||||
|
||||
protected static final Predicate<Entity> b = (entity) -> {
|
||||
@@ -37,26 +43,37 @@
|
||||
|
||||
protected void updateBoundingBox() {
|
||||
if (this.direction != null) {
|
||||
- double d0 = (double) this.blockPosition.getX() + 0.5D;
|
||||
- double d1 = (double) this.blockPosition.getY() + 0.5D;
|
||||
- double d2 = (double) this.blockPosition.getZ() + 0.5D;
|
||||
+ // CraftBukkit start code moved in to calculateBoundingBox
|
||||
+ this.a(calculateBoundingBox(this, this.blockPosition, this.direction, this.getHangingWidth(), this.getHangingHeight()));
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start - break out BB calc into own method
|
||||
+ public static AxisAlignedBB calculateBoundingBox(@Nullable Entity entity, BlockPosition blockPosition, EnumDirection direction, int width, int height) {
|
||||
+ {
|
||||
+ double d0 = (double) blockPosition.getX() + 0.5D;
|
||||
+ double d1 = (double) blockPosition.getY() + 0.5D;
|
||||
+ double d2 = (double) blockPosition.getZ() + 0.5D;
|
||||
double d3 = 0.46875D;
|
||||
- double d4 = this.a(this.getHangingWidth());
|
||||
- double d5 = this.a(this.getHangingHeight());
|
||||
+ double d4 = a(width);
|
||||
+ double d5 = a(height);
|
||||
|
||||
- d0 -= (double) this.direction.getAdjacentX() * 0.46875D;
|
||||
- d2 -= (double) this.direction.getAdjacentZ() * 0.46875D;
|
||||
+ d0 -= (double) direction.getAdjacentX() * 0.46875D;
|
||||
+ d2 -= (double) direction.getAdjacentZ() * 0.46875D;
|
||||
d1 += d5;
|
||||
- EnumDirection enumdirection = this.direction.h();
|
||||
+ EnumDirection enumdirection = direction.h();
|
||||
|
||||
d0 += d4 * (double) enumdirection.getAdjacentX();
|
||||
d2 += d4 * (double) enumdirection.getAdjacentZ();
|
||||
- this.setPositionRaw(d0, d1, d2);
|
||||
- double d6 = (double) this.getHangingWidth();
|
||||
- double d7 = (double) this.getHangingHeight();
|
||||
- double d8 = (double) this.getHangingWidth();
|
||||
+ if (entity != null) {
|
||||
+ entity.setPositionRaw(d0, d1, d2);
|
||||
+ }
|
||||
+ double d6 = (double) width;
|
||||
+ double d7 = (double) height;
|
||||
+ double d8 = (double) width;
|
||||
|
||||
- if (this.direction.n() == EnumDirection.EnumAxis.Z) {
|
||||
+ if (direction.n() == EnumDirection.EnumAxis.Z) {
|
||||
d8 = 1.0D;
|
||||
} else {
|
||||
d6 = 1.0D;
|
||||
@@ -65,11 +82,12 @@
|
||||
d6 /= 32.0D;
|
||||
d7 /= 32.0D;
|
||||
d8 /= 32.0D;
|
||||
- this.a(new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8));
|
||||
+ return new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8);
|
||||
}
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
- private double a(int i) {
|
||||
+ private static double a(int i) { // CraftBukkit - static
|
||||
return i % 32 == 0 ? 0.5D : 0.0D;
|
||||
}
|
||||
|
||||
@@ -83,6 +101,24 @@
|
||||
if (this.e++ == 100) {
|
||||
this.e = 0;
|
||||
if (!this.dead && !this.survives()) {
|
||||
+ // CraftBukkit start - fire break events
|
||||
+ Material material = this.world.getType(this.getChunkCoordinates()).getMaterial();
|
||||
+ HangingBreakEvent.RemoveCause cause;
|
||||
+
|
||||
+ if (!material.equals(Material.AIR)) {
|
||||
+ // TODO: This feels insufficient to catch 100% of suffocation cases
|
||||
+ cause = HangingBreakEvent.RemoveCause.OBSTRUCTION;
|
||||
+ } else {
|
||||
+ cause = HangingBreakEvent.RemoveCause.PHYSICS;
|
||||
+ }
|
||||
+
|
||||
+ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), cause);
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (dead || event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.die();
|
||||
this.a((Entity) null);
|
||||
}
|
||||
@@ -146,6 +182,22 @@
|
||||
return false;
|
||||
} else {
|
||||
if (!this.dead && !this.world.isClientSide) {
|
||||
+ // CraftBukkit start - fire break events
|
||||
+ Entity damager = (damagesource instanceof EntityDamageSourceIndirect) ? ((EntityDamageSourceIndirect) damagesource).getProximateDamageSource() : damagesource.getEntity();
|
||||
+ HangingBreakEvent event;
|
||||
+ if (damager != null) {
|
||||
+ event = new HangingBreakByEntityEvent((Hanging) this.getBukkitEntity(), damager.getBukkitEntity(), damagesource.isExplosion() ? HangingBreakEvent.RemoveCause.EXPLOSION : HangingBreakEvent.RemoveCause.ENTITY);
|
||||
+ } else {
|
||||
+ event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), damagesource.isExplosion() ? HangingBreakEvent.RemoveCause.EXPLOSION : HangingBreakEvent.RemoveCause.DEFAULT);
|
||||
+ }
|
||||
+
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (this.dead || event.isCancelled()) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.die();
|
||||
this.velocityChanged();
|
||||
this.a(damagesource.getEntity());
|
||||
@@ -158,6 +210,18 @@
|
||||
@Override
|
||||
public void move(EnumMoveType enummovetype, Vec3D vec3d) {
|
||||
if (!this.world.isClientSide && !this.dead && vec3d.g() > 0.0D) {
|
||||
+ if (this.dead) return; // CraftBukkit
|
||||
+
|
||||
+ // CraftBukkit start - fire break events
|
||||
+ // TODO - Does this need its own cause? Seems to only be triggered by pistons
|
||||
+ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.PHYSICS);
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (this.dead || event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.die();
|
||||
this.a((Entity) null);
|
||||
}
|
||||
@@ -166,7 +230,7 @@
|
||||
|
||||
@Override
|
||||
public void i(double d0, double d1, double d2) {
|
||||
- if (!this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
|
||||
+ if (false && !this.world.isClientSide && !this.dead && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { // CraftBukkit - not needed
|
||||
this.die();
|
||||
this.a((Entity) null);
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
--- a/net/minecraft/server/EntityItemFrame.java
|
||||
+++ b/net/minecraft/server/EntityItemFrame.java
|
||||
@@ -53,16 +53,27 @@
|
||||
@Override
|
||||
protected void updateBoundingBox() {
|
||||
if (this.direction != null) {
|
||||
+ // CraftBukkit start code moved in to calculateBoundingBox
|
||||
+ this.a(calculateBoundingBox(this, this.blockPosition, this.direction, this.getHangingWidth(), this.getHangingHeight()));
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start - break out BB calc into own method
|
||||
+ public static AxisAlignedBB calculateBoundingBox(@Nullable Entity entity, BlockPosition blockPosition, EnumDirection direction, int width, int height) {
|
||||
+ {
|
||||
double d0 = 0.46875D;
|
||||
- double d1 = (double) this.blockPosition.getX() + 0.5D - (double) this.direction.getAdjacentX() * 0.46875D;
|
||||
- double d2 = (double) this.blockPosition.getY() + 0.5D - (double) this.direction.getAdjacentY() * 0.46875D;
|
||||
- double d3 = (double) this.blockPosition.getZ() + 0.5D - (double) this.direction.getAdjacentZ() * 0.46875D;
|
||||
-
|
||||
- this.setPositionRaw(d1, d2, d3);
|
||||
- double d4 = (double) this.getHangingWidth();
|
||||
- double d5 = (double) this.getHangingHeight();
|
||||
- double d6 = (double) this.getHangingWidth();
|
||||
- EnumDirection.EnumAxis enumdirection_enumaxis = this.direction.n();
|
||||
+ double d1 = (double) blockPosition.getX() + 0.5D - (double) direction.getAdjacentX() * 0.46875D;
|
||||
+ double d2 = (double) blockPosition.getY() + 0.5D - (double) direction.getAdjacentY() * 0.46875D;
|
||||
+ double d3 = (double) blockPosition.getZ() + 0.5D - (double) direction.getAdjacentZ() * 0.46875D;
|
||||
+
|
||||
+ if (entity != null) {
|
||||
+ entity.setPositionRaw(d1, d2, d3);
|
||||
+ }
|
||||
+ double d4 = (double) width;
|
||||
+ double d5 = (double) height;
|
||||
+ double d6 = (double) width;
|
||||
+ EnumDirection.EnumAxis enumdirection_enumaxis = direction.n();
|
||||
|
||||
switch (enumdirection_enumaxis) {
|
||||
case X:
|
||||
@@ -78,9 +89,10 @@
|
||||
d4 /= 32.0D;
|
||||
d5 /= 32.0D;
|
||||
d6 /= 32.0D;
|
||||
- this.a(new AxisAlignedBB(d1 - d4, d2 - d5, d3 - d6, d1 + d4, d2 + d5, d3 + d6));
|
||||
+ return new AxisAlignedBB(d1 - d4, d2 - d5, d3 - d6, d1 + d4, d2 + d5, d3 + d6);
|
||||
}
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
@Override
|
||||
public boolean survives() {
|
||||
@@ -130,6 +142,11 @@
|
||||
return false;
|
||||
} else if (!damagesource.isExplosion() && !this.getItem().isEmpty()) {
|
||||
if (!this.world.isClientSide) {
|
||||
+ // CraftBukkit start - fire EntityDamageEvent
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false) || this.dead) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.b(damagesource.getEntity(), false);
|
||||
this.playSound(SoundEffects.ENTITY_ITEM_FRAME_REMOVE_ITEM, 1.0F, 1.0F);
|
||||
}
|
||||
@@ -217,6 +234,12 @@
|
||||
}
|
||||
|
||||
public void setItem(ItemStack itemstack, boolean flag) {
|
||||
+ // CraftBukkit start
|
||||
+ this.setItem(itemstack, flag, true);
|
||||
+ }
|
||||
+
|
||||
+ public void setItem(ItemStack itemstack, boolean flag, boolean playSound) {
|
||||
+ // CraftBukkit end
|
||||
if (!itemstack.isEmpty()) {
|
||||
itemstack = itemstack.cloneItemStack();
|
||||
itemstack.setCount(1);
|
||||
@@ -224,7 +247,7 @@
|
||||
}
|
||||
|
||||
this.getDataWatcher().set(EntityItemFrame.ITEM, itemstack);
|
||||
- if (!itemstack.isEmpty()) {
|
||||
+ if (!itemstack.isEmpty() && playSound) { // CraftBukkit
|
||||
this.playSound(SoundEffects.ENTITY_ITEM_FRAME_ADD_ITEM, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
--- a/net/minecraft/server/EntityLeash.java
|
||||
+++ b/net/minecraft/server/EntityLeash.java
|
||||
@@ -4,6 +4,8 @@
|
||||
import java.util.List;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
+
|
||||
public class EntityLeash extends EntityHanging {
|
||||
|
||||
public EntityLeash(EntityTypes<? extends EntityLeash> entitytypes, World world) {
|
||||
@@ -29,6 +31,7 @@
|
||||
@Override
|
||||
protected void updateBoundingBox() {
|
||||
this.setPositionRaw((double) this.blockPosition.getX() + 0.5D, (double) this.blockPosition.getY() + 0.5D, (double) this.blockPosition.getZ() + 0.5D);
|
||||
+ if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,22 +78,42 @@
|
||||
while (iterator.hasNext()) {
|
||||
entityinsentient = (EntityInsentient) iterator.next();
|
||||
if (entityinsentient.getLeashHolder() == entityhuman) {
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callPlayerLeashEntityEvent(entityinsentient, this, entityhuman).isCancelled()) {
|
||||
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutAttachEntity(entityinsentient, entityinsentient.getLeashHolder()));
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
entityinsentient.setLeashHolder(this, true);
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!flag) {
|
||||
- this.die();
|
||||
- if (entityhuman.abilities.canInstantlyBuild) {
|
||||
+ // CraftBukkit start - Move below
|
||||
+ // this.die();
|
||||
+ boolean die = true;
|
||||
+ // CraftBukkit end
|
||||
+ if (true || entityhuman.abilities.canInstantlyBuild) { // CraftBukkit - Process for non-creative as well
|
||||
iterator = list.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
entityinsentient = (EntityInsentient) iterator.next();
|
||||
if (entityinsentient.isLeashed() && entityinsentient.getLeashHolder() == this) {
|
||||
- entityinsentient.unleash(true, false);
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(entityinsentient, entityhuman).isCancelled()) {
|
||||
+ die = false;
|
||||
+ continue;
|
||||
+ }
|
||||
+ entityinsentient.unleash(true, !entityhuman.abilities.canInstantlyBuild); // false -> survival mode boolean
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ if (die) {
|
||||
+ this.die();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
--- a/net/minecraft/server/EntityPainting.java
|
||||
+++ b/net/minecraft/server/EntityPainting.java
|
||||
@@ -11,6 +11,10 @@
|
||||
|
||||
public EntityPainting(EntityTypes<? extends EntityPainting> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
+ // CraftBukkit start - generate a non-null painting
|
||||
+ List<Paintings> list = Lists.newArrayList(Paintings.a);
|
||||
+ this.art = (Paintings) list.get(this.random.nextInt(list.size()));
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public EntityPainting(World world, BlockPosition blockposition, EnumDirection enumdirection) {
|
||||
@@ -0,0 +1,42 @@
|
||||
--- a/net/minecraft/server/EntityFallingBlock.java
|
||||
+++ b/net/minecraft/server/EntityFallingBlock.java
|
||||
@@ -4,6 +4,8 @@
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
+
|
||||
public class EntityFallingBlock extends Entity {
|
||||
|
||||
private IBlockData block;
|
||||
@@ -70,7 +72,7 @@
|
||||
|
||||
if (this.ticksLived++ == 0) {
|
||||
blockposition = this.getChunkCoordinates();
|
||||
- if (this.world.getType(blockposition).a(block)) {
|
||||
+ if (this.world.getType(blockposition).a(block) && !CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
|
||||
this.world.a(blockposition, false);
|
||||
} else if (!this.world.isClientSide) {
|
||||
this.die();
|
||||
@@ -122,6 +124,11 @@
|
||||
this.block = (IBlockData) this.block.set(BlockProperties.C, true);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.block).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (this.world.setTypeAndData(blockposition, this.block, 3)) {
|
||||
if (block instanceof BlockFalling) {
|
||||
((BlockFalling) block).a(this.world, blockposition, this.block, iblockdata, this);
|
||||
@@ -178,7 +185,9 @@
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
+ CraftEventFactory.entityDamage = this; // CraftBukkit
|
||||
entity.damageEntity(damagesource, (float) Math.min(MathHelper.d((float) i * this.fallHurtAmount), this.fallHurtMax));
|
||||
+ CraftEventFactory.entityDamage = null; // CraftBukkit
|
||||
}
|
||||
|
||||
if (flag && (double) this.random.nextFloat() < 0.05000000074505806D + (double) i * 0.05D) {
|
||||
@@ -0,0 +1,145 @@
|
||||
--- a/net/minecraft/server/EntityItem.java
|
||||
+++ b/net/minecraft/server/EntityItem.java
|
||||
@@ -6,6 +6,11 @@
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
+import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityItem extends Entity {
|
||||
|
||||
private static final DataWatcherObject<ItemStack> ITEM = DataWatcher.a(EntityItem.class, DataWatcherRegistry.g);
|
||||
@@ -15,6 +20,7 @@
|
||||
private UUID thrower;
|
||||
private UUID owner;
|
||||
public final float b;
|
||||
+ private int lastTick = MinecraftServer.currentTick - 1; // CraftBukkit
|
||||
|
||||
public EntityItem(EntityTypes<? extends EntityItem> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -50,9 +56,12 @@
|
||||
this.die();
|
||||
} else {
|
||||
super.tick();
|
||||
- if (this.pickupDelay > 0 && this.pickupDelay != 32767) {
|
||||
- --this.pickupDelay;
|
||||
- }
|
||||
+ // CraftBukkit start - Use wall time for pickup and despawn timers
|
||||
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
|
||||
+ if (this.pickupDelay != 32767) this.pickupDelay -= elapsedTicks;
|
||||
+ if (this.age != -32768) this.age += elapsedTicks;
|
||||
+ this.lastTick = MinecraftServer.currentTick;
|
||||
+ // CraftBukkit end
|
||||
|
||||
this.lastX = this.locX();
|
||||
this.lastY = this.locY();
|
||||
@@ -108,9 +117,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ /* CraftBukkit start - moved up
|
||||
if (this.age != -32768) {
|
||||
++this.age;
|
||||
}
|
||||
+ // CraftBukkit end */
|
||||
|
||||
this.impulse |= this.aK();
|
||||
if (!this.world.isClientSide) {
|
||||
@@ -122,6 +133,12 @@
|
||||
}
|
||||
|
||||
if (!this.world.isClientSide && this.age >= 6000) {
|
||||
+ // CraftBukkit start - fire ItemDespawnEvent
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
|
||||
+ this.age = 0;
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.die();
|
||||
}
|
||||
|
||||
@@ -197,10 +214,11 @@
|
||||
private static void a(EntityItem entityitem, ItemStack itemstack, ItemStack itemstack1) {
|
||||
ItemStack itemstack2 = a(itemstack, itemstack1, 64);
|
||||
|
||||
- entityitem.setItemStack(itemstack2);
|
||||
+ if (!itemstack2.isEmpty()) entityitem.setItemStack(itemstack2); // CraftBukkit - don't set empty stacks
|
||||
}
|
||||
|
||||
private static void a(EntityItem entityitem, ItemStack itemstack, EntityItem entityitem1, ItemStack itemstack1) {
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemMergeEvent(entityitem1, entityitem).isCancelled()) return; // CraftBukkit
|
||||
a(entityitem, itemstack, itemstack1);
|
||||
entityitem.pickupDelay = Math.max(entityitem.pickupDelay, entityitem1.pickupDelay);
|
||||
entityitem.age = Math.min(entityitem.age, entityitem1.age);
|
||||
@@ -224,6 +242,11 @@
|
||||
} else if (!this.getItemStack().getItem().a(damagesource)) {
|
||||
return false;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.velocityChanged();
|
||||
this.f = (int) ((float) this.f - f);
|
||||
if (this.f <= 0) {
|
||||
@@ -285,6 +308,46 @@
|
||||
Item item = itemstack.getItem();
|
||||
int i = itemstack.getCount();
|
||||
|
||||
+ // CraftBukkit start - fire PlayerPickupItemEvent
|
||||
+ int canHold = entityhuman.inventory.canHold(itemstack);
|
||||
+ int remaining = i - canHold;
|
||||
+
|
||||
+ if (this.pickupDelay <= 0 && canHold > 0) {
|
||||
+ itemstack.setCount(canHold);
|
||||
+ // Call legacy event
|
||||
+ PlayerPickupItemEvent playerEvent = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
|
||||
+ playerEvent.setCancelled(!entityhuman.canPickUpLoot);
|
||||
+ this.world.getServer().getPluginManager().callEvent(playerEvent);
|
||||
+ if (playerEvent.isCancelled()) {
|
||||
+ itemstack.setCount(i); // SPIGOT-5294 - restore count
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // Call newer event afterwards
|
||||
+ EntityPickupItemEvent entityEvent = new EntityPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
|
||||
+ entityEvent.setCancelled(!entityhuman.canPickUpLoot);
|
||||
+ this.world.getServer().getPluginManager().callEvent(entityEvent);
|
||||
+ if (entityEvent.isCancelled()) {
|
||||
+ itemstack.setCount(i); // SPIGOT-5294 - restore count
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // Update the ItemStack if it was changed in the event
|
||||
+ ItemStack current = this.getItemStack();
|
||||
+ if (!itemstack.equals(current)) {
|
||||
+ itemstack = current;
|
||||
+ } else {
|
||||
+ itemstack.setCount(canHold + remaining); // = i
|
||||
+ }
|
||||
+
|
||||
+ // Possibly < 0; fix here so we do not have to modify code below
|
||||
+ this.pickupDelay = 0;
|
||||
+ } else if (this.pickupDelay == 0) {
|
||||
+ // ensure that the code below isn't triggered if canHold says we can't pick the items up
|
||||
+ this.pickupDelay = -1;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(entityhuman.getUniqueID())) && entityhuman.inventory.pickup(itemstack)) {
|
||||
entityhuman.receive(this, i);
|
||||
if (itemstack.isEmpty()) {
|
||||
@@ -328,7 +391,9 @@
|
||||
}
|
||||
|
||||
public void setItemStack(ItemStack itemstack) {
|
||||
+ com.google.common.base.Preconditions.checkArgument(!itemstack.isEmpty(), "Cannot drop air"); // CraftBukkit
|
||||
this.getDataWatcher().set(EntityItem.ITEM, itemstack);
|
||||
+ this.getDataWatcher().markDirty(EntityItem.ITEM); // CraftBukkit - SPIGOT-4591, must mark dirty
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,53 @@
|
||||
--- a/net/minecraft/server/EntityTNTPrimed.java
|
||||
+++ b/net/minecraft/server/EntityTNTPrimed.java
|
||||
@@ -2,12 +2,16 @@
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
|
||||
+
|
||||
public class EntityTNTPrimed extends Entity {
|
||||
|
||||
private static final DataWatcherObject<Integer> FUSE_TICKS = DataWatcher.a(EntityTNTPrimed.class, DataWatcherRegistry.b);
|
||||
@Nullable
|
||||
public EntityLiving source;
|
||||
private int fuseTicks;
|
||||
+ public float yield = 4; // CraftBukkit - add field
|
||||
+ public boolean isIncendiary = false; // CraftBukkit - add field
|
||||
|
||||
public EntityTNTPrimed(EntityTypes<? extends EntityTNTPrimed> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -57,10 +61,13 @@
|
||||
|
||||
--this.fuseTicks;
|
||||
if (this.fuseTicks <= 0) {
|
||||
- this.die();
|
||||
+ // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event
|
||||
+ // this.die();
|
||||
if (!this.world.isClientSide) {
|
||||
this.explode();
|
||||
}
|
||||
+ this.die();
|
||||
+ // CraftBukkit end
|
||||
} else {
|
||||
this.aK();
|
||||
if (this.world.isClientSide) {
|
||||
@@ -71,9 +78,16 @@
|
||||
}
|
||||
|
||||
private void explode() {
|
||||
- float f = 4.0F;
|
||||
+ // CraftBukkit start
|
||||
+ // float f = 4.0F;
|
||||
|
||||
- this.world.explode(this, this.locX(), this.e(0.0625D), this.locZ(), 4.0F, Explosion.Effect.BREAK);
|
||||
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity());
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.world.createExplosion(this, this.locX(), this.e(0.0625D), this.locZ(), event.getRadius(), event.getFire(), Explosion.Effect.BREAK);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/EntityCaveSpider.java
|
||||
+++ b/net/minecraft/server/EntityCaveSpider.java
|
||||
@@ -25,7 +25,7 @@
|
||||
}
|
||||
|
||||
if (b0 > 0) {
|
||||
- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0));
|
||||
+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
--- a/net/minecraft/server/EntityCreeper.java
|
||||
+++ b/net/minecraft/server/EntityCreeper.java
|
||||
@@ -3,6 +3,12 @@
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
+import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityCreeper extends EntityMonster {
|
||||
|
||||
private static final DataWatcherObject<Integer> b = DataWatcher.a(EntityCreeper.class, DataWatcherRegistry.b);
|
||||
@@ -165,9 +171,19 @@
|
||||
@Override
|
||||
public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) {
|
||||
super.onLightningStrike(worldserver, entitylightning);
|
||||
- this.datawatcher.set(EntityCreeper.POWERED, true);
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callCreeperPowerEvent(this, entitylightning, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ this.setPowered(true);
|
||||
}
|
||||
|
||||
+ public void setPowered(boolean powered) {
|
||||
+ this.datawatcher.set(EntityCreeper.POWERED, powered);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
protected EnumInteractionResult b(EntityHuman entityhuman, EnumHand enumhand) {
|
||||
ItemStack itemstack = entityhuman.b(enumhand);
|
||||
@@ -192,10 +208,18 @@
|
||||
Explosion.Effect explosion_effect = this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING) ? Explosion.Effect.DESTROY : Explosion.Effect.NONE;
|
||||
float f = this.isPowered() ? 2.0F : 1.0F;
|
||||
|
||||
- this.killed = true;
|
||||
- this.world.explode(this, this.locX(), this.locY(), this.locZ(), (float) this.explosionRadius * f, explosion_effect);
|
||||
- this.die();
|
||||
- this.createEffectCloud();
|
||||
+ // CraftBukkit start
|
||||
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false);
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ this.killed = true;
|
||||
+ this.world.createExplosion(this, this.locX(), this.locY(), this.locZ(), event.getRadius(), event.getFire(), explosion_effect);
|
||||
+ this.die();
|
||||
+ this.createEffectCloud();
|
||||
+ } else {
|
||||
+ fuseTicks = 0;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -206,6 +230,7 @@
|
||||
if (!collection.isEmpty()) {
|
||||
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.world, this.locX(), this.locY(), this.locZ());
|
||||
|
||||
+ entityareaeffectcloud.setSource(this); // CraftBukkit
|
||||
entityareaeffectcloud.setRadius(2.5F);
|
||||
entityareaeffectcloud.setRadiusOnUse(-0.5F);
|
||||
entityareaeffectcloud.setWaitTime(10);
|
||||
@@ -219,7 +244,7 @@
|
||||
entityareaeffectcloud.addEffect(new MobEffect(mobeffect));
|
||||
}
|
||||
|
||||
- this.world.addEntity(entityareaeffectcloud);
|
||||
+ this.world.addEntity(entityareaeffectcloud, CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
--- a/net/minecraft/server/EntityEnderman.java
|
||||
+++ b/net/minecraft/server/EntityEnderman.java
|
||||
@@ -51,7 +51,17 @@
|
||||
|
||||
@Override
|
||||
public void setGoalTarget(@Nullable EntityLiving entityliving) {
|
||||
- super.setGoalTarget(entityliving);
|
||||
+ // CraftBukkit start - fire event
|
||||
+ setGoalTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.UNKNOWN, true);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean setGoalTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) {
|
||||
+ if (!super.setGoalTarget(entityliving, reason, fireEvent)) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ entityliving = getGoalTarget();
|
||||
+ // CraftBukkit end
|
||||
AttributeModifiable attributemodifiable = this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED);
|
||||
|
||||
if (entityliving == null) {
|
||||
@@ -66,6 +76,7 @@
|
||||
attributemodifiable.b(EntityEnderman.c);
|
||||
}
|
||||
}
|
||||
+ return true;
|
||||
|
||||
}
|
||||
|
||||
@@ -359,8 +370,12 @@
|
||||
boolean flag = movingobjectpositionblock.getBlockPosition().equals(blockposition);
|
||||
|
||||
if (block.a((Tag) TagsBlock.ENDERMAN_HOLDABLE) && flag) {
|
||||
- world.a(blockposition, false);
|
||||
- this.enderman.setCarried(iblockdata.getBlock().getBlockData());
|
||||
+ // CraftBukkit start - Pickup event
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
|
||||
+ world.a(blockposition, false);
|
||||
+ this.enderman.setCarried(iblockdata.getBlock().getBlockData());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -395,8 +410,12 @@
|
||||
if (iblockdata2 != null) {
|
||||
iblockdata2 = Block.b(iblockdata2, (GeneratorAccess) this.a.world, blockposition);
|
||||
if (this.a(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) {
|
||||
+ // CraftBukkit start - Place event
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, iblockdata2).isCancelled()) {
|
||||
world.setTypeAndData(blockposition, iblockdata2, 3);
|
||||
this.a.setCarried((IBlockData) null);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
--- a/net/minecraft/server/EntityGhast.java
|
||||
+++ b/net/minecraft/server/EntityGhast.java
|
||||
@@ -163,7 +163,8 @@
|
||||
|
||||
EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, d2, d3, d4);
|
||||
|
||||
- entitylargefireball.yield = this.ghast.getPower();
|
||||
+ // CraftBukkit - set bukkitYield when setting explosionpower
|
||||
+ entitylargefireball.bukkitYield = entitylargefireball.yield = this.ghast.getPower();
|
||||
entitylargefireball.setPosition(this.ghast.locX() + vec3d.x * 4.0D, this.ghast.e(0.5D) + 0.5D, entitylargefireball.locZ() + vec3d.z * 4.0D);
|
||||
world.addEntity(entitylargefireball);
|
||||
this.a = -40;
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/EntityGuardianElder.java
|
||||
+++ b/net/minecraft/server/EntityGuardianElder.java
|
||||
@@ -65,7 +65,7 @@
|
||||
|
||||
if (!entityplayer.hasEffect(mobeffectlist) || entityplayer.getEffect(mobeffectlist).getAmplifier() < 2 || entityplayer.getEffect(mobeffectlist).getDuration() < 1200) {
|
||||
entityplayer.playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.k, this.isSilent() ? 0.0F : 1.0F));
|
||||
- entityplayer.addEffect(new MobEffect(mobeffectlist, 6000, 2));
|
||||
+ entityplayer.addEffect(new MobEffect(mobeffectlist, 6000, 2), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
--- a/net/minecraft/server/EntityIllagerIllusioner.java
|
||||
+++ b/net/minecraft/server/EntityIllagerIllusioner.java
|
||||
@@ -30,7 +30,7 @@
|
||||
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
|
||||
this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.0F));
|
||||
this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F));
|
||||
- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a());
|
||||
+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a(new Class[0])); // CraftBukkit - decompile error
|
||||
this.targetSelector.a(2, (new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true)).a(300));
|
||||
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, false)).a(300));
|
||||
this.targetSelector.a(3, (new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, false)).a(300));
|
||||
@@ -169,7 +169,7 @@
|
||||
|
||||
@Override
|
||||
protected void j() {
|
||||
- EntityIllagerIllusioner.this.getGoalTarget().addEffect(new MobEffect(MobEffects.BLINDNESS, 400));
|
||||
+ EntityIllagerIllusioner.this.getGoalTarget().addEffect(new MobEffect(MobEffects.BLINDNESS, 400), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -206,7 +206,7 @@
|
||||
|
||||
@Override
|
||||
protected void j() {
|
||||
- EntityIllagerIllusioner.this.addEffect(new MobEffect(MobEffects.INVISIBILITY, 1200));
|
||||
+ EntityIllagerIllusioner.this.addEffect(new MobEffect(MobEffects.INVISIBILITY, 1200), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ILLUSION); // CraftBukkit
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/server/EntityIllagerWizard.java
|
||||
+++ b/net/minecraft/server/EntityIllagerWizard.java
|
||||
@@ -145,6 +145,11 @@
|
||||
public void e() {
|
||||
--this.b;
|
||||
if (this.b == 0) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleEntitySpellCastEvent(EntityIllagerWizard.this, this.getCastSpell())) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.j();
|
||||
EntityIllagerWizard.this.playSound(EntityIllagerWizard.this.getSoundCastSpell(), 1.0F, 1.0F);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/EntityPhantom.java
|
||||
+++ b/net/minecraft/server/EntityPhantom.java
|
||||
@@ -207,7 +207,7 @@
|
||||
EntityHuman entityhuman = (EntityHuman) iterator.next();
|
||||
|
||||
if (EntityPhantom.this.a((EntityLiving) entityhuman, PathfinderTargetCondition.a)) {
|
||||
- EntityPhantom.this.setGoalTarget(entityhuman);
|
||||
+ EntityPhantom.this.setGoalTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit - reason
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
--- a/net/minecraft/server/EntityPigZombie.java
|
||||
+++ b/net/minecraft/server/EntityPigZombie.java
|
||||
@@ -35,7 +35,7 @@
|
||||
protected void m() {
|
||||
this.goalSelector.a(2, new PathfinderGoalZombieAttack(this, 1.0D, false));
|
||||
this.goalSelector.a(7, new PathfinderGoalRandomStrollLand(this, 1.0D));
|
||||
- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a());
|
||||
+ this.targetSelector.a(1, new PathfinderGoalHurtByTarget(this).a(new Class[0])); // CraftBukkit - decompile error
|
||||
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, 10, true, false, this::a_));
|
||||
this.targetSelector.a(3, new PathfinderGoalUniversalAngerReset<>(this, true));
|
||||
}
|
||||
@@ -108,7 +108,7 @@
|
||||
}).filter((entitypigzombie) -> {
|
||||
return !entitypigzombie.r(this.getGoalTarget());
|
||||
}).forEach((entitypigzombie) -> {
|
||||
- entitypigzombie.setGoalTarget(this.getGoalTarget());
|
||||
+ entitypigzombie.setGoalTarget(this.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_NEARBY_ENTITY, true); // CraftBukkit
|
||||
});
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void setGoalTarget(@Nullable EntityLiving entityliving) {
|
||||
+ public boolean setGoalTarget(@Nullable EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fireEvent) { // CraftBukkit - signature
|
||||
if (this.getGoalTarget() == null && entityliving != null) {
|
||||
this.bo = EntityPigZombie.d.a(this.random);
|
||||
this.bt = EntityPigZombie.bs.a(this.random);
|
||||
@@ -127,12 +127,21 @@
|
||||
this.e((EntityHuman) entityliving);
|
||||
}
|
||||
|
||||
- super.setGoalTarget(entityliving);
|
||||
+ return super.setGoalTarget(entityliving, reason, fireEvent); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
public void anger() {
|
||||
- this.setAnger(EntityPigZombie.bp.a(this.random));
|
||||
+ // CraftBukkit start
|
||||
+ Entity entity = ((WorldServer) this.world).getEntity(getAngerTarget());
|
||||
+ org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entity == null) ? null : entity.getBukkitEntity(), EntityPigZombie.bp.a(this.random));
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ this.setAngerTarget(null);
|
||||
+ return;
|
||||
+ }
|
||||
+ this.setAnger(event.getNewAnger());
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public static boolean b(EntityTypes<EntityPigZombie> entitytypes, GeneratorAccess generatoraccess, EnumMobSpawn enummobspawn, BlockPosition blockposition, Random random) {
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/EntityPillager.java
|
||||
+++ b/net/minecraft/server/EntityPillager.java
|
||||
@@ -22,7 +22,7 @@
|
||||
this.goalSelector.a(8, new PathfinderGoalRandomStroll(this, 0.6D));
|
||||
this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 15.0F, 1.0F));
|
||||
this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 15.0F));
|
||||
- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a());
|
||||
+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a(new Class[0])); // CraftBukkit - decompile error
|
||||
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
|
||||
this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, false));
|
||||
this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, true));
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/server/EntityRavager.java
|
||||
+++ b/net/minecraft/server/EntityRavager.java
|
||||
@@ -28,7 +28,7 @@
|
||||
this.goalSelector.a(5, new PathfinderGoalRandomStrollLand(this, 0.4D));
|
||||
this.goalSelector.a(6, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 6.0F));
|
||||
this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F));
|
||||
- this.targetSelector.a(2, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a());
|
||||
+ this.targetSelector.a(2, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a(new Class[0])); // CraftBukkit - decompile error
|
||||
this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
|
||||
this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityVillagerAbstract.class, true));
|
||||
this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityIronGolem.class, true));
|
||||
@@ -119,7 +119,7 @@
|
||||
IBlockData iblockdata = this.world.getType(blockposition);
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
- if (block instanceof BlockLeaves) {
|
||||
+ if (block instanceof BlockLeaves && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { // CraftBukkit
|
||||
flag = this.world.a(blockposition, true, this) || flag;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
--- a/net/minecraft/server/EntityShulker.java
|
||||
+++ b/net/minecraft/server/EntityShulker.java
|
||||
@@ -7,6 +7,11 @@
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.event.entity.EntityTeleportEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityShulker extends EntityGolem implements IMonster {
|
||||
|
||||
private static final UUID bp = UUID.fromString("7E0292F2-9434-48D5-A29F-9583AF7DF27F");
|
||||
@@ -31,7 +36,7 @@
|
||||
this.goalSelector.a(4, new EntityShulker.a());
|
||||
this.goalSelector.a(7, new EntityShulker.e());
|
||||
this.goalSelector.a(8, new PathfinderGoalRandomLookaround(this));
|
||||
- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a());
|
||||
+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error
|
||||
this.targetSelector.a(2, new EntityShulker.d(this));
|
||||
this.targetSelector.a(3, new EntityShulker.c(this));
|
||||
}
|
||||
@@ -279,6 +284,16 @@
|
||||
EnumDirection enumdirection = this.g(blockposition1);
|
||||
|
||||
if (enumdirection != null) {
|
||||
+ // CraftBukkit start
|
||||
+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), new Location(this.world.getWorld(), blockposition1.getX(), blockposition1.getY(), blockposition1.getZ()));
|
||||
+ this.world.getServer().getPluginManager().callEvent(teleport);
|
||||
+ if (!teleport.isCancelled()) {
|
||||
+ Location to = teleport.getTo();
|
||||
+ blockposition1 = new BlockPosition(to.getX(), to.getY(), to.getZ());
|
||||
+ } else {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.datawatcher.set(EntityShulker.b, enumdirection);
|
||||
this.playSound(SoundEffects.ENTITY_SHULKER_TELEPORT, 1.0F, 1.0F);
|
||||
this.datawatcher.set(EntityShulker.c, Optional.of(blockposition1));
|
||||
@@ -319,6 +334,7 @@
|
||||
}
|
||||
|
||||
this.g((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D);
|
||||
+ if (valid) ((WorldServer) world).chunkCheck(this); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
--- a/net/minecraft/server/EntitySilverfish.java
|
||||
+++ b/net/minecraft/server/EntitySilverfish.java
|
||||
@@ -18,7 +18,7 @@
|
||||
this.goalSelector.a(3, this.b);
|
||||
this.goalSelector.a(4, new PathfinderGoalMeleeAttack(this, 1.0D, false));
|
||||
this.goalSelector.a(5, new EntitySilverfish.PathfinderGoalSilverfishHideInBlock(this));
|
||||
- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a());
|
||||
+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error
|
||||
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
|
||||
}
|
||||
|
||||
@@ -156,6 +156,11 @@
|
||||
IBlockData iblockdata = world.getType(blockposition);
|
||||
|
||||
if (BlockMonsterEggs.h(iblockdata)) {
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.a, blockposition, BlockMonsterEggs.c(iblockdata.getBlock())).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.setTypeAndData(blockposition, BlockMonsterEggs.c(iblockdata.getBlock()), 3);
|
||||
this.a.doSpawnEffect();
|
||||
this.a.die();
|
||||
@@ -202,6 +207,11 @@
|
||||
Block block = iblockdata.getBlock();
|
||||
|
||||
if (block instanceof BlockMonsterEggs) {
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.silverfish, blockposition1, Blocks.AIR.getBlockData()).isCancelled()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) {
|
||||
world.a(blockposition1, true, this.silverfish);
|
||||
} else {
|
||||
@@ -0,0 +1,23 @@
|
||||
--- a/net/minecraft/server/EntitySkeletonAbstract.java
|
||||
+++ b/net/minecraft/server/EntitySkeletonAbstract.java
|
||||
@@ -154,8 +154,19 @@
|
||||
double d3 = (double) MathHelper.sqrt(d0 * d0 + d2 * d2);
|
||||
|
||||
entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.world.getDifficulty().a() * 4));
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getItemInMainHand(), null, entityarrow, EnumHand.MAIN_HAND, 0.8F, true);
|
||||
+ if (event.isCancelled()) {
|
||||
+ event.getProjectile().remove();
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (event.getProjectile() == entityarrow.getBukkitEntity()) {
|
||||
+ world.addEntity(entityarrow);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.playSound(SoundEffects.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
|
||||
- this.world.addEntity(entityarrow);
|
||||
+ // this.world.addEntity(entityarrow); // CraftBukkit - moved up
|
||||
}
|
||||
|
||||
protected EntityArrow b(ItemStack itemstack, float f) {
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/EntitySkeletonWither.java
|
||||
+++ b/net/minecraft/server/EntitySkeletonWither.java
|
||||
@@ -80,7 +80,7 @@
|
||||
return false;
|
||||
} else {
|
||||
if (entity instanceof EntityLiving) {
|
||||
- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 200));
|
||||
+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.WITHER, 200), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -0,0 +1,65 @@
|
||||
--- a/net/minecraft/server/EntitySlime.java
|
||||
+++ b/net/minecraft/server/EntitySlime.java
|
||||
@@ -6,6 +6,14 @@
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.List;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityTransformEvent;
|
||||
+import org.bukkit.event.entity.SlimeSplitEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntitySlime extends EntityInsentient implements IMonster {
|
||||
|
||||
private static final DataWatcherObject<Integer> bo = DataWatcher.a(EntitySlime.class, DataWatcherRegistry.b);
|
||||
@@ -149,7 +157,7 @@
|
||||
|
||||
@Override
|
||||
public EntityTypes<? extends EntitySlime> getEntityType() {
|
||||
- return super.getEntityType();
|
||||
+ return (EntityTypes<? extends EntitySlime>) super.getEntityType(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -163,6 +171,19 @@
|
||||
int j = i / 2;
|
||||
int k = 2 + this.random.nextInt(3);
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), k);
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (!event.isCancelled() && event.getCount() > 0) {
|
||||
+ k = event.getCount();
|
||||
+ } else {
|
||||
+ super.die();
|
||||
+ return;
|
||||
+ }
|
||||
+ List<EntityLiving> slimes = new ArrayList<>(j);
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
for (int l = 0; l < k; ++l) {
|
||||
float f1 = ((float) (l % 2) - 0.5F) * f;
|
||||
float f2 = ((float) (l / 2) - 0.5F) * f;
|
||||
@@ -177,8 +198,17 @@
|
||||
entityslime.setInvulnerable(this.isInvulnerable());
|
||||
entityslime.setSize(j, true);
|
||||
entityslime.setPositionRotation(this.locX() + (double) f1, this.locY() + 0.5D, this.locZ() + (double) f2, this.random.nextFloat() * 360.0F, 0.0F);
|
||||
- this.world.addEntity(entityslime);
|
||||
+ slimes.add(entityslime); // CraftBukkit
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callEntityTransformEvent(this, slimes, EntityTransformEvent.TransformReason.SPLIT).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ for (EntityLiving living : slimes) {
|
||||
+ this.world.addEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
super.die();
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/EntitySpider.java
|
||||
+++ b/net/minecraft/server/EntitySpider.java
|
||||
@@ -136,7 +136,7 @@
|
||||
MobEffectList mobeffectlist = ((EntitySpider.GroupDataSpider) object).a;
|
||||
|
||||
if (mobeffectlist != null) {
|
||||
- this.addEffect(new MobEffect(mobeffectlist, Integer.MAX_VALUE));
|
||||
+ this.addEffect(new MobEffect(mobeffectlist, Integer.MAX_VALUE), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.SPIDER_SPAWN); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
--- a/net/minecraft/server/EntityStrider.java
|
||||
+++ b/net/minecraft/server/EntityStrider.java
|
||||
@@ -252,7 +252,12 @@
|
||||
IBlockData iblockdata1 = this.aN();
|
||||
boolean flag = iblockdata.a((Tag) TagsBlock.STRIDER_WARM_BLOCKS) || iblockdata1.a((Tag) TagsBlock.STRIDER_WARM_BLOCKS) || this.b((Tag) TagsFluid.LAVA) > 0.0D;
|
||||
|
||||
- this.setShivering(!flag);
|
||||
+ // CraftBukkit start
|
||||
+ if (!flag ^ this.isShivering()) {
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callStriderTemperatureChangeEvent(this, !flag);
|
||||
+ this.setShivering(!flag);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
super.tick();
|
||||
this.eU();
|
||||
this.checkBlockCollisions();
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/server/EntityVex.java
|
||||
+++ b/net/minecraft/server/EntityVex.java
|
||||
@@ -45,7 +45,7 @@
|
||||
this.goalSelector.a(8, new EntityVex.d());
|
||||
this.goalSelector.a(9, new PathfinderGoalLookAtPlayer(this, EntityHuman.class, 3.0F, 1.0F));
|
||||
this.goalSelector.a(10, new PathfinderGoalLookAtPlayer(this, EntityInsentient.class, 8.0F));
|
||||
- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a());
|
||||
+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityRaider.class})).a(new Class[0])); // CraftBukkit - decompile error
|
||||
this.targetSelector.a(2, new EntityVex.b(this));
|
||||
this.targetSelector.a(3, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
|
||||
}
|
||||
@@ -186,7 +186,7 @@
|
||||
|
||||
@Override
|
||||
public void c() {
|
||||
- EntityVex.this.setGoalTarget(EntityVex.this.c.getGoalTarget());
|
||||
+ EntityVex.this.setGoalTarget(EntityVex.this.c.getGoalTarget(), org.bukkit.event.entity.EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET, true); // CraftBukkit
|
||||
super.c();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/EntityWitch.java
|
||||
+++ b/net/minecraft/server/EntityWitch.java
|
||||
@@ -93,7 +93,7 @@
|
||||
while (iterator.hasNext()) {
|
||||
MobEffect mobeffect = (MobEffect) iterator.next();
|
||||
|
||||
- this.addEffect(new MobEffect(mobeffect));
|
||||
+ this.addEffect(new MobEffect(mobeffect), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
--- a/net/minecraft/server/EntityZombie.java
|
||||
+++ b/net/minecraft/server/EntityZombie.java
|
||||
@@ -9,6 +9,14 @@
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.entity.Zombie;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
+import org.bukkit.event.entity.EntityTransformEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityZombie extends EntityMonster {
|
||||
|
||||
private static final UUID b = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836");
|
||||
@@ -23,6 +31,7 @@
|
||||
private boolean bs;
|
||||
private int bt;
|
||||
public int drownedConversionTime;
|
||||
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
|
||||
|
||||
public EntityZombie(EntityTypes<? extends EntityZombie> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -139,7 +148,10 @@
|
||||
public void tick() {
|
||||
if (!this.world.isClientSide && this.isAlive() && !this.isNoAI()) {
|
||||
if (this.isDrownConverting()) {
|
||||
- --this.drownedConversionTime;
|
||||
+ // CraftBukkit start - Use wall time instead of ticks for conversion
|
||||
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
|
||||
+ this.drownedConversionTime -= elapsedTicks;
|
||||
+ // CraftBukkit end
|
||||
if (this.drownedConversionTime < 0) {
|
||||
this.eP();
|
||||
}
|
||||
@@ -156,6 +168,7 @@
|
||||
}
|
||||
|
||||
super.tick();
|
||||
+ this.lastTick = MinecraftServer.currentTick; // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -188,6 +201,7 @@
|
||||
}
|
||||
|
||||
public void startDrownedConversion(int i) {
|
||||
+ this.lastTick = MinecraftServer.currentTick; // CraftBukkit
|
||||
this.drownedConversionTime = i;
|
||||
this.getDataWatcher().set(EntityZombie.DROWN_CONVERTING, true);
|
||||
}
|
||||
@@ -201,11 +215,15 @@
|
||||
}
|
||||
|
||||
protected void b(EntityTypes<? extends EntityZombie> entitytypes) {
|
||||
- EntityZombie entityzombie = (EntityZombie) this.a(entitytypes, true);
|
||||
+ EntityZombie entityzombie = (EntityZombie) this.a(entitytypes, true, EntityTransformEvent.TransformReason.DROWNED, CreatureSpawnEvent.SpawnReason.DROWNED);
|
||||
|
||||
if (entityzombie != null) {
|
||||
entityzombie.y(entityzombie.world.getDamageScaler(entityzombie.getChunkCoordinates()).d());
|
||||
entityzombie.u(entityzombie.eK() && this.eU());
|
||||
+ // CraftBukkit start - SPIGOT-5208: End conversion to stop event spam
|
||||
+ } else {
|
||||
+ ((Zombie) getBukkitEntity()).setConversionTime(-1);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -245,9 +263,9 @@
|
||||
if (SpawnerCreature.a(entitypositiontypes_surface, (IWorldReader) this.world, blockposition, entitytypes) && EntityPositionTypes.a(entitytypes, worldserver, EnumMobSpawn.REINFORCEMENT, blockposition, this.world.random)) {
|
||||
entityzombie.setPosition((double) i1, (double) j1, (double) k1);
|
||||
if (!this.world.isPlayerNearby((double) i1, (double) j1, (double) k1, 7.0D) && this.world.j((Entity) entityzombie) && this.world.getCubes(entityzombie) && !this.world.containsLiquid(entityzombie.getBoundingBox())) {
|
||||
- entityzombie.setGoalTarget(entityliving);
|
||||
+ entityzombie.setGoalTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit
|
||||
entityzombie.prepare(worldserver, this.world.getDamageScaler(entityzombie.getChunkCoordinates()), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (NBTTagCompound) null);
|
||||
- worldserver.addAllEntities(entityzombie);
|
||||
+ worldserver.addAllEntities(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit
|
||||
this.getAttributeInstance(GenericAttributes.SPAWN_REINFORCEMENTS).addModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION));
|
||||
entityzombie.getAttributeInstance(GenericAttributes.SPAWN_REINFORCEMENTS).addModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION));
|
||||
break;
|
||||
@@ -268,7 +286,14 @@
|
||||
float f = this.world.getDamageScaler(this.getChunkCoordinates()).b();
|
||||
|
||||
if (this.getItemInMainHand().isEmpty() && this.isBurning() && this.random.nextFloat() < f * 0.3F) {
|
||||
- entity.setOnFire(2 * (int) f);
|
||||
+ // CraftBukkit start
|
||||
+ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 2 * (int) f); // PAIL: fixme
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
+ entity.setOnFire(event.getDuration(), false);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,7 +374,12 @@
|
||||
}
|
||||
|
||||
EntityVillager entityvillager = (EntityVillager) entityliving;
|
||||
- EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.a(EntityTypes.ZOMBIE_VILLAGER, false);
|
||||
+ // CraftBukkit start
|
||||
+ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.a(EntityTypes.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, CreatureSpawnEvent.SpawnReason.INFECTION);
|
||||
+ if (entityzombievillager == null) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
entityzombievillager.prepare(worldserver, worldserver.getDamageScaler(entityzombievillager.getChunkCoordinates()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true), (NBTTagCompound) null);
|
||||
entityzombievillager.setVillagerData(entityvillager.getVillagerData());
|
||||
@@ -406,7 +436,7 @@
|
||||
entitychicken1.prepare(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null, (NBTTagCompound) null);
|
||||
entitychicken1.setChickenJockey(true);
|
||||
this.startRiding(entitychicken1);
|
||||
- worldaccess.addEntity(entitychicken1);
|
||||
+ worldaccess.addEntity(entitychicken1, CreatureSpawnEvent.SpawnReason.MOUNT); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/EntityZombieHusk.java
|
||||
+++ b/net/minecraft/server/EntityZombieHusk.java
|
||||
@@ -44,7 +44,7 @@
|
||||
if (flag && this.getItemInMainHand().isEmpty() && entity instanceof EntityLiving) {
|
||||
float f = this.world.getDamageScaler(this.getChunkCoordinates()).b();
|
||||
|
||||
- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.HUNGER, 140 * (int) f));
|
||||
+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.HUNGER, 140 * (int) f), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
}
|
||||
|
||||
return flag;
|
||||
@@ -0,0 +1,86 @@
|
||||
--- a/net/minecraft/server/EntityZombieVillager.java
|
||||
+++ b/net/minecraft/server/EntityZombieVillager.java
|
||||
@@ -6,6 +6,12 @@
|
||||
import javax.annotation.Nullable;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.entity.ZombieVillager;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
+import org.bukkit.event.entity.EntityTransformEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityZombieVillager extends EntityZombie implements VillagerDataHolder {
|
||||
|
||||
public static final DataWatcherObject<Boolean> CONVERTING = DataWatcher.a(EntityZombieVillager.class, DataWatcherRegistry.i);
|
||||
@@ -15,6 +21,7 @@
|
||||
private NBTBase bp;
|
||||
private NBTTagCompound bq;
|
||||
private int br;
|
||||
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
|
||||
|
||||
public EntityZombieVillager(EntityTypes<? extends EntityZombieVillager> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -31,7 +38,7 @@
|
||||
@Override
|
||||
public void saveData(NBTTagCompound nbttagcompound) {
|
||||
super.saveData(nbttagcompound);
|
||||
- DataResult dataresult = VillagerData.a.encodeStart(DynamicOpsNBT.a, this.getVillagerData());
|
||||
+ DataResult<NBTBase> dataresult = VillagerData.a.encodeStart(DynamicOpsNBT.a, this.getVillagerData()); // CraftBukkit - decompile error
|
||||
Logger logger = EntityZombieVillager.LOGGER;
|
||||
|
||||
logger.getClass();
|
||||
@@ -87,6 +94,10 @@
|
||||
public void tick() {
|
||||
if (!this.world.isClientSide && this.isAlive() && this.isConverting()) {
|
||||
int i = this.getConversionProgress();
|
||||
+ // CraftBukkit start - Use wall time instead of ticks for villager conversion
|
||||
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
|
||||
+ i *= elapsedTicks;
|
||||
+ // CraftBukkit end
|
||||
|
||||
this.conversionTime -= i;
|
||||
if (this.conversionTime <= 0) {
|
||||
@@ -95,6 +106,7 @@
|
||||
}
|
||||
|
||||
super.tick();
|
||||
+ this.lastTick = MinecraftServer.currentTick; // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,13 +150,22 @@
|
||||
this.conversionPlayer = uuid;
|
||||
this.conversionTime = i;
|
||||
this.getDataWatcher().set(EntityZombieVillager.CONVERTING, true);
|
||||
- this.removeEffect(MobEffects.WEAKNESS);
|
||||
- this.addEffect(new MobEffect(MobEffects.INCREASE_DAMAGE, i, Math.min(this.world.getDifficulty().a() - 1, 0)));
|
||||
+ // CraftBukkit start
|
||||
+ this.persistent = true; // CraftBukkit - SPIGOT-4684 update persistence
|
||||
+ this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
|
||||
+ this.addEffect(new MobEffect(MobEffects.INCREASE_DAMAGE, i, Math.min(this.world.getDifficulty().a() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
|
||||
+ // CraftBukkit end
|
||||
this.world.broadcastEntityEffect(this, (byte) 16);
|
||||
}
|
||||
|
||||
private void c(WorldServer worldserver) {
|
||||
- EntityVillager entityvillager = (EntityVillager) this.a(EntityTypes.VILLAGER, false);
|
||||
+ // CraftBukkit start
|
||||
+ EntityVillager entityvillager = (EntityVillager) this.a(EntityTypes.VILLAGER, false, EntityTransformEvent.TransformReason.CURED, CreatureSpawnEvent.SpawnReason.CURED);
|
||||
+ if (entityvillager == null) {
|
||||
+ ((ZombieVillager) getBukkitEntity()).setConversionTime(-1); // SPIGOT-5208: End conversion to stop event spam
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
EnumItemSlot[] aenumitemslot = EnumItemSlot.values();
|
||||
int i = aenumitemslot.length;
|
||||
|
||||
@@ -185,7 +206,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0));
|
||||
+ entityvillager.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); // CraftBukkit
|
||||
if (!this.isSilent()) {
|
||||
worldserver.a((EntityHuman) null, 1027, this.getChunkCoordinates(), 0);
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/server/EntityPiglinAbstract.java
|
||||
+++ b/net/minecraft/server/EntityPiglinAbstract.java
|
||||
@@ -81,7 +81,7 @@
|
||||
}
|
||||
|
||||
protected void c(WorldServer worldserver) {
|
||||
- EntityPigZombie entitypigzombie = (EntityPigZombie) this.a(EntityTypes.ZOMBIFIED_PIGLIN, true);
|
||||
+ EntityPigZombie entitypigzombie = (EntityPigZombie) this.a(EntityTypes.ZOMBIFIED_PIGLIN, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED); // CraftBukkit - add spawn and transform reasons
|
||||
|
||||
if (entitypigzombie != null) {
|
||||
entitypigzombie.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0));
|
||||
@@ -96,7 +96,7 @@
|
||||
@Nullable
|
||||
@Override
|
||||
public EntityLiving getGoalTarget() {
|
||||
- return (EntityLiving) this.bg.getMemory(MemoryModuleType.ATTACK_TARGET).orElse((Object) null);
|
||||
+ return (EntityLiving) this.bg.getMemory(MemoryModuleType.ATTACK_TARGET).orElse(null); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
protected boolean eO() {
|
||||
@@ -0,0 +1,102 @@
|
||||
--- a/net/minecraft/server/PiglinAI.java
|
||||
+++ b/net/minecraft/server/PiglinAI.java
|
||||
@@ -52,7 +52,8 @@
|
||||
private static void b(EntityPiglin entitypiglin, BehaviorController<EntityPiglin> behaviorcontroller) {
|
||||
behaviorcontroller.a(Activity.FLIGHT, 10, ImmutableList.of(new BehaviorAttackTargetForget<>((entityliving) -> {
|
||||
return !b(entitypiglin, entityliving);
|
||||
- }), new BehaviorRunIf<>(PiglinAI::c, new BehaviorRetreat<>(5, 0.75F)), new BehaviorWalkAwayOutOfRange(1.0F), new BehaviorAttack(20), new BehaviorCrossbowAttack<>(), new BehaviorRememberHuntedHoglin<>(), new BehaviorRemoveMemory<>(PiglinAI::j, MemoryModuleType.ATTACK_TARGET)), MemoryModuleType.ATTACK_TARGET);
|
||||
+ // CraftBukkit - decompile error
|
||||
+ }), new BehaviorRunIf<>((l) -> PiglinAI.c((EntityLiving) l), new BehaviorRetreat<>(5, 0.75F)), new BehaviorWalkAwayOutOfRange(1.0F), new BehaviorAttack(20), new BehaviorCrossbowAttack<>(), new BehaviorRememberHuntedHoglin<>(), new BehaviorRemoveMemory<>(PiglinAI::j, MemoryModuleType.ATTACK_TARGET)), MemoryModuleType.ATTACK_TARGET);
|
||||
}
|
||||
|
||||
private static void c(BehaviorController<EntityPiglin> behaviorcontroller) {
|
||||
@@ -70,7 +71,8 @@
|
||||
}
|
||||
|
||||
private static void f(BehaviorController<EntityPiglin> behaviorcontroller) {
|
||||
- behaviorcontroller.a(Activity.RIDE, 10, ImmutableList.of(new BehaviorStartRiding<>(0.8F), new BehaviorLookTarget(PiglinAI::b, 8.0F), new BehaviorRunIf<>(Entity::isPassenger, a()), new BehaviorStopRiding<>(8, PiglinAI::a)), MemoryModuleType.RIDE_TARGET);
|
||||
+ // CraftBukkit - decompile error
|
||||
+ behaviorcontroller.a(Activity.RIDE, 10, ImmutableList.of(new BehaviorStartRiding<>(0.8F), new BehaviorLookTarget(PiglinAI::b, 8.0F), new BehaviorRunIf<>(Entity::isPassenger, a()), new BehaviorStopRiding<EntityPiglin, Entity>(8, PiglinAI::a)), MemoryModuleType.RIDE_TARGET);
|
||||
}
|
||||
|
||||
private static BehaviorGateSingle<EntityPiglin> a() {
|
||||
@@ -78,7 +80,8 @@
|
||||
}
|
||||
|
||||
private static BehaviorGateSingle<EntityPiglin> b() {
|
||||
- return new BehaviorGateSingle<>(ImmutableList.of(Pair.of(new BehaviorStrollRandomUnconstrained(0.6F), 2), Pair.of(BehaviorInteract.a(EntityTypes.PIGLIN, 8, MemoryModuleType.INTERACTION_TARGET, 0.6F, 2), 2), Pair.of(new BehaviorRunIf<>(PiglinAI::g, new BehaviorLookWalk(0.6F, 3)), 2), Pair.of(new BehaviorNop(30, 60), 1)));
|
||||
+ // CraftBukkit - decompile error
|
||||
+ return new BehaviorGateSingle<>(ImmutableList.of(Pair.of(new BehaviorStrollRandomUnconstrained(0.6F), 2), Pair.of(BehaviorInteract.a(EntityTypes.PIGLIN, 8, MemoryModuleType.INTERACTION_TARGET, 0.6F, 2), 2), Pair.of(new BehaviorRunIf<>((java.util.function.Predicate<EntityLiving>) PiglinAI::g, new BehaviorLookWalk(0.6F, 3)), 2), Pair.of(new BehaviorNop(30, 60), 1)));
|
||||
}
|
||||
|
||||
private static BehaviorWalkAway<BlockPosition> c() {
|
||||
@@ -95,10 +98,10 @@
|
||||
|
||||
protected static void b(EntityPiglin entitypiglin) {
|
||||
BehaviorController<EntityPiglin> behaviorcontroller = entitypiglin.getBehaviorController();
|
||||
- Activity activity = (Activity) behaviorcontroller.f().orElse((Object) null);
|
||||
+ Activity activity = (Activity) behaviorcontroller.f().orElse(null); // CraftBukkit - decompile error
|
||||
|
||||
behaviorcontroller.a((List) ImmutableList.of(Activity.ADMIRE_ITEM, Activity.FLIGHT, Activity.AVOID, Activity.CELEBRATE, Activity.RIDE, Activity.IDLE));
|
||||
- Activity activity1 = (Activity) behaviorcontroller.f().orElse((Object) null);
|
||||
+ Activity activity1 = (Activity) behaviorcontroller.f().orElse(null); // CraftBukkit - decompile error
|
||||
|
||||
if (activity != activity1) {
|
||||
d(entitypiglin).ifPresent(entitypiglin::a);
|
||||
@@ -130,14 +133,18 @@
|
||||
n(entitypiglin);
|
||||
ItemStack itemstack;
|
||||
|
||||
- if (entityitem.getItemStack().getItem() == Items.GOLD_NUGGET) {
|
||||
+ // CraftBukkit start
|
||||
+ if (entityitem.getItemStack().getItem() == Items.GOLD_NUGGET && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(entitypiglin, entityitem, 0, false).isCancelled()) {
|
||||
entitypiglin.receive(entityitem, entityitem.getItemStack().getCount());
|
||||
itemstack = entityitem.getItemStack();
|
||||
entityitem.die();
|
||||
- } else {
|
||||
+ } else if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(entitypiglin, entityitem, entityitem.getItemStack().getCount() - 1, false).isCancelled()) {
|
||||
entitypiglin.receive(entityitem, 1);
|
||||
itemstack = a(entityitem);
|
||||
+ } else {
|
||||
+ return;
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
|
||||
Item item = itemstack.getItem();
|
||||
|
||||
@@ -148,7 +155,7 @@
|
||||
} else if (c(item) && !u(entitypiglin)) {
|
||||
s(entitypiglin);
|
||||
} else {
|
||||
- boolean flag = entitypiglin.g(itemstack);
|
||||
+ boolean flag = entitypiglin.g(itemstack, entityitem); // CraftBukkit
|
||||
|
||||
if (!flag) {
|
||||
d(entitypiglin, itemstack);
|
||||
@@ -350,7 +357,7 @@
|
||||
}
|
||||
|
||||
public static void a(EntityHuman entityhuman, boolean flag) {
|
||||
- List<EntityPiglin> list = entityhuman.world.a(EntityPiglin.class, entityhuman.getBoundingBox().g(16.0D));
|
||||
+ List<EntityPiglinAbstract> list = entityhuman.world.a(EntityPiglin.class, entityhuman.getBoundingBox().g(16.0D)); // CraftBukkit - decompile error
|
||||
|
||||
list.stream().filter(PiglinAI::d).filter((entitypiglin) -> {
|
||||
return !flag || BehaviorUtil.c(entitypiglin, entityhuman);
|
||||
@@ -586,7 +593,7 @@
|
||||
EntityLiving entityliving = (EntityLiving) behaviorcontroller.getMemory(MemoryModuleType.AVOID_TARGET).get();
|
||||
EntityTypes<?> entitytypes = entityliving.getEntityType();
|
||||
|
||||
- return entitytypes == EntityTypes.HOGLIN ? p(entitypiglin) : (a(entitytypes) ? !behaviorcontroller.b(MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, (Object) entityliving) : false);
|
||||
+ return entitytypes == EntityTypes.HOGLIN ? p(entitypiglin) : (a(entitytypes) ? !behaviorcontroller.b(MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, entityliving) : false); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -668,7 +675,7 @@
|
||||
}
|
||||
|
||||
public static boolean b(EntityLiving entityliving) {
|
||||
- return entityliving.getEntityType() == EntityTypes.PLAYER && entityliving.a(PiglinAI::a);
|
||||
+ return entityliving.getEntityType() == EntityTypes.PLAYER && entityliving.a((java.util.function.Predicate<Item>) PiglinAI::a); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
private static boolean x(EntityPiglin entitypiglin) {
|
||||
@@ -0,0 +1,119 @@
|
||||
--- a/net/minecraft/server/EntityVillager.java
|
||||
+++ b/net/minecraft/server/EntityVillager.java
|
||||
@@ -19,6 +19,14 @@
|
||||
import javax.annotation.Nullable;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.entity.Villager;
|
||||
+import org.bukkit.event.entity.EntityTransformEvent;
|
||||
+import org.bukkit.event.entity.VillagerReplenishTradeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityVillager extends EntityVillagerAbstract implements ReputationHandler, VillagerDataHolder {
|
||||
|
||||
private static final DataWatcherObject<VillagerData> br = DataWatcher.a(EntityVillager.class, DataWatcherRegistry.q);
|
||||
@@ -64,7 +72,7 @@
|
||||
|
||||
@Override
|
||||
public BehaviorController<EntityVillager> getBehaviorController() {
|
||||
- return super.getBehaviorController();
|
||||
+ return (BehaviorController<EntityVillager>) super.getBehaviorController(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,7 +91,7 @@
|
||||
public void c(WorldServer worldserver) {
|
||||
BehaviorController<EntityVillager> behaviorcontroller = this.getBehaviorController();
|
||||
|
||||
- behaviorcontroller.b(worldserver, (EntityLiving) this);
|
||||
+ behaviorcontroller.b(worldserver, this); // CraftBukkit - decompile error
|
||||
this.bg = behaviorcontroller.h();
|
||||
this.a(this.getBehaviorController());
|
||||
}
|
||||
@@ -133,7 +141,7 @@
|
||||
@Override
|
||||
protected void mobTick() {
|
||||
this.world.getMethodProfiler().enter("villagerBrain");
|
||||
- this.getBehaviorController().a((WorldServer) this.world, (EntityLiving) this);
|
||||
+ this.getBehaviorController().a((WorldServer) this.world, this); // CraftBukkit - decompile error
|
||||
this.world.getMethodProfiler().exit();
|
||||
if (this.bF) {
|
||||
this.bF = false;
|
||||
@@ -147,7 +155,7 @@
|
||||
this.bu = false;
|
||||
}
|
||||
|
||||
- this.addEffect(new MobEffect(MobEffects.REGENERATION, 200, 0));
|
||||
+ this.addEffect(new MobEffect(MobEffects.REGENERATION, 200, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.VILLAGER_TRADE); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,7 +366,14 @@
|
||||
while (iterator.hasNext()) {
|
||||
MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
|
||||
|
||||
- merchantrecipe.increaseSpecialPrice(-MathHelper.d((float) i * merchantrecipe.getPriceMultiplier()));
|
||||
+ // CraftBukkit start
|
||||
+ int bonus = -MathHelper.d((float) i * merchantrecipe.getPriceMultiplier());
|
||||
+ VillagerReplenishTradeEvent event = new VillagerReplenishTradeEvent((Villager) this.getBukkitEntity(), merchantrecipe.asBukkit(), bonus);
|
||||
+ Bukkit.getPluginManager().callEvent(event);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ merchantrecipe.increaseSpecialPrice(event.getBonus());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -387,7 +402,7 @@
|
||||
@Override
|
||||
public void saveData(NBTTagCompound nbttagcompound) {
|
||||
super.saveData(nbttagcompound);
|
||||
- DataResult dataresult = VillagerData.a.encodeStart(DynamicOpsNBT.a, this.getVillagerData());
|
||||
+ DataResult<NBTBase> dataresult = VillagerData.a.encodeStart(DynamicOpsNBT.a, this.getVillagerData()); // CraftBukkit - decompile error
|
||||
Logger logger = EntityVillager.LOGGER;
|
||||
|
||||
logger.getClass();
|
||||
@@ -700,7 +715,12 @@
|
||||
}
|
||||
|
||||
entitywitch.setPersistent();
|
||||
- worldserver.addAllEntities(entitywitch);
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ worldserver.addAllEntities(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
|
||||
+ // CraftBukkit end
|
||||
this.fq();
|
||||
this.die();
|
||||
} else {
|
||||
@@ -833,7 +853,7 @@
|
||||
|
||||
if (entityirongolem != null) {
|
||||
if (entityirongolem.a((GeneratorAccess) worldserver, EnumMobSpawn.MOB_SUMMONED) && entityirongolem.a((IWorldReader) worldserver)) {
|
||||
- worldserver.addAllEntities(entityirongolem);
|
||||
+ worldserver.addAllEntities(entityirongolem, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE); // CraftBukkit
|
||||
return entityirongolem;
|
||||
}
|
||||
|
||||
@@ -911,7 +931,7 @@
|
||||
@Override
|
||||
public void entitySleep(BlockPosition blockposition) {
|
||||
super.entitySleep(blockposition);
|
||||
- this.bg.setMemory(MemoryModuleType.LAST_SLEPT, (Object) this.world.getTime());
|
||||
+ this.bg.setMemory(MemoryModuleType.LAST_SLEPT, this.world.getTime()); // CraftBukkit - decompile error
|
||||
this.bg.removeMemory(MemoryModuleType.WALK_TARGET);
|
||||
this.bg.removeMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
|
||||
}
|
||||
@@ -919,7 +939,7 @@
|
||||
@Override
|
||||
public void entityWakeup() {
|
||||
super.entityWakeup();
|
||||
- this.bg.setMemory(MemoryModuleType.LAST_WOKEN, (Object) this.world.getTime());
|
||||
+ this.bg.setMemory(MemoryModuleType.LAST_WOKEN, this.world.getTime()); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
private boolean b(long i) {
|
||||
@@ -0,0 +1,52 @@
|
||||
--- a/net/minecraft/server/EntityVillagerAbstract.java
|
||||
+++ b/net/minecraft/server/EntityVillagerAbstract.java
|
||||
@@ -5,14 +5,30 @@
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftMerchant;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe;
|
||||
+import org.bukkit.entity.AbstractVillager;
|
||||
+import org.bukkit.event.entity.VillagerAcquireTradeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class EntityVillagerAbstract extends EntityAgeable implements NPC, IMerchant {
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private CraftMerchant craftMerchant;
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftMerchant getCraftMerchant() {
|
||||
+ return (craftMerchant == null) ? craftMerchant = new CraftMerchant(this) : craftMerchant;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
private static final DataWatcherObject<Integer> bp = DataWatcher.a(EntityVillagerAbstract.class, DataWatcherRegistry.b);
|
||||
@Nullable
|
||||
private EntityHuman tradingPlayer;
|
||||
@Nullable
|
||||
protected MerchantRecipeList trades;
|
||||
- private final InventorySubcontainer inventory = new InventorySubcontainer(8);
|
||||
+ private final InventorySubcontainer inventory = new InventorySubcontainer(8, (org.bukkit.craftbukkit.entity.CraftAbstractVillager) this.getBukkitEntity()); // CraftBukkit add argument
|
||||
|
||||
public EntityVillagerAbstract(EntityTypes<? extends EntityVillagerAbstract> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -213,7 +229,16 @@
|
||||
MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.a(this, this.random);
|
||||
|
||||
if (merchantrecipe != null) {
|
||||
- merchantrecipelist.add(merchantrecipe);
|
||||
+ // CraftBukkit start
|
||||
+ VillagerAcquireTradeEvent event = new VillagerAcquireTradeEvent((AbstractVillager) getBukkitEntity(), merchantrecipe.asBukkit());
|
||||
+ // Suppress during worldgen
|
||||
+ if (this.valid) {
|
||||
+ Bukkit.getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+ if (!event.isCancelled()) {
|
||||
+ merchantrecipelist.add(CraftMerchantRecipe.fromBukkit(event.getRecipe()).toMinecraft());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user