Update to Minecraft 1.20

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2023-06-08 01:30:00 +10:00
parent bac55e67d6
commit 9d740b84b0
269 changed files with 2605 additions and 2568 deletions

View File

@@ -67,7 +67,7 @@
private static final Logger LOGGER = LogUtils.getLogger();
public static final String ID_TAG = "id";
public static final String PASSENGERS_TAG = "Passengers";
@@ -236,6 +294,25 @@
@@ -240,6 +298,25 @@
public boolean hasVisualFire;
@Nullable
private IBlockData feetBlockState;
@@ -93,7 +93,7 @@
public Entity(EntityTypes<?> entitytypes, World world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -367,6 +444,12 @@
@@ -373,6 +450,12 @@
public void onClientRemoval() {}
public void setPose(EntityPose entitypose) {
@@ -106,7 +106,7 @@
this.entityData.set(Entity.DATA_POSE, entitypose);
}
@@ -391,6 +474,33 @@
@@ -397,6 +480,33 @@
}
protected void setRot(float f, float f1) {
@@ -140,7 +140,7 @@
this.setYRot(f % 360.0F);
this.setXRot(f1 % 360.0F);
}
@@ -432,6 +542,15 @@
@@ -438,6 +548,15 @@
this.baseTick();
}
@@ -154,9 +154,9 @@
+ // CraftBukkit end
+
public void baseTick() {
this.level.getProfiler().push("entityBaseTick");
this.level().getProfiler().push("entityBaseTick");
this.feetBlockState = null;
@@ -446,7 +565,7 @@
@@ -452,7 +571,7 @@
this.walkDistO = this.walkDist;
this.xRotO = this.getXRot();
this.yRotO = this.getYRot();
@@ -165,7 +165,7 @@
if (this.canSpawnSprintParticle()) {
this.spawnSprintParticle();
}
@@ -481,6 +600,10 @@
@@ -487,6 +606,10 @@
if (this.isInLava()) {
this.lavaHurt();
this.fallDistance *= 0.5F;
@@ -175,8 +175,8 @@
+ // CraftBukkit end
}
this.checkOutOfWorld();
@@ -524,15 +647,48 @@
this.checkBelowWorld();
@@ -538,15 +661,48 @@
public void lavaHurt() {
if (!this.fireImmune()) {
@@ -226,8 +226,8 @@
int j = i * 20;
if (this instanceof EntityLiving) {
@@ -646,6 +802,28 @@
block.updateEntityAfterFallOn(this.level, this);
@@ -697,6 +853,28 @@
block.updateEntityAfterFallOn(this.level(), this);
}
+ // CraftBukkit start
@@ -252,10 +252,10 @@
+ }
+ // CraftBukkit end
+
if (this.onGround) {
block.stepOn(this.level, blockposition, iblockdata, this);
if (this.onGround()) {
block.stepOn(this.level(), blockposition, iblockdata, this);
}
@@ -948,6 +1126,20 @@
@@ -1024,6 +1202,20 @@
return SoundEffects.GENERIC_SPLASH;
}
@@ -276,7 +276,7 @@
protected void checkInsideBlocks() {
AxisAlignedBB axisalignedbb = this.getBoundingBox();
BlockPosition blockposition = BlockPosition.containing(axisalignedbb.minX + 1.0E-7D, axisalignedbb.minY + 1.0E-7D, axisalignedbb.minZ + 1.0E-7D);
@@ -1311,6 +1503,7 @@
@@ -1430,6 +1622,7 @@
this.yo = d1;
this.zo = d4;
this.setPos(d3, d1, d4);
@@ -284,7 +284,7 @@
}
public void moveTo(Vec3D vec3d) {
@@ -1505,6 +1698,12 @@
@@ -1624,6 +1817,12 @@
return false;
}
@@ -297,7 +297,7 @@
public void awardKillScore(Entity entity, int i, DamageSource damagesource) {
if (entity instanceof EntityPlayer) {
CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource);
@@ -1538,7 +1737,7 @@
@@ -1657,7 +1856,7 @@
} else {
String s = this.getEncodeId();
@@ -306,7 +306,7 @@
return false;
} else {
nbttagcompound.putString("id", s);
@@ -1563,6 +1762,18 @@
@@ -1682,6 +1881,18 @@
Vec3D vec3d = this.getDeltaMovement();
nbttagcompound.put("Motion", this.newDoubleList(vec3d.x, vec3d.y, vec3d.z));
@@ -325,7 +325,7 @@
nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot()));
nbttagcompound.putFloat("FallDistance", this.fallDistance);
nbttagcompound.putShort("Fire", (short) this.remainingFireTicks);
@@ -1571,6 +1782,25 @@
@@ -1690,6 +1901,25 @@
nbttagcompound.putBoolean("Invulnerable", this.invulnerable);
nbttagcompound.putInt("PortalCooldown", this.portalCooldown);
nbttagcompound.putUUID("UUID", this.getUUID());
@@ -351,7 +351,7 @@
IChatBaseComponent ichatbasecomponent = this.getCustomName();
if (ichatbasecomponent != null) {
@@ -1638,6 +1868,11 @@
@@ -1757,6 +1987,11 @@
}
}
@@ -363,7 +363,7 @@
return nbttagcompound;
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
@@ -1721,6 +1956,45 @@
@@ -1840,6 +2075,45 @@
} else {
throw new IllegalStateException("Entity has invalid position");
}
@@ -409,8 +409,8 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
@@ -1796,9 +2070,22 @@
} else if (this.level.isClientSide) {
@@ -1915,9 +2189,22 @@
} else if (this.level().isClientSide) {
return null;
} else {
+ // CraftBukkit start - Capture drops for death event
@@ -419,7 +419,7 @@
+ return null;
+ }
+ // CraftBukkit end
EntityItem entityitem = new EntityItem(this.level, this.getX(), this.getY() + (double) f, this.getZ(), itemstack);
EntityItem entityitem = new EntityItem(this.level(), this.getX(), this.getY() + (double) f, this.getZ(), itemstack);
entityitem.setDefaultPickUpDelay();
+ // CraftBukkit start
@@ -429,10 +429,10 @@
+ return null;
+ }
+ // CraftBukkit end
this.level.addFreshEntity(entityitem);
this.level().addFreshEntity(entityitem);
return entityitem;
}
@@ -1894,7 +2181,7 @@
@@ -2013,7 +2300,7 @@
this.setPose(EntityPose.STANDING);
this.vehicle = entity;
@@ -441,7 +441,7 @@
entity.getIndirectPassengersStream().filter((entity2) -> {
return entity2 instanceof EntityPlayer;
}).forEach((entity2) -> {
@@ -1925,7 +2212,7 @@
@@ -2044,7 +2331,7 @@
Entity entity = this.vehicle;
this.vehicle = null;
@@ -450,7 +450,7 @@
}
}
@@ -1934,10 +2221,31 @@
@@ -2053,10 +2340,31 @@
this.removeVehicle();
}
@@ -483,7 +483,7 @@
if (this.passengers.isEmpty()) {
this.passengers = ImmutableList.of(entity);
} else {
@@ -1954,12 +2262,32 @@
@@ -2073,12 +2381,32 @@
this.gameEvent(GameEvent.ENTITY_MOUNT, entity);
}
@@ -517,7 +517,7 @@
if (this.passengers.size() == 1 && this.passengers.get(0) == entity) {
this.passengers = ImmutableList.of();
} else {
@@ -1971,6 +2299,7 @@
@@ -2090,6 +2418,7 @@
entity.boardingCooldown = 60;
this.gameEvent(GameEvent.ENTITY_DISMOUNT, entity);
}
@@ -525,17 +525,17 @@
}
protected boolean canAddPassenger(Entity entity) {
@@ -2037,14 +2366,20 @@
@@ -2156,14 +2485,20 @@
if (this.isInsidePortal) {
MinecraftServer minecraftserver = worldserver.getServer();
- ResourceKey<World> resourcekey = this.level.dimension() == World.NETHER ? World.OVERWORLD : World.NETHER;
+ ResourceKey<World> resourcekey = this.level.getTypeKey() == WorldDimension.NETHER ? World.OVERWORLD : World.NETHER; // CraftBukkit
- ResourceKey<World> resourcekey = this.level().dimension() == World.NETHER ? World.OVERWORLD : World.NETHER;
+ ResourceKey<World> resourcekey = this.level().getTypeKey() == WorldDimension.NETHER ? World.OVERWORLD : World.NETHER; // CraftBukkit
WorldServer worldserver1 = minecraftserver.getLevel(resourcekey);
- if (worldserver1 != null && minecraftserver.isNetherEnabled() && !this.isPassenger() && this.portalTime++ >= i) {
+ if (true && !this.isPassenger() && this.portalTime++ >= i) { // CraftBukkit
this.level.getProfiler().push("portal");
this.level().getProfiler().push("portal");
this.portalTime = i;
this.setPortalCooldown();
- this.changeDimension(worldserver1);
@@ -546,10 +546,10 @@
+ this.changeDimension(worldserver1);
+ }
+ // CraftBukkit end
this.level.getProfiler().pop();
this.level().getProfiler().pop();
}
@@ -2164,6 +2499,13 @@
@@ -2283,6 +2618,13 @@
}
public void setSwimming(boolean flag) {
@@ -563,7 +563,7 @@
this.setSharedFlag(4, flag);
}
@@ -2209,8 +2551,12 @@
@@ -2332,8 +2674,12 @@
return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false;
}
@@ -577,7 +577,7 @@
}
public boolean getSharedFlag(int i) {
@@ -2229,7 +2575,7 @@
@@ -2352,7 +2698,7 @@
}
public int getMaxAirSupply() {
@@ -586,7 +586,7 @@
}
public int getAirSupply() {
@@ -2237,7 +2583,18 @@
@@ -2360,7 +2706,18 @@
}
public void setAirSupply(int i) {
@@ -606,7 +606,7 @@
}
public int getTicksFrozen() {
@@ -2264,11 +2621,41 @@
@@ -2387,11 +2744,41 @@
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
this.setRemainingFireTicks(this.remainingFireTicks + 1);
@@ -650,7 +650,7 @@
}
public void onAboveBubbleCol(boolean flag) {
@@ -2433,15 +2820,38 @@
@@ -2556,15 +2943,38 @@
@Nullable
public Entity changeDimension(WorldServer worldserver) {
@@ -661,16 +661,16 @@
+ @Nullable
+ public Entity teleportTo(WorldServer worldserver, Position location) {
+ // CraftBukkit end
if (this.level instanceof WorldServer && !this.isRemoved()) {
this.level.getProfiler().push("changeDimension");
if (this.level() instanceof WorldServer && !this.isRemoved()) {
this.level().getProfiler().push("changeDimension");
- this.unRide();
+ // CraftBukkit start
+ // this.decouple();
+ // this.unRide();
+ if (worldserver == null) {
+ return null;
+ }
+ // CraftBukkit end
this.level.getProfiler().push("reposition");
this.level().getProfiler().push("reposition");
- ShapeDetectorShape shapedetectorshape = this.findDimensionEntryPoint(worldserver);
+ ShapeDetectorShape shapedetectorshape = (location == null) ? this.findDimensionEntryPoint(worldserver) : new ShapeDetectorShape(new Vec3D(location.x(), location.y(), location.z()), Vec3D.ZERO, this.yRot, this.xRot, worldserver, null); // CraftBukkit
@@ -688,10 +688,10 @@
+ this.unRide();
+ // CraftBukkit end
+
this.level.getProfiler().popPush("reloading");
this.level().getProfiler().popPush("reloading");
Entity entity = this.getType().create(worldserver);
@@ -2450,9 +2860,17 @@
@@ -2573,9 +2983,17 @@
entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot());
entity.setDeltaMovement(shapedetectorshape.speed);
worldserver.addDuringTeleport(entity);
@@ -711,17 +711,17 @@
}
this.removeAfterChangingDimensions();
@@ -2473,20 +2891,34 @@
@@ -2596,20 +3014,34 @@
@Nullable
protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) {
- boolean flag = this.level.dimension() == World.END && worldserver.dimension() == World.OVERWORLD;
- boolean flag = this.level().dimension() == World.END && worldserver.dimension() == World.OVERWORLD;
- boolean flag1 = worldserver.dimension() == World.END;
+ // CraftBukkit start
+ if (worldserver == null) {
+ return null;
+ }
+ boolean flag = this.level.getTypeKey() == WorldDimension.END && worldserver.getTypeKey() == WorldDimension.OVERWORLD; // fromEndToOverworld
+ boolean flag = this.level().getTypeKey() == WorldDimension.END && worldserver.getTypeKey() == WorldDimension.OVERWORLD; // fromEndToOverworld
+ boolean flag1 = worldserver.getTypeKey() == WorldDimension.END; // targetIsEnd
+ // CraftBukkit end
@@ -729,12 +729,12 @@
- boolean flag2 = worldserver.dimension() == World.NETHER;
+ boolean flag2 = worldserver.getTypeKey() == WorldDimension.NETHER; // CraftBukkit
- if (this.level.dimension() != World.NETHER && !flag2) {
+ if (this.level.getTypeKey() != WorldDimension.NETHER && !flag2) { // CraftBukkit
- if (this.level().dimension() != World.NETHER && !flag2) {
+ if (this.level().getTypeKey() != WorldDimension.NETHER && !flag2) { // CraftBukkit
return null;
} else {
WorldBorder worldborder = worldserver.getWorldBorder();
double d0 = DimensionManager.getTeleportationScale(this.level.dimensionType(), worldserver.dimensionType());
double d0 = DimensionManager.getTeleportationScale(this.level().dimensionType(), worldserver.dimensionType());
BlockPosition blockposition = worldborder.clampToBounds(this.getX() * d0, this.getY(), this.getZ() * d0);
+ // CraftBukkit start
+ CraftPortalEvent event = callPortalEvent(this, worldserver, new Position(blockposition.getX(), blockposition.getY(), blockposition.getZ()), PlayerTeleportEvent.TeleportCause.NETHER_PORTAL, flag2 ? 16 : 128, 16);
@@ -748,10 +748,10 @@
- return (ShapeDetectorShape) this.getExitPortal(worldserver, blockposition, flag2, worldborder).map((blockutil_rectangle) -> {
+ return (ShapeDetectorShape) this.getExitPortal(worldserver, blockposition, flag2, worldborder, event.getSearchRadius(), event.getCanCreatePortal(), event.getCreationRadius()).map((blockutil_rectangle) -> {
+ // CraftBukkit end
IBlockData iblockdata = this.level.getBlockState(this.portalEntrancePos);
IBlockData iblockdata = this.level().getBlockState(this.portalEntrancePos);
EnumDirection.EnumAxis enumdirection_enumaxis;
Vec3D vec3d;
@@ -2503,8 +2935,8 @@
@@ -2626,8 +3058,8 @@
vec3d = new Vec3D(0.5D, 0.0D, 0.0D);
}
@@ -762,7 +762,7 @@
}
} else {
BlockPosition blockposition1;
@@ -2514,8 +2946,14 @@
@@ -2637,8 +3069,14 @@
} else {
blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos());
}
@@ -778,7 +778,7 @@
}
}
@@ -2523,8 +2961,23 @@
@@ -2646,8 +3084,23 @@
return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose()));
}
@@ -804,7 +804,7 @@
}
public boolean canChangeDimensions() {
@@ -2644,6 +3097,12 @@
@@ -2767,6 +3220,12 @@
}
}
@@ -817,7 +817,7 @@
public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1) {
float f2 = MathHelper.clamp(f1, -90.0F, 90.0F);
@@ -2773,7 +3232,26 @@
@@ -2901,7 +3360,26 @@
}
public final void setBoundingBox(AxisAlignedBB axisalignedbb) {
@@ -845,7 +845,7 @@
}
protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) {
@@ -3084,6 +3562,11 @@
@@ -3212,6 +3690,11 @@
vec3d = vec3d.add(vec3d1);
++k1;
}

View File

@@ -28,8 +28,8 @@
@Override
public void aiStep() {
super.aiStep();
- if (this.level.isClientSide) {
+ if (this.level.isClientSide || ageLocked) { // CraftBukkit
- if (this.level().isClientSide) {
+ if (this.level().isClientSide || ageLocked) { // CraftBukkit
if (this.forcedAgeTimer > 0) {
if (this.forcedAgeTimer % 4 == 0) {
this.level.addParticle(Particles.HAPPY_VILLAGER, this.getRandomX(1.0D), this.getRandomY() + 0.5D, this.getRandomZ(1.0D), 0.0D, 0.0D, 0.0D);
this.level().addParticle(Particles.HAPPY_VILLAGER, this.getRandomX(1.0D), this.getRandomY() + 0.5D, this.getRandomZ(1.0D), 0.0D, 0.0D, 0.0D);

View File

@@ -15,7 +15,7 @@
if (this instanceof EntityTameableAnimal && ((EntityTameableAnimal) this).isInSittingPose()) {
if (f > 10.0F) {
+ this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
+ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
this.dropLeash(true, true);
}
@@ -23,7 +23,7 @@
this.onLeashDistance(f);
if (f > 10.0F) {
+ this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
+ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
this.dropLeash(true, true);
this.goalSelector.disableControlFlag(PathfinderGoal.Type.MOVE);
} else if (f > 6.0F) {

View File

@@ -46,9 +46,9 @@
Vec3D vec3d = new Vec3D(this.followingPlayer.getX() - this.getX(), this.followingPlayer.getY() + (double) this.followingPlayer.getEyeHeight() / 2.0D - this.getY(), this.followingPlayer.getZ() - this.getZ());
double d0 = vec3d.lengthSqr();
@@ -222,12 +245,12 @@
@@ -227,12 +250,12 @@
public void playerTouch(EntityHuman entityhuman) {
if (!this.level.isClientSide) {
if (!this.level().isClientSide) {
if (entityhuman.takeXpDelay == 0) {
- entityhuman.takeXpDelay = 2;
+ entityhuman.takeXpDelay = CraftEventFactory.callPlayerXpCooldownEvent(entityhuman, 2, PlayerExpCooldownChangeEvent.ChangeReason.PICKUP_ORB).getNewCooldown(); // CraftBukkit - entityhuman.takeXpDelay = 2;
@@ -61,7 +61,7 @@
}
--this.count;
@@ -245,9 +268,17 @@
@@ -250,9 +273,17 @@
if (entry != null) {
ItemStack itemstack = (ItemStack) entry.getValue();
int j = Math.min(this.xpToDurability(this.value), itemstack.getDamageValue());
@@ -79,7 +79,7 @@
return k > 0 ? this.repairPlayerItems(entityhuman, k) : 0;
} else {
@@ -272,6 +303,24 @@
@@ -277,6 +308,24 @@
}
public static int getExperienceValue(int i) {

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/EntityInsentient.java
+++ b/net/minecraft/world/entity/EntityInsentient.java
@@ -75,6 +75,19 @@
@@ -74,6 +74,19 @@
import net.minecraft.world.level.material.FluidType;
import net.minecraft.world.level.pathfinder.PathType;
import net.minecraft.world.level.storage.loot.LootTableInfo;
+// CraftBukkit start
+import net.minecraft.server.level.EntityPlayer;
@@ -20,7 +20,7 @@
public abstract class EntityInsentient extends EntityLiving implements Targeting {
private static final DataWatcherObject<Byte> DATA_MOB_FLAGS_ID = DataWatcher.defineId(EntityInsentient.class, DataWatcherRegistry.BYTE);
@@ -121,6 +134,8 @@
@@ -120,6 +133,8 @@
private BlockPosition restrictCenter;
private float restrictRadius;
@@ -29,7 +29,7 @@
protected EntityInsentient(EntityTypes<? extends EntityInsentient> entitytypes, World world) {
super(entitytypes, world);
this.handItems = NonNullList.withSize(2, ItemStack.EMPTY);
@@ -146,6 +161,12 @@
@@ -145,6 +160,12 @@
}
@@ -42,7 +42,7 @@
protected void registerGoals() {}
public static AttributeProvider.Builder createMobAttributes() {
@@ -254,7 +275,38 @@
@@ -257,7 +278,38 @@
}
public void setTarget(@Nullable EntityLiving entityliving) {
@@ -57,14 +57,14 @@
+ reason = getTarget().isAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
+ }
+ if (reason == EntityTargetEvent.TargetReason.UNKNOWN) {
+ level.getCraftServer().getLogger().log(java.util.logging.Level.WARNING, "Unknown target reason, please report on the issue tracker", new Exception());
+ this.level().getCraftServer().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);
+ level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return false;
+ }
@@ -81,7 +81,7 @@
}
@Override
@@ -394,6 +446,12 @@
@@ -397,6 +449,12 @@
return null;
}
@@ -94,7 +94,7 @@
@Override
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.addAdditionalSaveData(nbttagcompound);
@@ -483,16 +541,26 @@
@@ -486,16 +544,26 @@
nbttagcompound.putBoolean("NoAI", this.isNoAi());
}
@@ -123,7 +123,7 @@
NBTTagList nbttaglist;
int i;
@@ -539,6 +607,11 @@
@@ -542,6 +610,11 @@
}
this.setNoAi(nbttagcompound.getBoolean("NoAI"));
@@ -135,7 +135,7 @@
}
@Override
@@ -606,7 +679,7 @@
@@ -609,7 +682,7 @@
protected void pickUpItem(EntityItem entityitem) {
ItemStack itemstack = entityitem.getItem();
@@ -144,7 +144,7 @@
if (!itemstack1.isEmpty()) {
this.onItemPickup(entityitem);
@@ -620,6 +693,12 @@
@@ -623,6 +696,12 @@
}
public ItemStack equipItemIfPossible(ItemStack itemstack) {
@@ -157,8 +157,8 @@
EnumItemSlot enumitemslot = getEquipmentSlotForItem(itemstack);
ItemStack itemstack1 = this.getItemBySlot(enumitemslot);
boolean flag = this.canReplaceCurrentItem(itemstack, itemstack1);
@@ -630,11 +709,19 @@
flag = this.canReplaceCurrentItem(itemstack, itemstack1);
@@ -633,11 +712,19 @@
flag = itemstack1.isEmpty();
}
- if (flag && this.canHoldItem(itemstack)) {
@@ -178,15 +178,15 @@
}
if (enumitemslot.isArmor() && itemstack.getCount() > 1) {
@@ -779,6 +866,7 @@
@@ -782,6 +869,7 @@
@Override
protected final void serverAiStep() {
++this.noActionTime;
+ if (!this.aware) return; // CraftBukkit
this.level.getProfiler().push("sensing");
this.level().getProfiler().push("sensing");
this.sensing.tick();
this.level.getProfiler().pop();
@@ -1172,6 +1260,12 @@
this.level().getProfiler().pop();
@@ -1175,6 +1263,12 @@
if (!this.isAlive()) {
return EnumInteractionResult.PASS;
} else if (this.getLeashHolder() == entityhuman) {
@@ -198,8 +198,8 @@
+ // CraftBukkit end
this.dropLeash(true, !entityhuman.getAbilities().instabuild);
this.gameEvent(GameEvent.ENTITY_INTERACT, entityhuman);
return EnumInteractionResult.sidedSuccess(this.level.isClientSide);
@@ -1197,6 +1291,12 @@
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);
@@ -1200,6 +1294,12 @@
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
if (itemstack.is(Items.LEAD) && this.canBeLeashed(entityhuman)) {
@@ -211,17 +211,17 @@
+ // CraftBukkit end
this.setLeashedTo(entityhuman, true);
itemstack.shrink(1);
return EnumInteractionResult.sidedSuccess(this.level.isClientSide);
@@ -1212,7 +1312,7 @@
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);
@@ -1215,7 +1315,7 @@
if (itemstack.getItem() instanceof ItemMonsterEgg) {
if (this.level instanceof WorldServer) {
if (this.level() instanceof WorldServer) {
ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem();
- Optional<EntityInsentient> optional = itemmonsteregg.spawnOffspringFromSpawnEgg(entityhuman, this, this.getType(), (WorldServer) this.level, this.position(), itemstack);
+ Optional<EntityInsentient> optional = itemmonsteregg.spawnOffspringFromSpawnEgg(entityhuman, this, (EntityTypes<? extends EntityInsentient>) this.getType(), (WorldServer) this.level, this.position(), itemstack); // CraftBukkit - decompile error
- Optional<EntityInsentient> optional = itemmonsteregg.spawnOffspringFromSpawnEgg(entityhuman, this, this.getType(), (WorldServer) this.level(), this.position(), itemstack);
+ Optional<EntityInsentient> optional = itemmonsteregg.spawnOffspringFromSpawnEgg(entityhuman, this, (EntityTypes<? extends EntityInsentient>) this.getType(), (WorldServer) this.level(), this.position(), itemstack); // CraftBukkit - decompile error
optional.ifPresent((entityinsentient) -> {
this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient);
@@ -1262,12 +1362,19 @@
@@ -1265,12 +1365,19 @@
return this.restrictRadius != -1.0F;
}
@@ -237,52 +237,52 @@
if (this.isRemoved()) {
return null;
} else {
- T t0 = (EntityInsentient) entitytypes.create(this.level);
+ T t0 = entitytypes.create(this.level); // CraftBukkit - decompile error
- T t0 = (EntityInsentient) entitytypes.create(this.level());
+ T t0 = entitytypes.create(this.level()); // CraftBukkit - decompile error
if (t0 == null) {
return null;
@@ -1302,7 +1409,12 @@
@@ -1304,7 +1411,12 @@
}
}
- this.level.addFreshEntity(t0);
- this.level().addFreshEntity(t0);
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, t0, transformReason).isCancelled()) {
+ return null;
+ }
+ this.level.addFreshEntity(t0, spawnReason);
+ this.level().addFreshEntity(t0, spawnReason);
+ // CraftBukkit end
if (this.isPassenger()) {
Entity entity = this.getVehicle();
@@ -1323,6 +1435,7 @@
@@ -1325,6 +1437,7 @@
if (this.leashHolder != null) {
if (!this.isAlive() || !this.leashHolder.isAlive()) {
+ this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit
+ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), (!this.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit
this.dropLeash(true, true);
}
@@ -1334,7 +1447,9 @@
@@ -1336,7 +1449,9 @@
this.leashHolder = null;
this.leashInfoTag = null;
if (!this.level.isClientSide && flag1) {
if (!this.level().isClientSide && flag1) {
+ this.forceDrops = true; // CraftBukkit
this.spawnAtLocation((IMaterial) Items.LEAD);
+ this.forceDrops = false; // CraftBukkit
}
if (!this.level.isClientSide && flag && this.level instanceof WorldServer) {
@@ -1384,6 +1499,7 @@
if (!this.level().isClientSide && flag && this.level() instanceof WorldServer) {
@@ -1386,6 +1501,7 @@
boolean flag1 = super.startRiding(entity, flag);
if (flag1 && this.isLeashed()) {
+ this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
+ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
this.dropLeash(true, true);
}
@@ -1408,7 +1524,9 @@
@@ -1410,7 +1526,9 @@
}
if (this.tickCount > 100) {
@@ -292,7 +292,7 @@
this.leashInfoTag = null;
}
}
@@ -1484,7 +1602,14 @@
@@ -1486,7 +1604,14 @@
int i = EnchantmentManager.getFireAspect(this);
if (i > 0) {
@@ -308,15 +308,11 @@
}
boolean flag = entity.hurt(this.damageSources().mobAttack(this), f);
@@ -1558,9 +1683,10 @@
@@ -1560,6 +1685,7 @@
@Override
protected void removeAfterChangingDimensions() {
super.removeAfterChangingDimensions();
+ this.level.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
+ this.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
this.dropLeash(true, false);
this.getAllSlots().forEach((itemstack) -> {
- itemstack.setCount(0);
+ if (!itemstack.isEmpty()) itemstack.setCount(0); // CraftBukkit
});
}
if (!itemstack.isEmpty()) {

View File

@@ -17,18 +17,18 @@
- if (this.life >= 0) {
+ if (this.life >= 0 && !this.visualOnly) { // CraftBukkit - add !this.visualOnly
if (!(this.level instanceof WorldServer)) {
this.level.setSkyFlashTime(2);
if (!(this.level() instanceof WorldServer)) {
this.level().setSkyFlashTime(2);
} else if (!this.visualOnly) {
@@ -163,8 +167,12 @@
IBlockData iblockdata = BlockFireAbstract.getState(this.level, blockposition);
IBlockData iblockdata = BlockFireAbstract.getState(this.level(), blockposition);
if (this.level.getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level, blockposition)) {
- this.level.setBlockAndUpdate(blockposition, iblockdata);
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
- this.level().setBlockAndUpdate(blockposition, iblockdata);
- ++this.blocksSetOnFire;
+ // CraftBukkit start - add "!visualOnly"
+ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(level, blockposition, this).isCancelled()) {
+ this.level.setBlockAndUpdate(blockposition, iblockdata);
+ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(this.level(), blockposition, this).isCancelled()) {
+ this.level().setBlockAndUpdate(blockposition, iblockdata);
+ ++this.blocksSetOnFire;
+ }
+ // CraftBukkit end
@@ -37,13 +37,13 @@
for (int j = 0; j < i; ++j) {
@@ -172,8 +180,12 @@
iblockdata = BlockFireAbstract.getState(this.level, blockposition1);
if (this.level.getBlockState(blockposition1).isAir() && iblockdata.canSurvive(this.level, blockposition1)) {
- this.level.setBlockAndUpdate(blockposition1, iblockdata);
iblockdata = BlockFireAbstract.getState(this.level(), blockposition1);
if (this.level().getBlockState(blockposition1).isAir() && iblockdata.canSurvive(this.level(), blockposition1)) {
- this.level().setBlockAndUpdate(blockposition1, iblockdata);
- ++this.blocksSetOnFire;
+ // CraftBukkit start - add "!visualOnly"
+ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(level, blockposition1, this).isCancelled()) {
+ this.level.setBlockAndUpdate(blockposition1, iblockdata);
+ if (!visualOnly && !CraftEventFactory.callBlockIgniteEvent(this.level(), blockposition1, this).isCancelled()) {
+ this.level().setBlockAndUpdate(blockposition1, iblockdata);
+ ++this.blocksSetOnFire;
+ }
+ // CraftBukkit end

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/EntityLiving.java
+++ b/net/minecraft/world/entity/EntityLiving.java
@@ -117,6 +117,30 @@
@@ -119,6 +119,30 @@
import net.minecraft.world.scores.ScoreboardTeam;
import org.slf4j.Logger;
@@ -31,7 +31,7 @@
public abstract class EntityLiving extends Entity implements Attackable {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -224,6 +248,20 @@
@@ -227,6 +251,20 @@
private float swimAmountO;
protected BehaviorController<?> brain;
private boolean skipDropExperience;
@@ -52,7 +52,7 @@
protected EntityLiving(EntityTypes<? extends EntityLiving> entitytypes, World world) {
super(entitytypes, world);
@@ -236,7 +274,9 @@
@@ -239,7 +277,9 @@
this.useItem = ItemStack.EMPTY;
this.lastClimbablePos = Optional.empty();
this.attributes = new AttributeMapBase(AttributeDefaults.getSupplier(entitytypes));
@@ -63,22 +63,22 @@
this.blocksBuilding = true;
this.rotA = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
this.reapplyPosition();
@@ -303,7 +343,13 @@
double d1 = Math.min((double) (0.2F + f / 15.0F), 2.5D);
int i = (int) (150.0D * d1);
@@ -318,7 +358,13 @@
double d7 = Math.min((double) (0.2F + f / 15.0F), 2.5D);
int i = (int) (150.0D * d7);
- ((WorldServer) this.level).sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.getX(), this.getY(), this.getZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D);
+ // CraftBukkit start - visiblity api
+ if (this instanceof EntityPlayer) {
+ ((WorldServer) this.level).sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), this.getX(), this.getY(), this.getZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false);
+ } else {
+ ((WorldServer) this.level).sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), this.getX(), this.getY(), this.getZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D);
+ }
+ // CraftBukkit end
}
- ((WorldServer) this.level()).sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d1, d2, d3, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D);
+ // CraftBukkit start - visiblity api
+ if (this instanceof EntityPlayer) {
+ ((WorldServer) this.level()).sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), this.getX(), this.getY(), this.getZ(), i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false);
+ } else {
+ ((WorldServer) this.level()).sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d1, d2, d3, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D);
+ }
+ // CraftBukkit end
}
@@ -655,13 +701,19 @@
super.checkFallDamage(d0, flag, iblockdata, blockposition);
@@ -673,13 +719,19 @@
}
public void onEquipItem(EnumItemSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1) {
@@ -94,12 +94,12 @@
Equipable equipable = Equipable.get(itemstack1);
if (equipable != null && !this.isSpectator() && equipable.getEquipmentSlot() == enumitemslot) {
- if (!this.level.isClientSide() && !this.isSilent()) {
+ if (!this.level.isClientSide() && !this.isSilent() && !silent) { // CraftBukkit
this.level.playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), equipable.getEquipSound(), this.getSoundSource(), 1.0F, 1.0F);
- if (!this.level().isClientSide() && !this.isSilent()) {
+ if (!this.level().isClientSide() && !this.isSilent() && !silent) { // CraftBukkit
this.level().playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), equipable.getEquipSound(), this.getSoundSource(), 1.0F, 1.0F);
}
@@ -735,6 +787,17 @@
@@ -753,6 +805,17 @@
}
}
@@ -117,7 +117,7 @@
if (nbttagcompound.contains("Health", 99)) {
this.setHealth(nbttagcompound.getFloat("Health"));
}
@@ -772,9 +835,32 @@
@@ -790,9 +853,32 @@
}
@@ -150,10 +150,10 @@
try {
while (iterator.hasNext()) {
MobEffectList mobeffectlist = (MobEffectList) iterator.next();
@@ -784,6 +870,12 @@
@@ -802,6 +888,12 @@
this.onEffectUpdated(mobeffect, true, (Entity) null);
})) {
if (!this.level.isClientSide) {
if (!this.level().isClientSide) {
+ // CraftBukkit start
+ EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, mobeffect, null, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.EXPIRATION);
+ if (event.isCancelled()) {
@@ -163,7 +163,7 @@
iterator.remove();
this.onEffectRemoved(mobeffect);
}
@@ -794,6 +886,17 @@
@@ -812,6 +904,17 @@
} catch (ConcurrentModificationException concurrentmodificationexception) {
;
}
@@ -180,8 +180,8 @@
+ // CraftBukkit end
if (this.effectsDirty) {
if (!this.level.isClientSide) {
@@ -920,7 +1023,13 @@
if (!this.level().isClientSide) {
@@ -938,7 +1041,13 @@
this.entityData.set(EntityLiving.DATA_EFFECT_COLOR_ID, 0);
}
@@ -192,10 +192,10 @@
+
+ public boolean removeAllEffects(EntityPotionEffectEvent.Cause cause) {
+ // CraftBukkit end
if (this.level.isClientSide) {
if (this.level().isClientSide) {
return false;
} else {
@@ -929,7 +1038,14 @@
@@ -947,7 +1056,14 @@
boolean flag;
for (flag = false; iterator.hasNext(); flag = true) {
@@ -211,7 +211,7 @@
iterator.remove();
}
@@ -958,18 +1074,48 @@
@@ -976,18 +1092,48 @@
return this.addEffect(mobeffect, (Entity) null);
}
@@ -261,7 +261,7 @@
return true;
} else {
return false;
@@ -1006,13 +1152,39 @@
@@ -1024,13 +1170,39 @@
return this.getMobType() == EnumMonsterType.UNDEAD;
}
@@ -302,7 +302,7 @@
if (mobeffect != null) {
this.onEffectRemoved(mobeffect);
@@ -1049,20 +1221,55 @@
@@ -1098,20 +1270,55 @@
}
@@ -319,7 +319,7 @@
+ EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), f, regainReason);
+ // Suppress during worldgen
+ if (this.valid) {
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+ }
+
+ if (!event.isCancelled()) {
@@ -359,16 +359,16 @@
this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.clamp(f, 0.0F, this.getMaxHealth()));
}
@@ -1076,7 +1283,7 @@
@@ -1125,7 +1332,7 @@
return false;
} else if (this.level.isClientSide) {
} else if (this.level().isClientSide) {
return false;
- } else if (this.isDeadOrDying()) {
+ } else if (this.isRemoved() || this.dead || 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.is(DamageTypeTags.IS_FIRE) && this.hasEffect(MobEffects.FIRE_RESISTANCE)) {
return false;
@@ -1087,10 +1294,11 @@
@@ -1136,10 +1343,11 @@
this.noActionTime = 0;
float f1 = f;
@@ -382,7 +382,7 @@
this.hurtCurrentlyUsedShield(f);
f2 = f;
f = 0.0F;
@@ -1114,27 +1322,46 @@
@@ -1163,27 +1371,46 @@
this.walkAnimation.setSpeed(1.5F);
boolean flag1 = true;
@@ -434,7 +434,7 @@
Entity entity1 = damagesource.getEntity();
if (entity1 != null) {
@@ -1248,19 +1475,32 @@
@@ -1297,19 +1524,32 @@
EnumHand[] aenumhand = EnumHand.values();
int i = aenumhand.length;
@@ -460,7 +460,7 @@
+ org.bukkit.inventory.EquipmentSlot handSlot = (hand != null) ? org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand) : null;
+ EntityResurrectEvent event = new EntityResurrectEvent((LivingEntity) this.getBukkitEntity(), handSlot);
+ event.setCancelled(itemstack == null);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ if (!itemstack1.isEmpty()) {
@@ -471,7 +471,7 @@
EntityPlayer entityplayer = (EntityPlayer) this;
entityplayer.awardStat(StatisticList.ITEM_USED.get(Items.TOTEM_OF_UNDYING));
@@ -1268,14 +1508,16 @@
@@ -1317,14 +1557,16 @@
}
this.setHealth(1.0F);
@@ -485,7 +485,7 @@
+ this.addEffect(new MobEffect(MobEffects.ABSORPTION, 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.level.broadcastEntityEvent(this, (byte) 35);
this.level().broadcastEntityEvent(this, (byte) 35);
}
- return itemstack != null;
@@ -493,20 +493,20 @@
}
}
@@ -1380,14 +1622,22 @@
@@ -1433,14 +1675,22 @@
IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState();
if (this.level.getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level, blockposition)) {
- this.level.setBlock(blockposition, iblockdata, 3);
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
- this.level().setBlock(blockposition, iblockdata, 3);
- flag = true;
+ // CraftBukkit start - call EntityBlockFormEvent for Wither Rose
+ flag = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level, blockposition, iblockdata, 3, this);
+ flag = org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level(), blockposition, iblockdata, 3, this);
+ // CraftBukkit end
}
}
if (!flag) {
EntityItem entityitem = new EntityItem(this.level, this.getX(), this.getY(), this.getZ(), new ItemStack(Items.WITHER_ROSE));
EntityItem entityitem = new EntityItem(this.level(), this.getX(), this.getY(), this.getZ(), new ItemStack(Items.WITHER_ROSE));
+ // CraftBukkit start
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
@@ -515,15 +515,15 @@
+ return;
+ }
+ // CraftBukkit end
this.level.addFreshEntity(entityitem);
this.level().addFreshEntity(entityitem);
}
}
@@ -1407,21 +1657,40 @@
@@ -1460,21 +1710,40 @@
boolean flag = this.lastHurtByPlayerTime > 0;
+ this.dropEquipment(); // CraftBukkit - from below
if (this.shouldDropLoot() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
if (this.shouldDropLoot() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
this.dropFromLootTable(damagesource, flag);
this.dropCustomDeathLoot(damagesource, i, flag);
}
@@ -542,27 +542,27 @@
- protected void dropExperience() {
+ // CraftBukkit start
+ public int getExpReward() {
if (this.level instanceof WorldServer && !this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) {
- EntityExperienceOrb.award((WorldServer) this.level, this.position(), this.getExperienceReward());
if (this.level() instanceof WorldServer && !this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) {
- EntityExperienceOrb.award((WorldServer) this.level(), this.position(), this.getExperienceReward());
+ int i = this.getExperienceReward();
+ return i;
+ } else {
+ return 0;
+ }
}
+ }
+ // CraftBukkit end
+
+ protected void dropExperience() {
+ // CraftBukkit start - Update getExpReward() above if the removed if() changes!
+ if (true && !(this instanceof net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon)) { // CraftBukkit - SPIGOT-2420: Special case ender dragon will drop the xp over time
+ EntityExperienceOrb.award((WorldServer) this.level, this.position(), this.expToDrop);
+ EntityExperienceOrb.award((WorldServer) this.level(), this.position(), this.expToDrop);
+ this.expToDrop = 0;
}
+ }
+ // CraftBukkit end
}
@@ -1512,6 +1781,28 @@
@@ -1565,6 +1834,28 @@
return itemstack.getEatingSound();
}
@@ -588,10 +588,10 @@
+ }
+ // CraftBukkit end
+
@Override
public void setOnGround(boolean flag) {
super.setOnGround(flag);
@@ -1567,9 +1858,14 @@
public Optional<BlockPosition> getLastClimbablePos() {
return this.lastClimbablePos;
}
@@ -1611,9 +1902,14 @@
int i = this.calculateFallDamage(f, f1);
if (i > 0) {
@@ -607,7 +607,7 @@
return true;
} else {
return flag;
@@ -1621,7 +1917,7 @@
@@ -1665,7 +1961,7 @@
protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) {
if (!damagesource.is(DamageTypeTags.BYPASSES_ARMOR)) {
@@ -616,7 +616,7 @@
f = CombatMath.getDamageAfterAbsorb(f, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS));
}
@@ -1634,7 +1930,8 @@
@@ -1678,7 +1974,8 @@
} else {
int i;
@@ -626,7 +626,7 @@
i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
int j = 25 - i;
float f1 = f * (float) j;
@@ -1667,16 +1964,125 @@
@@ -1711,16 +2008,125 @@
}
}
@@ -712,7 +712,10 @@
+ }
+
+ f = (float) event.getFinalDamage();
+
- f = Math.max(f - this.getAbsorptionAmount(), 0.0F);
- this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - f));
- float f2 = f1 - f;
+ // Resistance
+ if (event.getDamage(DamageModifier.RESISTANCE) < 0) {
+ float f3 = (float) -event.getDamage(DamageModifier.RESISTANCE);
@@ -724,7 +727,7 @@
+ }
+ }
+ }
+
+ // Apply damage to helmet
+ if (damagesource.is(DamageTypeTags.DAMAGES_HELMET) && !this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) {
+ this.hurtHelmet(damagesource, f);
@@ -738,7 +741,7 @@
+
+ // Apply blocking code // PAIL: steal from above
+ if (event.getDamage(DamageModifier.BLOCKING) < 0) {
+ this.level.broadcastEntityEvent(this, (byte) 29); // SPIGOT-4635 - shield damage sound
+ this.level().broadcastEntityEvent(this, (byte) 29); // SPIGOT-4635 - shield damage sound
+ this.hurtCurrentlyUsedShield((float) -event.getDamage(DamageModifier.BLOCKING));
+ Entity entity = damagesource.getDirectEntity();
+
@@ -746,21 +749,18 @@
+ this.blockUsingShield((EntityLiving) entity);
+ }
+ }
- f = Math.max(f - this.getAbsorptionAmount(), 0.0F);
- this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - f));
- float f2 = f1 - f;
+
+ absorptionModifier = (float) -event.getDamage(DamageModifier.ABSORPTION);
+ this.setAbsorptionAmount(Math.max(this.getAbsorptionAmount() - absorptionModifier, 0.0F));
+ float f2 = absorptionModifier;
+
+ if (f2 > 0.0F && f2 < 3.4028235E37F && this instanceof EntityHuman) {
+ ((EntityHuman) this).awardStat(StatisticList.DAMAGE_ABSORBED, Math.round(f2 * 10.0F));
+ }
if (f2 > 0.0F && f2 < 3.4028235E37F) {
Entity entity = damagesource.getEntity();
@@ -1687,15 +2093,49 @@
@@ -1731,13 +2137,47 @@
}
}
@@ -774,10 +774,8 @@
+ }
+ }
+ // CraftBukkit end
float f3 = this.getHealth();
this.getCombatTracker().recordDamage(damagesource, f3, f);
this.setHealth(f3 - f);
this.getCombatTracker().recordDamage(damagesource, f);
this.setHealth(this.getHealth() - f);
- this.setAbsorptionAmount(this.getAbsorptionAmount() - f);
+ // CraftBukkit start
+ if (!human) {
@@ -812,28 +810,27 @@
}
public CombatTracker getCombatTracker() {
@@ -1716,9 +2156,19 @@
@@ -1758,8 +2198,18 @@
}
public final void setArrowCount(int i) {
- this.entityData.set(EntityLiving.DATA_ARROW_COUNT_ID, 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.entityData.set(EntityLiving.DATA_ARROW_COUNT_ID, event.getNewAmount());
+ }
}
+ // CraftBukkit end
+
public final int getStingerCount() {
return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID);
}
@@ -1959,6 +2409,12 @@
@@ -2001,6 +2451,12 @@
public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot);
@@ -846,23 +843,23 @@
@Override
public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack);
@@ -2198,6 +2654,7 @@
@@ -2238,6 +2694,7 @@
}
if (this.onGround && !this.level.isClientSide) {
if (this.onGround() && !this.level().isClientSide) {
+ if (getSharedFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit
this.setSharedFlag(7, false);
}
} else {
@@ -2757,6 +3214,7 @@
@@ -2809,6 +3266,7 @@
}
if (!this.level.isClientSide) {
if (!this.level().isClientSide) {
+ if (flag != this.getSharedFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, flag).isCancelled()) // CraftBukkit
this.setSharedFlag(7, flag);
}
@@ -2916,14 +3374,21 @@
@@ -2968,14 +3426,21 @@
@Override
public boolean isPickable() {
@@ -886,18 +883,18 @@
@Override
public float getYHeadRot() {
return this.yHeadRot;
@@ -3118,7 +3583,26 @@
@@ -3170,7 +3635,26 @@
} else {
if (!this.useItem.isEmpty() && this.isUsingItem()) {
this.triggerItemUseEffects(this.useItem, 16);
- ItemStack itemstack = this.useItem.finishUsingItem(this.level, this);
- ItemStack itemstack = this.useItem.finishUsingItem(this.level(), this);
+ // CraftBukkit start - fire PlayerItemConsumeEvent
+ ItemStack itemstack;
+ if (this instanceof EntityPlayer) {
+ org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.useItem);
+ org.bukkit.inventory.EquipmentSlot hand = org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(enumhand);
+ PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem, hand);
+ level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ // Update client
@@ -906,15 +903,15 @@
+ return;
+ }
+
+ itemstack = (craftItem.equals(event.getItem())) ? this.useItem.finishUsingItem(this.level, this) : CraftItemStack.asNMSCopy(event.getItem()).finishUsingItem(level, this);
+ itemstack = (craftItem.equals(event.getItem())) ? this.useItem.finishUsingItem(this.level(), this) : CraftItemStack.asNMSCopy(event.getItem()).finishUsingItem(this.level(), this);
+ } else {
+ itemstack = this.useItem.finishUsingItem(this.level, this);
+ itemstack = this.useItem.finishUsingItem(this.level(), this);
+ }
+ // CraftBukkit end
if (itemstack != this.useItem) {
this.setItemInHand(enumhand, itemstack);
@@ -3196,6 +3680,12 @@
@@ -3248,6 +3732,12 @@
}
public boolean randomTeleport(double d0, double d1, double d2, boolean flag) {
@@ -927,7 +924,7 @@
double d3 = this.getX();
double d4 = this.getY();
double d5 = this.getZ();
@@ -3220,16 +3710,41 @@
@@ -3272,16 +3762,41 @@
}
if (flag2) {
@@ -945,8 +942,8 @@
+
+ if (flag1) {
+ if (!(this instanceof EntityPlayer)) {
+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.level.getWorld(), d3, d4, d5), new Location(this.level.getWorld(), d0, d6, d2));
+ this.level.getCraftServer().getPluginManager().callEvent(teleport);
+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.level().getWorld(), d3, d4, d5), new Location(this.level().getWorld(), d0, d6, d2));
+ this.level().getCraftServer().getPluginManager().callEvent(teleport);
+ if (!teleport.isCancelled()) {
+ Location to = teleport.getTo();
+ this.teleportTo(to.getX(), to.getY(), to.getZ());
@@ -972,7 +969,7 @@
} else {
if (flag) {
world.broadcastEntityEvent(this, (byte) 46);
@@ -3239,7 +3754,7 @@
@@ -3291,7 +3806,7 @@
((EntityCreature) this).getNavigation().stop();
}
@@ -981,25 +978,25 @@
}
}
@@ -3322,7 +3837,7 @@
@@ -3374,7 +3889,7 @@
}
public void stopSleeping() {
- Optional optional = this.getSleepingPos();
+ Optional<BlockPosition> optional = this.getSleepingPos(); // CraftBukkit - decompile error
World world = this.level;
World world = this.level();
java.util.Objects.requireNonNull(this.level);
@@ -3356,7 +3871,7 @@
java.util.Objects.requireNonNull(world);
@@ -3408,7 +3923,7 @@
@Nullable
public EnumDirection getBedOrientation() {
- BlockPosition blockposition = (BlockPosition) this.getSleepingPos().orElse((Object) null);
+ BlockPosition blockposition = (BlockPosition) this.getSleepingPos().orElse(null); // CraftBukkit - decompile error
return blockposition != null ? BlockBed.getBedOrientation(this.level, blockposition) : null;
return blockposition != null ? BlockBed.getBedOrientation(this.level(), blockposition) : null;
}
@@ -3404,7 +3919,7 @@
@@ -3456,7 +3971,7 @@
Pair<MobEffect, Float> pair = (Pair) iterator.next();
if (!world.isClientSide && pair.getFirst() != null && world.random.nextFloat() < (Float) pair.getSecond()) {

View File

@@ -7,5 +7,5 @@
- if (!entity1.isPushable()) {
+ if (!entity1.canCollideWithBukkit(entity) || !entity.canCollideWithBukkit(entity1)) { // CraftBukkit - collidable API
return false;
} else if (entity.level.isClientSide && (!(entity1 instanceof EntityHuman) || !((EntityHuman) entity1).isLocalPlayer())) {
} else if (entity.level().isClientSide && (!(entity1 instanceof EntityHuman) || !((EntityHuman) entity1).isLocalPlayer())) {
return false;

View File

@@ -22,7 +22,7 @@
Logger logger;
if (nbttagcompound.contains("attack")) {
@@ -138,12 +144,19 @@
@@ -143,12 +149,19 @@
public boolean skipAttackInteraction(Entity entity) {
if (entity instanceof EntityHuman) {
EntityHuman entityhuman = (EntityHuman) entity;
@@ -34,7 +34,7 @@
+ }
+ // CraftBukkit end
this.attack = new Interaction.PlayerAction(entityhuman.getUUID(), this.level.getGameTime());
this.attack = new Interaction.PlayerAction(entityhuman.getUUID(), this.level().getGameTime());
if (entityhuman instanceof EntityPlayer) {
EntityPlayer entityplayer = (EntityPlayer) entityhuman;

View File

@@ -14,7 +14,7 @@
private static final int TIMEOUT_TO_GET_WITHIN_ATTACK_RANGE = 200;
@@ -41,6 +47,18 @@
if (entityinsentient.canAttack(entityliving) && (!flag || !isTiredOfTryingToReachTarget(entityinsentient, behaviorbuilder_b.tryGet(memoryaccessor1))) && entityliving.isAlive() && entityliving.level == entityinsentient.level && !predicate.test(entityliving)) {
if (entityinsentient.canAttack(entityliving) && (!flag || !isTiredOfTryingToReachTarget(entityinsentient, behaviorbuilder_b.tryGet(memoryaccessor1))) && entityliving.isAlive() && entityliving.level() == entityinsentient.level() && !predicate.test(entityliving)) {
return true;
} else {
+ // CraftBukkit start

View File

@@ -1,6 +1,17 @@
--- a/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorFarm.java
@@ -80,8 +80,8 @@
@@ -26,6 +26,10 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.gameevent.GameEvent;
+// CraftBukkit start
+import net.minecraft.world.level.block.Blocks;
+// CraftBukkit end
+
public class BehaviorFarm extends Behavior<EntityVillager> {
private static final int HARVEST_DURATION = 200;
@@ -81,8 +85,8 @@
protected void start(WorldServer worldserver, EntityVillager entityvillager, long i) {
if (i > this.nextOkStartTime && this.aboveFarmlandPos != null) {
@@ -11,7 +22,7 @@
}
}
@@ -101,7 +101,11 @@
@@ -102,7 +106,11 @@
Block block1 = worldserver.getBlockState(this.aboveFarmlandPos.below()).getBlock();
if (block instanceof BlockCrops && ((BlockCrops) block).isMaxAge(iblockdata)) {
@@ -24,45 +35,24 @@
}
if (iblockdata.isAir() && block1 instanceof BlockSoil && entityvillager.hasFarmSeeds()) {
@@ -114,27 +118,30 @@
if (!itemstack.isEmpty()) {
IBlockData iblockdata1;
@@ -119,9 +127,13 @@
ItemBlock itemblock = (ItemBlock) item;
IBlockData iblockdata1 = itemblock.getBlock().defaultBlockState();
+ // CraftBukkit start
if (itemstack.is(Items.WHEAT_SEEDS)) {
iblockdata1 = Blocks.WHEAT.defaultBlockState();
- worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
- worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
flag = true;
} else if (itemstack.is(Items.POTATO)) {
iblockdata1 = Blocks.POTATOES.defaultBlockState();
- worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
- worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
flag = true;
} else if (itemstack.is(Items.CARROT)) {
iblockdata1 = Blocks.CARROTS.defaultBlockState();
- worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
- worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
flag = true;
} else if (itemstack.is(Items.BEETROOT_SEEDS)) {
iblockdata1 = Blocks.BEETROOTS.defaultBlockState();
+ flag = true;
+ } else {
+ iblockdata1 = null;
+ }
+
+ if (iblockdata1 != null && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, iblockdata1).isCancelled()) {
worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
- flag = true;
+ } else {
+ flag = false;
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entityvillager, this.aboveFarmlandPos, iblockdata1).isCancelled()) {
+ worldserver.setBlockAndUpdate(this.aboveFarmlandPos, iblockdata1);
+ worldserver.gameEvent(GameEvent.BLOCK_PLACE, this.aboveFarmlandPos, GameEvent.a.of(entityvillager, iblockdata1));
+ flag = true;
+ }
+ // CraftBukkit end
}
+ // CraftBukkit end
}
if (flag) {
@@ -153,8 +160,8 @@
@@ -141,8 +153,8 @@
this.aboveFarmlandPos = this.getValidFarmland(worldserver);
if (this.aboveFarmlandPos != null) {
this.nextOkStartTime = i + 20L;

View File

@@ -3,7 +3,7 @@
@@ -28,6 +28,20 @@
EntityItem entityitem = (EntityItem) behaviorbuilder_b.get(memoryaccessor2);
if (behaviorbuilder_b.tryGet(memoryaccessor3).isEmpty() && predicate.test(entityliving) && entityitem.closerThan(entityliving, (double) i) && entityliving.level.getWorldBorder().isWithinBounds(entityitem.blockPosition())) {
if (behaviorbuilder_b.tryGet(memoryaccessor3).isEmpty() && predicate.test(entityliving) && entityitem.closerThan(entityliving, (double) i) && entityliving.level().getWorldBorder().isWithinBounds(entityitem.blockPosition())) {
+ // CraftBukkit start
+ if (entityliving instanceof net.minecraft.world.entity.animal.allay.Allay) {
+ org.bukkit.event.entity.EntityTargetEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(entityliving, entityitem, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_ENTITY);

View File

@@ -5,8 +5,8 @@
if (!blockdoor.isOpen(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.level, blockposition));
+ entityliving.level.getCraftServer().getPluginManager().callEvent(event);
+ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entityliving.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(entityliving.level(), blockposition));
+ entityliving.level().getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return false;
+ }
@@ -19,8 +19,8 @@
if (!blockdoor1.isOpen(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.level, blockposition1));
+ entityliving.level.getCraftServer().getPluginManager().callEvent(event);
+ org.bukkit.event.entity.EntityInteractEvent event = new org.bukkit.event.entity.EntityInteractEvent(entityliving.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(entityliving.level(), blockposition1));
+ entityliving.level().getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return false;
+ }

View File

@@ -26,7 +26,7 @@
public static void throwItem(EntityLiving entityliving, ItemStack itemstack, Vec3D vec3d, Vec3D vec3d1, float f) {
+ if (itemstack.isEmpty()) return; // CraftBukkit - SPIGOT-4940: no empty loot
double d0 = entityliving.getEyeY() - (double) f;
EntityItem entityitem = new EntityItem(entityliving.level, entityliving.getX(), d0, entityliving.getZ(), itemstack);
EntityItem entityitem = new EntityItem(entityliving.level(), entityliving.getX(), d0, entityliving.getZ(), itemstack);
@@ -101,12 +102,19 @@
vec3d2 = vec3d2.normalize().multiply(vec3d1.x, vec3d1.y, vec3d1.z);
@@ -34,12 +34,12 @@
entityitem.setDefaultPickUpDelay();
+ // CraftBukkit start
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(entityliving.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
+ entityitem.level.getCraftServer().getPluginManager().callEvent(event);
+ entityitem.level().getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
entityliving.level.addFreshEntity(entityitem);
entityliving.level().addFreshEntity(entityitem);
}
public static SectionPosition findSectionClosestToVillage(WorldServer worldserver, SectionPosition sectionposition, int i) {

View File

@@ -3,13 +3,13 @@
@@ -71,6 +71,12 @@
}
if (this.breakTime == this.getDoorBreakTime() && this.isValidDifficulty(this.mob.level.getDifficulty())) {
if (this.breakTime == this.getDoorBreakTime() && this.isValidDifficulty(this.mob.level().getDifficulty())) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreakDoorEvent(this.mob, this.doorPos).isCancelled()) {
+ this.start();
+ return;
+ }
+ // CraftBukkit end
this.mob.level.removeBlock(this.doorPos, false);
this.mob.level.levelEvent(1021, this.doorPos, 0);
this.mob.level.levelEvent(2001, this.doorPos, Block.getId(this.mob.level.getBlockState(this.doorPos)));
this.mob.level().removeBlock(this.doorPos, false);
this.mob.level().levelEvent(1021, this.doorPos, 0);
this.mob.level().levelEvent(2001, this.doorPos, Block.getId(this.mob.level().getBlockState(this.doorPos)));

View File

@@ -22,7 +22,7 @@
+ CraftEntity entity = this.tamable.getBukkitEntity();
+ Location to = new Location(entity.getWorld(), (double) i + 0.5D, (double) j, (double) k + 0.5D, this.tamable.getYRot(), this.tamable.getXRot());
+ EntityTeleportEvent event = new EntityTeleportEvent(entity, entity.getLocation(), to);
+ this.tamable.level.getCraftServer().getPluginManager().callEvent(event);
+ this.tamable.level().getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return false;
+ }

View File

@@ -8,4 +8,4 @@
+ return this.mob.isOrderedToSit() && this.mob.getTarget() == null; // CraftBukkit - Allow sitting for wild animals
} else if (this.mob.isInWaterOrBubble()) {
return false;
} else if (!this.mob.isOnGround()) {
} else if (!this.mob.onGround()) {

View File

@@ -26,7 +26,7 @@
@@ -43,6 +50,15 @@
return false;
} else {
this.player = this.mob.level.getNearestPlayer(this.targetingConditions, this.mob);
this.player = this.mob.level().getNearestPlayer(this.targetingConditions, this.mob);
+ // CraftBukkit start
+ if (this.player != null) {
+ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this.mob, this.player, EntityTargetEvent.TargetReason.TEMPT);

View File

@@ -12,12 +12,12 @@
@@ -140,16 +142,24 @@
}
if (this.level.getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null) {
if (this.level().getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null) {
+ // CraftBukkit Start - Call BatToggleSleepEvent
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
+ this.setResting(false);
+ if (!flag) {
+ this.level.levelEvent((EntityHuman) null, 1025, blockposition, 0);
+ this.level().levelEvent((EntityHuman) null, 1025, blockposition, 0);
+ }
+ }
+ // CraftBukkit End
@@ -27,22 +27,22 @@
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {
this.setResting(false);
if (!flag) {
this.level.levelEvent((EntityHuman) null, 1025, blockposition, 0);
this.level().levelEvent((EntityHuman) null, 1025, blockposition, 0);
}
}
- } else {
- this.setResting(false);
- if (!flag) {
- this.level.levelEvent((EntityHuman) null, 1025, blockposition, 0);
- this.level().levelEvent((EntityHuman) null, 1025, blockposition, 0);
- }
+ // CraftBukkit End - Call BatToggleSleepEvent
}
} else {
if (this.targetPosition != null && (!this.level.isEmptyBlock(this.targetPosition) || this.targetPosition.getY() <= this.level.getMinBuildHeight())) {
if (this.targetPosition != null && (!this.level().isEmptyBlock(this.targetPosition) || this.targetPosition.getY() <= this.level().getMinBuildHeight())) {
@@ -173,7 +183,11 @@
this.zza = 0.5F;
this.setYRot(this.getYRot() + f1);
if (this.random.nextInt(100) == 0 && this.level.getBlockState(blockposition1).isRedstoneConductor(this.level, blockposition1)) {
if (this.random.nextInt(100) == 0 && this.level().getBlockState(blockposition1).isRedstoneConductor(this.level(), blockposition1)) {
- this.setResting(true);
+ // CraftBukkit Start - Call BatToggleSleepEvent
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, false)) {
@@ -55,7 +55,7 @@
@@ -198,7 +212,11 @@
return false;
} else {
if (!this.level.isClientSide && this.isResting()) {
if (!this.level().isClientSide && this.isResting()) {
- this.setResting(false);
+ // CraftBukkit Start - Call BatToggleSleepEvent
+ if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityAnimal.java
+++ b/net/minecraft/world/entity/animal/EntityAnimal.java
@@ -29,12 +29,19 @@
@@ -30,12 +30,19 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.pathfinder.PathType;
@@ -20,7 +20,7 @@
protected EntityAnimal(EntityTypes<? extends EntityAnimal> entitytypes, World world) {
super(entitytypes, world);
@@ -71,6 +78,9 @@
@@ -72,6 +79,9 @@
}
@@ -30,7 +30,7 @@
@Override
public boolean hurt(DamageSource damagesource, float f) {
if (this.isInvulnerableTo(damagesource)) {
@@ -80,6 +90,7 @@
@@ -81,6 +91,7 @@
return super.hurt(damagesource, f);
}
}
@@ -38,7 +38,7 @@
@Override
public float getWalkTargetValue(BlockPosition blockposition, IWorldReader iworldreader) {
@@ -174,10 +185,17 @@
@@ -175,10 +186,17 @@
}
public void setInLove(@Nullable EntityHuman entityhuman) {
@@ -55,41 +55,45 @@
}
+ this.breedItem = entityhuman.getInventory().getSelected(); // CraftBukkit
this.level.broadcastEntityEvent(this, (byte) 18);
this.level().broadcastEntityEvent(this, (byte) 18);
}
@@ -222,6 +240,16 @@
if (entityplayer == null && entityanimal.getLoveCause() != null) {
entityplayer = entityanimal.getLoveCause();
}
+ // CraftBukkit start - call EntityBreedEvent
+ entityageable.setBaby(true);
+ entityageable.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
+ 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.awardStat(StatisticList.ANIMALS_BRED);
@@ -232,12 +260,14 @@
entityanimal.setAge(6000);
this.resetLove();
entityanimal.resetLove();
- entityageable.setBaby(true);
- entityageable.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
@@ -221,14 +239,23 @@
entityageable.setBaby(true);
entityageable.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
this.finalizeSpawnChildFromBreeding(worldserver, entityanimal, entityageable);
- worldserver.addFreshEntityWithPassengers(entityageable);
+ worldserver.addFreshEntityWithPassengers(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
worldserver.broadcastEntityEvent(this, (byte) 18);
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
- worldserver.addFreshEntity(new EntityExperienceOrb(worldserver, this.getX(), this.getY(), this.getZ(), this.getRandom().nextInt(7) + 1));
+ // CraftBukkit start - use event experience
+ if (experience > 0) {
+ worldserver.addFreshEntity(new EntityExperienceOrb(worldserver, this.getX(), this.getY(), this.getZ(), experience));
+ }
+ // CraftBukkit end
}
}
}
public void finalizeSpawnChildFromBreeding(WorldServer worldserver, EntityAnimal entityanimal, @Nullable EntityAgeable entityageable) {
- Optional.ofNullable(this.getLoveCause()).or(() -> {
+ // CraftBukkit start - call EntityBreedEvent
+ Optional<EntityPlayer> cause = Optional.ofNullable(this.getLoveCause()).or(() -> {
return Optional.ofNullable(entityanimal.getLoveCause());
- }).ifPresent((entityplayer) -> {
+ });
+ int experience = this.getRandom().nextInt(7) + 1;
+ org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityageable, this, entityanimal, cause.orElse(null), this.breedItem, experience);
+ if (entityBreedEvent.isCancelled()) {
+ return;
+ }
+ experience = entityBreedEvent.getExperience();
+ cause.ifPresent((entityplayer) -> {
+ // CraftBukkit end
entityplayer.awardStat(StatisticList.ANIMALS_BRED);
CriterionTriggers.BRED_ANIMALS.trigger(entityplayer, this, entityanimal, entityageable);
});
@@ -238,7 +265,11 @@
entityanimal.resetLove();
worldserver.broadcastEntityEvent(this, (byte) 18);
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
- worldserver.addFreshEntity(new EntityExperienceOrb(worldserver, this.getX(), this.getY(), this.getZ(), this.getRandom().nextInt(7) + 1));
+ // CraftBukkit start - use event experience
+ if (experience > 0) {
+ worldserver.addFreshEntity(new EntityExperienceOrb(worldserver, this.getX(), this.getY(), this.getZ(), experience));
+ }
+ // CraftBukkit end
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityBee.java
+++ b/net/minecraft/world/entity/animal/EntityBee.java
@@ -243,7 +243,7 @@
@@ -242,7 +242,7 @@
}
if (b0 > 0) {
@@ -9,15 +9,15 @@
}
}
@@ -641,11 +641,15 @@
@@ -640,11 +640,15 @@
if (this.isInvulnerableTo(damagesource)) {
return false;
} else {
- if (!this.level.isClientSide) {
- if (!this.level().isClientSide) {
+ // CraftBukkit start
+ boolean result = super.hurt(damagesource, f);
+
+ if (result && !this.level.isClientSide) {
+ if (result && !this.level().isClientSide) {
this.beePollinateGoal.stopPollinating();
}
@@ -27,16 +27,16 @@
}
}
@@ -1221,7 +1225,7 @@
@@ -1216,7 +1220,7 @@
}
}
- if (flag) {
+ if (flag && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityBee.this, blockposition, iblockdata.setValue(blockstateinteger, (Integer) iblockdata.getValue(blockstateinteger) + 1)).isCancelled()) { // Spigot
EntityBee.this.level.levelEvent(2005, blockposition, 0);
EntityBee.this.level.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(blockstateinteger, (Integer) iblockdata.getValue(blockstateinteger) + 1));
- if (iblockdata1 != null) {
+ if (iblockdata1 != null&& !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityBee.this, blockposition, iblockdata1).isCancelled()) { // CraftBukkit
EntityBee.this.level().levelEvent(2005, blockposition, 0);
EntityBee.this.level().setBlockAndUpdate(blockposition, iblockdata1);
EntityBee.this.incrementNumCropsGrownSincePollination();
@@ -1294,7 +1298,7 @@
@@ -1289,7 +1293,7 @@
@Override
protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) {
if (entityinsentient instanceof EntityBee && this.mob.hasLineOfSight(entityliving)) {
@@ -45,7 +45,7 @@
}
}
@@ -1303,7 +1307,7 @@
@@ -1298,7 +1302,7 @@
private static class c extends PathfinderGoalNearestAttackableTarget<EntityHuman> {
c(EntityBee entitybee) {

View File

@@ -8,7 +8,7 @@
+ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { // CraftBukkit
this.tame(entityhuman);
this.setOrderedToSit(true);
this.level.broadcastEntityEvent(this, (byte) 7);
this.level().broadcastEntityEvent(this, (byte) 7);
@@ -469,7 +469,7 @@
private static class PathfinderGoalTemptChance extends PathfinderGoalTempt {
@@ -22,15 +22,15 @@
while (iterator.hasNext()) {
ItemStack itemstack = (ItemStack) iterator.next();
- this.cat.level.addFreshEntity(new EntityItem(this.cat.level, (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.cat.yBodyRot * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.cat.yBodyRot * 0.017453292F), itemstack));
- this.cat.level().addFreshEntity(new EntityItem(this.cat.level(), (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.cat.yBodyRot * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.cat.yBodyRot * 0.017453292F), itemstack));
+ // CraftBukkit start
+ EntityItem entityitem = new EntityItem(this.cat.level, (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.cat.yBodyRot * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.cat.yBodyRot * 0.017453292F), itemstack);
+ EntityItem entityitem = new EntityItem(this.cat.level(), (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.cat.yBodyRot * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.cat.yBodyRot * 0.017453292F), itemstack);
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.cat.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
+ entityitem.level.getCraftServer().getPluginManager().callEvent(event);
+ entityitem.level().getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ continue;
+ }
+ this.cat.level.addFreshEntity(entityitem);
+ this.cat.level().addFreshEntity(entityitem);
+ // CraftBukkit end
}

View File

@@ -2,7 +2,7 @@
+++ b/net/minecraft/world/entity/animal/EntityChicken.java
@@ -96,7 +96,9 @@
this.flap += this.flapping * 2.0F;
if (!this.level.isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) {
if (!this.level().isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) {
this.playSound(SoundEffects.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
+ this.forceDrops = true; // CraftBukkit
this.spawnAtLocation((IMaterial) Items.EGG);

View File

@@ -17,7 +17,7 @@
if (itemstack.is(Items.BUCKET) && !this.isBaby()) {
+ // CraftBukkit start - Got milk?
+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level, entityhuman, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, enumhand);
+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level(), entityhuman, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, enumhand);
+
+ if (event.isCancelled()) {
+ return EnumInteractionResult.PASS;
@@ -29,4 +29,4 @@
+ ItemStack itemstack1 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
entityhuman.setItemInHand(enumhand, itemstack1);
return EnumInteractionResult.sidedSuccess(this.level.isClientSide);
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);

View File

@@ -40,7 +40,7 @@
@Override
public boolean canUse() {
- return this.dolphin.gotFish() && this.dolphin.getAirSupply() >= 100;
+ return this.dolphin.gotFish() && this.dolphin.getAirSupply() >= 100 && this.dolphin.level.getWorld().canGenerateStructures(); // MC-151364, SPIGOT-5494: hangs if generate-structures=false
+ return this.dolphin.gotFish() && this.dolphin.getAirSupply() >= 100 && this.dolphin.level().getWorld().canGenerateStructures(); // MC-151364, SPIGOT-5494: hangs if generate-structures=false
}
@Override
@@ -56,7 +56,7 @@
@@ -508,7 +520,7 @@
}
if (this.player.isSwimming() && this.player.level.random.nextInt(6) == 0) {
if (this.player.isSwimming() && this.player.level().random.nextInt(6) == 0) {
- this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin);
+ this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
}

View File

@@ -55,7 +55,7 @@
+ return;
+ }
+ // CraftBukkit end
int j = 1 + EntityFox.this.level.random.nextInt(2) + (i == 3 ? 1 : 0);
int j = 1 + EntityFox.this.level().random.nextInt(2) + (i == 3 ? 1 : 0);
ItemStack itemstack = EntityFox.this.getItemBySlot(EnumItemSlot.MAINHAND);
@@ -1441,7 +1459,7 @@

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityIronGolem.java
+++ b/net/minecraft/world/entity/animal/EntityIronGolem.java
@@ -105,7 +105,7 @@
@@ -102,7 +102,7 @@
@Override
protected void doPush(Entity entity) {
if (entity instanceof IMonster && !(entity instanceof EntityCreeper) && this.getRandom().nextInt(20) == 0) {

View File

@@ -16,7 +16,7 @@
private static final DataWatcherObject<String> DATA_TYPE = DataWatcher.defineId(EntityMushroomCow.class, DataWatcherRegistry.STRING);
@@ -115,6 +122,11 @@
this.playSound(soundeffect, 1.0F, 1.0F);
return EnumInteractionResult.sidedSuccess(this.level.isClientSide);
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);
} else if (itemstack.is(Items.SHEARS) && this.readyForShearing()) {
+ // CraftBukkit start
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
@@ -25,11 +25,11 @@
+ // CraftBukkit end
this.shear(SoundCategory.PLAYERS);
this.gameEvent(GameEvent.SHEAR, entityhuman);
if (!this.level.isClientSide) {
if (!this.level().isClientSide) {
@@ -165,7 +177,7 @@
if (entitycow != null) {
((WorldServer) this.level).sendParticles(Particles.EXPLOSION, this.getX(), this.getY(0.5D), this.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
((WorldServer) this.level()).sendParticles(Particles.EXPLOSION, this.getX(), this.getY(0.5D), this.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
- this.discard();
+ // this.discard(); // CraftBukkit - moved down
entitycow.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
@@ -39,26 +39,26 @@
}
entitycow.setInvulnerable(this.isInvulnerable());
- this.level.addFreshEntity(entitycow);
- this.level().addFreshEntity(entitycow);
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) {
+ return;
+ }
+ this.level.addFreshEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED);
+ this.level().addFreshEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED);
+
+ this.discard(); // CraftBukkit - from above
+ // CraftBukkit end
for (int i = 0; i < 5; ++i) {
- this.level.addFreshEntity(new EntityItem(this.level, this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getVariant().blockState.getBlock())));
- this.level().addFreshEntity(new EntityItem(this.level(), this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getVariant().blockState.getBlock())));
+ // CraftBukkit start
+ EntityItem entityitem = new EntityItem(this.level, this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getVariant().blockState.getBlock()));
+ EntityItem entityitem = new EntityItem(this.level(), this.getX(), this.getY(1.0D), this.getZ(), new ItemStack(this.getVariant().blockState.getBlock()));
+ EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
+ Bukkit.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ continue;
+ }
+ this.level.addFreshEntity(entityitem);
+ this.level().addFreshEntity(entityitem);
+ // CraftBukkit end
}
}

View File

@@ -3,13 +3,13 @@
@@ -177,7 +177,8 @@
if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemstack) && entityhuman.distanceToSqr((Entity) this) < 9.0D) {
this.usePlayerItem(entityhuman, enumhand, itemstack);
if (!this.level.isClientSide) {
if (!this.level().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.spawnTrustingParticles(true);
this.level.broadcastEntityEvent(this, (byte) 41);
this.level().broadcastEntityEvent(this, (byte) 41);
@@ -308,10 +309,10 @@
private final EntityOcelot ocelot;

View File

@@ -35,7 +35,7 @@
@@ -1105,7 +1107,7 @@
@Override
protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) {
if (entityinsentient instanceof EntityPanda && ((EntityPanda) entityinsentient).isAggressive()) {
if (entityinsentient instanceof EntityPanda && entityinsentient.isAggressive()) {
- entityinsentient.setTarget(entityliving);
+ entityinsentient.setTarget(entityliving, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit
}

View File

@@ -3,11 +3,11 @@
@@ -261,7 +261,7 @@
}
if (!this.level.isClientSide) {
if (!this.level().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.level.broadcastEntityEvent(this, (byte) 7);
this.level().broadcastEntityEvent(this, (byte) 7);
} else {
@@ -275,7 +275,7 @@
itemstack.shrink(1);
@@ -30,7 +30,7 @@
@@ -398,7 +398,7 @@
return false;
} else {
if (!this.level.isClientSide) {
if (!this.level().isClientSide) {
- this.setOrderedToSit(false);
+ // this.setOrderedToSit(false); // CraftBukkit - moved into EntityLiving.damageEntity(DamageSource, float)
}

View File

@@ -15,7 +15,7 @@
@Override
public void registerGoals() {
@@ -570,9 +576,23 @@
@@ -576,9 +582,23 @@
int i = (Integer) iblockdata.getValue(BlockCarrots.AGE);
if (i == 0) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntitySheep.java
+++ b/net/minecraft/world/entity/animal/EntitySheep.java
@@ -63,6 +63,14 @@
@@ -64,6 +64,14 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.storage.loot.LootTables;
@@ -15,10 +15,10 @@
public class EntitySheep extends EntityAnimal implements IShearable {
private static final int EAT_ANIMATION_TICKS = 40;
@@ -243,6 +251,11 @@
@@ -244,6 +252,11 @@
if (itemstack.is(Items.SHEARS)) {
if (!this.level.isClientSide && this.readyForShearing()) {
if (!this.level().isClientSide && this.readyForShearing()) {
+ // CraftBukkit start
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
+ return EnumInteractionResult.PASS;
@@ -27,7 +27,7 @@
this.shear(SoundCategory.PLAYERS);
this.gameEvent(GameEvent.SHEAR, entityhuman);
itemstack.hurtAndBreak(1, entityhuman, (entityhuman1) -> {
@@ -264,7 +277,9 @@
@@ -265,7 +278,9 @@
int i = 1 + this.random.nextInt(3);
for (int j = 0; j < i; ++j) {
@@ -37,29 +37,29 @@
if (entityitem != null) {
entityitem.setDeltaMovement(entityitem.getDeltaMovement().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)));
@@ -357,6 +372,12 @@
@@ -358,6 +373,12 @@
@Override
public void ate() {
+ // CraftBukkit start
+ SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity());
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) return;
+ // CraftBukkit end
super.ate();
this.setSheared(false);
if (this.isBaby()) {
@@ -376,7 +397,7 @@
@@ -377,7 +398,7 @@
EnumColor enumcolor = ((EntitySheep) entityanimal).getColor();
EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor();
InventoryCrafting inventorycrafting = makeContainer(enumcolor, enumcolor1);
- Optional optional = this.level.getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level).map((recipecrafting) -> {
+ Optional<Item> optional = this.level.getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level).map((recipecrafting) -> { // CraftBukkit - decompile error
return recipecrafting.assemble(inventorycrafting, this.level.registryAccess());
- Optional optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level()).map((recipecrafting) -> {
+ Optional<Item> optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, inventorycrafting, this.level()).map((recipecrafting) -> { // CraftBukkit - decompile error
return recipecrafting.assemble(inventorycrafting, this.level().registryAccess());
}).map(ItemStack::getItem);
@@ -399,10 +420,18 @@
@@ -400,10 +421,18 @@
public boolean stillValid(EntityHuman entityhuman) {
return false;
}
@@ -72,9 +72,9 @@
+ // CraftBukkit end
}, 2, 1);
inventorycrafting.setItem(0, new ItemStack(ItemDye.byColor(enumcolor)));
inventorycrafting.setItem(1, new ItemStack(ItemDye.byColor(enumcolor1)));
+ inventorycrafting.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event
return inventorycrafting;
transientcraftingcontainer.setItem(0, new ItemStack(ItemDye.byColor(enumcolor)));
transientcraftingcontainer.setItem(1, new ItemStack(ItemDye.byColor(enumcolor1)));
+ transientcraftingcontainer.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event
return transientcraftingcontainer;
}

View File

@@ -13,24 +13,24 @@
private static final DataWatcherObject<Byte> DATA_PUMPKIN_ID = DataWatcher.defineId(EntitySnowman.class, DataWatcherRegistry.BYTE);
@@ -97,7 +101,7 @@
super.aiStep();
if (!this.level.isClientSide) {
if (this.level.getBiome(this.blockPosition()).is(BiomeTags.SNOW_GOLEM_MELTS)) {
if (!this.level().isClientSide) {
if (this.level().getBiome(this.blockPosition()).is(BiomeTags.SNOW_GOLEM_MELTS)) {
- this.hurt(this.damageSources().onFire(), 1.0F);
+ this.hurt(this.damageSources().melting, 1.0F); // CraftBukkit - DamageSource.BURN -> CraftEventFactory.MELTING
}
if (!this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
if (!this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
@@ -113,7 +117,11 @@
BlockPosition blockposition = new BlockPosition(j, k, l);
if (this.level.getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level, blockposition)) {
- this.level.setBlockAndUpdate(blockposition, iblockdata);
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
- this.level().setBlockAndUpdate(blockposition, iblockdata);
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level, blockposition, iblockdata, this)) {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level(), blockposition, iblockdata, this)) {
+ continue;
+ }
+ // CraftBukkit end
this.level.gameEvent(GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(this, iblockdata));
this.level().gameEvent(GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(this, iblockdata));
}
}
@@ -145,6 +153,11 @@
@@ -44,10 +44,10 @@
+ // CraftBukkit end
this.shear(SoundCategory.PLAYERS);
this.gameEvent(GameEvent.SHEAR, entityhuman);
if (!this.level.isClientSide) {
if (!this.level().isClientSide) {
@@ -164,7 +177,9 @@
this.level.playSound((EntityHuman) null, (Entity) this, SoundEffects.SNOW_GOLEM_SHEAR, soundcategory, 1.0F, 1.0F);
if (!this.level.isClientSide()) {
this.level().playSound((EntityHuman) null, (Entity) this, SoundEffects.SNOW_GOLEM_SHEAR, soundcategory, 1.0F, 1.0F);
if (!this.level().isClientSide()) {
this.setPumpkin(false);
+ this.forceDrops = true; // CraftBukkit
this.spawnAtLocation(new ItemStack(Items.CARVED_PUMPKIN), 1.7F);

View File

@@ -3,7 +3,7 @@
@@ -308,7 +308,9 @@
protected void ageBoundaryReached() {
super.ageBoundaryReached();
if (!this.isBaby() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
if (!this.isBaby() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
+ this.forceDrops = true; // CraftBukkit
this.spawnAtLocation(Items.SCUTE, 1);
+ this.forceDrops = false; // CraftBukkit
@@ -22,7 +22,7 @@
private static class e extends ControllerMove {
@@ -487,12 +491,16 @@
} else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) {
World world = this.turtle.level;
World world = this.turtle.level();
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), (IBlockData) Blocks.TURTLE_EGG.defaultBlockState().setValue(BlockTurtleEgg.EGGS, this.turtle.random.nextInt(4) + 1)).isCancelled()) {

View File

@@ -40,7 +40,7 @@
@@ -298,7 +321,7 @@
Entity entity = damagesource.getEntity();
if (!this.level.isClientSide) {
if (!this.level().isClientSide) {
- this.setOrderedToSit(false);
+ // this.setOrderedToSit(false); // CraftBukkit - moved into EntityLiving.damageEntity(DamageSource, float)
}
@@ -55,31 +55,31 @@
} else {
this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(8.0D);
}
@@ -349,7 +372,7 @@
itemstack.shrink(1);
}
- this.heal((float) item.getFoodProperties().getNutrition());
+ this.heal((float) item.getFoodProperties().getNutrition(), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
return EnumInteractionResult.SUCCESS;
}
@@ -360,7 +383,7 @@
this.setOrderedToSit(!this.isOrderedToSit());
this.jumping = false;
this.navigation.stop();
- this.setTarget((EntityLiving) null);
+ this.setTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason
return EnumInteractionResult.SUCCESS;
}
@@ -382,7 +405,8 @@
@@ -348,7 +371,7 @@
itemstack.shrink(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.heal((float) item.getFoodProperties().getNutrition());
+ this.heal((float) item.getFoodProperties().getNutrition(), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
return EnumInteractionResult.SUCCESS;
} else {
if (item instanceof ItemDye) {
@@ -376,7 +399,7 @@
this.setOrderedToSit(!this.isOrderedToSit());
this.jumping = false;
this.navigation.stop();
this.setTarget((EntityLiving) null);
- this.setTarget((EntityLiving) null);
+ this.setTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason
return EnumInteractionResult.SUCCESS;
} else {
return enuminteractionresult;
@@ -387,7 +410,8 @@
itemstack.shrink(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.stop();
this.setTarget((EntityLiving) null);

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/animal/allay/Allay.java
+++ b/net/minecraft/world/entity/animal/allay/Allay.java
@@ -93,13 +93,14 @@
private final DynamicGameEventListener<Allay.b> dynamicJukeboxListener;
private final DynamicGameEventListener<Allay.a> dynamicJukeboxListener;
private final InventorySubcontainer inventory = new InventorySubcontainer(1);
@Nullable
- private BlockPosition jukeboxPos;
@@ -17,8 +17,8 @@
public Allay(EntityTypes<? extends Allay> entitytypes, World world) {
super(entitytypes, world);
@@ -112,6 +113,12 @@
this.dynamicJukeboxListener = new DynamicGameEventListener<>(new Allay.b(entitypositionsource, GameEvent.JUKEBOX_PLAY.getNotificationRadius()));
@@ -111,6 +112,12 @@
this.dynamicJukeboxListener = new DynamicGameEventListener<>(new Allay.a(this.vibrationUser.getPositionSource(), GameEvent.JUKEBOX_PLAY.getNotificationRadius()));
}
+ // CraftBukkit start
@@ -30,7 +30,7 @@
@Override
protected BehaviorController.b<Allay> brainProvider() {
return BehaviorController.provider(Allay.MEMORY_TYPES, Allay.SENSOR_TYPES);
@@ -124,7 +131,7 @@
@@ -123,7 +130,7 @@
@Override
public BehaviorController<Allay> getBrain() {
@@ -39,16 +39,16 @@
}
public static AttributeProvider.Builder createAttributes() {
@@ -231,7 +238,7 @@
@@ -230,7 +237,7 @@
public void aiStep() {
super.aiStep();
if (!this.level.isClientSide && this.isAlive() && this.tickCount % 10 == 0) {
if (!this.level().isClientSide && this.isAlive() && this.tickCount % 10 == 0) {
- this.heal(1.0F);
+ this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
}
if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) {
@@ -301,7 +308,12 @@
@@ -300,7 +307,12 @@
ItemStack itemstack1 = this.getItemInHand(EnumHand.MAIN_HAND);
if (this.isDancing() && this.isDuplicationItem(itemstack) && this.canDuplicate()) {
@@ -59,59 +59,59 @@
+ return EnumInteractionResult.SUCCESS;
+ }
+ // CraftBukkit end
this.level.broadcastEntityEvent(this, (byte) 18);
this.level.playSound(entityhuman, (Entity) this, SoundEffects.AMETHYST_BLOCK_CHIME, SoundCategory.NEUTRAL, 2.0F, 1.0F);
this.level().broadcastEntityEvent(this, (byte) 18);
this.level().playSound(entityhuman, (Entity) this, SoundEffects.AMETHYST_BLOCK_CHIME, SoundCategory.NEUTRAL, 2.0F, 1.0F);
this.removeInteractionItem(entityhuman, itemstack);
@@ -313,7 +325,7 @@
@@ -311,7 +323,7 @@
this.setItemInHand(EnumHand.MAIN_HAND, itemstack2);
this.removeInteractionItem(entityhuman, itemstack);
this.level.playSound(entityhuman, (Entity) this, SoundEffects.ALLAY_ITEM_GIVEN, SoundCategory.NEUTRAL, 2.0F, 1.0F);
this.level().playSound(entityhuman, (Entity) this, SoundEffects.ALLAY_ITEM_GIVEN, SoundCategory.NEUTRAL, 2.0F, 1.0F);
- this.getBrain().setMemory(MemoryModuleType.LIKED_PLAYER, (Object) entityhuman.getUUID());
+ this.getBrain().setMemory(MemoryModuleType.LIKED_PLAYER, entityhuman.getUUID()); // CraftBukkit - decompile error
return EnumInteractionResult.SUCCESS;
} else if (!itemstack1.isEmpty() && enumhand == EnumHand.MAIN_HAND && itemstack.isEmpty()) {
this.setItemSlot(EnumItemSlot.MAINHAND, ItemStack.EMPTY);
@@ -434,6 +446,7 @@
@@ -432,6 +444,7 @@
}
private boolean shouldStopDancing() {
+ if (this.forceDancing) {return false;} // CraftBukkit
return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), (double) GameEvent.JUKEBOX_PLAY.getNotificationRadius()) || !this.level.getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX);
return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), (double) GameEvent.JUKEBOX_PLAY.getNotificationRadius()) || !this.level().getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX);
}
@@ -478,7 +491,7 @@
@@ -476,7 +489,7 @@
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.addAdditionalSaveData(nbttagcompound);
this.writeInventoryToTag(nbttagcompound);
- DataResult dataresult = VibrationListener.codec(this.vibrationListenerConfig).encodeStart(DynamicOpsNBT.INSTANCE, (VibrationListener) this.dynamicVibrationListener.getListener());
+ DataResult<net.minecraft.nbt.NBTBase> dataresult = VibrationListener.codec(this.vibrationListenerConfig).encodeStart(DynamicOpsNBT.INSTANCE, (VibrationListener) this.dynamicVibrationListener.getListener()); // CraftBukkit - decompile error
- DataResult dataresult = VibrationSystem.a.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.vibrationData);
+ DataResult<net.minecraft.nbt.NBTBase> dataresult = VibrationSystem.a.CODEC.encodeStart(DynamicOpsNBT.INSTANCE, this.vibrationData); // CraftBukkit - decompile error
Logger logger = Allay.LOGGER;
Objects.requireNonNull(logger);
@@ -494,7 +507,7 @@
@@ -492,7 +505,7 @@
super.readAdditionalSaveData(nbttagcompound);
this.readInventoryFromTag(nbttagcompound);
if (nbttagcompound.contains("listener", 10)) {
- DataResult dataresult = VibrationListener.codec(this.vibrationListenerConfig).parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("listener")));
+ DataResult<VibrationListener> dataresult = VibrationListener.codec(this.vibrationListenerConfig).parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("listener"))); // CraftBukkit - decompile error
- DataResult dataresult = VibrationSystem.a.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("listener")));
+ DataResult<VibrationSystem.a> dataresult = VibrationSystem.a.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("listener"))); // CraftBukkit - decompile error
Logger logger = Allay.LOGGER;
Objects.requireNonNull(logger);
@@ -527,7 +540,7 @@
@@ -525,7 +538,7 @@
return Allay.DUPLICATION_ITEM.test(itemstack);
}
- private void duplicateAllay() {
+ public Allay duplicateAllay() { // CraftBukkit - return allay and private -> public
Allay allay = (Allay) EntityTypes.ALLAY.create(this.level);
Allay allay = (Allay) EntityTypes.ALLAY.create(this.level());
if (allay != null) {
@@ -535,17 +548,17 @@
@@ -533,17 +546,17 @@
allay.setPersistenceRequired();
allay.resetDuplicationCooldown();
this.resetDuplicationCooldown();
- this.level.addFreshEntity(allay);
+ this.level.addFreshEntity(allay, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DUPLICATION); // CraftBukkit - reason for duplicated allay
- this.level().addFreshEntity(allay);
+ this.level().addFreshEntity(allay, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DUPLICATION); // CraftBukkit - reason for duplicated allay
}
-
+ return allay; // CraftBukkit

View File

@@ -26,7 +26,7 @@
if (itemstack.is(Items.BUCKET) && !this.isBaby()) {
+ // CraftBukkit start - Got milk?
+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level, entityhuman, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, enumhand);
+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level(), entityhuman, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, enumhand);
+
+ if (event.isCancelled()) {
+ return EnumInteractionResult.PASS;
@@ -37,4 +37,4 @@
+ ItemStack itemstack1 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
entityhuman.setItemInHand(enumhand, itemstack1);
return EnumInteractionResult.sidedSuccess(this.level.isClientSide);
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);

View File

@@ -17,7 +17,7 @@
protected EntityHorseAbstract(EntityTypes<? extends EntityHorseAbstract> entitytypes, World world) {
super(entitytypes, world);
@@ -338,7 +341,7 @@
@@ -334,7 +337,7 @@
public void createInventory() {
InventorySubcontainer inventorysubcontainer = this.inventory;
@@ -46,7 +46,7 @@
@@ -590,7 +593,7 @@
super.aiStep();
if (!this.level.isClientSide && this.isAlive()) {
if (!this.level().isClientSide && this.isAlive()) {
if (this.random.nextInt(900) == 0 && this.deathTime == 0) {
- this.heal(1.0F);
+ this.heal(1.0F, RegainReason.REGEN); // CraftBukkit

View File

@@ -1,22 +1,24 @@
--- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java
+++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java
@@ -75,12 +75,21 @@
@@ -82,14 +82,23 @@
public Sniffer(EntityTypes<? extends EntityAnimal> entitytypes, World world) {
super(entitytypes, world);
- this.entityData.define(Sniffer.DATA_STATE, Sniffer.a.IDLING);
- this.entityData.define(Sniffer.DATA_STATE, Sniffer.State.IDLING);
- this.entityData.define(Sniffer.DATA_DROP_SEED_AT_TICK, 0);
+ // this.entityData.define(Sniffer.DATA_STATE, Sniffer.a.IDLING); // CraftBukkit - moved down to appropriate location
+ // this.entityData.define(Sniffer.DATA_STATE, Sniffer.State.IDLING); // CraftBukkit - moved down to appropriate location
+ // this.entityData.define(Sniffer.DATA_DROP_SEED_AT_TICK, 0); // CraftBukkit - moved down to appropriate location
this.getNavigation().setCanFloat(true);
this.setPathfindingMalus(PathType.WATER, -2.0F);
this.setPathfindingMalus(PathType.WATER, -1.0F);
this.setPathfindingMalus(PathType.DANGER_POWDER_SNOW, -1.0F);
this.setPathfindingMalus(PathType.DAMAGE_CAUTIOUS, -1.0F);
}
+ // CraftBukkit start - SPIGOT-7295: moved from constructor to appropriate location
+ @Override
+ protected void defineSynchedData() {
+ super.defineSynchedData();
+ this.entityData.define(Sniffer.DATA_STATE, Sniffer.a.IDLING);
+ this.entityData.define(Sniffer.DATA_STATE, Sniffer.State.IDLING);
+ this.entityData.define(Sniffer.DATA_DROP_SEED_AT_TICK, 0);
+ }
+ // CraftBukkit end
@@ -24,67 +26,30 @@
@Override
protected float getStandingEyeHeight(EntityPose entitypose, EntitySize entitysize) {
return this.getDimensions(entitypose).height * 0.6F;
@@ -114,7 +123,7 @@
return BlockPosition.containing(vec3d.x(), this.getY(), vec3d.z());
}
@@ -270,6 +279,13 @@
ItemStack itemstack = (ItemStack) iterator.next();
EntityItem entityitem = new EntityItem(worldserver, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack);
- private Sniffer.a getState() {
+ public Sniffer.a getState() { // PAIL private -> public
return (Sniffer.a) this.entityData.get(Sniffer.DATA_STATE);
}
+ // CraftBukkit start - handle EntityDropItemEvent
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ continue;
+ }
+ // CraftBukkit end
entityitem.setDefaultPickUpDelay();
worldserver.addFreshEntity(entityitem);
}
@@ -309,7 +325,7 @@
List<GlobalPos> list = (List) this.getExploredPositions().limit(20L).collect(Collectors.toList());
@@ -207,7 +216,7 @@
return this;
}
- Optional<BlockPosition> calculateDigPosition() {
+ public Optional<BlockPosition> calculateDigPosition() { // PAIL public
return IntStream.range(0, 5).mapToObj((i) -> {
return LandRandomPos.getPos(this, 10 + 2 * i, 3);
}).filter(Objects::nonNull).map(BlockPosition::containing).map(BlockPosition::below).filter(this::canDig).findFirst();
@@ -218,7 +227,7 @@
return false;
}
- boolean canDig() {
+ public boolean canDig() { // PAIL public
return !this.isPanicking() && !this.isBaby() && !this.isInWater() && this.canDig(this.getHeadPosition().below());
}
@@ -245,6 +254,13 @@
BlockPosition blockposition = this.getHeadPosition();
EntityItem entityitem = new EntityItem(this.level, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack);
+ // CraftBukkit start - handle EntityDropItemEvent
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
entityitem.setDefaultPickUpDelay();
this.level.addFreshEntity(entityitem);
this.playSound(SoundEffects.SNIFFER_DROP_SEED, 1.0F, 1.0F);
@@ -274,15 +290,15 @@
return this;
}
- private Sniffer storeExploredPosition(BlockPosition blockposition) {
+ public Sniffer storeExploredPosition(BlockPosition blockposition) { // PAIL private -> public
List<BlockPosition> list = (List) this.getExploredPositions().limit(20L).collect(Collectors.toList());
list.add(0, blockposition);
list.add(0, GlobalPos.of(this.level().dimension(), blockposition));
- this.getBrain().setMemory(MemoryModuleType.SNIFFER_EXPLORED_POSITIONS, (Object) list);
+ this.getBrain().setMemory(MemoryModuleType.SNIFFER_EXPLORED_POSITIONS, list); // CraftBukkit - decompile error
return this;
}
- private Stream<BlockPosition> getExploredPositions() {
+ public Stream<BlockPosition> getExploredPositions() { // PAIL private -> public
return this.getBrain().getMemory(MemoryModuleType.SNIFFER_EXPLORED_POSITIONS).stream().flatMap(Collection::stream);
}
@@ -416,7 +432,7 @@
@@ -461,7 +477,7 @@
@Override
public BehaviorController<Sniffer> getBrain() {

View File

@@ -15,11 +15,11 @@
@@ -55,7 +60,11 @@
BlockPosition blockposition = this.blockPosition();
if (((WorldServer) this.level).dragonFight() != null && this.level.getBlockState(blockposition).isAir()) {
- this.level.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(this.level, blockposition));
if (((WorldServer) this.level()).getDragonFight() != null && this.level().getBlockState(blockposition).isAir()) {
- this.level().setBlockAndUpdate(blockposition, BlockFireAbstract.getState(this.level(), blockposition));
+ // CraftBukkit start
+ if (!CraftEventFactory.callBlockIgniteEvent(this.level, blockposition, this).isCancelled()) {
+ this.level.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(this.level, blockposition));
+ if (!CraftEventFactory.callBlockIgniteEvent(this.level(), blockposition, this).isCancelled()) {
+ this.level().setBlockAndUpdate(blockposition, BlockFireAbstract.getState(this.level(), blockposition));
+ }
+ // CraftBukkit end
}
@@ -28,7 +28,7 @@
@@ -95,11 +104,24 @@
return false;
} else {
if (!this.isRemoved() && !this.level.isClientSide) {
if (!this.isRemoved() && !this.level().isClientSide) {
+ // CraftBukkit start - All non-living entities need this
+ if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false)) {
+ return false;
@@ -38,15 +38,15 @@
if (!damagesource.is(DamageTypeTags.IS_EXPLOSION)) {
DamageSource damagesource1 = damagesource.getEntity() != null ? this.damageSources().explosion(this, damagesource.getEntity()) : null;
- this.level.explode(this, damagesource1, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), 6.0F, false, World.a.BLOCK);
- this.level().explode(this, damagesource1, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), 6.0F, false, World.a.BLOCK);
+ // CraftBukkit start
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 6.0F, false);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ this.unsetRemoved();
+ return false;
+ }
+ this.level.explode(this, damagesource1, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.BLOCK);
+ this.level().explode(this, damagesource1, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.BLOCK);
+ // CraftBukkit end
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java
+++ b/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java
@@ -51,6 +51,18 @@
@@ -51,6 +51,19 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
@@ -9,6 +9,7 @@
+import net.minecraft.world.level.Explosion;
+import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.entity.TileEntity;
+import net.minecraft.world.level.storage.loot.LootParams;
+import net.minecraft.world.level.storage.loot.LootTableInfo;
+import net.minecraft.world.level.storage.loot.parameters.LootContextParameters;
+import org.bukkit.craftbukkit.block.CraftBlock;
@@ -19,23 +20,23 @@
public class EntityEnderDragon extends EntityInsentient implements IMonster {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -87,6 +99,7 @@
private final PathPoint[] nodes = new PathPoint[24];
private final int[] nodeAdjacency = new int[24];
private final Path openSet = new Path();
@@ -88,6 +101,7 @@
private final PathPoint[] nodes;
private final int[] nodeAdjacency;
private final Path openSet;
+ private final Explosion explosionSource; // CraftBukkit - reusable source for CraftTNTPrimed.getSource()
public EntityEnderDragon(EntityTypes<? extends EntityEnderDragon> entitytypes, World world) {
super(EntityTypes.ENDER_DRAGON, world);
@@ -101,6 +114,7 @@
}
@@ -109,6 +123,7 @@
this.noPhysics = true;
this.noCulling = true;
this.phaseManager = new DragonControllerManager(this);
+ this.explosionSource = new Explosion(world, this, null, null, Double.NaN, Double.NaN, Double.NaN, Float.NaN, true, Explosion.Effect.DESTROY); // CraftBukkit
}
public static AttributeProvider.Builder createAttributes() {
@@ -234,7 +248,7 @@
public void setDragonFight(EnderDragonBattle enderdragonbattle) {
@@ -267,7 +282,7 @@
Vec3D vec3d1 = idragoncontroller.getFlyTargetLocation();
@@ -44,14 +45,14 @@
d0 = vec3d1.x - this.getX();
d1 = vec3d1.y - this.getY();
d2 = vec3d1.z - this.getZ();
@@ -375,7 +389,14 @@
@@ -408,7 +423,14 @@
if (this.nearestCrystal.isRemoved()) {
this.nearestCrystal = null;
} else if (this.tickCount % 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.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ this.setHealth((float) (this.getHealth() + event.getAmount()));
@@ -60,7 +61,7 @@
}
}
@@ -450,6 +471,9 @@
@@ -483,6 +505,9 @@
int j1 = MathHelper.floor(axisalignedbb.maxZ);
boolean flag = false;
boolean flag1 = false;
@@ -70,20 +71,20 @@
for (int k1 = i; k1 <= l; ++k1) {
for (int l1 = j; l1 <= i1; ++l1) {
@@ -459,7 +483,11 @@
@@ -492,7 +517,11 @@
if (!iblockdata.isAir() && !iblockdata.is(TagsBlock.DRAGON_TRANSPARENT)) {
if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.is(TagsBlock.DRAGON_IMMUNE)) {
- flag1 = this.level.removeBlock(blockposition, false) || flag1;
if (this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.is(TagsBlock.DRAGON_IMMUNE)) {
- flag1 = this.level().removeBlock(blockposition, false) || flag1;
+ // CraftBukkit start - Add blocks to list rather than destroying them
+ // flag1 = this.level.removeBlock(blockposition, false) || flag1;
+ // flag1 = this.level().removeBlock(blockposition, false) || flag1;
+ flag1 = true;
+ destroyedBlocks.add(CraftBlock.at(level, blockposition));
+ destroyedBlocks.add(CraftBlock.at(this.level(), blockposition));
+ // CraftBukkit end
} else {
flag = true;
}
@@ -468,6 +496,51 @@
@@ -501,6 +530,51 @@
}
}
@@ -103,7 +104,7 @@
+ } else if (event.getYield() == 0F) {
+ // Yield zero ==> no drops
+ for (org.bukkit.block.Block block : event.blockList()) {
+ this.level.removeBlock(new BlockPosition(block.getX(), block.getY(), block.getZ()), false);
+ this.level().removeBlock(new BlockPosition(block.getX(), block.getY(), block.getZ()), false);
+ }
+ } else {
+ for (org.bukkit.block.Block block : event.blockList()) {
@@ -117,17 +118,17 @@
+
+ Block nmsBlock = craftBlock.getNMS().getBlock();
+ if (nmsBlock.dropFromExplosion(explosionSource)) {
+ TileEntity tileentity = craftBlock.getNMS().hasBlockEntity() ? this.level.getBlockEntity(blockposition) : null;
+ LootTableInfo.Builder loottableinfo_builder = (new LootTableInfo.Builder((WorldServer) this.level)).withRandom(this.level.random).withParameter(LootContextParameters.ORIGIN, Vec3D.atCenterOf(blockposition)).withParameter(LootContextParameters.TOOL, ItemStack.EMPTY).withParameter(LootContextParameters.EXPLOSION_RADIUS, 1.0F / event.getYield()).withOptionalParameter(LootContextParameters.BLOCK_ENTITY, tileentity);
+ TileEntity tileentity = craftBlock.getNMS().hasBlockEntity() ? this.level().getBlockEntity(blockposition) : null;
+ LootParams.a loottableinfo_builder = (new LootParams.a((WorldServer) this.level())).withParameter(LootContextParameters.ORIGIN, Vec3D.atCenterOf(blockposition)).withParameter(LootContextParameters.TOOL, ItemStack.EMPTY).withParameter(LootContextParameters.EXPLOSION_RADIUS, 1.0F / event.getYield()).withOptionalParameter(LootContextParameters.BLOCK_ENTITY, tileentity);
+
+ craftBlock.getNMS().getDrops(loottableinfo_builder).forEach((itemstack) -> {
+ Block.popResource(level, blockposition, itemstack);
+ Block.popResource(this.level(), blockposition, itemstack);
+ });
+ craftBlock.getNMS().spawnAfterBreak((WorldServer) level, blockposition, ItemStack.EMPTY, false);
+ craftBlock.getNMS().spawnAfterBreak((WorldServer) this.level(), blockposition, ItemStack.EMPTY, false);
+ }
+ nmsBlock.wasExploded(level, blockposition, explosionSource);
+ nmsBlock.wasExploded(this.level(), blockposition, explosionSource);
+
+ this.level.removeBlock(blockposition, false);
+ this.level().removeBlock(blockposition, false);
+ }
+ }
+ // CraftBukkit end
@@ -135,7 +136,7 @@
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));
@@ -532,6 +605,21 @@
@@ -565,6 +639,21 @@
}
@@ -143,7 +144,7 @@
+ @Override
+ public int getExpReward() {
+ // CraftBukkit - Moved from #tickDeath method
+ boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT);
+ boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT);
+ short short0 = 500;
+
+ if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) {
@@ -157,13 +158,13 @@
@Override
protected void tickDeath() {
if (this.dragonFight != null) {
@@ -547,15 +635,20 @@
this.level.addParticle(Particles.EXPLOSION_EMITTER, this.getX() + (double) f, this.getY() + 2.0D + (double) f1, this.getZ() + (double) f2, 0.0D, 0.0D, 0.0D);
@@ -580,15 +669,20 @@
this.level().addParticle(Particles.EXPLOSION_EMITTER, this.getX() + (double) f, this.getY() + 2.0D + (double) f1, this.getZ() + (double) f2, 0.0D, 0.0D, 0.0D);
}
+ // CraftBukkit start - SPIGOT-2420: Moved up to #getExpReward method
+ /*
boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT);
boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT);
short short0 = 500;
if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) {
@@ -173,22 +174,22 @@
+ int short0 = expToDrop;
+ // CraftBukkit end
if (this.level instanceof WorldServer) {
if (this.level() instanceof WorldServer) {
- if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && flag) {
+ if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && true) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp
EntityExperienceOrb.award((WorldServer) this.level, this.position(), MathHelper.floor((float) short0 * 0.08F));
EntityExperienceOrb.award((WorldServer) this.level(), this.position(), MathHelper.floor((float) short0 * 0.08F));
}
@@ -566,7 +659,7 @@
@@ -599,7 +693,7 @@
this.move(EnumMoveType.SELF, new Vec3D(0.0D, 0.10000000149011612D, 0.0D));
if (this.dragonDeathTime == 200 && this.level instanceof WorldServer) {
if (this.dragonDeathTime == 200 && this.level() instanceof WorldServer) {
- if (flag) {
+ if (true) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp
EntityExperienceOrb.award((WorldServer) this.level, this.position(), MathHelper.floor((float) short0 * 0.2F));
EntityExperienceOrb.award((WorldServer) this.level(), this.position(), MathHelper.floor((float) short0 * 0.2F));
}
@@ -787,6 +880,7 @@
@@ -820,6 +914,7 @@
super.addAdditionalSaveData(nbttagcompound);
nbttagcompound.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId());
nbttagcompound.putInt("DragonDeathTime", this.dragonDeathTime);
@@ -196,7 +197,7 @@
}
@Override
@@ -800,6 +894,11 @@
@@ -833,6 +928,11 @@
this.dragonDeathTime = nbttagcompound.getInt("DragonDeathTime");
}

View File

@@ -22,7 +22,7 @@
+ (this.currentPhase == null) ? null : CraftEnderDragon.getBukkitPhase(this.currentPhase.getPhase()),
+ CraftEnderDragon.getBukkitPhase(dragoncontrollerphase)
+ );
+ this.dragon.level.getCraftServer().getPluginManager().callEvent(event);
+ this.dragon.level().getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return;
+ }
@@ -30,7 +30,7 @@
+ // CraftBukkit end
+
this.currentPhase = this.getPhase(dragoncontrollerphase);
if (!this.dragon.level.isClientSide) {
if (!this.dragon.level().isClientSide) {
this.dragon.getEntityData().set(EntityEnderDragon.DATA_PHASE, dragoncontrollerphase.getId());
@@ -45,6 +63,6 @@
this.phases[i] = dragoncontrollerphase.createInstance(this.dragon);

View File

@@ -22,22 +22,22 @@
i = this.getInvulnerableTicks() - 1;
this.bossEvent.setProgress(1.0F - (float) i / 220.0F);
if (i <= 0) {
- this.level.explode(this, this.getX(), this.getEyeY(), this.getZ(), 7.0F, false, World.a.MOB);
- this.level().explode(this, this.getX(), this.getEyeY(), this.getZ(), 7.0F, false, World.a.MOB);
+ // CraftBukkit start
+ // this.level.explode(this, this.getX(), this.getEyeY(), this.getZ(), 7.0F, false, World.a.MOB);
+ // this.level().explode(this, this.getX(), this.getEyeY(), this.getZ(), 7.0F, false, World.a.MOB);
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ this.level.explode(this, this.getX(), this.getEyeY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB);
+ this.level().explode(this, this.getX(), this.getEyeY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB);
+ }
+ // CraftBukkit end
+
if (!this.isSilent()) {
- this.level.globalLevelEvent(1023, this.blockPosition(), 0);
- this.level().globalLevelEvent(1023, this.blockPosition(), 0);
+ // CraftBukkit start - Use relative location for far away sounds
+ // this.world.globalLevelEvent(1023, new BlockPosition(this), 0);
+ int viewDistance = ((WorldServer) this.level).getCraftServer().getViewDistance() * 16;
+ // this.level().globalLevelEvent(1023, new BlockPosition(this), 0);
+ int viewDistance = ((WorldServer) this.level()).getCraftServer().getViewDistance() * 16;
+ for (EntityPlayer player : (List<EntityPlayer>) MinecraftServer.getServer().getPlayerList().players) {
+ double deltaX = this.getX() - player.getX();
+ double deltaZ = this.getZ() - player.getZ();
@@ -71,7 +71,7 @@
}
}
@@ -331,6 +368,11 @@
IBlockData iblockdata = this.level.getBlockState(blockposition);
IBlockData iblockdata = this.level().getBlockState(blockposition);
if (canDestroy(iblockdata)) {
+ // CraftBukkit start
@@ -79,7 +79,7 @@
+ continue;
+ }
+ // CraftBukkit end
flag = this.level.destroyBlock(blockposition, true, this) || flag;
flag = this.level().destroyBlock(blockposition, true, this) || flag;
}
}
@@ -344,7 +386,7 @@

View File

@@ -53,11 +53,13 @@
}
}
@@ -403,6 +426,22 @@
@@ -401,7 +424,25 @@
return false;
} else {
ItemStack itemstack2;
} else if (itemstack1.isEmpty() && (this.disabledSlots & 1 << enumitemslot.getFilterFlag() + 16) != 0) {
return false;
- } else if (entityhuman.getAbilities().instabuild && itemstack1.isEmpty() && !itemstack.isEmpty()) {
+ // CraftBukkit start
+ } else {
+ org.bukkit.inventory.ItemStack armorStandItem = CraftItemStack.asCraftMirror(itemstack1);
+ org.bukkit.inventory.ItemStack playerHeldItem = CraftItemStack.asCraftMirror(itemstack);
+
@@ -66,19 +68,28 @@
+
+ EquipmentSlot slot = CraftEquipmentSlot.getSlot(enumitemslot);
+ EquipmentSlot hand = CraftEquipmentSlot.getHand(enumhand);
+ PlayerArmorStandManipulateEvent armorStandManipulateEvent = new PlayerArmorStandManipulateEvent(player,self,playerHeldItem,armorStandItem,slot,hand);
+ this.level.getCraftServer().getPluginManager().callEvent(armorStandManipulateEvent);
+ PlayerArmorStandManipulateEvent armorStandManipulateEvent = new PlayerArmorStandManipulateEvent(player, self, playerHeldItem, armorStandItem, slot, hand);
+ this.level().getCraftServer().getPluginManager().callEvent(armorStandManipulateEvent);
+
+ if (armorStandManipulateEvent.isCancelled()) {
+ return true;
+ }
+
+ if (entityhuman.getAbilities().instabuild && itemstack1.isEmpty() && !itemstack.isEmpty()) {
+ // CraftBukkit end
this.setItemSlot(enumitemslot, itemstack.copyWithCount(1));
return true;
} else if (!itemstack.isEmpty() && itemstack.getCount() > 1) {
@@ -416,15 +457,26 @@
entityhuman.setItemInHand(enumhand, itemstack1);
return true;
}
+ } // CraftBukkit
}
if (entityhuman.getAbilities().instabuild && itemstack1.isEmpty() && !itemstack.isEmpty()) {
itemstack2 = itemstack.copy();
@@ -431,9 +470,19 @@
@Override
public boolean hurt(DamageSource damagesource, float f) {
if (!this.level.isClientSide && !this.isRemoved()) {
if (!this.level().isClientSide && !this.isRemoved()) {
if (damagesource.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
@@ -97,7 +108,7 @@
if (damagesource.is(DamageTypeTags.IS_EXPLOSION)) {
this.brokenByAnything(damagesource);
this.kill();
@@ -482,7 +531,7 @@
@@ -473,7 +525,7 @@
} else {
this.brokenByPlayer(damagesource);
this.showBreakingParticles();
@@ -106,11 +117,11 @@
}
return true;
@@ -550,13 +599,13 @@
@@ -541,13 +593,13 @@
itemstack.setHoverName(this.getCustomName());
}
- Block.popResource(this.level, this.blockPosition(), itemstack);
- Block.popResource(this.level(), this.blockPosition(), itemstack);
+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops
this.brokenByAnything(damagesource);
}
@@ -122,20 +133,20 @@
ItemStack itemstack;
int i;
@@ -564,7 +613,7 @@
@@ -555,7 +607,7 @@
for (i = 0; i < this.handItems.size(); ++i) {
itemstack = (ItemStack) this.handItems.get(i);
if (!itemstack.isEmpty()) {
- Block.popResource(this.level, this.blockPosition().above(), itemstack);
- Block.popResource(this.level(), this.blockPosition().above(), itemstack);
+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops
this.handItems.set(i, ItemStack.EMPTY);
}
}
@@ -572,10 +621,11 @@
@@ -563,10 +615,11 @@
for (i = 0; i < this.armorItems.size(); ++i) {
itemstack = (ItemStack) this.armorItems.get(i);
if (!itemstack.isEmpty()) {
- Block.popResource(this.level, this.blockPosition().above(), itemstack);
- Block.popResource(this.level(), this.blockPosition().above(), itemstack);
+ drops.add(org.bukkit.craftbukkit.inventory.CraftItemStack.asBukkitCopy(itemstack)); // CraftBukkit - add to drops
this.armorItems.set(i, ItemStack.EMPTY);
}
@@ -144,7 +155,7 @@
}
@@ -676,8 +726,16 @@
@@ -667,8 +720,16 @@
return this.isSmall();
}

View File

@@ -1,12 +1,11 @@
--- a/net/minecraft/world/entity/decoration/EntityHanging.java
+++ b/net/minecraft/world/entity/decoration/EntityHanging.java
@@ -26,6 +26,14 @@
@@ -26,6 +26,13 @@
import org.apache.commons.lang3.Validate;
import org.slf4j.Logger;
+// CraftBukkit start
+import net.minecraft.tags.DamageTypeTags;
+import net.minecraft.world.level.material.Material;
+import org.bukkit.entity.Hanging;
+import org.bukkit.event.hanging.HangingBreakByEntityEvent;
+import org.bukkit.event.hanging.HangingBreakEvent;
@@ -15,7 +14,7 @@
public abstract class EntityHanging extends Entity {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -60,26 +68,37 @@
@@ -60,26 +67,37 @@
protected void recalculateBoundingBox() {
if (this.direction != null) {
@@ -66,7 +65,7 @@
d8 = 1.0D;
} else {
d6 = 1.0D;
@@ -88,11 +107,12 @@
@@ -88,11 +106,12 @@
d6 /= 32.0D;
d7 /= 32.0D;
d8 /= 32.0D;
@@ -81,15 +80,15 @@
return i % 32 == 0 ? 0.5D : 0.0D;
}
@@ -103,6 +123,24 @@
@@ -103,6 +122,24 @@
if (this.checkInterval++ == 100) {
this.checkInterval = 0;
if (!this.isRemoved() && !this.survives()) {
+ // CraftBukkit start - fire break events
+ Material material = this.level.getBlockState(this.blockPosition()).getMaterial();
+ IBlockData material = this.level().getBlockState(this.blockPosition());
+ HangingBreakEvent.RemoveCause cause;
+
+ if (!material.equals(Material.AIR)) {
+ if (!material.isAir()) {
+ // TODO: This feels insufficient to catch 100% of suffocation cases
+ cause = HangingBreakEvent.RemoveCause.OBSTRUCTION;
+ } else {
@@ -97,7 +96,7 @@
+ }
+
+ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), cause);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (this.isRemoved() || event.isCancelled()) {
+ return;
@@ -106,10 +105,10 @@
this.discard();
this.dropItem((Entity) null);
}
@@ -166,6 +204,22 @@
@@ -166,6 +203,22 @@
return false;
} else {
if (!this.isRemoved() && !this.level.isClientSide) {
if (!this.isRemoved() && !this.level().isClientSide) {
+ // CraftBukkit start - fire break events
+ Entity damager = (damagesource.isIndirect()) ? damagesource.getEntity() : damagesource.getDirectEntity();
+ HangingBreakEvent event;
@@ -119,7 +118,7 @@
+ event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), damagesource.is(DamageTypeTags.IS_EXPLOSION) ? HangingBreakEvent.RemoveCause.EXPLOSION : HangingBreakEvent.RemoveCause.DEFAULT);
+ }
+
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (this.isRemoved() || event.isCancelled()) {
+ return true;
@@ -129,16 +128,16 @@
this.kill();
this.markHurt();
this.dropItem(damagesource.getEntity());
@@ -178,6 +232,18 @@
@@ -178,6 +231,18 @@
@Override
public void move(EnumMoveType enummovetype, Vec3D vec3d) {
if (!this.level.isClientSide && !this.isRemoved() && vec3d.lengthSqr() > 0.0D) {
if (!this.level().isClientSide && !this.isRemoved() && vec3d.lengthSqr() > 0.0D) {
+ if (this.isRemoved()) 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.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (this.isRemoved() || event.isCancelled()) {
+ return;
@@ -148,12 +147,12 @@
this.kill();
this.dropItem((Entity) null);
}
@@ -186,7 +252,7 @@
@@ -186,7 +251,7 @@
@Override
public void push(double d0, double d1, double d2) {
- if (!this.level.isClientSide && !this.isRemoved() && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
+ if (false && !this.level.isClientSide && !this.isRemoved() && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { // CraftBukkit - not needed
- if (!this.level().isClientSide && !this.isRemoved() && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
+ if (false && !this.level().isClientSide && !this.isRemoved() && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { // CraftBukkit - not needed
this.kill();
this.dropItem((Entity) null);
}

View File

@@ -52,7 +52,7 @@
@@ -173,6 +185,11 @@
return false;
} else if (!damagesource.is(DamageTypeTags.IS_EXPLOSION) && !this.getItem().isEmpty()) {
if (!this.level.isClientSide) {
if (!this.level().isClientSide) {
+ // CraftBukkit start - fire EntityDamageEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false) || this.isRemoved()) {
+ return true;
@@ -61,7 +61,7 @@
this.dropItem(damagesource.getEntity(), false);
this.gameEvent(GameEvent.BLOCK_CHANGE, damagesource.getEntity());
this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F);
@@ -302,6 +319,12 @@
@@ -302,13 +319,19 @@
}
public void setItem(ItemStack itemstack, boolean flag) {
@@ -72,9 +72,8 @@
+ public void setItem(ItemStack itemstack, boolean flag, boolean playSound) {
+ // CraftBukkit end
if (!itemstack.isEmpty()) {
itemstack = itemstack.copy();
itemstack.setCount(1);
@@ -309,7 +332,7 @@
itemstack = itemstack.copyWithCount(1);
}
this.onItemChanged(itemstack);
this.getEntityData().set(EntityItemFrame.DATA_ITEM, itemstack);

View File

@@ -9,17 +9,6 @@
public class EntityFallingBlock extends Entity {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -57,8 +59,8 @@
public boolean dropItem;
private boolean cancelDrop;
public boolean hurtEntities;
- private int fallDamageMax;
- private float fallDamagePerDistance;
+ public int fallDamageMax;
+ public float fallDamagePerDistance;
@Nullable
public NBTTagCompound blockData;
protected static final DataWatcherObject<BlockPosition> DATA_START_POS = DataWatcher.defineId(EntityFallingBlock.class, DataWatcherRegistry.BLOCK_POS);
@@ -83,10 +85,17 @@
}
@@ -49,24 +38,15 @@
+ return;
+ }
+ // CraftBukkit end
if (this.level.setBlock(blockposition, this.blockState, 3)) {
((WorldServer) this.level).getChunkSource().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level.getBlockState(blockposition)));
if (this.level().setBlock(blockposition, this.blockState, 3)) {
((WorldServer) this.level()).getChunkSource().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level().getBlockState(blockposition)));
this.discard();
@@ -239,7 +254,7 @@
if (i < 0) {
return false;
} else {
- Predicate predicate;
+ Predicate<Entity> predicate; // CraftBukkit - decompile error
DamageSource damagesource1;
if (this.blockState.getBlock() instanceof Fallable) {
@@ -255,7 +270,9 @@
float f2 = (float) Math.min(MathHelper.floor((float) i * this.fallDamagePerDistance), this.fallDamageMax);
this.level.getEntities((Entity) this, this.getBoundingBox(), predicate).forEach((entity) -> {
this.level().getEntities((Entity) this, this.getBoundingBox(), predicate).forEach((entity) -> {
+ CraftEventFactory.entityDamage = this; // CraftBukkit
entity.hurt(damagesource1, f2);
entity.hurt(damagesource2, f2);
+ CraftEventFactory.entityDamage = null; // CraftBukkit
});
boolean flag = this.blockState.is(TagsBlock.ANVIL);

View File

@@ -48,11 +48,11 @@
+ // CraftBukkit end */
this.hasImpulse |= this.updateInWaterStateAndDoFluidPushing();
if (!this.level.isClientSide) {
if (!this.level().isClientSide) {
@@ -176,6 +188,12 @@
}
if (!this.level.isClientSide && this.age >= 6000) {
if (!this.level().isClientSide && this.age >= 6000) {
+ // CraftBukkit start - fire ItemDespawnEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled()) {
+ this.age = 0;
@@ -62,7 +62,7 @@
this.discard();
}
@@ -251,10 +269,11 @@
@@ -255,10 +273,11 @@
private static void merge(EntityItem entityitem, ItemStack itemstack, ItemStack itemstack1) {
ItemStack itemstack2 = merge(itemstack, itemstack1, 64);
@@ -75,8 +75,8 @@
merge(entityitem, itemstack, itemstack1);
entityitem.pickupDelay = Math.max(entityitem.pickupDelay, entityitem1.pickupDelay);
entityitem.age = Math.min(entityitem.age, entityitem1.age);
@@ -280,6 +299,11 @@
} else if (this.level.isClientSide) {
@@ -284,6 +303,11 @@
} else if (this.level().isClientSide) {
return true;
} else {
+ // CraftBukkit start
@@ -87,7 +87,7 @@
this.markHurt();
this.health = (int) ((float) this.health - f);
this.gameEvent(GameEvent.ENTITY_DAMAGE, damagesource.getEntity());
@@ -343,6 +367,46 @@
@@ -347,6 +371,46 @@
Item item = itemstack.getItem();
int i = itemstack.getCount();
@@ -100,7 +100,7 @@
+ // Call legacy event
+ PlayerPickupItemEvent playerEvent = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
+ playerEvent.setCancelled(!playerEvent.getPlayer().getCanPickupItems());
+ this.level.getCraftServer().getPluginManager().callEvent(playerEvent);
+ this.level().getCraftServer().getPluginManager().callEvent(playerEvent);
+ if (playerEvent.isCancelled()) {
+ itemstack.setCount(i); // SPIGOT-5294 - restore count
+ return;
@@ -109,7 +109,7 @@
+ // Call newer event afterwards
+ EntityPickupItemEvent entityEvent = new EntityPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
+ entityEvent.setCancelled(!entityEvent.getEntity().getCanPickupItems());
+ this.level.getCraftServer().getPluginManager().callEvent(entityEvent);
+ this.level().getCraftServer().getPluginManager().callEvent(entityEvent);
+ if (entityEvent.isCancelled()) {
+ itemstack.setCount(i); // SPIGOT-5294 - restore count
+ return;
@@ -134,7 +134,7 @@
if (this.pickupDelay == 0 && (this.target == null || this.target.equals(entityhuman.getUUID())) && entityhuman.getInventory().add(itemstack)) {
entityhuman.take(this, i);
if (itemstack.isEmpty()) {
@@ -386,7 +450,9 @@
@@ -390,7 +454,9 @@
}
public void setItem(ItemStack itemstack) {

View File

@@ -24,14 +24,14 @@
- this.discard();
+ // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event
+ // this.discard();
if (!this.level.isClientSide) {
if (!this.level().isClientSide) {
this.explode();
}
+ this.discard();
+ // CraftBukkit end
} else {
this.updateInWaterStateAndDoFluidPushing();
if (this.level.isClientSide) {
if (this.level().isClientSide) {
@@ -85,9 +92,16 @@
}
@@ -40,12 +40,12 @@
+ // CraftBukkit start
+ // float f = 4.0F;
- this.level.explode(this, this.getX(), this.getY(0.0625D), this.getZ(), 4.0F, World.a.TNT);
- this.level().explode(this, this.getX(), this.getY(0.0625D), this.getZ(), 4.0F, World.a.TNT);
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity());
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ this.level.explode(this, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT);
+ this.level().explode(this, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT);
+ }
+ // CraftBukkit end
}

View File

@@ -35,19 +35,19 @@
protected EnumInteractionResult mobInteract(EntityHuman entityhuman, EnumHand enumhand) {
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
@@ -250,10 +266,18 @@
if (!this.level.isClientSide) {
if (!this.level().isClientSide) {
float f = this.isPowered() ? 2.0F : 1.0F;
- this.dead = true;
- this.level.explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, World.a.MOB);
- this.level().explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, World.a.MOB);
- this.discard();
- this.spawnLingeringCloud();
+ // CraftBukkit start
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), this.explosionRadius * f, false);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ this.dead = true;
+ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB);
+ this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB);
+ this.discard();
+ this.spawnLingeringCloud();
+ } else {
@@ -59,7 +59,7 @@
}
@@ -264,6 +288,7 @@
if (!collection.isEmpty()) {
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level, this.getX(), this.getY(), this.getZ());
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ());
+ entityareaeffectcloud.setOwner(this); // CraftBukkit
entityareaeffectcloud.setRadius(2.5F);
@@ -69,8 +69,8 @@
entityareaeffectcloud.addEffect(new MobEffect(mobeffect));
}
- this.level.addFreshEntity(entityareaeffectcloud);
+ this.level.addFreshEntity(entityareaeffectcloud, CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit
- this.level().addFreshEntity(entityareaeffectcloud);
+ this.level().addFreshEntity(entityareaeffectcloud, CreatureSpawnEvent.SpawnReason.EXPLOSION); // CraftBukkit
}
}

View File

@@ -4,8 +4,8 @@
@Override
public void performRangedAttack(EntityLiving entityliving, float f) {
- EntityThrownTrident entitythrowntrident = new EntityThrownTrident(this.level, this, new ItemStack(Items.TRIDENT));
+ EntityThrownTrident entitythrowntrident = new EntityThrownTrident(this.level, this, this.getItemInHand(net.minecraft.world.entity.projectile.ProjectileHelper.getWeaponHoldingHand(this, Items.TRIDENT))); // CraftBukkit - Use Trident in hand like skeletons (SPIGOT-7025)
- EntityThrownTrident entitythrowntrident = new EntityThrownTrident(this.level(), this, new ItemStack(Items.TRIDENT));
+ EntityThrownTrident entitythrowntrident = new EntityThrownTrident(this.level(), this, this.getItemInHand(net.minecraft.world.entity.projectile.ProjectileHelper.getWeaponHoldingHand(this, Items.TRIDENT))); // CraftBukkit - Use Trident in hand like skeletons (SPIGOT-7025)
double d0 = entityliving.getX() - this.getX();
double d1 = entityliving.getY(0.3333333333333333D) - entitythrowntrident.getY();
double d2 = entityliving.getZ() - this.getZ();

View File

@@ -29,7 +29,7 @@
@@ -487,9 +498,13 @@
if (iblockdata2 != null) {
iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level, blockposition);
iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level(), blockposition);
if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) {
+ // CraftBukkit start - Place event
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.enderman, blockposition, iblockdata2).isCancelled()) {

View File

@@ -4,8 +4,8 @@
super.customServerAiStep();
if ((this.tickCount + this.getId()) % 1200 == 0) {
MobEffect mobeffect = new MobEffect(MobEffects.DIG_SLOWDOWN, 6000, 2);
- List<EntityPlayer> list = MobEffectUtil.addEffectToPlayersAround((WorldServer) this.level, this, this.position(), 50.0D, mobeffect, 1200);
+ List<EntityPlayer> list = MobEffectUtil.addEffectToPlayersAround((WorldServer) this.level, this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
- List<EntityPlayer> list = MobEffectUtil.addEffectToPlayersAround((WorldServer) this.level(), this, this.position(), 50.0D, mobeffect, 1200);
+ List<EntityPlayer> list = MobEffectUtil.addEffectToPlayersAround((WorldServer) this.level(), this, this.position(), 50.0D, mobeffect, 1200, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
list.forEach((entityplayer) -> {
entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.GUARDIAN_ELDER_EFFECT, this.isSilent() ? 0.0F : 1.0F));

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/monster/EntityPhantom.java
+++ b/net/minecraft/world/entity/monster/EntityPhantom.java
@@ -538,14 +538,14 @@
List<EntityHuman> list = EntityPhantom.this.level.getNearbyPlayers(this.attackTargeting, EntityPhantom.this, EntityPhantom.this.getBoundingBox().inflate(16.0D, 64.0D, 16.0D));
List<EntityHuman> list = EntityPhantom.this.level().getNearbyPlayers(this.attackTargeting, EntityPhantom.this, EntityPhantom.this.getBoundingBox().inflate(16.0D, 64.0D, 16.0D));
if (!list.isEmpty()) {
- list.sort(Comparator.comparing(Entity::getY).reversed());

View File

@@ -30,9 +30,9 @@
public void startPersistentAngerTimer() {
- this.setRemainingPersistentAngerTime(EntityPigZombie.PERSISTENT_ANGER_TIME.sample(this.random));
+ // CraftBukkit start
+ Entity entity = ((WorldServer) this.level).getEntity(getPersistentAngerTarget());
+ Entity entity = ((WorldServer) this.level()).getEntity(getPersistentAngerTarget());
+ org.bukkit.event.entity.PigZombieAngerEvent event = new org.bukkit.event.entity.PigZombieAngerEvent((org.bukkit.entity.PigZombie) this.getBukkitEntity(), (entity == null) ? null : entity.getBukkitEntity(), EntityPigZombie.PERSISTENT_ANGER_TIME.sample(this.random));
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ this.setPersistentAngerTarget(null);
+ return;

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/entity/monster/EntityRavager.java
+++ b/net/minecraft/world/entity/monster/EntityRavager.java
@@ -170,7 +170,7 @@
IBlockData iblockdata = this.level.getBlockState(blockposition);
IBlockData iblockdata = this.level().getBlockState(blockposition);
Block block = iblockdata.getBlock();
- if (block instanceof BlockLeaves) {
+ if (block instanceof BlockLeaves && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState()).isCancelled()) { // CraftBukkit
flag = this.level.destroyBlock(blockposition, true, this) || flag;
flag = this.level().destroyBlock(blockposition, true, this) || flag;
}
}

View File

@@ -18,8 +18,8 @@
if (enumdirection != null) {
+ // CraftBukkit start
+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), CraftLocation.toBukkit(blockposition1, this.level.getWorld()));
+ this.level.getCraftServer().getPluginManager().callEvent(teleport);
+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), this.getBukkitEntity().getLocation(), CraftLocation.toBukkit(blockposition1, this.level().getWorld()));
+ this.level().getCraftServer().getPluginManager().callEvent(teleport);
+ if (!teleport.isCancelled()) {
+ Location to = teleport.getTo();
+ blockposition1 = BlockPosition.containing(to.getX(), to.getY(), to.getZ());
@@ -34,8 +34,8 @@
if (entityshulker != null) {
entityshulker.setVariant(this.getVariant());
entityshulker.moveTo(vec3d);
- this.level.addFreshEntity(entityshulker);
+ this.level.addFreshEntity(entityshulker, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - the mysteries of life
- this.level().addFreshEntity(entityshulker);
+ this.level().addFreshEntity(entityshulker, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - the mysteries of life
}
}

View File

@@ -7,5 +7,5 @@
- this.convertTo(EntityTypes.STRAY, true);
+ this.convertTo(EntityTypes.STRAY, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.FROZEN, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.FROZEN); // CraftBukkit - add spawn and transform reasons
if (!this.isSilent()) {
this.level.levelEvent((EntityHuman) null, 1048, this.blockPosition(), 0);
this.level().levelEvent((EntityHuman) null, 1048, this.blockPosition(), 0);
}

View File

@@ -3,7 +3,7 @@
@@ -200,8 +200,19 @@
double d3 = Math.sqrt(d0 * d0 + d2 * d2);
entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.level.getDifficulty().getId() * 4));
entityarrow.shoot(d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - this.level().getDifficulty().getId() * 4));
+ // CraftBukkit start
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getMainHandItem(), null, entityarrow, net.minecraft.world.EnumHand.MAIN_HAND, 0.8F, true);
+ if (event.isCancelled()) {
@@ -12,12 +12,12 @@
+ }
+
+ if (event.getProjectile() == entityarrow.getBukkitEntity()) {
+ level.addFreshEntity(entityarrow);
+ this.level().addFreshEntity(entityarrow);
+ }
+ // CraftBukkit end
this.playSound(SoundEffects.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));
- this.level.addFreshEntity(entityarrow);
+ // this.level.addFreshEntity(entityarrow); // CraftBukkit - moved up
- this.level().addFreshEntity(entityarrow);
+ // this.level().addFreshEntity(entityarrow); // CraftBukkit - moved up
}
protected EntityArrow getArrow(ItemStack itemstack, float f) {

View File

@@ -30,7 +30,7 @@
+ // CraftBukkit start
+ SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), k);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled() && event.getCount() > 0) {
+ k = event.getCount();
@@ -48,7 +48,7 @@
entityslime.setInvulnerable(this.isInvulnerable());
entityslime.setSize(j, true);
entityslime.moveTo(this.getX() + (double) f1, this.getY() + 0.5D, this.getZ() + (double) f2, this.random.nextFloat() * 360.0F, 0.0F);
- this.level.addFreshEntity(entityslime);
- this.level().addFreshEntity(entityslime);
+ slimes.add(entityslime); // CraftBukkit
}
}
@@ -58,7 +58,7 @@
+ return;
+ }
+ for (EntityLiving living : slimes) {
+ this.level.addFreshEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
+ this.level().addFreshEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
+ }
+ // CraftBukkit end
}

View File

@@ -26,7 +26,7 @@
super(entitytypes, world);
@@ -202,7 +212,10 @@
public void tick() {
if (!this.level.isClientSide && this.isAlive() && !this.isNoAi()) {
if (!this.level().isClientSide && this.isAlive() && !this.isNoAi()) {
if (this.isUnderWaterConverting()) {
- --this.conversionTime;
+ // CraftBukkit start - Use wall time instead of ticks for conversion
@@ -60,7 +60,7 @@
+ EntityZombie entityzombie = (EntityZombie) this.convertTo(entitytypes, true, EntityTransformEvent.TransformReason.DROWNED, CreatureSpawnEvent.SpawnReason.DROWNED);
if (entityzombie != null) {
entityzombie.handleAttributes(entityzombie.level.getCurrentDifficultyAt(entityzombie.blockPosition()).getSpecialMultiplier());
entityzombie.handleAttributes(entityzombie.level().getCurrentDifficultyAt(entityzombie.blockPosition()).getSpecialMultiplier());
entityzombie.setCanBreakDoors(entityzombie.supportsBreakDoorGoal() && this.canBreakDoors());
+ // CraftBukkit start - SPIGOT-5208: End conversion to stop event spam
+ } else {
@@ -70,25 +70,25 @@
}
@@ -308,9 +327,9 @@
if (SpawnerCreature.isSpawnPositionOk(entitypositiontypes_surface, this.level, blockposition, entitytypes) && EntityPositionTypes.checkSpawnRules(entitytypes, worldserver, EnumMobSpawn.REINFORCEMENT, blockposition, this.level.random)) {
if (SpawnerCreature.isSpawnPositionOk(entitypositiontypes_surface, this.level(), blockposition, entitytypes) && EntityPositionTypes.checkSpawnRules(entitytypes, worldserver, EnumMobSpawn.REINFORCEMENT, blockposition, this.level().random)) {
entityzombie.setPos((double) i1, (double) j1, (double) k1);
if (!this.level.hasNearbyAlivePlayer((double) i1, (double) j1, (double) k1, 7.0D) && this.level.isUnobstructed(entityzombie) && this.level.noCollision((Entity) entityzombie) && !this.level.containsAnyLiquid(entityzombie.getBoundingBox())) {
if (!this.level().hasNearbyAlivePlayer((double) i1, (double) j1, (double) k1, 7.0D) && this.level().isUnobstructed(entityzombie) && this.level().noCollision((Entity) entityzombie) && !this.level().containsAnyLiquid(entityzombie.getBoundingBox())) {
- entityzombie.setTarget(entityliving);
+ entityzombie.setTarget(entityliving, EntityTargetEvent.TargetReason.REINFORCEMENT_TARGET, true); // CraftBukkit
entityzombie.finalizeSpawn(worldserver, this.level.getCurrentDifficultyAt(entityzombie.blockPosition()), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (NBTTagCompound) null);
entityzombie.finalizeSpawn(worldserver, this.level().getCurrentDifficultyAt(entityzombie.blockPosition()), EnumMobSpawn.REINFORCEMENT, (GroupDataEntity) null, (NBTTagCompound) null);
- worldserver.addFreshEntityWithPassengers(entityzombie);
+ worldserver.addFreshEntityWithPassengers(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit
this.getAttribute(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE).addPermanentModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION));
entityzombie.getAttribute(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE).addPermanentModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, AttributeModifier.Operation.ADDITION));
break;
@@ -331,7 +350,14 @@
float f = this.level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty();
float f = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty();
if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < f * 0.3F) {
- entity.setSecondsOnFire(2 * (int) f);
+ // CraftBukkit start
+ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 2 * (int) f); // PAIL: fixme
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ entity.setSecondsOnFire(event.getDuration(), false);

View File

@@ -2,7 +2,7 @@
+++ b/net/minecraft/world/entity/monster/EntityZombieHusk.java
@@ -58,7 +58,7 @@
if (flag && this.getMainHandItem().isEmpty() && entity instanceof EntityLiving) {
float f = this.level.getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty();
float f = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty();
- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.HUNGER, 140 * (int) f), this);
+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.HUNGER, 140 * (int) f), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit

View File

@@ -33,7 +33,7 @@
Objects.requireNonNull(logger);
@@ -138,6 +146,10 @@
public void tick() {
if (!this.level.isClientSide && this.isAlive() && this.isConverting()) {
if (!this.level().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;
@@ -55,12 +55,12 @@
this.villagerConversionTime = i;
this.getEntityData().set(EntityZombieVillager.DATA_CONVERTING_ID, true);
- this.removeEffect(MobEffects.WEAKNESS);
- this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level.getDifficulty().getId() - 1, 0)));
- this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level().getDifficulty().getId() - 1, 0)));
+ // CraftBukkit start
+ this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
+ this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level.getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
+ this.addEffect(new MobEffect(MobEffects.DAMAGE_BOOST, i, Math.min(this.level().getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION);
+ // CraftBukkit end
this.level.broadcastEntityEvent(this, (byte) 16);
this.level().broadcastEntityEvent(this, (byte) 16);
}
@@ -207,7 +222,13 @@

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/piglin/EntityPiglin.java
+++ b/net/minecraft/world/entity/monster/piglin/EntityPiglin.java
@@ -56,6 +56,18 @@
@@ -55,6 +55,18 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData;
@@ -19,7 +19,7 @@
public class EntityPiglin extends EntityPiglinAbstract implements ICrossbow, InventoryCarrier {
private static final DataWatcherObject<Boolean> DATA_BABY_ID = DataWatcher.defineId(EntityPiglin.class, DataWatcherRegistry.BOOLEAN);
@@ -76,6 +88,10 @@
@@ -75,6 +87,10 @@
public boolean cannotHunt;
protected static final ImmutableList<SensorType<? extends Sensor<? super EntityPiglin>>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.NEAREST_ITEMS, SensorType.HURT_BY, SensorType.PIGLIN_SPECIFIC_SENSOR);
protected static final ImmutableList<MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.DOORS_TO_CLOSE, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ADULT_PIGLINS, MemoryModuleType.NEARBY_ADULT_PIGLINS, MemoryModuleType.NEAREST_VISIBLE_WANTED_ITEM, MemoryModuleType.ITEM_PICKUP_COOLDOWN_TICKS, MemoryModuleType.HURT_BY, MemoryModuleType.HURT_BY_ENTITY, new MemoryModuleType[]{MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.INTERACTION_TARGET, MemoryModuleType.PATH, MemoryModuleType.ANGRY_AT, MemoryModuleType.UNIVERSAL_ANGER, MemoryModuleType.AVOID_TARGET, MemoryModuleType.ADMIRING_ITEM, MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM, MemoryModuleType.ADMIRING_DISABLED, MemoryModuleType.DISABLE_WALK_TO_ADMIRE_ITEM, MemoryModuleType.CELEBRATE_LOCATION, MemoryModuleType.DANCING, MemoryModuleType.HUNTED_RECENTLY, MemoryModuleType.NEAREST_VISIBLE_BABY_HOGLIN, MemoryModuleType.NEAREST_VISIBLE_NEMESIS, MemoryModuleType.NEAREST_VISIBLE_ZOMBIFIED, MemoryModuleType.RIDE_TARGET, MemoryModuleType.VISIBLE_ADULT_PIGLIN_COUNT, MemoryModuleType.VISIBLE_ADULT_HOGLIN_COUNT, MemoryModuleType.NEAREST_VISIBLE_HUNTABLE_HOGLIN, MemoryModuleType.NEAREST_TARGETABLE_PLAYER_NOT_WEARING_GOLD, MemoryModuleType.NEAREST_PLAYER_HOLDING_WANTED_ITEM, MemoryModuleType.ATE_RECENTLY, MemoryModuleType.NEAREST_REPELLENT});
@@ -30,7 +30,7 @@
public EntityPiglin(EntityTypes<? extends EntityPiglinAbstract> entitytypes, World world) {
super(entitytypes, world);
@@ -94,6 +110,14 @@
@@ -93,6 +109,14 @@
}
this.writeInventoryToTag(nbttagcompound);
@@ -45,7 +45,7 @@
}
@Override
@@ -102,6 +126,10 @@
@@ -101,6 +125,10 @@
this.setBaby(nbttagcompound.getBoolean("IsBaby"));
this.setCannotHunt(nbttagcompound.getBoolean("CannotHunt"));
this.readInventoryFromTag(nbttagcompound);
@@ -56,7 +56,7 @@
}
@VisibleForDebug
@@ -223,7 +251,7 @@
@@ -220,7 +248,7 @@
@Override
public BehaviorController<EntityPiglin> getBrain() {
@@ -65,7 +65,7 @@
}
@Override
@@ -368,7 +396,7 @@
@@ -365,7 +393,7 @@
}
protected void holdInOffHand(ItemStack itemstack) {
@@ -74,7 +74,7 @@
this.setItemSlot(EnumItemSlot.OFFHAND, itemstack);
this.setGuaranteedDrop(EnumItemSlot.OFFHAND);
} else {
@@ -394,8 +422,8 @@
@@ -391,8 +419,8 @@
if (EnchantmentManager.hasBindingCurse(itemstack1)) {
return false;
} else {
@@ -85,12 +85,12 @@
return flag && !flag1 ? true : (!flag && flag1 ? false : (this.isAdult() && !itemstack.is(Items.CROSSBOW) && itemstack1.is(Items.CROSSBOW) ? false : super.canReplaceCurrentItem(itemstack, itemstack1)));
}
@@ -424,7 +452,7 @@
@@ -421,7 +449,7 @@
@Override
protected SoundEffect getAmbientSound() {
- return this.level.isClientSide ? null : (SoundEffect) PiglinAI.getSoundForCurrentActivity(this).orElse((Object) null);
+ return this.level.isClientSide ? null : (SoundEffect) PiglinAI.getSoundForCurrentActivity(this).orElse(null); // CraftBukkit - Decompile error
- return this.level().isClientSide ? null : (SoundEffect) PiglinAI.getSoundForCurrentActivity(this).orElse((Object) null);
+ return this.level().isClientSide ? null : (SoundEffect) PiglinAI.getSoundForCurrentActivity(this).orElse(null); // CraftBukkit - Decompile error
}
@Override

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/warden/Warden.java
+++ b/net/minecraft/world/entity/monster/warden/Warden.java
@@ -370,7 +370,7 @@
@@ -371,7 +371,7 @@
@Override
public BehaviorController<Warden> getBrain() {
@@ -9,7 +9,7 @@
}
@Override
@@ -421,13 +421,13 @@
@@ -412,13 +412,13 @@
public static void applyDarknessAround(WorldServer worldserver, Vec3D vec3d, @Nullable Entity entity, int i) {
MobEffect mobeffect = new MobEffect(MobEffects.DARKNESS, 260, 0, false, false);
@@ -25,7 +25,7 @@
Logger logger = Warden.LOGGER;
Objects.requireNonNull(logger);
@@ -452,7 +452,7 @@
@@ -443,7 +443,7 @@
dataresult = AngerManagement.codec(this::canTargetEntity).parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.get("anger")));
logger = Warden.LOGGER;
Objects.requireNonNull(logger);
@@ -34,16 +34,16 @@
this.angerManagement = angermanagement;
});
this.syncClientAngerLevel();
@@ -462,7 +462,7 @@
dataresult = VibrationListener.codec(this).parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("listener")));
@@ -453,7 +453,7 @@
dataresult = VibrationSystem.a.CODEC.parse(new Dynamic(DynamicOpsNBT.INSTANCE, nbttagcompound.getCompound("listener")));
logger = Warden.LOGGER;
Objects.requireNonNull(logger);
- dataresult.resultOrPartial(logger::error).ifPresent((vibrationlistener) -> {
+ ((DataResult<VibrationListener>) dataresult).resultOrPartial(logger::error).ifPresent((vibrationlistener) -> { // CraftBukkit - decompile error
this.dynamicGameEventListener.updateListener(vibrationlistener, this.level);
- dataresult.resultOrPartial(logger::error).ifPresent((vibrationsystem_a) -> {
+ ((DataResult<VibrationSystem.a>) dataresult).resultOrPartial(logger::error).ifPresent((vibrationsystem_a) -> { // CraftBukkit - decompile error
this.vibrationData = vibrationsystem_a;
});
}
@@ -496,7 +496,7 @@
@@ -487,7 +487,7 @@
public void increaseAngerAt(@Nullable Entity entity, int i, boolean flag) {
if (!this.isNoAi() && this.canTargetEntity(entity)) {
WardenAi.setDigCooldown(this);
@@ -52,7 +52,7 @@
int j = this.angerManagement.increaseAnger(entity, i);
if (entity instanceof EntityHuman && flag1 && AngerLevel.byAnger(j).isAngry()) {
@@ -517,7 +517,7 @@
@@ -508,7 +508,7 @@
@Nullable
@Override
public EntityLiving getTarget() {
@@ -61,7 +61,7 @@
}
@Override
@@ -560,7 +560,7 @@
@@ -551,7 +551,7 @@
public void setAttackTarget(EntityLiving entityliving) {
this.getBrain().eraseMemory(MemoryModuleType.ROAR_TARGET);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/npc/EntityVillager.java
+++ b/net/minecraft/world/entity/npc/EntityVillager.java
@@ -90,6 +90,14 @@
@@ -91,6 +91,14 @@
import net.minecraft.world.phys.AxisAlignedBB;
import org.slf4j.Logger;
@@ -15,7 +15,7 @@
public class EntityVillager extends EntityVillagerAbstract implements ReputationHandler, VillagerDataHolder {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -148,7 +156,7 @@
@@ -149,7 +157,7 @@
@Override
public BehaviorController<EntityVillager> getBrain() {
@@ -24,7 +24,7 @@
}
@Override
@@ -231,7 +239,7 @@
@@ -232,7 +240,7 @@
this.increaseProfessionLevelOnUpdate = false;
}
@@ -33,7 +33,7 @@
}
}
@@ -359,7 +367,13 @@
@@ -360,7 +368,13 @@
while (iterator.hasNext()) {
MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
@@ -48,7 +48,7 @@
}
this.resendOffersToTradingPlayer();
@@ -428,7 +442,13 @@
@@ -429,7 +443,13 @@
while (iterator.hasNext()) {
MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
@@ -63,7 +63,7 @@
}
}
@@ -488,7 +508,7 @@
@@ -489,7 +509,7 @@
@Override
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.addAdditionalSaveData(nbttagcompound);
@@ -72,7 +72,7 @@
Logger logger = EntityVillager.LOGGER;
Objects.requireNonNull(logger);
@@ -832,7 +852,12 @@
@@ -833,7 +853,12 @@
}
entitywitch.setPersistenceRequired();
@@ -86,7 +86,7 @@
this.releaseAllPois();
this.discard();
} else {
@@ -921,7 +946,7 @@
@@ -924,7 +949,7 @@
}).limit(5L).collect(Collectors.toList());
if (list1.size() >= j) {
@@ -95,21 +95,21 @@
list.forEach(SensorGolemLastSeen::golemDetected);
}
}
@@ -978,7 +1003,7 @@
@@ -981,7 +1006,7 @@
@Override
public void startSleeping(BlockPosition blockposition) {
super.startSleeping(blockposition);
- this.brain.setMemory(MemoryModuleType.LAST_SLEPT, (Object) this.level.getGameTime());
+ this.brain.setMemory(MemoryModuleType.LAST_SLEPT, this.level.getGameTime()); // CraftBukkit - decompile error
- this.brain.setMemory(MemoryModuleType.LAST_SLEPT, (Object) this.level().getGameTime());
+ this.brain.setMemory(MemoryModuleType.LAST_SLEPT, this.level().getGameTime()); // CraftBukkit - decompile error
this.brain.eraseMemory(MemoryModuleType.WALK_TARGET);
this.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
}
@@ -986,7 +1011,7 @@
@@ -989,7 +1014,7 @@
@Override
public void stopSleeping() {
super.stopSleeping();
- this.brain.setMemory(MemoryModuleType.LAST_WOKEN, (Object) this.level.getGameTime());
+ this.brain.setMemory(MemoryModuleType.LAST_WOKEN, this.level.getGameTime()); // CraftBukkit - decompile error
- this.brain.setMemory(MemoryModuleType.LAST_WOKEN, (Object) this.level().getGameTime());
+ this.brain.setMemory(MemoryModuleType.LAST_WOKEN, this.level().getGameTime()); // CraftBukkit - decompile error
}
private boolean golemSpawnConditionsMet(long i) {

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/npc/EntityVillagerTrader.java
+++ b/net/minecraft/world/entity/npc/EntityVillagerTrader.java
@@ -46,6 +46,13 @@
@@ -44,6 +44,13 @@
import net.minecraft.world.level.World;
import net.minecraft.world.phys.Vec3D;
import org.apache.commons.lang3.ArrayUtils;
+// CraftBukkit start
+import org.bukkit.Bukkit;
@@ -14,7 +14,7 @@
public class EntityVillagerTrader extends EntityVillagerAbstract {
private static final int NUMBER_OF_TRADE_OFFERS = 5;
@@ -55,6 +62,7 @@
@@ -53,6 +60,7 @@
public EntityVillagerTrader(EntityTypes<? extends EntityVillagerTrader> entitytypes, World world) {
super(entitytypes, world);
@@ -22,7 +22,7 @@
}
@Override
@@ -140,7 +148,16 @@
@@ -130,7 +138,16 @@
MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.getOffer(this, this.random);
if (merchantrecipe != null) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/player/EntityHuman.java
+++ b/net/minecraft/world/entity/player/EntityHuman.java
@@ -117,6 +117,20 @@
@@ -118,6 +118,20 @@
import net.minecraft.world.scores.ScoreboardTeamBase;
import org.slf4j.Logger;
@@ -21,7 +21,7 @@
public abstract class EntityHuman extends EntityLiving {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -130,7 +144,8 @@
@@ -131,7 +145,8 @@
public static final float SWIMMING_BB_HEIGHT = 0.6F;
public static final float DEFAULT_EYE_HEIGHT = 1.62F;
public static final EntitySize STANDING_DIMENSIONS = EntitySize.scalable(0.6F, 1.8F);
@@ -31,7 +31,7 @@
private static final int FLY_ACHIEVEMENT_SPEED = 25;
private static final DataWatcherObject<Float> DATA_PLAYER_ABSORPTION_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.FLOAT);
private static final DataWatcherObject<Integer> DATA_SCORE_ID = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.INT);
@@ -140,10 +155,10 @@
@@ -141,10 +156,10 @@
protected static final DataWatcherObject<NBTTagCompound> DATA_SHOULDER_RIGHT = DataWatcher.defineId(EntityHuman.class, DataWatcherRegistry.COMPOUND_TAG);
private long timeEntitySatOnShoulder;
private final PlayerInventory inventory = new PlayerInventory(this);
@@ -44,7 +44,7 @@
protected int jumpTriggerTime;
public float oBob;
public float bob;
@@ -172,6 +187,16 @@
@@ -173,6 +188,16 @@
public EntityFishingHook fishing;
protected float hurtDir;
@@ -61,7 +61,7 @@
public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile) {
super(EntityTypes.PLAYER, world);
this.lastItemInMainHand = ItemStack.EMPTY;
@@ -311,7 +336,7 @@
@@ -312,7 +337,7 @@
ItemStack itemstack = this.getItemBySlot(EnumItemSlot.HEAD);
if (itemstack.is(Items.TURTLE_HELMET) && !this.isEyeInFluid(TagsFluid.WATER)) {
@@ -70,9 +70,9 @@
}
}
@@ -477,8 +502,14 @@
@@ -478,8 +503,14 @@
public void rideTick() {
if (!this.level.isClientSide && this.wantsToStopRiding() && this.isPassenger()) {
if (!this.level().isClientSide && this.wantsToStopRiding() && this.isPassenger()) {
this.stopRiding();
- this.setShiftKeyDown(false);
- } else {
@@ -87,9 +87,9 @@
double d0 = this.getX();
double d1 = this.getY();
double d2 = this.getZ();
@@ -505,7 +536,8 @@
@@ -506,7 +537,8 @@
if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL && this.level.getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.level().getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
if (this.getHealth() < this.getMaxHealth() && this.tickCount % 20 == 0) {
- this.heal(1.0F);
+ // CraftBukkit - added regain reason of "REGEN" for filtering purposes.
@@ -97,7 +97,7 @@
}
if (this.foodData.needsFood() && this.tickCount % 10 == 0) {
@@ -664,6 +696,13 @@
@@ -665,6 +697,13 @@
@Nullable
public EntityItem drop(ItemStack itemstack, boolean flag, boolean flag1) {
@@ -111,7 +111,7 @@
if (itemstack.isEmpty()) {
return null;
} else {
@@ -698,6 +737,33 @@
@@ -699,6 +738,33 @@
entityitem.setDeltaMovement((double) (-f3 * f2 * 0.3F) + Math.cos((double) f5) * (double) f6, (double) (-f1 * 0.3F + 0.1F + (this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (f4 * f2 * 0.3F) + Math.sin((double) f5) * (double) f6);
}
@@ -123,7 +123,7 @@
+ Item drop = (Item) entityitem.getBukkitEntity();
+
+ PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand();
@@ -145,7 +145,7 @@
return entityitem;
}
}
@@ -788,7 +854,7 @@
@@ -789,7 +855,7 @@
}
if (nbttagcompound.contains("LastDeathLocation", 10)) {
@@ -154,7 +154,7 @@
Logger logger = EntityHuman.LOGGER;
Objects.requireNonNull(logger);
@@ -821,7 +887,7 @@
@@ -822,7 +888,7 @@
}
this.getLastDeathLocation().flatMap((globalpos) -> {
@@ -163,22 +163,22 @@
Logger logger = EntityHuman.LOGGER;
Objects.requireNonNull(logger);
@@ -848,12 +914,12 @@
@@ -849,12 +915,12 @@
return false;
} else {
if (!this.level.isClientSide) {
if (!this.level().isClientSide) {
- this.removeEntitiesOnShoulder();
+ // this.removeEntitiesOnShoulder(); // CraftBukkit - moved down
}
if (damagesource.scalesWithDifficulty()) {
if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL) {
if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL) {
- f = 0.0F;
+ return false; // CraftBukkit - f = 0.0f -> return false
}
if (this.level.getDifficulty() == EnumDifficulty.EASY) {
@@ -865,7 +931,13 @@
if (this.level().getDifficulty() == EnumDifficulty.EASY) {
@@ -866,7 +932,13 @@
}
}
@@ -193,7 +193,7 @@
}
}
}
@@ -885,10 +957,29 @@
@@ -886,10 +958,29 @@
}
public boolean canHarmPlayer(EntityHuman entityhuman) {
@@ -210,8 +210,8 @@
+ }
+ } else {
+ // This should never be called, but is implemented anyway
+ org.bukkit.OfflinePlayer thisPlayer = entityhuman.level.getCraftServer().getOfflinePlayer(entityhuman.getScoreboardName());
+ team = entityhuman.level.getCraftServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer);
+ org.bukkit.OfflinePlayer thisPlayer = entityhuman.level().getCraftServer().getOfflinePlayer(entityhuman.getScoreboardName());
+ team = entityhuman.level().getCraftServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer);
+ if (team == null || team.allowFriendlyFire()) {
+ return true;
+ }
@@ -221,12 +221,12 @@
+ if (this instanceof EntityPlayer) {
+ return !team.hasPlayer(((EntityPlayer) this).getBukkitEntity());
+ }
+ return !team.hasPlayer(this.level.getCraftServer().getOfflinePlayer(this.getScoreboardName()));
+ return !team.hasPlayer(this.level().getCraftServer().getOfflinePlayer(this.getScoreboardName()));
+ // CraftBukkit end
}
@Override
@@ -930,8 +1021,13 @@
@@ -931,8 +1022,13 @@
}
}
@@ -241,17 +241,17 @@
if (!this.isInvulnerableTo(damagesource)) {
f = this.getDamageAfterArmorAbsorb(damagesource, f);
f = this.getDamageAfterMagicAbsorb(damagesource, f);
@@ -946,7 +1042,7 @@
@@ -947,7 +1043,7 @@
}
if (f != 0.0F) {
- this.causeFoodExhaustion(damagesource.getFoodExhaustion());
+ this.causeFoodExhaustion(damagesource.getFoodExhaustion(), EntityExhaustionEvent.ExhaustionReason.DAMAGED); // CraftBukkit - EntityExhaustionEvent
float f3 = this.getHealth();
this.getCombatTracker().recordDamage(damagesource, f3, f);
this.getCombatTracker().recordDamage(damagesource, f);
this.setHealth(this.getHealth() - f);
if (f < 3.4028235E37F) {
@@ -957,6 +1053,7 @@
this.gameEvent(GameEvent.ENTITY_DAMAGE);
}
}
+ return false; // CraftBukkit
@@ -308,7 +308,7 @@
+ org.bukkit.util.Vector velocity = CraftVector.toBukkit(vec3d);
+
+ PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone());
+ level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ cancelled = true;
@@ -340,7 +340,7 @@
+ // CraftBukkit end
}
if (this.level instanceof WorldServer && f5 > 2.0F) {
if (this.level() instanceof WorldServer && f5 > 2.0F) {
@@ -1256,12 +1387,17 @@
}
}
@@ -348,7 +348,7 @@
- this.causeFoodExhaustion(0.1F);
+ this.causeFoodExhaustion(0.1F, EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent
} else {
this.level.playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F);
this.level().playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_ATTACK_NODAMAGE, this.getSoundSource(), 1.0F, 1.0F);
if (flag4) {
entity.clearFire();
}
@@ -373,7 +373,7 @@
this.startSleeping(blockposition);
this.sleepCounter = 0;
return Either.right(Unit.INSTANCE);
@@ -1422,9 +1564,9 @@
@@ -1425,9 +1567,9 @@
super.jumpFromGround();
this.awardStat(StatisticList.JUMP);
if (this.isSprinting()) {
@@ -385,7 +385,7 @@
}
}
@@ -1454,7 +1596,11 @@
@@ -1457,7 +1599,11 @@
this.setDeltaMovement(vec3d2.x, d3 * 0.6D, vec3d2.z);
this.resetFallDistance();
@@ -398,7 +398,7 @@
} else {
super.travel(vec3d);
}
@@ -1489,19 +1635,19 @@
@@ -1492,19 +1638,19 @@
i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
if (i > 0) {
this.awardStat(StatisticList.SWIM_ONE_CM, i);
@@ -421,7 +421,7 @@
}
} else if (this.onClimbable()) {
if (d1 > 0.0D) {
@@ -1512,13 +1658,13 @@
@@ -1515,13 +1661,13 @@
if (i > 0) {
if (this.isSprinting()) {
this.awardStat(StatisticList.SPRINT_ONE_CM, i);
@@ -438,7 +438,7 @@
}
}
} else if (this.isFallFlying()) {
@@ -1584,12 +1730,24 @@
@@ -1587,12 +1733,24 @@
}
public void startFallFlying() {
@@ -464,7 +464,7 @@
}
@Override
@@ -1680,10 +1838,21 @@
@@ -1706,10 +1864,21 @@
return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2);
}
@@ -476,7 +476,7 @@
+ public void causeFoodExhaustion(float f, EntityExhaustionEvent.ExhaustionReason reason) {
+ // CraftBukkit end
if (!this.abilities.invulnerable) {
if (!this.level.isClientSide) {
if (!this.level().isClientSide) {
- this.foodData.addExhaustion(f);
+ // CraftBukkit start
+ EntityExhaustionEvent event = CraftEventFactory.callPlayerExhaustionEvent(this, reason, f);
@@ -487,7 +487,7 @@
}
}
@@ -1769,13 +1938,20 @@
@@ -1795,13 +1964,20 @@
@Override
public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
@@ -511,19 +511,19 @@
}
}
@@ -1814,26 +1990,31 @@
@@ -1840,26 +2016,31 @@
protected void removeEntitiesOnShoulder() {
if (this.timeEntitySatOnShoulder + 20L < this.level.getGameTime()) {
if (this.timeEntitySatOnShoulder + 20L < this.level().getGameTime()) {
- this.respawnEntityOnShoulder(this.getShoulderEntityLeft());
- this.setShoulderEntityLeft(new NBTTagCompound());
- this.respawnEntityOnShoulder(this.getShoulderEntityRight());
- this.setShoulderEntityRight(new NBTTagCompound());
+ // CraftBukkit start
+ if (this.spawnEntityFromShoulder(this.getShoulderEntityLeft())) {
+ if (this.respawnEntityOnShoulder(this.getShoulderEntityLeft())) {
+ this.setShoulderEntityLeft(new NBTTagCompound());
+ }
+ if (this.spawnEntityFromShoulder(this.getShoulderEntityRight())) {
+ if (this.respawnEntityOnShoulder(this.getShoulderEntityRight())) {
+ this.setShoulderEntityRight(new NBTTagCompound());
+ }
+ // CraftBukkit end
@@ -532,18 +532,18 @@
}
- private void respawnEntityOnShoulder(NBTTagCompound nbttagcompound) {
+ private boolean spawnEntityFromShoulder(NBTTagCompound nbttagcompound) { // CraftBukkit void->boolean
if (!this.level.isClientSide && !nbttagcompound.isEmpty()) {
- EntityTypes.create(nbttagcompound, this.level).ifPresent((entity) -> {
+ return EntityTypes.create(nbttagcompound, this.level).map((entity) -> { // CraftBukkit
+ private boolean respawnEntityOnShoulder(NBTTagCompound nbttagcompound) { // CraftBukkit void->boolean
if (!this.level().isClientSide && !nbttagcompound.isEmpty()) {
- EntityTypes.create(nbttagcompound, this.level()).ifPresent((entity) -> {
+ return EntityTypes.create(nbttagcompound, this.level()).map((entity) -> { // CraftBukkit
if (entity instanceof EntityTameableAnimal) {
((EntityTameableAnimal) entity).setOwnerUUID(this.uuid);
}
entity.setPos(this.getX(), this.getY() + 0.699999988079071D, this.getZ());
- ((WorldServer) this.level).addWithUUID(entity);
- ((WorldServer) this.level()).addWithUUID(entity);
- });
+ return ((WorldServer) this.level).addWithUUID(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit
+ return ((WorldServer) this.level()).addWithUUID(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit
+ }).orElse(true); // CraftBukkit
}

View File

@@ -40,15 +40,15 @@
@@ -522,7 +534,22 @@
@Override
public void playerTouch(EntityHuman entityhuman) {
if (!this.level.isClientSide && (this.inGround || this.isNoPhysics()) && this.shakeTime <= 0) {
if (!this.level().isClientSide && (this.inGround || this.isNoPhysics()) && this.shakeTime <= 0) {
- if (this.tryPickup(entityhuman)) {
+ // CraftBukkit start
+ ItemStack itemstack = this.getPickupItem();
+ if (this.pickup == PickupStatus.ALLOWED && !itemstack.isEmpty() && entityhuman.getInventory().canHold(itemstack) > 0) {
+ EntityItem item = new EntityItem(this.level, this.getX(), this.getY(), this.getZ(), itemstack);
+ PlayerPickupArrowEvent event = new PlayerPickupArrowEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.level.getCraftServer(), this, item), (org.bukkit.entity.AbstractArrow) this.getBukkitEntity());
+ EntityItem item = new EntityItem(this.level(), this.getX(), this.getY(), this.getZ(), itemstack);
+ PlayerPickupArrowEvent event = new PlayerPickupArrowEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.level().getCraftServer(), this, item), (org.bukkit.entity.AbstractArrow) this.getBukkitEntity());
+ // event.setCancelled(!entityhuman.canPickUpLoot); TODO
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;

View File

@@ -19,7 +19,7 @@
@@ -47,22 +56,42 @@
protected void onHit(MovingObjectPosition movingobjectposition) {
super.onHit(movingobjectposition);
if (!this.level.isClientSide) {
if (!this.level().isClientSide) {
- if (this.random.nextInt(8) == 0) {
+ boolean hatching = this.random.nextInt(8) == 0; // CraftBukkit
+ if (true) {
@@ -30,7 +30,7 @@
}
- for (int i = 0; i < b0; ++i) {
- EntityChicken entitychicken = (EntityChicken) EntityTypes.CHICKEN.create(this.level);
- EntityChicken entitychicken = (EntityChicken) EntityTypes.CHICKEN.create(this.level());
+ // CraftBukkit start
+ if (!hatching) {
+ b0 = 0;
@@ -40,7 +40,7 @@
+ Entity shooter = this.getOwner();
+ if (shooter instanceof EntityPlayer) {
+ PlayerEggThrowEvent event = new PlayerEggThrowEvent((Player) shooter.getBukkitEntity(), (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, b0, hatchingType);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ b0 = event.getNumHatches();
+ hatching = event.isHatching();
@@ -50,19 +50,19 @@
- if (entitychicken != null) {
- entitychicken.setAge(-24000);
- entitychicken.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F);
- this.level.addFreshEntity(entitychicken);
- this.level().addFreshEntity(entitychicken);
+ if (hatching) {
+ for (int i = 0; i < b0; ++i) {
+ Entity entity = level.getWorld().createEntity(new org.bukkit.Location(level.getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass());
+ Entity entity = this.level().getWorld().createEntity(new org.bukkit.Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass());
+ if (entity != null) {
+ if (entity.getBukkitEntity() instanceof Ageable) {
+ ((Ageable) entity.getBukkitEntity()).setBaby();
+ }
+ level.getWorld().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG);
+ this.level().getWorld().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG);
+ }
}
}
+ // CraftBukkit end
}
this.level.broadcastEntityEvent(this, (byte) 3);
this.level().broadcastEntityEvent(this, (byte) 3);

View File

@@ -17,9 +17,9 @@
@@ -52,23 +59,36 @@
EntityPlayer entityplayer = (EntityPlayer) entity;
if (entityplayer.connection.isAcceptingMessages() && entityplayer.level == this.level && !entityplayer.isSleeping()) {
- if (this.random.nextFloat() < 0.05F && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) {
- EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(this.level);
if (entityplayer.connection.isAcceptingMessages() && entityplayer.level() == this.level() && !entityplayer.isSleeping()) {
- if (this.random.nextFloat() < 0.05F && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) {
- EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(this.level());
+ // CraftBukkit start - Fire PlayerTeleportEvent
+ org.bukkit.craftbukkit.entity.CraftPlayer player = entityplayer.getBukkitEntity();
+ org.bukkit.Location location = getBukkitEntity().getLocation();
@@ -30,18 +30,18 @@
+ Bukkit.getPluginManager().callEvent(teleEvent);
+
+ if (!teleEvent.isCancelled() && entityplayer.connection.isAcceptingMessages()) {
+ if (this.random.nextFloat() < 0.05F && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) {
+ EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(this.level);
+ if (this.random.nextFloat() < 0.05F && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) {
+ EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(this.level());
+
+ if (entityendermite != null) {
+ entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot());
+ this.level.addFreshEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL);
+ this.level().addFreshEntity(entityendermite, CreatureSpawnEvent.SpawnReason.ENDER_PEARL);
+ }
+ }
- if (entityendermite != null) {
- entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot());
- this.level.addFreshEntity(entityendermite);
- this.level().addFreshEntity(entityendermite);
+ if (entity.isPassenger()) {
+ entity.stopRiding();
}
@@ -68,8 +68,8 @@
public Entity changeDimension(WorldServer worldserver) {
Entity entity = this.getOwner();
- if (entity != null && entity.level.dimension() != worldserver.dimension()) {
+ if (entity != null && worldserver != null && entity.level.dimension() != worldserver.dimension()) { // CraftBukkit - SPIGOT-6113
- if (entity != null && entity.level().dimension() != worldserver.dimension()) {
+ if (entity != null && worldserver != null && entity.level().dimension() != worldserver.dimension()) { // CraftBukkit - SPIGOT-6113
this.setOwner((Entity) null);
}

View File

@@ -1,15 +1,15 @@
--- a/net/minecraft/world/entity/projectile/EntityEnderSignal.java
+++ b/net/minecraft/world/entity/projectile/EntityEnderSignal.java
@@ -36,7 +36,7 @@
@@ -35,7 +35,7 @@
}
public void setItem(ItemStack itemstack) {
- if (!itemstack.is(Items.ENDER_EYE) || itemstack.hasTag()) {
+ if (true || !itemstack.is(Items.ENDER_EYE) || itemstack.hasTag()) { // CraftBukkit - always allow item changing
this.getEntityData().set(EntityEnderSignal.DATA_ITEM_STACK, (ItemStack) SystemUtils.make(itemstack.copy(), (itemstack1) -> {
itemstack1.setCount(1);
}));
@@ -180,7 +180,7 @@
this.getEntityData().set(EntityEnderSignal.DATA_ITEM_STACK, itemstack.copyWithCount(1));
}
@@ -177,7 +177,7 @@
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
ItemStack itemstack = ItemStack.of(nbttagcompound.getCompound("Item"));

View File

@@ -30,7 +30,7 @@
if (d6 != 0.0D) {
@@ -75,7 +85,13 @@
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity);
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity);
if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) {
- this.onHit(movingobjectposition);
@@ -47,7 +47,7 @@
@@ -161,6 +177,11 @@
if (entity != null) {
if (!this.level.isClientSide) {
if (!this.level().isClientSide) {
+ // CraftBukkit start
+ if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false)) {
+ return false;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/EntityFireballFireball.java
+++ b/net/minecraft/world/entity/projectile/EntityFireballFireball.java
@@ -68,6 +68,6 @@
@@ -65,6 +65,6 @@
super.readAdditionalSaveData(nbttagcompound);
ItemStack itemstack = ItemStack.of(nbttagcompound.getCompound("Item"));

View File

@@ -10,7 +10,7 @@
public static final DataWatcherObject<ItemStack> DATA_ID_FIREWORKS_ITEM = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.ITEM_STACK);
@@ -143,7 +145,7 @@
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity);
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity);
if (!this.noPhysics) {
- this.onHit(movingobjectposition);
@@ -21,7 +21,7 @@
@@ -158,7 +160,11 @@
}
if (!this.level.isClientSide && this.life > this.lifetime) {
if (!this.level().isClientSide && this.life > this.lifetime) {
- this.explode();
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) {
@@ -34,7 +34,7 @@
@@ -174,7 +180,11 @@
protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) {
super.onHitEntity(movingobjectpositionentity);
if (!this.level.isClientSide) {
if (!this.level().isClientSide) {
- this.explode();
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) {
@@ -46,8 +46,8 @@
@@ -184,7 +194,11 @@
this.level.getBlockState(blockposition).entityInside(this.level, blockposition, this);
if (!this.level.isClientSide() && this.hasExplosion()) {
this.level().getBlockState(blockposition).entityInside(this.level(), blockposition, this);
if (!this.level().isClientSide() && this.hasExplosion()) {
- this.explode();
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) {

View File

@@ -34,7 +34,7 @@
this.syncronizedRandom = RandomSource.create();
@@ -261,7 +279,7 @@
private void checkCollision() {
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity);
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity);
- this.onHit(movingobjectposition);
+ this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event
@@ -45,13 +45,13 @@
int i = 1;
BlockPosition blockposition1 = blockposition.above();
- if (this.random.nextFloat() < 0.25F && this.level.isRainingAt(blockposition1)) {
+ if (this.rainInfluenced && this.random.nextFloat() < 0.25F && this.level.isRainingAt(blockposition1)) { // CraftBukkit
- if (this.random.nextFloat() < 0.25F && this.level().isRainingAt(blockposition1)) {
+ if (this.rainInfluenced && this.random.nextFloat() < 0.25F && this.level().isRainingAt(blockposition1)) { // CraftBukkit
++i;
}
- if (this.random.nextFloat() < 0.5F && !this.level.canSeeSky(blockposition1)) {
+ if (this.skyInfluenced && this.random.nextFloat() < 0.5F && !this.level.canSeeSky(blockposition1)) { // CraftBukkit
- if (this.random.nextFloat() < 0.5F && !this.level().canSeeSky(blockposition1)) {
+ if (this.skyInfluenced && this.random.nextFloat() < 0.5F && !this.level().canSeeSky(blockposition1)) { // CraftBukkit
--i;
}
@@ -61,7 +61,7 @@
this.getEntityData().set(EntityFishingHook.DATA_BITING, false);
+ // CraftBukkit start
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.getPlayerOwner().getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
+ this.level.getCraftServer().getPluginManager().callEvent(playerFishEvent);
+ this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent);
+ // CraftBukkit end
}
} else {
@@ -72,7 +72,7 @@
} else {
+ // CraftBukkit start
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.getPlayerOwner().getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.BITE);
+ this.level.getCraftServer().getPluginManager().callEvent(playerFishEvent);
+ this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent);
+ if (playerFishEvent.isCancelled()) {
+ return;
+ }
@@ -107,7 +107,7 @@
if (this.hookedIn != null) {
+ // CraftBukkit start
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), this.hookedIn.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
+ this.level.getCraftServer().getPluginManager().callEvent(playerFishEvent);
+ this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent);
+
+ if (playerFishEvent.isCancelled()) {
+ return 0;
@@ -115,15 +115,15 @@
+ // CraftBukkit end
this.pullEntity(this.hookedIn);
CriterionTriggers.FISHING_ROD_HOOKED.trigger((EntityPlayer) entityhuman, itemstack, this, Collections.emptyList());
this.level.broadcastEntityEvent(this, (byte) 31);
this.level().broadcastEntityEvent(this, (byte) 31);
@@ -460,6 +501,15 @@
while (iterator.hasNext()) {
ItemStack itemstack1 = (ItemStack) iterator.next();
EntityItem entityitem = new EntityItem(this.level, this.getX(), this.getY(), this.getZ(), itemstack1);
EntityItem entityitem = new EntityItem(this.level(), this.getX(), this.getY(), this.getZ(), itemstack1);
+ // CraftBukkit start
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), entityitem.getBukkitEntity(), (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
+ playerFishEvent.setExpToDrop(this.random.nextInt(6) + 1);
+ this.level.getCraftServer().getPluginManager().callEvent(playerFishEvent);
+ this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent);
+
+ if (playerFishEvent.isCancelled()) {
+ return 0;
@@ -135,11 +135,11 @@
@@ -467,7 +517,11 @@
entityitem.setDeltaMovement(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D);
this.level.addFreshEntity(entityitem);
- entityhuman.level.addFreshEntity(new EntityExperienceOrb(entityhuman.level, entityhuman.getX(), entityhuman.getY() + 0.5D, entityhuman.getZ() + 0.5D, this.random.nextInt(6) + 1));
this.level().addFreshEntity(entityitem);
- entityhuman.level().addFreshEntity(new EntityExperienceOrb(entityhuman.level(), entityhuman.getX(), entityhuman.getY() + 0.5D, entityhuman.getZ() + 0.5D, this.random.nextInt(6) + 1));
+ // CraftBukkit start - this.random.nextInt(6) + 1 -> playerFishEvent.getExpToDrop()
+ if (playerFishEvent.getExpToDrop() > 0) {
+ entityhuman.level.addFreshEntity(new EntityExperienceOrb(entityhuman.level, entityhuman.getX(), entityhuman.getY() + 0.5D, entityhuman.getZ() + 0.5D, playerFishEvent.getExpToDrop()));
+ entityhuman.level().addFreshEntity(new EntityExperienceOrb(entityhuman.level(), entityhuman.getX(), entityhuman.getY() + 0.5D, entityhuman.getZ() + 0.5D, playerFishEvent.getExpToDrop()));
+ }
+ // CraftBukkit end
if (itemstack1.is(TagsItem.FISHES)) {
@@ -148,10 +148,10 @@
@@ -477,8 +531,25 @@
}
if (this.onGround) {
if (this.onGround()) {
+ // CraftBukkit start
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND);
+ this.level.getCraftServer().getPluginManager().callEvent(playerFishEvent);
+ this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent);
+
+ if (playerFishEvent.isCancelled()) {
+ return 0;
@@ -162,7 +162,7 @@
+ // CraftBukkit start
+ if (i == 0) {
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) entityhuman.getBukkitEntity(), null, (FishHook) this.getBukkitEntity(), PlayerFishEvent.State.REEL_IN);
+ this.level.getCraftServer().getPluginManager().callEvent(playerFishEvent);
+ this.level().getCraftServer().getPluginManager().callEvent(playerFishEvent);
+ if (playerFishEvent.isCancelled()) {
+ return 0;
+ }

View File

@@ -12,28 +12,28 @@
public EntityLargeFireball(EntityTypes<? extends EntityLargeFireball> entitytypes, World world) {
super(entitytypes, world);
+ isIncendiary = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit
+ isIncendiary = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit
}
public EntityLargeFireball(World world, EntityLiving entityliving, double d0, double d1, double d2, int i) {
super(EntityTypes.FIREBALL, entityliving, d0, d1, d2, world);
this.explosionPower = i;
+ isIncendiary = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit
+ isIncendiary = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit
}
@Override
@@ -28,7 +32,15 @@
if (!this.level.isClientSide) {
boolean flag = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING);
if (!this.level().isClientSide) {
boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING);
- this.level.explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionPower, flag, World.a.MOB);
- this.level().explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionPower, flag, World.a.MOB);
+ // CraftBukkit start - fire ExplosionPrimeEvent
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity());
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ // give 'this' instead of (Entity) null so we know what causes the damage
+ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB);
+ this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB);
+ }
+ // CraftBukkit end
this.discard();

View File

@@ -2,7 +2,7 @@
+++ b/net/minecraft/world/entity/projectile/EntityLlamaSpit.java
@@ -32,7 +32,7 @@
Vec3D vec3d = this.getDeltaMovement();
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity);
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity);
- this.onHit(movingobjectposition);
+ this.preOnHit(movingobjectposition); // CraftBukkit - projectile hit event

View File

@@ -29,7 +29,7 @@
@@ -148,6 +158,7 @@
private void applySplash(List<MobEffect> list, @Nullable Entity entity) {
AxisAlignedBB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D);
List<EntityLiving> list1 = this.level.getEntitiesOfClass(EntityLiving.class, axisalignedbb);
List<EntityLiving> list1 = this.level().getEntitiesOfClass(EntityLiving.class, axisalignedbb);
+ Map<LivingEntity, Double> affected = new HashMap<LivingEntity, Double>(); // CraftBukkit
if (!list1.isEmpty()) {
@@ -64,7 +64,7 @@
+ MobEffect mobeffect = (MobEffect) iterator1.next();
+ MobEffectList mobeffectlist = mobeffect.getEffect();
+ // CraftBukkit start - Abide by PVP settings - for players only!
+ if (!this.level.pvpMode && this.getOwner() instanceof EntityPlayer && entityliving instanceof EntityPlayer && entityliving != this.getOwner()) {
+ if (!this.level().pvpMode && this.getOwner() instanceof EntityPlayer && entityliving instanceof EntityPlayer && entityliving != this.getOwner()) {
+ int i = MobEffectList.getId(mobeffectlist);
+ // Block SLOWER_MOVEMENT, SLOWER_DIG, HARM, BLINDNESS, HUNGER, WEAKNESS and POISON potions
+ if (i == 2 || i == 4 || i == 7 || i == 15 || i == 17 || i == 18 || i == 19) {
@@ -106,11 +106,11 @@
entityareaeffectcloud.setFixedColor(nbttagcompound.getInt("CustomPotionColor"));
}
- this.level.addFreshEntity(entityareaeffectcloud);
- this.level().addFreshEntity(entityareaeffectcloud);
+ // CraftBukkit start
+ org.bukkit.event.entity.LingeringPotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callLingeringPotionSplashEvent(this, entityareaeffectcloud);
+ if (!(event.isCancelled() || entityareaeffectcloud.isRemoved())) {
+ this.level.addFreshEntity(entityareaeffectcloud);
+ this.level().addFreshEntity(entityareaeffectcloud);
+ } else {
+ entityareaeffectcloud.discard();
+ }
@@ -119,31 +119,31 @@
public boolean isLingering() {
@@ -232,13 +276,25 @@
IBlockData iblockdata = this.level.getBlockState(blockposition);
IBlockData iblockdata = this.level().getBlockState(blockposition);
if (iblockdata.is(TagsBlock.FIRE)) {
- this.level.removeBlock(blockposition, false);
- this.level().removeBlock(blockposition, false);
+ // CraftBukkit start
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) {
+ this.level.removeBlock(blockposition, false);
+ this.level().removeBlock(blockposition, false);
+ }
+ // CraftBukkit end
} else if (AbstractCandleBlock.isLit(iblockdata)) {
- AbstractCandleBlock.extinguish((EntityHuman) null, iblockdata, this.level, blockposition);
- AbstractCandleBlock.extinguish((EntityHuman) null, iblockdata, this.level(), blockposition);
+ // CraftBukkit start
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.setValue(AbstractCandleBlock.LIT, false)).isCancelled()) {
+ AbstractCandleBlock.extinguish((EntityHuman) null, iblockdata, this.level, blockposition);
+ AbstractCandleBlock.extinguish((EntityHuman) null, iblockdata, this.level(), blockposition);
+ }
+ // CraftBukkit end
} else if (BlockCampfire.isLitCampfire(iblockdata)) {
- this.level.levelEvent((EntityHuman) null, 1009, blockposition, 0);
- BlockCampfire.dowse(this.getOwner(), this.level, blockposition, iblockdata);
- this.level.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(BlockCampfire.LIT, false));
- this.level().levelEvent((EntityHuman) null, 1009, blockposition, 0);
- BlockCampfire.dowse(this.getOwner(), this.level(), blockposition, iblockdata);
- this.level().setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(BlockCampfire.LIT, false));
+ // CraftBukkit start
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.setValue(BlockCampfire.LIT, false)).isCancelled()) {
+ this.level.levelEvent((EntityHuman) null, 1009, blockposition, 0);
+ BlockCampfire.dowse(this.getOwner(), this.level, blockposition, iblockdata);
+ this.level.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(BlockCampfire.LIT, false));
+ this.level().levelEvent((EntityHuman) null, 1009, blockposition, 0);
+ BlockCampfire.dowse(this.getOwner(), this.level(), blockposition, iblockdata);
+ this.level().setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(BlockCampfire.LIT, false));
+ }
+ // CraftBukkit end
}

View File

@@ -1,15 +1,6 @@
--- a/net/minecraft/world/entity/projectile/EntityProjectileThrowable.java
+++ b/net/minecraft/world/entity/projectile/EntityProjectileThrowable.java
@@ -30,7 +30,7 @@
public void setItem(ItemStack itemstack) {
if (!itemstack.is(this.getDefaultItem()) || itemstack.hasTag()) {
this.getEntityData().set(EntityProjectileThrowable.DATA_ITEM_STACK, (ItemStack) SystemUtils.make(itemstack.copy(), (itemstack1) -> {
- itemstack1.setCount(1);
+ if (!itemstack1.isEmpty()) itemstack1.setCount(1); // CraftBukkit
}));
}
@@ -38,6 +38,12 @@
@@ -35,6 +35,12 @@
protected abstract Item getDefaultItem();

View File

@@ -23,7 +23,7 @@
public SoundCategory getSoundSource() {
return SoundCategory.HOSTILE;
@@ -225,7 +238,7 @@
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResult(this, this::canHitEntity);
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity);
if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) {
- this.onHit(movingobjectposition);
@@ -49,6 +49,6 @@
+ return false;
+ }
+ // CraftBukkit end
if (!this.level.isClientSide) {
if (!this.level().isClientSide) {
this.playSound(SoundEffects.SHULKER_BULLET_HURT, 1.0F, 1.0F);
((WorldServer) this.level).sendParticles(Particles.CRIT, this.getX(), this.getY(), this.getZ(), 15, 0.2D, 0.2D, 0.2D, 0.0D);
((WorldServer) this.level()).sendParticles(Particles.CRIT, this.getX(), this.getY(), this.getZ(), 15, 0.2D, 0.2D, 0.2D, 0.0D);

View File

@@ -15,7 +15,7 @@
super(EntityTypes.SMALL_FIREBALL, entityliving, d0, d1, d2, world);
+ // CraftBukkit start
+ if (this.getOwner() != null && this.getOwner() instanceof EntityInsentient) {
+ isIncendiary = this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING);
+ isIncendiary = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING);
+ }
+ // CraftBukkit end
}
@@ -28,7 +28,7 @@
- entity.setSecondsOnFire(5);
+ // CraftBukkit start - Entity damage by entity event + combust event
+ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), entity.getBukkitEntity(), 5);
+ entity.level.getCraftServer().getPluginManager().callEvent(event);
+ entity.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ entity.setSecondsOnFire(event.getDuration(), false);
@@ -38,15 +38,15 @@
entity.setRemainingFireTicks(i);
} else if (entity1 instanceof EntityLiving) {
@@ -51,10 +65,10 @@
if (!this.level.isClientSide) {
if (!this.level().isClientSide) {
Entity entity = this.getOwner();
- if (!(entity instanceof EntityInsentient) || this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
- if (!(entity instanceof EntityInsentient) || this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
+ if (isIncendiary) { // CraftBukkit
BlockPosition blockposition = movingobjectpositionblock.getBlockPos().relative(movingobjectpositionblock.getDirection());
- if (this.level.isEmptyBlock(blockposition)) {
+ if (this.level.isEmptyBlock(blockposition) && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, blockposition, this).isCancelled()) { // CraftBukkit
this.level.setBlockAndUpdate(blockposition, BlockFireAbstract.getState(this.level, blockposition));
- if (this.level().isEmptyBlock(blockposition)) {
+ if (this.level().isEmptyBlock(blockposition) && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(this.level(), blockposition, this).isCancelled()) { // CraftBukkit
this.level().setBlockAndUpdate(blockposition, BlockFireAbstract.getState(this.level(), blockposition));
}
}

View File

@@ -3,20 +3,20 @@
@@ -39,9 +39,18 @@
protected void onHit(MovingObjectPosition movingobjectposition) {
super.onHit(movingobjectposition);
if (this.level instanceof WorldServer) {
- this.level.levelEvent(2002, this.blockPosition(), PotionUtil.getColor(Potions.WATER));
if (this.level() instanceof WorldServer) {
- this.level().levelEvent(2002, this.blockPosition(), PotionUtil.getColor(Potions.WATER));
+ // CraftBukkit - moved to after event
+ // this.level.levelEvent(2002, this.blockPosition(), PotionUtil.getColor(Potions.WATER));
int i = 3 + this.level.random.nextInt(5) + this.level.random.nextInt(5);
+ // this.level().levelEvent(2002, this.blockPosition(), PotionUtil.getColor(Potions.WATER));
int i = 3 + this.level().random.nextInt(5) + this.level().random.nextInt(5);
+ // CraftBukkit start
+ org.bukkit.event.entity.ExpBottleEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callExpBottleEvent(this, i);
+ i = event.getExperience();
+ if (event.getShowEffect()) {
+ this.level.levelEvent(2002, this.blockPosition(), PotionUtil.getColor(Potions.WATER));
+ this.level().levelEvent(2002, this.blockPosition(), PotionUtil.getColor(Potions.WATER));
+ }
+ // CraftBukkit end
+
EntityExperienceOrb.award((WorldServer) this.level, this.position(), i);
EntityExperienceOrb.award((WorldServer) this.level(), this.position(), i);
this.discard();
}

View File

@@ -4,8 +4,8 @@
if (entitylightning != null) {
entitylightning.moveTo(Vec3D.atBottomCenterOf(blockposition));
entitylightning.setCause(entity1 instanceof EntityPlayer ? (EntityPlayer) entity1 : null);
- this.level.addFreshEntity(entitylightning);
+ ((WorldServer) this.level).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit
- this.level().addFreshEntity(entitylightning);
+ ((WorldServer) this.level()).strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRIDENT); // CraftBukkit
soundeffect = SoundEffects.TRIDENT_THUNDER;
f1 = 5.0F;
}

View File

@@ -30,15 +30,15 @@
@@ -92,7 +94,15 @@
protected void onHit(MovingObjectPosition movingobjectposition) {
super.onHit(movingobjectposition);
if (!this.level.isClientSide) {
- this.level.explode(this, this.getX(), this.getY(), this.getZ(), 1.0F, false, World.a.MOB);
if (!this.level().isClientSide) {
- this.level().explode(this, this.getX(), this.getY(), this.getZ(), 1.0F, false, World.a.MOB);
+ // CraftBukkit start
+ // this.level.explode(this, this.getX(), this.getY(), this.getZ(), 1.0F, false, World.a.MOB);
+ // this.level().explode(this, this.getX(), this.getY(), this.getZ(), 1.0F, false, World.a.MOB);
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 1.0F, false);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ this.level.explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB);
+ this.level().explode(this, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB);
+ }
+ // CraftBukkit end
this.discard();

View File

@@ -30,8 +30,8 @@
}
@@ -146,6 +155,16 @@
this.setDeltaMovement(this.getDeltaMovement().add(vec3d.x, entity.isOnGround() ? 0.0D : vec3d.y, vec3d.z));
@@ -147,6 +156,16 @@
this.setDeltaMovement(this.getDeltaMovement().add(vec3d.x, entity.onGround() ? 0.0D : vec3d.y, vec3d.z));
}
+ // CraftBukkit start - call projectile hit event
@@ -47,7 +47,7 @@
protected void onHit(MovingObjectPosition movingobjectposition) {
MovingObjectPosition.EnumMovingObjectType movingobjectposition_enummovingobjecttype = movingobjectposition.getType();
@@ -166,6 +185,11 @@
@@ -167,6 +186,11 @@
protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) {}
protected void onHitBlock(MovingObjectPositionBlock movingobjectpositionblock) {
@@ -56,6 +56,6 @@
+ return;
+ }
+ // CraftBukkit end
IBlockData iblockdata = this.level.getBlockState(movingobjectpositionblock.getBlockPos());
IBlockData iblockdata = this.level().getBlockState(movingobjectpositionblock.getBlockPos());
iblockdata.onProjectileHit(this.level, iblockdata, movingobjectpositionblock, this);
iblockdata.onProjectileHit(this.level(), iblockdata, movingobjectpositionblock, this);

View File

@@ -3,7 +3,7 @@
@@ -165,7 +165,7 @@
MobEffect mobeffect1 = new MobEffect(MobEffects.BAD_OMEN, 120000, i, false, false, true);
if (!this.level.getGameRules().getBoolean(GameRules.RULE_DISABLE_RAIDS)) {
if (!this.level().getGameRules().getBoolean(GameRules.RULE_DISABLE_RAIDS)) {
- entityhuman.addEffect(mobeffect1);
+ entityhuman.addEffect(mobeffect1, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.PATROL_CAPTAIN); // CraftBukkit
}

View File

@@ -16,7 +16,7 @@
@@ -237,4 +244,51 @@
public void stopOpen(EntityHuman entityhuman) {
this.level.gameEvent(GameEvent.CONTAINER_CLOSE, this.position(), GameEvent.a.of((Entity) entityhuman));
this.level().gameEvent(GameEvent.CONTAINER_CLOSE, this.position(), GameEvent.a.of((Entity) entityhuman));
}
+
+ // CraftBukkit start

View File

@@ -35,13 +35,13 @@
@@ -162,6 +180,19 @@
if (this.isInvulnerableTo(damagesource)) {
return false;
} else if (!this.level.isClientSide && !this.isRemoved()) {
} else if (!this.level().isClientSide && !this.isRemoved()) {
+ // CraftBukkit start
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ org.bukkit.entity.Entity attacker = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();
+
+ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) f);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return false;
@@ -58,14 +58,14 @@
if (flag || this.getDamage() > 40.0F) {
+ // CraftBukkit start
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
+ this.level.getCraftServer().getPluginManager().callEvent(destroyEvent);
+ this.level().getCraftServer().getPluginManager().callEvent(destroyEvent);
+
+ if (destroyEvent.isCancelled()) {
+ this.setDamage(40F); // Maximize damage so this doesn't get triggered again right away
+ return true;
+ }
+ // CraftBukkit end
if (!flag && this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
if (!flag && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
this.destroy(damagesource);
}
@@ -209,9 +249,29 @@
@@ -75,7 +75,7 @@
+ // CraftBukkit start
+ if (!this.isPassengerOfSameVehicle(entity)) {
+ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
@@ -88,7 +88,7 @@
+ // CraftBukkit start
+ if (!this.isPassengerOfSameVehicle(entity)) {
+ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return;
@@ -111,8 +111,8 @@
}
+ // CraftBukkit start
+ org.bukkit.Server server = this.level.getCraftServer();
+ org.bukkit.World bworld = this.level.getWorld();
+ org.bukkit.Server server = this.level().getCraftServer();
+ org.bukkit.World bworld = this.level().getWorld();
+
+ Location to = CraftLocation.toBukkit(this.position(), bworld, this.getYRot(), this.getXRot());
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
@@ -132,14 +132,14 @@
@@ -830,6 +907,11 @@
this.causeFallDamage(this.fallDistance, 1.0F, this.damageSources().fall());
if (!this.level.isClientSide && !this.isRemoved()) {
if (!this.level().isClientSide && !this.isRemoved()) {
+ // CraftBukkit start
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null);
+ this.level.getCraftServer().getPluginManager().callEvent(destroyEvent);
+ this.level().getCraftServer().getPluginManager().callEvent(destroyEvent);
+ if (!destroyEvent.isCancelled()) {
this.kill();
if (this.level.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
if (this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
int i;
@@ -843,6 +925,7 @@
}

View File

@@ -17,7 +17,7 @@
public abstract class EntityMinecartAbstract extends Entity {
private static final DataWatcherObject<Integer> DATA_ID_HURT = DataWatcher.defineId(EntityMinecartAbstract.class, DataWatcherRegistry.INT);
@@ -89,6 +99,17 @@
@@ -90,6 +100,17 @@
private double lyd;
private double lzd;
@@ -35,7 +35,7 @@
protected EntityMinecartAbstract(EntityTypes<?> entitytypes, World world) {
super(entitytypes, world);
this.blocksBuilding = true;
@@ -215,6 +236,19 @@
@@ -216,6 +237,19 @@
if (this.isInvulnerableTo(damagesource)) {
return false;
} else {
@@ -44,7 +44,7 @@
+ org.bukkit.entity.Entity passenger = (damagesource.getEntity() == null) ? null : damagesource.getEntity().getBukkitEntity();
+
+ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, f);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ return false;
@@ -55,13 +55,13 @@
this.setHurtDir(-this.getHurtDir());
this.setHurtTime(10);
this.markHurt();
@@ -223,6 +257,15 @@
@@ -224,6 +258,15 @@
boolean flag = damagesource.getEntity() instanceof EntityHuman && ((EntityHuman) damagesource.getEntity()).getAbilities().instabuild;
if (flag || this.getDamage() > 40.0F) {
+ // CraftBukkit start
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger);
+ this.level.getCraftServer().getPluginManager().callEvent(destroyEvent);
+ this.level().getCraftServer().getPluginManager().callEvent(destroyEvent);
+
+ if (destroyEvent.isCancelled()) {
+ this.setDamage(40); // Maximize damage so this doesn't get triggered again right away
@@ -71,7 +71,7 @@
this.ejectPassengers();
if (flag && !this.hasCustomName()) {
this.discard();
@@ -284,6 +327,14 @@
@@ -285,6 +328,14 @@
@Override
public void tick() {
@@ -86,41 +86,41 @@
if (this.getHurtTime() > 0) {
this.setHurtTime(this.getHurtTime() - 1);
}
@@ -293,7 +344,7 @@
@@ -294,7 +345,7 @@
}
this.checkOutOfWorld();
this.checkBelowWorld();
- this.handleNetherPortal();
+ // this.handleNetherPortal(); // CraftBukkit - handled in postTick
double d0;
if (this.level.isClientSide) {
@@ -359,6 +410,18 @@
if (this.level().isClientSide) {
@@ -361,6 +412,18 @@
}
this.setRot(this.getYRot(), this.getXRot());
+ // CraftBukkit start
+ org.bukkit.World bworld = this.level.getWorld();
+ org.bukkit.World bworld = this.level().getWorld();
+ Location from = new Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch);
+ Location to = CraftLocation.toBukkit(this.position(), bworld, this.getYRot(), this.getXRot());
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+
+ this.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
+ this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
+
+ if (!from.equals(to)) {
+ this.level.getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to));
+ this.level().getCraftServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to));
+ }
+ // CraftBukkit end
if (this.getMinecartType() == EntityMinecartAbstract.EnumMinecartType.RIDEABLE && this.getDeltaMovement().horizontalDistanceSqr() > 0.01D) {
List<Entity> list = this.level.getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), IEntitySelector.pushableBy(this));
List<Entity> list = this.level().getEntities((Entity) this, this.getBoundingBox().inflate(0.20000000298023224D, 0.0D, 0.20000000298023224D), IEntitySelector.pushableBy(this));
@@ -367,8 +430,26 @@
@@ -369,8 +432,26 @@
Entity entity = (Entity) list.get(l);
if (!(entity instanceof EntityHuman) && !(entity instanceof EntityIronGolem) && !(entity instanceof EntityMinecartAbstract) && !this.isVehicle() && !entity.isPassenger()) {
+ // CraftBukkit start
+ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity.getBukkitEntity());
+ this.level.getCraftServer().getPluginManager().callEvent(collisionEvent);
+ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent);
+
+ if (collisionEvent.isCancelled()) {
+ continue;
@@ -131,7 +131,7 @@
+ // CraftBukkit start
+ if (!this.isPassengerOfSameVehicle(entity)) {
+ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity.getBukkitEntity());
+ this.level.getCraftServer().getPluginManager().callEvent(collisionEvent);
+ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent);
+
+ if (collisionEvent.isCancelled()) {
+ continue;
@@ -141,13 +141,13 @@
entity.push(this);
}
}
@@ -380,6 +461,14 @@
@@ -382,6 +463,14 @@
Entity entity1 = (Entity) iterator.next();
if (!this.hasPassenger(entity1) && entity1.isPushable() && entity1 instanceof EntityMinecartAbstract) {
+ // CraftBukkit start
+ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, entity1.getBukkitEntity());
+ this.level.getCraftServer().getPluginManager().callEvent(collisionEvent);
+ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent);
+
+ if (collisionEvent.isCancelled()) {
+ continue;
@@ -156,7 +156,7 @@
entity1.push(this);
}
}
@@ -396,7 +485,7 @@
@@ -398,7 +487,7 @@
}
protected double getMaxSpeed() {
@@ -165,10 +165,10 @@
}
public void activateMinecart(int i, int j, int k, boolean flag) {}
@@ -407,12 +496,16 @@
@@ -409,12 +498,16 @@
this.setDeltaMovement(MathHelper.clamp(vec3d.x, -d0, d0), vec3d.y, MathHelper.clamp(vec3d.z, -d0, d0));
if (this.onGround) {
if (this.onGround()) {
- this.setDeltaMovement(this.getDeltaMovement().scale(0.5D));
+ // CraftBukkit start - replace magic numbers with our variables
+ this.setDeltaMovement(new Vec3D(this.getDeltaMovement().x * this.derailedX, this.getDeltaMovement().y * this.derailedY, this.getDeltaMovement().z * this.derailedZ));
@@ -176,7 +176,7 @@
}
this.move(EnumMoveType.SELF, this.getDeltaMovement());
if (!this.onGround) {
if (!this.onGround()) {
- this.setDeltaMovement(this.getDeltaMovement().scale(0.95D));
+ // CraftBukkit start - replace magic numbers with our variables
+ this.setDeltaMovement(new Vec3D(this.getDeltaMovement().x * this.flyingX, this.getDeltaMovement().y * this.flyingY, this.getDeltaMovement().z * this.flyingZ));
@@ -184,7 +184,7 @@
}
}
@@ -603,7 +696,7 @@
@@ -610,7 +703,7 @@
}
protected void applyNaturalSlowdown() {
@@ -193,13 +193,13 @@
Vec3D vec3d = this.getDeltaMovement();
vec3d = vec3d.multiply(d0, 0.0D, d0);
@@ -742,6 +835,14 @@
if (!this.level.isClientSide) {
@@ -749,6 +842,14 @@
if (!this.level().isClientSide) {
if (!entity.noPhysics && !this.noPhysics) {
if (!this.hasPassenger(entity)) {
+ // CraftBukkit start
+ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), entity.getBukkitEntity());
+ this.level.getCraftServer().getPluginManager().callEvent(collisionEvent);
+ this.level().getCraftServer().getPluginManager().callEvent(collisionEvent);
+
+ if (collisionEvent.isCancelled()) {
+ return;
@@ -208,7 +208,7 @@
double d0 = entity.getX() - this.getX();
double d1 = entity.getZ() - this.getZ();
double d2 = d0 * d0 + d1 * d1;
@@ -916,4 +1017,26 @@
@@ -923,4 +1024,26 @@
private EnumMinecartType() {}
}

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.java
+++ b/net/minecraft/world/entity/vehicle/EntityMinecartCommandBlock.java
@@ -138,5 +138,12 @@
public CommandListenerWrapper createCommandSourceStack() {
return new CommandListenerWrapper(this, EntityMinecartCommandBlock.this.position(), EntityMinecartCommandBlock.this.getRotationVector(), this.getLevel(), 2, this.getName().getString(), EntityMinecartCommandBlock.this.getDisplayName(), this.getLevel().getServer(), EntityMinecartCommandBlock.this);
@@ -143,5 +143,12 @@
public boolean isValid() {
return !EntityMinecartCommandBlock.this.isRemoved();
}
+
+ // CraftBukkit start

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/vehicle/EntityMinecartTNT.java
+++ b/net/minecraft/world/entity/vehicle/EntityMinecartTNT.java
@@ -23,10 +23,14 @@
@@ -23,6 +23,10 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.material.Fluid;
@@ -11,33 +11,19 @@
public class EntityMinecartTNT extends EntityMinecartAbstract {
private static final byte EVENT_PRIME = 10;
- private int fuse = -1;
+ public int fuse = -1;
public EntityMinecartTNT(EntityTypes<? extends EntityMinecartTNT> entitytypes, World world) {
super(entitytypes, world);
@@ -103,7 +107,7 @@
return Items.TNT_MINECART;
}
- protected void explode(double d0) {
+ public void explode(double d0) {
this.explode((DamageSource) null, d0);
}
@@ -115,7 +119,15 @@
d1 = 5.0D;
}
- this.level.explode(this, damagesource, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), (float) (4.0D + this.random.nextDouble() * 1.5D * d1), false, World.a.TNT);
- this.level().explode(this, damagesource, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), (float) (4.0D + this.random.nextDouble() * 1.5D * d1), false, World.a.TNT);
+ // CraftBukkit start
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), (float) (4.0D + this.random.nextDouble() * 1.5D * d1), false);
+ this.level.getCraftServer().getPluginManager().callEvent(event);
+ this.level().getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ fuse = -1;
+ return;
+ }
+ this.level.explode(this, damagesource, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT);
+ this.level().explode(this, damagesource, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT);
+ // CraftBukkit end
this.discard();
}