Update to Minecraft 1.21.2

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2024-10-23 02:15:00 +11:00
parent 2c4beb962b
commit d3a23f42c3
522 changed files with 8501 additions and 6477 deletions

View File

@@ -0,0 +1,41 @@
--- a/net/minecraft/world/entity/ConversionType.java
+++ b/net/minecraft/world/entity/ConversionType.java
@@ -12,6 +12,11 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.scores.Scoreboard;
+// CraftBukkit start
+import net.minecraft.core.BlockPosition;
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public enum ConversionType {
SINGLE(true) {
@@ -31,7 +36,7 @@
while (iterator.hasNext()) {
entity1 = (Entity) iterator.next();
entity1.stopRiding();
- entity1.remove(Entity.RemovalReason.DISCARDED);
+ entity1.remove(Entity.RemovalReason.DISCARDED, EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
}
entity.startRiding(entityinsentient1);
@@ -64,7 +69,7 @@
entityinsentient1.hurtTime = entityinsentient.hurtTime;
entityinsentient1.yBodyRot = entityinsentient.yBodyRot;
entityinsentient1.setOnGround(entityinsentient.onGround());
- Optional optional = entityinsentient.getSleepingPos();
+ Optional<BlockPosition> optional = entityinsentient.getSleepingPos(); // CraftBukkit - decompile error
Objects.requireNonNull(entityinsentient1);
optional.ifPresent(entityinsentient1::setSleepingPos);
@@ -156,7 +161,7 @@
entityinsentient1.setNoGravity(entityinsentient.isNoGravity());
entityinsentient1.setPortalCooldown(entityinsentient.getPortalCooldown());
entityinsentient1.setSilent(entityinsentient.isSilent());
- Set set = entityinsentient.getTags();
+ Set<String> set = entityinsentient.getTags(); // CraftBukkit - decompile error
Objects.requireNonNull(entityinsentient1);
set.forEach(entityinsentient1::addTag);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/Entity.java
+++ b/net/minecraft/world/entity/Entity.java
@@ -131,8 +131,72 @@
@@ -139,8 +139,67 @@
import net.minecraft.world.scores.ScoreboardTeamBase;
import org.slf4j.Logger;
@@ -42,7 +42,7 @@
+import org.bukkit.plugin.PluginManager;
+// CraftBukkit end
+
public abstract class Entity implements SyncedDataHolder, INamableTileEntity, EntityAccess, ICommandListener, ScoreHolder {
public abstract class Entity implements SyncedDataHolder, INamableTileEntity, EntityAccess, ScoreHolder {
+ // CraftBukkit start
+ private static final int CURRENT_LEVEL = 2;
@@ -59,11 +59,6 @@
+ return bukkitEntity;
+ }
+
+ @Override
+ public CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
+ return getBukkitEntity();
+ }
+
+ // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
+ public int getDefaultMaxAirSupply() {
+ return TOTAL_AIR_SUPPLY;
@@ -73,10 +68,10 @@
private static final Logger LOGGER = LogUtils.getLogger();
public static final String ID_TAG = "id";
public static final String PASSENGERS_TAG = "Passengers";
@@ -245,6 +309,30 @@
public boolean hasVisualFire;
@Nullable
private IBlockData inBlockState;
@@ -253,6 +312,30 @@
private final List<Entity.b> movementThisTick;
private final Set<IBlockData> blocksInside;
private final LongSet visitedBlocks;
+ // CraftBukkit start
+ public boolean forceDrops;
+ public boolean persist = true;
@@ -104,10 +99,10 @@
public Entity(EntityTypes<?> entitytypes, World world) {
this.id = Entity.ENTITY_COUNTER.incrementAndGet();
@@ -351,12 +439,18 @@
@@ -362,12 +445,18 @@
}
public void kill() {
public void kill(WorldServer worldserver) {
- this.remove(Entity.RemovalReason.KILLED);
+ this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
this.gameEvent(GameEvent.ENTITY_DIE);
@@ -125,7 +120,7 @@
}
protected abstract void defineSynchedData(DataWatcher.a datawatcher_a);
@@ -365,6 +459,16 @@
@@ -376,6 +465,16 @@
return this.entityData;
}
@@ -142,7 +137,7 @@
public boolean equals(Object object) {
return object instanceof Entity ? ((Entity) object).id == this.id : false;
}
@@ -374,12 +478,24 @@
@@ -385,7 +484,13 @@
}
public void remove(Entity.RemovalReason entity_removalreason) {
@@ -157,6 +152,8 @@
}
public void onClientRemoval() {}
@@ -393,6 +498,12 @@
public void onRemoval(Entity.RemovalReason entity_removalreason) {}
public void setPose(EntityPose entitypose) {
+ // CraftBukkit start
@@ -168,7 +165,7 @@
this.entityData.set(Entity.DATA_POSE, entitypose);
}
@@ -404,6 +520,33 @@
@@ -417,6 +528,33 @@
}
protected void setRot(float f, float f1) {
@@ -202,7 +199,7 @@
this.setYRot(f % 360.0F);
this.setXRot(f1 % 360.0F);
}
@@ -445,6 +588,15 @@
@@ -458,6 +596,15 @@
this.baseTick();
}
@@ -216,18 +213,18 @@
+ // CraftBukkit end
+
public void baseTick() {
this.level().getProfiler().push("entityBaseTick");
this.inBlockState = null;
@@ -459,7 +611,7 @@
this.walkDistO = this.walkDist;
this.xRotO = this.getXRot();
this.yRotO = this.getYRot();
GameProfilerFiller gameprofilerfiller = Profiler.get();
@@ -471,7 +618,7 @@
--this.boardingCooldown;
}
- this.handlePortal();
+ if (this instanceof EntityPlayer) this.handlePortal(); // CraftBukkit - // Moved up to postTick
if (this.canSpawnSprintParticle()) {
this.spawnSprintParticle();
}
@@ -494,6 +646,10 @@
@@ -510,6 +657,10 @@
if (this.isInLava()) {
this.lavaHurt();
this.fallDistance *= 0.5F;
@@ -238,21 +235,20 @@
}
this.checkBelowWorld();
@@ -503,7 +659,7 @@
this.firstTick = false;
if (!this.level().isClientSide && this instanceof Leashable) {
- Leashable.tickLeash((Entity) ((Leashable) this));
+ Leashable.tickLeash((Entity & Leashable) this); // CraftBukkit - decompile error
@@ -521,7 +672,7 @@
world = this.level();
if (world instanceof WorldServer worldserver) {
if (this instanceof Leashable) {
- Leashable.tickLeash(worldserver, (Entity) ((Leashable) this));
+ Leashable.tickLeash(worldserver, (Entity & Leashable) this); // CraftBukkit - decompile error
}
}
this.level().getProfiler().pop();
@@ -545,15 +701,47 @@
@@ -564,15 +715,32 @@
public void lavaHurt() {
if (!this.fireImmune()) {
- this.igniteForSeconds(15.0F);
- if (this.hurt(this.damageSources().lava(), 4.0F)) {
+ // CraftBukkit start - Fallen in lava TODO: this event spams!
+ if (this instanceof EntityLiving && remainingFireTicks <= 0) {
+ // not on fire yet
@@ -268,13 +264,22 @@
+ // This will be called every single tick the entity is in lava, so don't throw an event
+ this.igniteForSeconds(15.0F, false);
+ }
+
+ if (this.hurt(this.damageSources().lava().directBlock(level, lastLavaContact), 4.0F)) {
this.playSound(SoundEffects.GENERIC_BURN, 0.4F, 2.0F + this.random.nextFloat() * 0.4F);
+ // CraftBukkit end
World world = this.level();
if (world instanceof WorldServer) {
WorldServer worldserver = (WorldServer) world;
- if (this.hurtServer(worldserver, this.damageSources().lava(), 4.0F) && this.shouldPlayLavaHurtSound() && !this.isSilent()) {
+ // CraftBukkit start
+ if (this.hurtServer(worldserver, this.damageSources().lava().directBlock(level, lastLavaContact), 4.0F) && this.shouldPlayLavaHurtSound() && !this.isSilent()) {
worldserver.playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.GENERIC_BURN, this.getSoundSource(), 0.4F, 2.0F + this.random.nextFloat() * 0.4F);
}
+ // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
}
+ // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
}
@@ -583,6 +751,22 @@
}
public final void igniteForSeconds(float f) {
@@ -297,7 +302,7 @@
this.igniteForTicks(MathHelper.floor(f * 20.0F));
}
@@ -577,7 +765,7 @@
@@ -606,7 +790,7 @@
}
protected void onBelowWorld() {
@@ -306,8 +311,8 @@
}
public boolean isFree(double d0, double d1, double d2) {
@@ -702,6 +890,28 @@
block.updateEntityAfterFallOn(this.level(), this);
@@ -739,6 +923,28 @@
}
}
+ // CraftBukkit start
@@ -332,10 +337,10 @@
+ }
+ // CraftBukkit end
+
if (this.onGround()) {
block.stepOn(this.level(), blockposition, iblockdata, this);
}
@@ -1073,6 +1283,20 @@
if (!this.level().isClientSide() || this.isControlledByLocalInstance()) {
Entity.MovementEmission entity_movementemission = this.getMovementEmission();
@@ -1120,6 +1326,20 @@
return SoundEffects.GENERIC_SPLASH;
}
@@ -353,10 +358,10 @@
+ }
+ // CraftBukkit end
+
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);
@@ -1512,6 +1736,7 @@
public void recordMovementThroughBlocks(Vec3D vec3d, Vec3D vec3d1) {
this.movementThisTick.add(new Entity.b(vec3d, vec3d1));
}
@@ -1586,6 +1806,7 @@
this.yo = d1;
this.zo = d4;
this.setPos(d3, d1, d4);
@@ -364,7 +369,7 @@
}
public void moveTo(Vec3D vec3d) {
@@ -1718,6 +1943,12 @@
@@ -1838,6 +2059,12 @@
return false;
}
@@ -377,7 +382,7 @@
public void awardKillScore(Entity entity, int i, DamageSource damagesource) {
if (entity instanceof EntityPlayer) {
CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource);
@@ -1746,16 +1977,22 @@
@@ -1866,16 +2093,22 @@
}
public boolean saveAsPassenger(NBTTagCompound nbttagcompound) {
@@ -402,7 +407,7 @@
return true;
}
}
@@ -1766,16 +2003,38 @@
@@ -1886,16 +2119,38 @@
}
public NBTTagCompound saveWithoutId(NBTTagCompound nbttagcompound) {
@@ -445,7 +450,7 @@
nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot()));
nbttagcompound.putFloat("FallDistance", this.fallDistance);
nbttagcompound.putShort("Fire", (short) this.remainingFireTicks);
@@ -1783,7 +2042,28 @@
@@ -1903,7 +2158,28 @@
nbttagcompound.putBoolean("OnGround", this.onGround());
nbttagcompound.putBoolean("Invulnerable", this.invulnerable);
nbttagcompound.putInt("PortalCooldown", this.portalCooldown);
@@ -475,7 +480,7 @@
IChatBaseComponent ichatbasecomponent = this.getCustomName();
if (ichatbasecomponent != null) {
@@ -1832,7 +2112,7 @@
@@ -1952,7 +2228,7 @@
nbttagcompound.put("Tags", nbttaglist);
}
@@ -484,7 +489,7 @@
if (this.isVehicle()) {
nbttaglist = new NBTTagList();
iterator = this.getPassengers().iterator();
@@ -1841,7 +2121,7 @@
@@ -1961,7 +2237,7 @@
Entity entity = (Entity) iterator.next();
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
@@ -493,7 +498,7 @@
nbttaglist.add(nbttagcompound1);
}
}
@@ -1851,6 +2131,11 @@
@@ -1971,6 +2247,11 @@
}
}
@@ -505,7 +510,7 @@
return nbttagcompound;
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
@@ -1934,6 +2219,45 @@
@@ -2055,6 +2336,45 @@
} else {
throw new IllegalStateException("Entity has invalid position");
}
@@ -551,7 +556,7 @@
} catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
@@ -1955,6 +2279,12 @@
@@ -2076,6 +2396,12 @@
return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null;
}
@@ -564,8 +569,8 @@
protected abstract void readAdditionalSaveData(NBTTagCompound nbttagcompound);
protected abstract void addAdditionalSaveData(NBTTagCompound nbttagcompound);
@@ -2009,9 +2339,22 @@
} else if (this.level().isClientSide) {
@@ -2128,9 +2454,22 @@
if (itemstack.isEmpty()) {
return null;
} else {
+ // CraftBukkit start - Capture drops for death event
@@ -574,7 +579,7 @@
+ return null;
+ }
+ // CraftBukkit end
EntityItem entityitem = new EntityItem(this.level(), this.getX(), this.getY() + (double) f, this.getZ(), itemstack);
EntityItem entityitem = new EntityItem(worldserver, this.getX(), this.getY() + (double) f, this.getZ(), itemstack);
entityitem.setDefaultPickUpDelay();
+ // CraftBukkit start
@@ -584,10 +589,10 @@
+ return null;
+ }
+ // CraftBukkit end
this.level().addFreshEntity(entityitem);
worldserver.addFreshEntity(entityitem);
return entityitem;
}
@@ -2040,6 +2383,12 @@
@@ -2159,6 +2498,12 @@
if (this.isAlive() && this instanceof Leashable leashable) {
if (leashable.getLeashHolder() == entityhuman) {
if (!this.level().isClientSide()) {
@@ -600,7 +605,7 @@
leashable.dropLeash(true, !entityhuman.hasInfiniteMaterials());
this.gameEvent(GameEvent.ENTITY_INTERACT, entityhuman);
}
@@ -2051,6 +2400,13 @@
@@ -2170,6 +2515,13 @@
if (itemstack.is(Items.LEAD) && leashable.canHaveALeashAttachedToIt()) {
if (!this.level().isClientSide()) {
@@ -614,7 +619,7 @@
leashable.setLeashedTo(entityhuman, true);
}
@@ -2134,6 +2490,27 @@
@@ -2255,6 +2607,27 @@
if (!flag && (!this.canRide(entity) || !entity.canAddPassenger(this))) {
return false;
} else {
@@ -642,7 +647,7 @@
if (this.isPassenger()) {
this.stopRiding();
}
@@ -2167,7 +2544,7 @@
@@ -2288,7 +2661,7 @@
Entity entity = this.vehicle;
this.vehicle = null;
@@ -651,7 +656,7 @@
}
}
@@ -2198,10 +2575,38 @@
@@ -2319,10 +2692,38 @@
}
}
@@ -691,7 +696,7 @@
if (this.passengers.size() == 1 && this.passengers.get(0) == entity) {
this.passengers = ImmutableList.of();
} else {
@@ -2213,6 +2618,7 @@
@@ -2334,6 +2735,7 @@
entity.boardingCooldown = 60;
this.gameEvent(GameEvent.ENTITY_DISMOUNT, entity);
}
@@ -699,16 +704,16 @@
}
protected boolean canAddPassenger(Entity entity) {
@@ -2307,7 +2713,7 @@
if (dimensiontransition != null) {
WorldServer worldserver1 = dimensiontransition.newLevel();
@@ -2434,7 +2836,7 @@
if (teleporttransition != null) {
WorldServer worldserver1 = teleporttransition.newLevel();
- if (worldserver.getServer().isLevelEnabled(worldserver1) && (worldserver1.dimension() == worldserver.dimension() || this.canChangeDimensions(worldserver, worldserver1))) {
+ if (this instanceof EntityPlayer || (worldserver1 != null && (worldserver1.dimension() == worldserver.dimension() || this.canChangeDimensions(worldserver, worldserver1)))) { // CraftBukkit - always call event for players
this.changeDimension(dimensiontransition);
- if (worldserver.getServer().isLevelEnabled(worldserver1) && (worldserver1.dimension() == worldserver.dimension() || this.canTeleport(worldserver, worldserver1))) {
+ if (this instanceof EntityPlayer || (worldserver1 != null && (worldserver1.dimension() == worldserver.dimension() || this.canTeleport(worldserver, worldserver1)))) { // CraftBukkit - always call event for players
this.teleport(teleporttransition);
}
}
@@ -2414,6 +2820,13 @@
@@ -2541,6 +2943,13 @@
}
public void setSwimming(boolean flag) {
@@ -722,7 +727,7 @@
this.setSharedFlag(4, flag);
}
@@ -2463,8 +2876,12 @@
@@ -2594,8 +3003,12 @@
return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false;
}
@@ -736,7 +741,7 @@
}
public boolean getSharedFlag(int i) {
@@ -2483,7 +2900,7 @@
@@ -2614,7 +3027,7 @@
}
public int getMaxAirSupply() {
@@ -745,7 +750,7 @@
}
public int getAirSupply() {
@@ -2491,7 +2908,18 @@
@@ -2622,7 +3035,18 @@
}
public void setAirSupply(int i) {
@@ -765,7 +770,7 @@
}
public int getTicksFrozen() {
@@ -2518,11 +2946,40 @@
@@ -2649,11 +3073,40 @@
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
this.setRemainingFireTicks(this.remainingFireTicks + 1);
@@ -786,7 +791,7 @@
+ // CraftBukkit end
}
- this.hurt(this.damageSources().lightningBolt(), 5.0F);
- this.hurtServer(worldserver, this.damageSources().lightningBolt(), 5.0F);
+ // CraftBukkit start
+ if (thisBukkitEntity instanceof Hanging) {
+ HangingBreakByEntityEvent hangingEvent = new HangingBreakByEntityEvent((Hanging) thisBukkitEntity, stormBukkitEntity);
@@ -801,47 +806,47 @@
+ return;
+ }
+
+ if (!this.hurt(this.damageSources().lightningBolt().customEntityDamager(entitylightning), 5.0F)) {
+ if (!this.hurtServer(worldserver, this.damageSources().lightningBolt().customEntityDamager(entitylightning), 5.0F)) {
+ return;
+ }
+ // CraftBukkit end
}
public void onAboveBubbleCol(boolean flag) {
@@ -2691,6 +3148,15 @@
@@ -2822,6 +3275,18 @@
if (world instanceof WorldServer worldserver) {
if (!this.isRemoved()) {
+ // CraftBukkit start
+ Location to = new Location(dimensiontransition.newLevel().getWorld(), dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), dimensiontransition.xRot());
+ PositionMoveRotation absolutePosition = PositionMoveRotation.calculateAbsolute(PositionMoveRotation.of(this), PositionMoveRotation.of(teleporttransition), teleporttransition.relatives());
+ Location to = CraftLocation.toBukkit(absolutePosition.position(), teleporttransition.newLevel().getWorld(), absolutePosition.yRot(), absolutePosition.xRot());
+ EntityTeleportEvent teleEvent = CraftEventFactory.callEntityTeleportEvent(this, to);
+ if (teleEvent.isCancelled()) {
+ return null;
+ }
+ to = teleEvent.getTo();
+ dimensiontransition = new DimensionTransition(((CraftWorld) to.getWorld()).getHandle(), CraftLocation.toVec3D(to), dimensiontransition.speed(), to.getYaw(), to.getPitch(), dimensiontransition.missingRespawnBlock(), dimensiontransition.postDimensionTransition(), dimensiontransition.cause());
+ if (!to.equals(teleEvent.getTo())) {
+ to = teleEvent.getTo();
+ teleporttransition = new TeleportTransition(((CraftWorld) to.getWorld()).getHandle(), CraftLocation.toVec3D(to), Vec3D.ZERO, to.getYaw(), to.getPitch(), teleporttransition.missingRespawnBlock(), teleporttransition.asPassenger(), Set.of(), teleporttransition.postTeleportTransition(), teleporttransition.cause());
+ }
+ // CraftBukkit end
WorldServer worldserver1 = dimensiontransition.newLevel();
List<Entity> list = this.getPassengers();
WorldServer worldserver1 = teleporttransition.newLevel();
boolean flag = worldserver1.dimension() != worldserver.dimension();
@@ -2716,11 +3182,15 @@
if (this != entity2) {
entity2.restoreFrom(this);
this.removeAfterChangingDimensions();
+ // CraftBukkit start - Forward the CraftEntity to the new entity
+ this.getBukkitEntity().setHandle(entity2);
+ entity2.bukkitEntity = this.getBukkitEntity();
+ // CraftBukkit end
}
@@ -2890,8 +3355,12 @@
} else {
entity.restoreFrom(this);
this.removeAfterChangingDimensions();
+ // CraftBukkit start - Forward the CraftEntity to the new entity
+ this.getBukkitEntity().setHandle(entity);
+ entity.bukkitEntity = this.getBukkitEntity();
+ // CraftBukkit end
entity.teleportSetPosition(PositionMoveRotation.of(teleporttransition), teleporttransition.relatives());
- worldserver.addDuringTeleport(entity);
+ if (this.inWorld) worldserver.addDuringTeleport(entity); // CraftBukkit - Don't spawn the new entity if the current entity isn't spawned
Iterator iterator1 = list1.iterator();
entity2.moveTo(dimensiontransition.pos().x, dimensiontransition.pos().y, dimensiontransition.pos().z, dimensiontransition.yRot(), entity2.getXRot());
entity2.setDeltaMovement(dimensiontransition.speed());
- if (this != entity2) {
+ if (this != entity2 && this.inWorld) { // CraftBukkit - Don't spawn the new entity if the current entity isn't spawned
worldserver1.addDuringTeleport(entity2);
}
@@ -2754,8 +3224,9 @@
while (iterator1.hasNext()) {
@@ -2965,8 +3434,9 @@
}
protected void removeAfterChangingDimensions() {
@@ -852,7 +857,7 @@
leashable.dropLeash(true, false);
}
@@ -2765,6 +3236,20 @@
@@ -2976,6 +3446,20 @@
return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose()));
}
@@ -873,35 +878,25 @@
public boolean canUsePortal(boolean flag) {
return (flag || !this.isPassenger()) && this.isAlive();
}
@@ -2877,6 +3362,12 @@
@@ -3104,9 +3588,15 @@
return (Boolean) this.entityData.get(Entity.DATA_CUSTOM_NAME_VISIBLE);
}
- public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<Relative> set, float f, float f1, boolean flag) {
+ // CraftBukkit start
+ public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) {
+ return this.teleportTo(worldserver, d0, d1, d2, set, f, f1);
+ public final boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<Relative> set, float f, float f1, boolean flag) {
+ return teleportTo(worldserver, d0, d1, d2, set, f, f1, flag, PlayerTeleportEvent.TeleportCause.UNKNOWN);
+ }
+ // CraftBukkit end
+
public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1) {
+ public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<Relative> set, float f, float f1, boolean flag, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause cause) {
float f2 = MathHelper.clamp(f1, -90.0F, 90.0F);
- Entity entity = this.teleport(new TeleportTransition(worldserver, new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f2, set, TeleportTransition.DO_NOTHING));
+ Entity entity = this.teleport(new TeleportTransition(worldserver, new Vec3D(d0, d1, d2), Vec3D.ZERO, f, f2, set, TeleportTransition.DO_NOTHING, cause));
+ // CraftBukkit end
@@ -2895,8 +3386,12 @@
entity.restoreFrom(this);
entity.moveTo(d0, d1, d2, f, f2);
entity.setYHeadRot(f);
- this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION);
- worldserver.addDuringTeleport(entity);
+ this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION, null); // CraftBukkit - add Bukkit remove cause
+ // CraftBukkit start - Don't spawn the new entity if the current entity isn't spawned
+ if (inWorld) {
+ worldserver.addDuringTeleport(entity);
+ }
+ // CraftBukkit end
}
return true;
@@ -3023,7 +3518,26 @@
return entity != null;
}
@@ -3228,7 +3718,26 @@
}
public final void setBoundingBox(AxisAlignedBB axisalignedbb) {
@@ -929,7 +924,7 @@
}
public final float getEyeHeight(EntityPose entitypose) {
@@ -3332,6 +3846,11 @@
@@ -3525,6 +4034,11 @@
vec3d = vec3d.add(vec3d1);
++k1;
}
@@ -941,7 +936,7 @@
}
}
}
@@ -3601,6 +4120,14 @@
@@ -3792,6 +4306,14 @@
@Override
public final void setRemoved(Entity.RemovalReason entity_removalreason) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/EntityAgeable.java
+++ b/net/minecraft/world/entity/EntityAgeable.java
@@ -20,6 +20,7 @@
@@ -21,6 +21,7 @@
protected int age;
protected int forcedAge;
protected int forcedAgeTimer;
@@ -8,7 +8,7 @@
protected EntityAgeable(EntityTypes<? extends EntityAgeable> entitytypes, World world) {
super(entitytypes, world);
@@ -103,6 +104,7 @@
@@ -104,6 +105,7 @@
super.addAdditionalSaveData(nbttagcompound);
nbttagcompound.putInt("Age", this.getAge());
nbttagcompound.putInt("ForcedAge", this.forcedAge);
@@ -16,7 +16,7 @@
}
@Override
@@ -110,6 +112,7 @@
@@ -111,6 +113,7 @@
super.readAdditionalSaveData(nbttagcompound);
this.setAge(nbttagcompound.getInt("Age"));
this.forcedAge = nbttagcompound.getInt("ForcedAge");
@@ -24,7 +24,7 @@
}
@Override
@@ -124,7 +127,7 @@
@@ -125,7 +128,7 @@
@Override
public void aiStep() {
super.aiStep();

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/EntityAreaEffectCloud.java
+++ b/net/minecraft/world/entity/EntityAreaEffectCloud.java
@@ -32,6 +32,12 @@
@@ -33,6 +33,12 @@
import net.minecraft.world.level.material.EnumPistonReaction;
import org.slf4j.Logger;
@@ -13,81 +13,81 @@
public class EntityAreaEffectCloud extends Entity implements TraceableEntity {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -188,7 +194,7 @@
}
@@ -200,7 +206,7 @@
private void serverTick(WorldServer worldserver) {
if (this.tickCount >= this.waitTime + this.duration) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
} else {
if (this.tickCount >= this.waitTime + this.duration) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
return;
}
boolean flag = this.isWaiting();
boolean flag1 = this.tickCount < this.waitTime;
@@ -215,7 +221,7 @@
if (this.radiusPerTick != 0.0F) {
f += this.radiusPerTick;
if (f < 0.5F) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
return;
}
@@ -205,7 +211,7 @@
if (this.radiusPerTick != 0.0F) {
f += this.radiusPerTick;
if (f < 0.5F) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
return;
}
@@ -249,11 +255,12 @@
if (!list1.isEmpty()) {
Iterator iterator1 = list1.iterator();
@@ -239,11 +245,12 @@
if (!list1.isEmpty()) {
Iterator iterator1 = list1.iterator();
+ List<LivingEntity> entities = new java.util.ArrayList<LivingEntity>(); // CraftBukkit
while (iterator1.hasNext()) {
EntityLiving entityliving = (EntityLiving) iterator1.next();
+ List<LivingEntity> entities = new java.util.ArrayList<LivingEntity>(); // CraftBukkit
while (iterator1.hasNext()) {
EntityLiving entityliving = (EntityLiving) iterator1.next();
if (!this.victims.containsKey(entityliving) && entityliving.isAffectedByPotions()) {
- Stream stream = list.stream();
+ Stream<MobEffect> stream = list.stream(); // CraftBukkit - decompile error
if (!this.victims.containsKey(entityliving) && entityliving.isAffectedByPotions()) {
- Stream stream = list.stream();
+ Stream<MobEffect> stream = list.stream(); // CraftBukkit - decompile error
Objects.requireNonNull(entityliving);
if (!stream.noneMatch(entityliving::canBeAffected)) {
@@ -262,6 +269,19 @@
double d2 = d0 * d0 + d1 * d1;
Objects.requireNonNull(entityliving);
if (!stream.noneMatch(entityliving::canBeAffected)) {
@@ -252,6 +259,19 @@
double d5 = d3 * d3 + d4 * d4;
if (d5 <= (double) (f * f)) {
+ // CraftBukkit start
+ entities.add((LivingEntity) entityliving.getBukkitEntity());
if (d2 <= (double) (f * f)) {
+ // CraftBukkit start
+ entities.add((LivingEntity) entityliving.getBukkitEntity());
+ }
+ }
+ }
+ }
+ }
+ {
+ org.bukkit.event.entity.AreaEffectCloudApplyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callAreaEffectCloudApplyEvent(this, entities);
+ if (!event.isCancelled()) {
+ for (LivingEntity entity : event.getAffectedEntities()) {
+ if (entity instanceof CraftLivingEntity) {
+ EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle();
+ // CraftBukkit end
this.victims.put(entityliving, this.tickCount + this.reapplicationDelay);
Iterator iterator2 = list.iterator();
+ {
+ org.bukkit.event.entity.AreaEffectCloudApplyEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callAreaEffectCloudApplyEvent(this, entities);
+ if (!event.isCancelled()) {
+ for (LivingEntity entity : event.getAffectedEntities()) {
+ if (entity instanceof CraftLivingEntity) {
+ EntityLiving entityliving = ((CraftLivingEntity) entity).getHandle();
+ // CraftBukkit end
this.victims.put(entityliving, this.tickCount + this.reapplicationDelay);
Iterator iterator2 = list.iterator();
@@ -261,14 +281,14 @@
if (((MobEffectList) mobeffect1.getEffect().value()).isInstantenous()) {
((MobEffectList) mobeffect1.getEffect().value()).applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D);
} else {
- entityliving.addEffect(new MobEffect(mobeffect1), this);
+ entityliving.addEffect(new MobEffect(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit
}
}
if (this.radiusOnUse != 0.0F) {
f += this.radiusOnUse;
if (f < 0.5F) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
return;
@@ -271,14 +291,14 @@
if (((MobEffectList) mobeffect1.getEffect().value()).isInstantenous()) {
((MobEffectList) mobeffect1.getEffect().value()).applyInstantenousEffect(worldserver, this, this.getOwner(), entityliving, mobeffect1.getAmplifier(), 0.5D);
} else {
- entityliving.addEffect(new MobEffect(mobeffect1), this);
+ entityliving.addEffect(new MobEffect(mobeffect1), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AREA_EFFECT_CLOUD); // CraftBukkit
}
}
@@ -278,7 +298,7 @@
if (this.durationOnUse != 0) {
this.duration += this.durationOnUse;
if (this.duration <= 0) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
return;
if (this.radiusOnUse != 0.0F) {
f += this.radiusOnUse;
if (f < 0.5F) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
return;
}
@@ -288,7 +308,7 @@
if (this.durationOnUse != 0) {
this.duration += this.durationOnUse;
if (this.duration <= 0) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
return;
}
}
}

View File

@@ -47,7 +47,7 @@
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();
@@ -118,7 +142,7 @@
@@ -119,7 +143,7 @@
++this.age;
if (this.age >= 6000) {
@@ -56,7 +56,7 @@
}
}
@@ -187,7 +211,7 @@
@@ -188,7 +212,7 @@
private void merge(EntityExperienceOrb entityexperienceorb) {
this.count += entityexperienceorb.count;
this.age = Math.min(this.age, entityexperienceorb.age);
@@ -65,7 +65,7 @@
}
private void setUnderwaterMovement() {
@@ -209,7 +233,7 @@
@@ -213,7 +237,7 @@
this.markHurt();
this.health = (int) ((float) this.health - f);
if (this.health <= 0) {
@@ -74,7 +74,7 @@
}
return true;
@@ -236,17 +260,17 @@
@@ -240,17 +264,17 @@
public void playerTouch(EntityHuman entityhuman) {
if (entityhuman instanceof EntityPlayer entityplayer) {
if (entityhuman.takeXpDelay == 0) {
@@ -95,7 +95,7 @@
}
}
@@ -260,12 +284,20 @@
@@ -264,12 +288,20 @@
ItemStack itemstack = ((EnchantedItemInUse) optional.get()).itemStack();
int j = EnchantmentManager.modifyDurabilityToRepairFromXp(entityplayer.serverLevel(), itemstack, i);
int k = Math.min(j, itemstack.getDamageValue());
@@ -116,7 +116,7 @@
return this.repairPlayerItems(entityplayer, l);
}
}
@@ -285,6 +317,24 @@
@@ -289,6 +321,24 @@
}
public static int getExperienceValue(int i) {

View File

@@ -1,15 +1,13 @@
--- a/net/minecraft/world/entity/EntityInsentient.java
+++ b/net/minecraft/world/entity/EntityInsentient.java
@@ -87,6 +87,20 @@
@@ -89,6 +89,18 @@
import net.minecraft.world.level.storage.loot.parameters.LootContextParameters;
import net.minecraft.world.phys.AxisAlignedBB;
+// CraftBukkit start
+import net.minecraft.server.level.EntityPlayer;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
+import org.bukkit.event.entity.EntityTargetEvent;
@@ -21,7 +19,7 @@
public abstract class EntityInsentient extends EntityLiving implements EquipmentUser, Leashable, Targeting {
private static final DataWatcherObject<Byte> DATA_MOB_FLAGS_ID = DataWatcher.defineId(EntityInsentient.class, DataWatcherRegistry.BYTE);
@@ -134,6 +148,8 @@
@@ -136,6 +148,8 @@
private BlockPosition restrictCenter;
private float restrictRadius;
@@ -30,7 +28,7 @@
protected EntityInsentient(EntityTypes<? extends EntityInsentient> entitytypes, World world) {
super(entitytypes, world);
this.handItems = NonNullList.withSize(2, ItemStack.EMPTY);
@@ -161,6 +177,12 @@
@@ -164,6 +178,12 @@
}
@@ -43,7 +41,7 @@
protected void registerGoals() {}
public static AttributeProvider.Builder createMobAttributes() {
@@ -265,11 +287,42 @@
@@ -268,11 +288,42 @@
@Nullable
protected final EntityLiving getTargetFromBrain() {
@@ -87,7 +85,7 @@
}
@Override
@@ -405,6 +458,12 @@
@@ -403,6 +454,12 @@
return null;
}
@@ -100,7 +98,7 @@
@Override
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.addAdditionalSaveData(nbttagcompound);
@@ -478,16 +537,26 @@
@@ -476,16 +533,26 @@
nbttagcompound.putBoolean("NoAI", this.isNoAi());
}
@@ -112,7 +110,7 @@
super.readAdditionalSaveData(nbttagcompound);
+
+ // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it
if (nbttagcompound.contains("CanPickUpLoot", 1)) {
if (nbttagcompound.contains("CanPickUpLoot", 99)) {
- this.setCanPickUpLoot(nbttagcompound.getBoolean("CanPickUpLoot"));
+ boolean data = nbttagcompound.getBoolean("CanPickUpLoot");
+ if (isLevelAtLeast(nbttagcompound, 1) || data) {
@@ -129,7 +127,7 @@
NBTTagList nbttaglist;
NBTTagCompound nbttagcompound1;
int i;
@@ -541,6 +610,11 @@
@@ -539,6 +606,11 @@
}
this.setNoAi(nbttagcompound.getBoolean("NoAI"));
@@ -141,12 +139,12 @@
}
@Override
@@ -615,20 +689,26 @@
@@ -615,20 +687,26 @@
protected void pickUpItem(EntityItem entityitem) {
protected void pickUpItem(WorldServer worldserver, EntityItem entityitem) {
ItemStack itemstack = entityitem.getItem();
- ItemStack itemstack1 = this.equipItemIfPossible(itemstack.copy());
+ ItemStack itemstack1 = this.equipItemIfPossible(itemstack.copy(), entityitem); // CraftBukkit - add item
- ItemStack itemstack1 = this.equipItemIfPossible(worldserver, itemstack.copy());
+ ItemStack itemstack1 = this.equipItemIfPossible(worldserver, itemstack.copy(), entityitem); // CraftBukkit - add item
if (!itemstack1.isEmpty()) {
this.onItemPickup(entityitem);
@@ -160,17 +158,17 @@
}
public ItemStack equipItemIfPossible(ItemStack itemstack) {
public ItemStack equipItemIfPossible(WorldServer worldserver, ItemStack itemstack) {
+ // CraftBukkit start - add item
+ return this.equipItemIfPossible(itemstack, null);
+ return this.equipItemIfPossible(worldserver, itemstack, null);
+ }
+
+ public ItemStack equipItemIfPossible(ItemStack itemstack, EntityItem entityitem) {
+ public ItemStack equipItemIfPossible(WorldServer worldserver, ItemStack itemstack, EntityItem entityitem) {
+ // CraftBukkit end
EnumItemSlot enumitemslot = this.getEquipmentSlotForItem(itemstack);
ItemStack itemstack1 = this.getItemBySlot(enumitemslot);
boolean flag = this.canReplaceCurrentItem(itemstack, itemstack1);
@@ -639,11 +719,19 @@
boolean flag = this.canReplaceCurrentItem(itemstack, itemstack1, enumitemslot);
@@ -639,11 +717,19 @@
flag = itemstack1.isEmpty();
}
@@ -186,12 +184,12 @@
if (!itemstack1.isEmpty() && (double) Math.max(this.random.nextFloat() - 0.1F, 0.0F) < d0) {
+ this.forceDrops = true; // CraftBukkit
this.spawnAtLocation(itemstack1);
this.spawnAtLocation(worldserver, itemstack1);
+ this.forceDrops = false; // CraftBukkit
}
ItemStack itemstack2 = enumitemslot.limit(itemstack);
@@ -772,7 +860,7 @@
@@ -770,7 +856,7 @@
@Override
public void checkDespawn() {
if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.shouldDespawnInPeaceful()) {
@@ -200,7 +198,7 @@
} else if (!this.isPersistenceRequired() && !this.requiresCustomPersistence()) {
EntityHuman entityhuman = this.level().getNearestPlayer(this, -1.0D);
@@ -782,14 +870,14 @@
@@ -780,14 +866,14 @@
int j = i * i;
if (d0 > (double) j && this.removeWhenFarAway(d0)) {
@@ -217,15 +215,15 @@
} else if (d0 < (double) l) {
this.noActionTime = 0;
}
@@ -803,6 +891,7 @@
@@ -801,6 +887,7 @@
@Override
protected final void serverAiStep() {
++this.noActionTime;
+ if (!this.aware) return; // CraftBukkit
GameProfilerFiller gameprofilerfiller = this.level().getProfiler();
GameProfilerFiller gameprofilerfiller = Profiler.get();
gameprofilerfiller.push("sensing");
@@ -1354,7 +1443,7 @@
@@ -1340,7 +1427,7 @@
if (itemstack.getItem() instanceof ItemMonsterEgg) {
if (this.level() instanceof WorldServer) {
ItemMonsterEgg itemmonsteregg = (ItemMonsterEgg) itemstack.getItem();
@@ -234,51 +232,71 @@
optional.ifPresent((entityinsentient) -> {
this.onOffspringSpawnedFromEgg(entityhuman, entityinsentient);
@@ -1403,12 +1492,19 @@
@@ -1391,12 +1478,19 @@
return this.restrictRadius != -1.0F;
}
+ // CraftBukkit start
@Nullable
public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, boolean flag) {
+ return this.convertTo(entitytypes, flag, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT);
public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, ConversionParams conversionparams, EntitySpawnReason entityspawnreason, ConversionParams.a<T> conversionparams_a) {
+ return this.convertTo(entitytypes, conversionparams, entityspawnreason, conversionparams_a, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT);
+ }
+
+ @Nullable
+ public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, boolean flag, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) {
+ public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, ConversionParams conversionparams, EntitySpawnReason entityspawnreason, ConversionParams.a<T> conversionparams_a, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) {
+ // CraftBukkit end
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(), entityspawnreason);
+ T t0 = entitytypes.create(this.level(), EntitySpawnReason.CONVERSION); // CraftBukkit - decompile error
if (t0 == null) {
return null;
@@ -1442,7 +1538,12 @@
}
}
@@ -1405,14 +1499,24 @@
conversionparams_a.finalizeConversion(t0);
World world = this.level();
- this.level().addFreshEntity(t0);
+ // CraftBukkit start
+ if (transformReason == null) {
+ // Special handling for slime split and pig lightning
+ return t0;
+ }
+
+ if (CraftEventFactory.callEntityTransformEvent(this, t0, transformReason).isCancelled()) {
+ return null;
+ }
+ this.level().addFreshEntity(t0, spawnReason);
+ // CraftBukkit end
if (this.isPassenger()) {
Entity entity = this.getVehicle();
if (world instanceof WorldServer) {
WorldServer worldserver = (WorldServer) world;
@@ -1450,7 +1551,7 @@
t0.startRiding(entity, true);
- worldserver.addFreshEntity(t0);
+ worldserver.addFreshEntity(t0, spawnReason); // CraftBukkit
}
if (conversionparams.type().shouldDiscardAfterConversion()) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
}
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
return t0;
}
}
@@ -1492,6 +1593,7 @@
@@ -1422,7 +1526,14 @@
@Nullable
public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, ConversionParams conversionparams, ConversionParams.a<T> conversionparams_a) {
- return this.convertTo(entitytypes, conversionparams, EntitySpawnReason.CONVERSION, conversionparams_a);
+ // CraftBukkit start
+ return this.convertTo(entitytypes, conversionparams, conversionparams_a, EntityTransformEvent.TransformReason.UNKNOWN, CreatureSpawnEvent.SpawnReason.DEFAULT);
+ }
+
+ @Nullable
+ public <T extends EntityInsentient> T convertTo(EntityTypes<T> entitytypes, ConversionParams conversionparams, ConversionParams.a<T> conversionparams_a, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) {
+ return this.convertTo(entitytypes, conversionparams, EntitySpawnReason.CONVERSION, conversionparams_a, transformReason, spawnReason);
+ // CraftBukkit end
}
@Nullable
@@ -1461,6 +1572,7 @@
boolean flag1 = super.startRiding(entity, flag);
if (flag1 && this.isLeashed()) {
@@ -286,10 +304,10 @@
this.dropLeash(true, true);
}
@@ -1578,7 +1680,7 @@
if (f1 > 0.0F && entity instanceof EntityLiving) {
EntityLiving entityliving = (EntityLiving) entity;
@@ -1545,7 +1657,7 @@
if (f1 > 0.0F && entity instanceof EntityLiving) {
entityliving = (EntityLiving) entity;
- entityliving.knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F)));
+ entityliving.knockback((double) (f1 * 0.5F), (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F)), this, org.bukkit.event.entity.EntityKnockbackEvent.KnockbackCause.ENTITY_ATTACK); // CraftBukkit
this.setDeltaMovement(this.getDeltaMovement().multiply(0.6D, 1.0D, 0.6D));

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/EntityLightning.java
+++ b/net/minecraft/world/entity/EntityLightning.java
@@ -30,6 +30,11 @@
@@ -31,6 +31,11 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
@@ -12,7 +12,7 @@
public class EntityLightning extends Entity {
private static final int START_LIFE = 2;
@@ -121,7 +126,7 @@
@@ -120,7 +125,7 @@
}
}
@@ -21,7 +21,7 @@
} else if (this.life < -this.random.nextInt(10)) {
--this.flashes;
this.life = 1;
@@ -130,7 +135,7 @@
@@ -129,7 +134,7 @@
}
}
@@ -30,37 +30,37 @@
if (!(this.level() instanceof WorldServer)) {
this.level().setSkyFlashTime(2);
} else if (!this.visualOnly) {
@@ -164,8 +169,12 @@
IBlockData iblockdata = BlockFireAbstract.getState(this.level(), blockposition);
@@ -169,8 +174,12 @@
IBlockData iblockdata = BlockFireAbstract.getState(this.level(), blockposition);
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(this.level(), blockposition, this).isCancelled()) {
+ this.level().setBlockAndUpdate(blockposition, iblockdata);
+ ++this.blocksSetOnFire;
+ }
+ // CraftBukkit end
}
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(this.level(), blockposition, this).isCancelled()) {
+ this.level().setBlockAndUpdate(blockposition, iblockdata);
+ ++this.blocksSetOnFire;
+ }
+ // CraftBukkit end
}
for (int j = 0; j < i; ++j) {
@@ -173,8 +182,12 @@
for (int j = 0; j < i; ++j) {
@@ -178,8 +187,12 @@
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(this.level(), blockposition1, this).isCancelled()) {
+ this.level().setBlockAndUpdate(blockposition1, iblockdata);
+ ++this.blocksSetOnFire;
+ }
+ // CraftBukkit end
}
}
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(this.level(), blockposition1, this).isCancelled()) {
+ this.level().setBlockAndUpdate(blockposition1, iblockdata);
+ ++this.blocksSetOnFire;
+ }
+ // CraftBukkit end
}
}
@@ -238,8 +251,9 @@
@@ -247,8 +260,9 @@
iblockdata = world.getBlockState(blockposition1);
} while (!(iblockdata.getBlock() instanceof WeatheringCopper));

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/EntityLiving.java
+++ b/net/minecraft/world/entity/EntityLiving.java
@@ -132,6 +132,32 @@
@@ -137,6 +137,33 @@
import net.minecraft.world.scores.ScoreboardTeam;
import org.slf4j.Logger;
@@ -8,10 +8,11 @@
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Set;
+import com.google.common.base.Function;
+import java.util.LinkedList;
+import java.util.UUID;
+import net.minecraft.nbt.NBTTagFloat;
+import net.minecraft.nbt.NBTTagInt;
+import net.minecraft.world.item.component.Consumable;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.attribute.CraftAttributeMap;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@@ -33,18 +34,9 @@
public abstract class EntityLiving extends Entity implements Attackable {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -157,7 +183,7 @@
private static final double MAX_LINE_OF_SIGHT_TEST_RANGE = 128.0D;
protected static final int LIVING_ENTITY_FLAG_IS_USING = 1;
protected static final int LIVING_ENTITY_FLAG_OFF_HAND = 2;
- protected static final int LIVING_ENTITY_FLAG_SPIN_ATTACK = 4;
+ public static final int LIVING_ENTITY_FLAG_SPIN_ATTACK = 4;
protected static final DataWatcherObject<Byte> DATA_LIVING_ENTITY_FLAGS = DataWatcher.defineId(EntityLiving.class, DataWatcherRegistry.BYTE);
public static final DataWatcherObject<Float> DATA_HEALTH_ID = DataWatcher.defineId(EntityLiving.class, DataWatcherRegistry.FLOAT);
private static final DataWatcherObject<List<ParticleParam>> DATA_EFFECT_PARTICLES = DataWatcher.defineId(EntityLiving.class, DataWatcherRegistry.PARTICLES);
@@ -249,6 +275,19 @@
@@ -262,6 +289,19 @@
protected boolean skipDropExperience;
private final Reference2ObjectMap<Enchantment, Set<EnchantmentLocationBasedEffect>> activeLocationDependentEnchantments;
private final EnumMap<EnumItemSlot, Reference2ObjectMap<Enchantment, Set<EnchantmentLocationBasedEffect>>> activeLocationDependentEnchantments;
protected float appliedScale;
+ // CraftBukkit start
+ public int expToDrop;
@@ -62,8 +54,8 @@
protected EntityLiving(EntityTypes<? extends EntityLiving> entitytypes, World world) {
super(entitytypes, world);
@@ -264,7 +303,9 @@
this.activeLocationDependentEnchantments = new Reference2ObjectArrayMap();
@@ -278,7 +318,9 @@
this.activeLocationDependentEnchantments = new EnumMap(EnumItemSlot.class);
this.appliedScale = 1.0F;
this.attributes = new AttributeMapBase(AttributeDefaults.getSupplier(entitytypes));
- this.setHealth(this.getMaxHealth());
@@ -73,22 +65,22 @@
this.blocksBuilding = true;
this.rotA = (float) ((Math.random() + 1.0D) * 0.009999999776482582D);
this.reapplyPosition();
@@ -344,7 +385,13 @@
@@ -358,7 +400,13 @@
double d8 = Math.min((double) (0.2F + f / 15.0F), 2.5D);
int i = (int) (150.0D * d8);
- ((WorldServer) this.level()).sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D);
- worldserver.sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, 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), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false);
+ worldserver.sendParticles((EntityPlayer) this, new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, false);
+ } else {
+ ((WorldServer) this.level()).sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D);
+ worldserver.sendParticles(new ParticleParamBlock(Particles.BLOCK, iblockdata), d2, d3, d4, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D);
+ }
+ // CraftBukkit end
}
}
}
@@ -555,7 +602,7 @@
@@ -573,7 +621,7 @@
++this.deathTime;
if (this.deathTime >= 20 && !this.level().isClientSide() && !this.isRemoved()) {
this.level().broadcastEntityEvent(this, (byte) 60);
@@ -97,7 +89,7 @@
}
}
@@ -661,13 +708,19 @@
@@ -679,13 +727,19 @@
}
public void onEquipItem(EnumItemSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1) {
@@ -107,18 +99,18 @@
+
+ public void onEquipItem(EnumItemSlot enumitemslot, ItemStack itemstack, ItemStack itemstack1, boolean silent) {
+ // CraftBukkit end
boolean flag = itemstack1.isEmpty() && itemstack.isEmpty();
if (!this.level().isClientSide() && !this.isSpectator()) {
boolean flag = itemstack1.isEmpty() && itemstack.isEmpty();
if (!flag && !ItemStack.isSameItemSameComponents(itemstack, itemstack1) && !this.firstTick) {
Equipable equipable = Equipable.get(itemstack1);
if (!flag && !ItemStack.isSameItemSameComponents(itemstack, itemstack1) && !this.firstTick) {
Equippable equippable = (Equippable) itemstack1.get(DataComponents.EQUIPPABLE);
if (!this.level().isClientSide() && !this.isSpectator()) {
- if (!this.isSilent() && equipable != null && equipable.getEquipmentSlot() == enumitemslot) {
+ if (!this.isSilent() && equipable != null && equipable.getEquipmentSlot() == enumitemslot && !silent) { // CraftBukkit
this.level().playSeededSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), equipable.getEquipSound(), this.getSoundSource(), 1.0F, 1.0F, this.random.nextLong());
- if (!this.isSilent() && equippable != null && enumitemslot == equippable.slot()) {
+ if (!this.isSilent() && equippable != null && enumitemslot == equippable.slot() && !silent) { // CraftBukkit
this.level().playSeededSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), equippable.equipSound(), this.getSoundSource(), 1.0F, 1.0F, this.random.nextLong());
}
@@ -681,11 +734,18 @@
@@ -699,6 +753,13 @@
@Override
public void remove(Entity.RemovalReason entity_removalreason) {
@@ -130,7 +122,10 @@
+ public void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) {
+ // CraftBukkit end
if (entity_removalreason == Entity.RemovalReason.KILLED || entity_removalreason == Entity.RemovalReason.DISCARDED) {
this.triggerOnDeathMobEffects(entity_removalreason);
World world = this.level();
@@ -709,7 +770,7 @@
}
}
- super.remove(entity_removalreason);
@@ -138,15 +133,15 @@
this.brain.clearMemories();
}
@@ -698,6 +758,7 @@
mobeffect.onMobRemoved(this, entity_removalreason);
@@ -722,6 +783,7 @@
mobeffect.onMobRemoved(worldserver, this, entity_removalreason);
}
+ this.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DEATH); // CraftBukkit
this.activeEffects.clear();
}
@@ -757,6 +818,17 @@
@@ -781,6 +843,17 @@
}
}
@@ -164,7 +159,7 @@
if (nbttagcompound.contains("Health", 99)) {
this.setHealth(nbttagcompound.getFloat("Health"));
}
@@ -795,9 +867,32 @@
@@ -819,9 +892,32 @@
}
@@ -197,7 +192,7 @@
try {
while (iterator.hasNext()) {
Holder<MobEffectList> holder = (Holder) iterator.next();
@@ -807,6 +902,12 @@
@@ -831,6 +927,12 @@
this.onEffectUpdated(mobeffect, true, (Entity) null);
})) {
if (!this.level().isClientSide) {
@@ -208,9 +203,9 @@
+ }
+ // CraftBukkit end
iterator.remove();
this.onEffectRemoved(mobeffect);
this.onEffectsRemoved(List.of(mobeffect));
}
@@ -817,6 +918,17 @@
@@ -841,6 +943,17 @@
} catch (ConcurrentModificationException concurrentmodificationexception) {
;
}
@@ -228,7 +223,7 @@
if (this.effectsDirty) {
if (!this.level().isClientSide) {
@@ -932,7 +1044,13 @@
@@ -952,17 +1065,36 @@
this.entityData.set(EntityLiving.DATA_EFFECT_PARTICLES, List.of());
}
@@ -241,24 +236,35 @@
+ // CraftBukkit end
if (this.level().isClientSide) {
return false;
} else if (this.activeEffects.isEmpty()) {
return false;
} else {
@@ -941,7 +1059,14 @@
boolean flag;
- Map<Holder<MobEffectList>, MobEffect> map = Maps.newHashMap(this.activeEffects);
+ // CraftBukkit start
+ List<MobEffect> toRemove = new LinkedList<>();
+ Iterator<MobEffect> iterator = this.activeEffects.values().iterator();
for (flag = false; iterator.hasNext(); flag = true) {
- this.onEffectRemoved((MobEffect) iterator.next());
+ // CraftBukkit start
+ MobEffect effect = (MobEffect) iterator.next();
- this.activeEffects.clear();
- this.onEffectsRemoved(map.values());
- return true;
+ while (iterator.hasNext()) {
+ MobEffect effect = iterator.next();
+ EntityPotionEffectEvent event = CraftEventFactory.callEntityPotionEffectChangeEvent(this, effect, null, cause, EntityPotionEffectEvent.Action.CLEARED);
+ if (event.isCancelled()) {
+ continue;
+ }
+ this.onEffectRemoved(effect);
+ // CraftBukkit end
iterator.remove();
}
+
+ iterator.remove();
+ toRemove.add(effect);
+ }
+
+ this.onEffectsRemoved(toRemove);
+ return !toRemove.isEmpty();
+ // CraftBukkit end
}
}
@@ -970,20 +1095,50 @@
@@ -987,20 +1119,50 @@
return this.addEffect(mobeffect, (Entity) null);
}
@@ -310,7 +316,7 @@
flag = true;
}
@@ -1014,13 +1169,39 @@
@@ -1031,13 +1193,39 @@
return this.getType().is(TagsEntity.INVERTED_HEALING_AND_HARM);
}
@@ -350,8 +356,8 @@
+ // CraftBukkit end
if (mobeffect != null) {
this.onEffectRemoved(mobeffect);
@@ -1118,20 +1299,55 @@
this.onEffectsRemoved(List.of(mobeffect));
@@ -1142,20 +1330,55 @@
}
@@ -408,18 +414,18 @@
this.entityData.set(EntityLiving.DATA_HEALTH_ID, MathHelper.clamp(f, 0.0F, this.getMaxHealth()));
}
@@ -1145,7 +1361,7 @@
return false;
} else if (this.level().isClientSide) {
@@ -1167,7 +1390,7 @@
public boolean hurtServer(WorldServer worldserver, DamageSource damagesource, float f) {
if (this.isInvulnerableTo(worldserver, damagesource)) {
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;
@@ -1156,10 +1372,11 @@
@@ -1182,10 +1405,11 @@
}
this.noActionTime = 0;
float f1 = f;
- boolean flag = false;
+ boolean flag = f > 0.0F && this.isDamageSourceBlocked(damagesource); // Copied from below
@@ -431,7 +437,7 @@
this.hurtCurrentlyUsedShield(f);
f2 = f;
f = 0.0F;
@@ -1176,30 +1393,50 @@
@@ -1202,15 +1426,26 @@
flag = true;
}
@@ -458,6 +464,10 @@
+ // CraftBukkit end
+
this.walkAnimation.setSpeed(1.5F);
if (Float.isNaN(f) || Float.isInfinite(f)) {
f = Float.MAX_VALUE;
@@ -1218,18 +1453,27 @@
boolean flag1 = true;
- if ((float) this.invulnerableTime > 10.0F && !damagesource.is(DamageTypeTags.BYPASSES_COOLDOWN)) {
@@ -466,9 +476,9 @@
return false;
}
- this.actuallyHurt(damagesource, f - this.lastHurt);
- this.actuallyHurt(worldserver, damagesource, f - this.lastHurt);
+ // CraftBukkit start
+ if (!this.actuallyHurt(damagesource, (float) event.getFinalDamage() - this.lastHurt, event)) {
+ if (!this.actuallyHurt(worldserver, damagesource, (float) event.getFinalDamage() - this.lastHurt, event)) {
+ return false;
+ }
+ // CraftBukkit end
@@ -476,20 +486,20 @@
flag1 = false;
} else {
+ // CraftBukkit start
+ if (!this.actuallyHurt(damagesource, (float) event.getFinalDamage(), event)) {
+ if (!this.actuallyHurt(worldserver, damagesource, (float) event.getFinalDamage(), event)) {
+ return false;
+ }
this.lastHurt = f;
- this.invulnerableTime = 20;
- this.actuallyHurt(damagesource, f);
- this.actuallyHurt(worldserver, damagesource, f);
+ this.invulnerableTime = this.invulnerableDuration; // CraftBukkit - restore use of maxNoDamageTicks
+ // this.actuallyHurt(damagesource, f);
+ // this.actuallyHurt(worldserver, damagesource, f);
+ // CraftBukkit end
this.hurtDuration = 10;
this.hurtTime = this.hurtDuration;
}
@@ -1245,7 +1482,7 @@
this.level().broadcastDamageEvent(this, damagesource);
@@ -1275,7 +1519,7 @@
worldserver.broadcastDamageEvent(this, damagesource);
}
- if (!damagesource.is(DamageTypeTags.NO_IMPACT) && (!flag || f > 0.0F)) {
@@ -497,7 +507,7 @@
this.markHurt();
}
@@ -1265,7 +1502,7 @@
@@ -1295,7 +1539,7 @@
d1 = damagesource.getSourcePosition().z() - this.getZ();
}
@@ -506,7 +516,7 @@
if (!flag) {
this.indicateDamage(d0, d1);
}
@@ -1284,7 +1521,7 @@
@@ -1314,7 +1558,7 @@
this.playHurtSound(damagesource);
}
@@ -515,7 +525,7 @@
if (flag2) {
this.lastDamageSource = damagesource;
@@ -1318,7 +1555,7 @@
@@ -1352,7 +1596,7 @@
}
protected void blockedByShield(EntityLiving entityliving) {
@@ -524,7 +534,7 @@
}
private boolean checkTotemDeathProtection(DamageSource damagesource) {
@@ -1329,19 +1566,32 @@
@@ -1364,20 +1608,33 @@
EnumHand[] aenumhand = EnumHand.values();
int i = aenumhand.length;
@@ -536,7 +546,8 @@
- ItemStack itemstack1 = this.getItemInHand(enumhand);
+ itemstack1 = this.getItemInHand(enumhand);
if (itemstack1.is(Items.TOTEM_OF_UNDYING)) {
deathprotection = (DeathProtection) itemstack1.get(DataComponents.DEATH_PROTECTION);
if (deathprotection != null) {
+ hand = enumhand; // CraftBukkit
itemstack = itemstack1.copy();
- itemstack1.shrink(1);
@@ -560,30 +571,8 @@
+ // CraftBukkit end
EntityPlayer entityplayer = (EntityPlayer) this;
entityplayer.awardStat(StatisticList.ITEM_USED.get(Items.TOTEM_OF_UNDYING));
@@ -1350,14 +1600,16 @@
}
this.setHealth(1.0F);
- this.removeAllEffects();
- this.addEffect(new MobEffect(MobEffects.REGENERATION, 900, 1));
- this.addEffect(new MobEffect(MobEffects.ABSORPTION, 100, 1));
- this.addEffect(new MobEffect(MobEffects.FIRE_RESISTANCE, 800, 0));
+ // CraftBukkit start
+ this.removeAllEffects(org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM);
+ this.addEffect(new MobEffect(MobEffects.REGENERATION, 900, 1), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TOTEM);
+ this.addEffect(new MobEffect(MobEffects.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);
}
- return itemstack != null;
+ return !event.isCancelled();
}
}
@@ -1464,14 +1716,22 @@
entityplayer.awardStat(StatisticList.ITEM_USED.get(itemstack.getItem()));
@@ -1501,14 +1758,22 @@
IBlockData iblockdata = Blocks.WITHER_ROSE.defaultBlockState();
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
@@ -608,13 +597,13 @@
this.level().addFreshEntity(entityitem);
}
}
@@ -1482,26 +1742,41 @@
@@ -1519,22 +1784,37 @@
protected void dropAllDeathLoot(WorldServer worldserver, DamageSource damagesource) {
boolean flag = this.lastHurtByPlayerTime > 0;
+ this.dropEquipment(); // CraftBukkit - from below
+ this.dropEquipment(worldserver); // CraftBukkit - from below
if (this.shouldDropLoot() && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
this.dropFromLootTable(damagesource, flag);
this.dropFromLootTable(worldserver, damagesource, flag);
this.dropCustomDeathLoot(worldserver, damagesource, flag);
}
+ // CraftBukkit start - Call death event
@@ -622,38 +611,34 @@
+ this.drops = new ArrayList<>();
+ // CraftBukkit end
- this.dropEquipment();
+ // this.dropEquipment();// CraftBukkit - moved up
this.dropExperience(damagesource.getEntity());
- this.dropEquipment(worldserver);
+ // this.dropEquipment(worldserver);// CraftBukkit - moved up
this.dropExperience(worldserver, damagesource.getEntity());
}
protected void dropEquipment() {}
protected void dropEquipment(WorldServer worldserver) {}
- protected void dropExperience(@Nullable Entity entity) {
+ public int getExpReward(@Nullable Entity entity) { // CraftBukkit
World world = this.level();
if (world instanceof WorldServer worldserver) {
if (!this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) {
- EntityExperienceOrb.award(worldserver, this.position(), this.getExperienceReward(worldserver, entity));
+ return this.getExperienceReward(worldserver, entity); // CraftBukkit
}
- protected void dropExperience(WorldServer worldserver, @Nullable Entity entity) {
+ public int getExpReward(WorldServer worldserver, @Nullable Entity entity) { // CraftBukkit
if (!this.wasExperienceConsumed() && (this.isAlwaysExperienceDropper() || this.lastHurtByPlayerTime > 0 && this.shouldDropExperience() && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT))) {
- EntityExperienceOrb.award(worldserver, this.position(), this.getExperienceReward(worldserver, entity));
+ return this.getExperienceReward(worldserver, entity); // CraftBukkit }
}
+ return 0; // CraftBukkit
+ }
+
+ protected void dropExperience(@Nullable Entity entity) {
+ protected void dropExperience(WorldServer worldserver, @Nullable Entity entity) {
+ // CraftBukkit start - Update getExpReward() above if the removed if() changes!
+ if (!(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.position(), this.expToDrop);
+ this.expToDrop = 0;
+ }
+ // CraftBukkit end
}
protected void dropCustomDeathLoot(WorldServer worldserver, DamageSource damagesource, boolean flag) {}
@@ -1540,9 +1815,14 @@
@@ -1601,9 +1881,14 @@
}
public void knockback(double d0, double d1, double d2) {
@@ -670,7 +655,7 @@
Vec3D vec3d;
@@ -1552,7 +1832,14 @@
@@ -1613,7 +1898,14 @@
Vec3D vec3d1 = (new Vec3D(d1, 0.0D, d2)).normalize().scale(d0);
@@ -686,8 +671,8 @@
}
}
@@ -1613,6 +1900,28 @@
return itemstack.getEatingSound();
@@ -1668,6 +1960,20 @@
return new EntityLiving.a(SoundEffects.GENERIC_SMALL_FALL, SoundEffects.GENERIC_BIG_FALL);
}
+ // CraftBukkit start - Add delegate methods
@@ -702,25 +687,17 @@
+ public SoundEffect getFallDamageSound0(int fallHeight) {
+ return getFallDamageSound(fallHeight);
+ }
+
+ public SoundEffect getDrinkingSound0(ItemStack itemstack) {
+ return getDrinkingSound(itemstack);
+ }
+
+ public SoundEffect getEatingSound0(ItemStack itemstack) {
+ return getEatingSound(itemstack);
+ }
+ // CraftBukkit end
+
public Optional<BlockPosition> getLastClimbablePos() {
return this.lastClimbablePos;
}
@@ -1666,9 +1975,14 @@
@@ -1746,9 +2052,14 @@
int i = this.calculateFallDamage(f, f1);
if (i > 0) {
+ // CraftBukkit start
+ if (!this.hurt(damagesource, (float) i)) {
+ if (!this.hurtServer((WorldServer) this.level(), damagesource, (float) i)) {
+ return true;
+ }
+ // CraftBukkit end
@@ -731,7 +708,7 @@
return true;
} else {
return flag;
@@ -1738,7 +2052,7 @@
@@ -1819,7 +2130,7 @@
protected float getDamageAfterArmorAbsorb(DamageSource damagesource, float f) {
if (!damagesource.is(DamageTypeTags.BYPASSES_ARMOR)) {
@@ -740,7 +717,7 @@
f = CombatMath.getDamageAfterAbsorb(this, f, damagesource, (float) this.getArmorValue(), (float) this.getAttributeValue(GenericAttributes.ARMOR_TOUGHNESS));
}
@@ -1749,7 +2063,8 @@
@@ -1830,7 +2141,8 @@
if (damagesource.is(DamageTypeTags.BYPASSES_EFFECTS)) {
return f;
} else {
@@ -750,16 +727,16 @@
int i = (this.getEffect(MobEffects.DAMAGE_RESISTANCE).getAmplifier() + 1) * 5;
int j = 25 - i;
float f1 = f * (float) j;
@@ -1792,15 +2107,140 @@
@@ -1873,15 +2185,140 @@
}
}
- protected void actuallyHurt(DamageSource damagesource, float f) {
- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) {
+ // CraftBukkit start
+ private EntityDamageEvent handleEntityDamage(final DamageSource damagesource, float f) {
+ float originalDamage = f;
+
+ Function<Double, Double> freezing = new Function<Double, Double>() {
+ com.google.common.base.Function<Double, Double> freezing = new com.google.common.base.Function<Double, Double>() {
+ @Override
+ public Double apply(Double f) {
+ if (damagesource.is(DamageTypeTags.IS_FREEZING) && EntityLiving.this.getType().is(TagsEntity.FREEZE_HURTS_EXTRA_TYPES)) {
@@ -771,7 +748,7 @@
+ float freezingModifier = freezing.apply((double) f).floatValue();
+ f += freezingModifier;
+
+ Function<Double, Double> hardHat = new Function<Double, Double>() {
+ com.google.common.base.Function<Double, Double> hardHat = new com.google.common.base.Function<Double, Double>() {
+ @Override
+ public Double apply(Double f) {
+ if (damagesource.is(DamageTypeTags.DAMAGES_HELMET) && !EntityLiving.this.getItemBySlot(EnumItemSlot.HEAD).isEmpty()) {
@@ -783,7 +760,7 @@
+ float hardHatModifier = hardHat.apply((double) f).floatValue();
+ f += hardHatModifier;
+
+ Function<Double, Double> blocking = new Function<Double, Double>() {
+ com.google.common.base.Function<Double, Double> blocking = new com.google.common.base.Function<Double, Double>() {
+ @Override
+ public Double apply(Double f) {
+ return -((EntityLiving.this.isDamageSourceBlocked(damagesource)) ? f : 0.0);
@@ -792,7 +769,7 @@
+ float blockingModifier = blocking.apply((double) f).floatValue();
+ f += blockingModifier;
+
+ Function<Double, Double> armor = new Function<Double, Double>() {
+ com.google.common.base.Function<Double, Double> armor = new com.google.common.base.Function<Double, Double>() {
+ @Override
+ public Double apply(Double f) {
+ return -(f - EntityLiving.this.getDamageAfterArmorAbsorb(damagesource, f.floatValue()));
@@ -801,7 +778,7 @@
+ float armorModifier = armor.apply((double) f).floatValue();
+ f += armorModifier;
+
+ Function<Double, Double> resistance = new Function<Double, Double>() {
+ com.google.common.base.Function<Double, Double> resistance = new com.google.common.base.Function<Double, Double>() {
+ @Override
+ public Double apply(Double f) {
+ if (!damagesource.is(DamageTypeTags.BYPASSES_EFFECTS) && EntityLiving.this.hasEffect(MobEffects.DAMAGE_RESISTANCE) && !damagesource.is(DamageTypeTags.BYPASSES_RESISTANCE)) {
@@ -816,7 +793,7 @@
+ float resistanceModifier = resistance.apply((double) f).floatValue();
+ f += resistanceModifier;
+
+ Function<Double, Double> magic = new Function<Double, Double>() {
+ com.google.common.base.Function<Double, Double> magic = new com.google.common.base.Function<Double, Double>() {
+ @Override
+ public Double apply(Double f) {
+ return -(f - EntityLiving.this.getDamageAfterMagicAbsorb(damagesource, f.floatValue()));
@@ -825,7 +802,7 @@
+ float magicModifier = magic.apply((double) f).floatValue();
+ f += magicModifier;
+
+ Function<Double, Double> absorption = new Function<Double, Double>() {
+ com.google.common.base.Function<Double, Double> absorption = new com.google.common.base.Function<Double, Double>() {
+ @Override
+ public Double apply(Double f) {
+ return -(Math.max(f - Math.max(f - EntityLiving.this.getAbsorptionAmount(), 0.0F), 0.0F));
@@ -836,8 +813,8 @@
+ return CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, freezingModifier, hardHatModifier, blockingModifier, armorModifier, resistanceModifier, magicModifier, absorptionModifier, freezing, hardHat, blocking, armor, resistance, magic, absorption);
+ }
+
+ protected boolean actuallyHurt(final DamageSource damagesource, float f, final EntityDamageEvent event) { // void -> boolean, add final
if (!this.isInvulnerableTo(damagesource)) {
+ protected boolean actuallyHurt(WorldServer worldserver, final DamageSource damagesource, float f, final EntityDamageEvent event) { // void -> boolean, add final
if (!this.isInvulnerableTo(worldserver, damagesource)) {
- f = this.getDamageAfterArmorAbsorb(damagesource, f);
- f = this.getDamageAfterMagicAbsorb(damagesource, f);
- float f1 = f;
@@ -898,7 +875,7 @@
if (f2 > 0.0F && f2 < 3.4028235E37F) {
Entity entity = damagesource.getEntity();
@@ -1812,13 +2252,48 @@
@@ -1893,13 +2330,48 @@
}
}
@@ -949,7 +926,7 @@
}
public CombatTracker getCombatTracker() {
@@ -1843,9 +2318,19 @@
@@ -1924,9 +2396,19 @@
}
public final void setArrowCount(int i) {
@@ -970,7 +947,7 @@
public final int getStingerCount() {
return (Integer) this.entityData.get(EntityLiving.DATA_STINGER_COUNT_ID);
}
@@ -2086,6 +2571,12 @@
@@ -2171,6 +2653,12 @@
public abstract ItemStack getItemBySlot(EnumItemSlot enumitemslot);
@@ -983,15 +960,7 @@
public abstract void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack);
public Iterable<ItemStack> getHandSlots() {
@@ -2336,6 +2827,7 @@
}
if (this.onGround() && !this.level().isClientSide) {
+ if (getSharedFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit
this.setSharedFlag(7, false);
}
} else {
@@ -2506,7 +2998,7 @@
@@ -2623,7 +3111,7 @@
}
}
@@ -1000,8 +969,8 @@
if (this.tickCount % 20 == 0) {
this.getCombatTracker().recheckStatus();
}
@@ -2610,7 +3102,7 @@
@@ -2730,7 +3218,7 @@
this.elytraAnimationState.tick();
}
- public void detectEquipmentUpdates() {
@@ -1009,15 +978,15 @@
Map<EnumItemSlot, ItemStack> map = this.collectEquipmentChanges();
if (map != null) {
@@ -2949,6 +3441,7 @@
}
@@ -3052,6 +3540,7 @@
this.checkSlowFallDistance();
if (!this.level().isClientSide) {
+ if (flag != this.getSharedFlag(7) && !CraftEventFactory.callToggleGlideEvent(this, flag).isCancelled()) // CraftBukkit
this.setSharedFlag(7, flag);
}
@@ -3141,13 +3634,20 @@
if (!this.canGlide()) {
+ if (this.getSharedFlag(7) != false && !CraftEventFactory.callToggleGlideEvent(this, false).isCancelled()) // CraftBukkit
this.setSharedFlag(7, false);
return;
}
@@ -3298,14 +3787,21 @@
@Override
public boolean isPickable() {
@@ -1029,30 +998,22 @@
public boolean isPushable() {
- return this.isAlive() && !this.isSpectator() && !this.onClimbable();
+ return this.isAlive() && !this.isSpectator() && !this.onClimbable() && this.collides; // CraftBukkit
+ }
+
}
+ // CraftBukkit start - collidable API
+ @Override
+ public boolean canCollideWithBukkit(Entity entity) {
+ return isPushable() && this.collides != this.collidableExemptions.contains(entity.getUUID());
}
+ }
+ // CraftBukkit end
+
@Override
public float getYHeadRot() {
@@ -3245,7 +3745,7 @@
}
- protected void setLivingEntityFlag(int i, boolean flag) {
+ public void setLivingEntityFlag(int i, boolean flag) {
int j = (Byte) this.entityData.get(EntityLiving.DATA_LIVING_ENTITY_FLAGS);
if (flag) {
@@ -3346,7 +3846,29 @@
return this.yHeadRot;
@@ -3476,7 +3972,30 @@
this.releaseUsingItem();
} else {
if (!this.useItem.isEmpty() && this.isUsingItem()) {
this.triggerItemUseEffects(this.useItem, 16);
- ItemStack itemstack = this.useItem.finishUsingItem(this.level(), this);
+ // CraftBukkit start - fire PlayerItemConsumeEvent
+ ItemStack itemstack;
@@ -1064,8 +1025,9 @@
+
+ if (event.isCancelled()) {
+ // Update client
+ if (this.useItem.getItem() instanceof net.minecraft.world.item.ItemSuspiciousStew itemSuspiciousStew) {
+ itemSuspiciousStew.cancelUsingItem(entityPlayer, this.useItem);
+ Consumable consumable = this.useItem.get(DataComponents.CONSUMABLE);
+ if (consumable != null) {
+ consumable.cancelUsingItem(entityPlayer, this.useItem);
+ }
+ entityPlayer.getBukkitEntity().updateInventory();
+ entityPlayer.getBukkitEntity().updateScaledHealth();
@@ -1080,7 +1042,7 @@
if (itemstack != this.useItem) {
this.setItemInHand(enumhand, itemstack);
@@ -3424,6 +3946,12 @@
@@ -3561,6 +4080,12 @@
}
public boolean randomTeleport(double d0, double d1, double d2, boolean flag) {
@@ -1093,7 +1055,7 @@
double d3 = this.getX();
double d4 = this.getY();
double d5 = this.getZ();
@@ -3448,16 +3976,41 @@
@@ -3585,16 +4110,41 @@
}
if (flag2) {
@@ -1121,7 +1083,7 @@
+ }
+ } else {
+ // player teleport event is called in the underlining code
+ if (!((EntityPlayer) this).connection.teleport(d0, d6, d2, this.getYRot(), this.getXRot(), java.util.Collections.emptySet(), cause)) {
+ if (!((EntityPlayer) this).connection.teleport(d0, d6, d2, this.getYRot(), this.getXRot(), cause)) {
+ return Optional.empty();
+ }
+ }
@@ -1138,7 +1100,7 @@
} else {
if (flag) {
world.broadcastEntityEvent(this, (byte) 46);
@@ -3469,7 +4022,7 @@
@@ -3606,7 +4156,7 @@
entitycreature.getNavigation().stop();
}
@@ -1147,7 +1109,7 @@
}
}
@@ -3562,7 +4115,7 @@
@@ -3699,7 +4249,7 @@
}
public void stopSleeping() {
@@ -1156,7 +1118,7 @@
World world = this.level();
java.util.Objects.requireNonNull(world);
@@ -3596,7 +4149,7 @@
@@ -3733,7 +4283,7 @@
@Nullable
public EnumDirection getBedOrientation() {
@@ -1165,12 +1127,3 @@
return blockposition != null ? BlockBed.getBedOrientation(this.level(), blockposition) : null;
}
@@ -3633,7 +4186,7 @@
FoodInfo.b foodinfo_b = (FoodInfo.b) iterator.next();
if (this.random.nextFloat() < foodinfo_b.probability()) {
- this.addEffect(foodinfo_b.effect());
+ this.addEffect(foodinfo_b.effect(), EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/EntityTameableAnimal.java
+++ b/net/minecraft/world/entity/EntityTameableAnimal.java
@@ -27,6 +27,12 @@
@@ -28,6 +28,12 @@
import net.minecraft.world.level.pathfinder.PathfinderNormal;
import net.minecraft.world.scores.ScoreboardTeam;
@@ -13,7 +13,7 @@
public abstract class EntityTameableAnimal extends EntityAnimal implements OwnableEntity {
public static final int TELEPORT_WHEN_DISTANCE_IS_SQ = 144;
@@ -281,7 +287,14 @@
@@ -292,7 +298,14 @@
if (!this.canTeleportTo(new BlockPosition(i, j, k))) {
return false;
} else {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/EntityTypes.java
+++ b/net/minecraft/world/entity/EntityTypes.java
@@ -168,6 +168,7 @@
@@ -176,6 +176,7 @@
import net.minecraft.world.phys.Vec3D;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapes;
@@ -8,83 +8,81 @@
import org.slf4j.Logger;
public class EntityTypes<T extends Entity> implements FeatureElement, EntityTypeTest<Entity, T> {
@@ -177,7 +178,7 @@
private static final float MAGIC_HORSE_WIDTH = 1.3964844F;
private static final int DISPLAY_TRACKING_RANGE = 10;
@@ -191,7 +192,7 @@
return Items.ACACIA_CHEST_BOAT;
}), EnumCreatureType.MISC).noLootTable().sized(1.375F, 0.5625F).eyeHeight(0.5625F).clientTrackingRange(10));
public static final EntityTypes<Allay> ALLAY = register("allay", EntityTypes.Builder.of(Allay::new, EnumCreatureType.CREATURE).sized(0.35F, 0.6F).eyeHeight(0.36F).ridingOffset(0.04F).clientTrackingRange(8).updateInterval(2));
- public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(Integer.MAX_VALUE));
+ public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds
- public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).noLootTable().fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(Integer.MAX_VALUE));
+ public static final EntityTypes<EntityAreaEffectCloud> AREA_EFFECT_CLOUD = register("area_effect_cloud", EntityTypes.Builder.of(EntityAreaEffectCloud::new, EnumCreatureType.MISC).noLootTable().fireImmune().sized(6.0F, 0.5F).clientTrackingRange(10).updateInterval(10)); // CraftBukkit - SPIGOT-3729: track area effect clouds
public static final EntityTypes<Armadillo> ARMADILLO = register("armadillo", EntityTypes.Builder.of(Armadillo::new, EnumCreatureType.CREATURE).sized(0.7F, 0.65F).eyeHeight(0.26F).clientTrackingRange(10));
public static final EntityTypes<EntityArmorStand> ARMOR_STAND = register("armor_stand", EntityTypes.Builder.of(EntityArmorStand::new, EnumCreatureType.MISC).sized(0.5F, 1.975F).eyeHeight(1.7775F).clientTrackingRange(10));
public static final EntityTypes<EntityTippedArrow> ARROW = register("arrow", EntityTypes.Builder.of(EntityTippedArrow::new, EnumCreatureType.MISC).sized(0.5F, 0.5F).eyeHeight(0.13F).clientTrackingRange(4).updateInterval(20));
@@ -325,8 +326,8 @@
private final float spawnDimensionsScale;
private final FeatureFlagSet requiredFeatures;
- private static <T extends Entity> EntityTypes<T> register(String s, EntityTypes.Builder<T> entitytypes_builder) {
- return (EntityTypes) IRegistry.register(BuiltInRegistries.ENTITY_TYPE, s, entitytypes_builder.build(s));
+ private static <T extends Entity> EntityTypes<T> register(String s, EntityTypes.Builder entitytypes_builder) { // CraftBukkit - decompile error
+ return (EntityTypes) IRegistry.register(BuiltInRegistries.ENTITY_TYPE, s, (EntityTypes<T>) entitytypes_builder.build(s)); // CraftBukkit - decompile error
public static final EntityTypes<EntityTippedArrow> ARROW = register("arrow", EntityTypes.Builder.of(EntityTippedArrow::new, EnumCreatureType.MISC).noLootTable().sized(0.5F, 0.5F).eyeHeight(0.13F).clientTrackingRange(4).updateInterval(20));
@@ -399,7 +400,7 @@
return ResourceKey.create(Registries.ENTITY_TYPE, MinecraftKey.withDefaultNamespace(s));
}
public static MinecraftKey getKey(EntityTypes<?> entitytypes) {
@@ -355,7 +356,14 @@
- private static <T extends Entity> EntityTypes<T> register(String s, EntityTypes.Builder<T> entitytypes_builder) {
+ private static <T extends Entity> EntityTypes<T> register(String s, EntityTypes.Builder entitytypes_builder) { // CraftBukkit - decompile error
return register(vanillaEntityId(s), entitytypes_builder);
}
@@ -431,7 +432,14 @@
@Nullable
public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) {
public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1) {
- Consumer consumer;
+ // CraftBukkit start
+ return this.spawn(worldserver, itemstack, entityhuman, blockposition, enummobspawn, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
+ return this.spawn(worldserver, itemstack, entityhuman, blockposition, entityspawnreason, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG);
+ }
+
+ @Nullable
+ public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
+ public T spawn(WorldServer worldserver, @Nullable ItemStack itemstack, @Nullable EntityHuman entityhuman, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
+ // CraftBukkit end
+ Consumer<T> consumer; // CraftBukkit - decompile error
if (itemstack != null) {
consumer = createDefaultStackConfig(worldserver, itemstack, entityhuman);
@@ -364,7 +372,7 @@
@@ -440,7 +448,7 @@
};
}
- return this.spawn(worldserver, consumer, blockposition, enummobspawn, flag, flag1);
+ return this.spawn(worldserver, consumer, blockposition, enummobspawn, flag, flag1, spawnReason); // CraftBukkit
- return this.spawn(worldserver, consumer, blockposition, entityspawnreason, flag, flag1);
+ return this.spawn(worldserver, consumer, blockposition, entityspawnreason, flag, flag1, spawnReason); // CraftBukkit
}
public static <T extends Entity> Consumer<T> createDefaultStackConfig(WorldServer worldserver, ItemStack itemstack, @Nullable EntityHuman entityhuman) {
@@ -388,21 +396,37 @@
public static <T extends Entity> Consumer<T> createDefaultStackConfig(World world, ItemStack itemstack, @Nullable EntityHuman entityhuman) {
@@ -464,21 +472,37 @@
CustomData customdata = (CustomData) itemstack.getOrDefault(DataComponents.ENTITY_DATA, CustomData.EMPTY);
return !customdata.isEmpty() ? consumer.andThen((entity) -> {
- updateCustomEntityTag(worldserver, entityhuman, entity, customdata);
+ try { updateCustomEntityTag(worldserver, entityhuman, entity, customdata); } catch (Throwable t) { LOGGER.warn("Error loading spawn egg NBT", t); } // CraftBukkit - SPIGOT-5665
- updateCustomEntityTag(world, entityhuman, entity, customdata);
+ try { updateCustomEntityTag(world, entityhuman, entity, customdata); } catch (Throwable t) { LOGGER.warn("Error loading spawn egg NBT", t); } // CraftBukkit - SPIGOT-5665
}) : consumer;
}
@Nullable
public T spawn(WorldServer worldserver, BlockPosition blockposition, EnumMobSpawn enummobspawn) {
- return this.spawn(worldserver, (Consumer) null, blockposition, enummobspawn, false, false);
public T spawn(WorldServer worldserver, BlockPosition blockposition, EntitySpawnReason entityspawnreason) {
- return this.spawn(worldserver, (Consumer) null, blockposition, entityspawnreason, false, false);
+ // CraftBukkit start
+ return this.spawn(worldserver, blockposition, enummobspawn, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
+ return this.spawn(worldserver, blockposition, entityspawnreason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
+ }
+
+ @Nullable
+ public T spawn(WorldServer worldserver, BlockPosition blockposition, EnumMobSpawn enummobspawn, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
+ return this.spawn(worldserver, (Consumer<T>) null, blockposition, enummobspawn, false, false, spawnReason); // CraftBukkit - decompile error
+ public T spawn(WorldServer worldserver, BlockPosition blockposition, EntitySpawnReason entityspawnreason, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
+ return this.spawn(worldserver, (Consumer<T>) null, blockposition, entityspawnreason, false, false, spawnReason); // CraftBukkit - decompile error
+ // CraftBukkit end
}
@Nullable
public T spawn(WorldServer worldserver, @Nullable Consumer<T> consumer, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1) {
public T spawn(WorldServer worldserver, @Nullable Consumer<T> consumer, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1) {
+ // CraftBukkit start
+ return this.spawn(worldserver, consumer, blockposition, enummobspawn, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
+ return this.spawn(worldserver, consumer, blockposition, entityspawnreason, flag, flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DEFAULT);
+ }
+
+ @Nullable
+ public T spawn(WorldServer worldserver, @Nullable Consumer<T> consumer, BlockPosition blockposition, EnumMobSpawn enummobspawn, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
+ public T spawn(WorldServer worldserver, @Nullable Consumer<T> consumer, BlockPosition blockposition, EntitySpawnReason entityspawnreason, boolean flag, boolean flag1, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason spawnReason) {
+ // CraftBukkit end
T t0 = this.create(worldserver, consumer, blockposition, enummobspawn, flag, flag1);
T t0 = this.create(worldserver, consumer, blockposition, entityspawnreason, flag, flag1);
if (t0 != null) {
- worldserver.addFreshEntityWithPassengers(t0);
@@ -94,7 +92,7 @@
}
return t0;
@@ -583,7 +607,7 @@
@@ -649,7 +673,7 @@
}
return entity;
@@ -102,8 +100,8 @@
+ }).orElse(null); // CraftBukkit - decompile error
}
public static Stream<Entity> loadEntitiesRecursive(final List<? extends NBTBase> list, final World world) {
@@ -644,7 +668,7 @@
public static Stream<Entity> loadEntitiesRecursive(final List<? extends NBTBase> list, final World world, final EntitySpawnReason entityspawnreason) {
@@ -710,7 +734,7 @@
@Nullable
public T tryCast(Entity entity) {
@@ -112,7 +110,7 @@
}
@Override
@@ -681,7 +705,7 @@
@@ -779,7 +803,7 @@
this.canSpawnFarFromPlayer = enumcreaturetype == EnumCreatureType.CREATURE || enumcreaturetype == EnumCreatureType.MISC;
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/IEntitySelector.java
+++ b/net/minecraft/world/entity/IEntitySelector.java
@@ -44,7 +44,7 @@
@@ -43,7 +43,7 @@
ScoreboardTeamBase.EnumTeamPush scoreboardteambase_enumteampush = scoreboardteam == null ? ScoreboardTeamBase.EnumTeamPush.ALWAYS : scoreboardteam.getCollisionRule();
return (Predicate) (scoreboardteambase_enumteampush == ScoreboardTeamBase.EnumTeamPush.NEVER ? Predicates.alwaysFalse() : IEntitySelector.NO_SPECTATORS.and((entity1) -> {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/Interaction.java
+++ b/net/minecraft/world/entity/Interaction.java
@@ -24,6 +24,12 @@
@@ -26,6 +26,12 @@
import net.minecraft.world.phys.AxisAlignedBB;
import org.slf4j.Logger;
@@ -13,7 +13,7 @@
public class Interaction extends Entity implements Attackable, Targeting {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -62,7 +68,7 @@
@@ -64,7 +70,7 @@
this.setHeight(nbttagcompound.getFloat("height"));
}
@@ -22,7 +22,7 @@
Logger logger;
if (nbttagcompound.contains("attack")) {
@@ -142,9 +148,16 @@
@@ -144,9 +150,16 @@
@Override
public boolean skipAttackInteraction(Entity entity) {
if (entity instanceof EntityHuman entityhuman) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/Leashable.java
+++ b/net/minecraft/world/entity/Leashable.java
@@ -15,6 +15,11 @@
@@ -16,6 +16,11 @@
import net.minecraft.world.level.IMaterial;
import net.minecraft.world.level.World;
@@ -12,7 +12,7 @@
public interface Leashable {
String LEASH_TAG = "leash";
@@ -44,7 +49,7 @@
@@ -45,7 +50,7 @@
default void setDelayedLeashHolderId(int i) {
this.setLeashData(new Leashable.a(i));
@@ -21,7 +21,7 @@
}
@Nullable
@@ -53,7 +58,7 @@
@@ -54,7 +59,7 @@
return new Leashable.a(Either.left(nbttagcompound.getCompound("leash").getUUID("UUID")));
} else {
if (nbttagcompound.contains("leash", 11)) {
@@ -30,7 +30,7 @@
if (either != null) {
return new Leashable.a(either);
@@ -68,6 +73,11 @@
@@ -69,6 +74,11 @@
if (leashable_a != null) {
Either<UUID, BlockPosition> either = leashable_a.delayedLeashInfo;
Entity entity = leashable_a.leashHolder;
@@ -42,17 +42,17 @@
if (entity instanceof EntityLeash) {
EntityLeash entityleash = (EntityLeash) entity;
@@ -110,7 +120,9 @@
@@ -111,7 +121,9 @@
}
if (e0.tickCount > 100) {
+ e0.forceDrops = true; // CraftBukkit
e0.spawnAtLocation((IMaterial) Items.LEAD);
e0.spawnAtLocation(worldserver, (IMaterial) Items.LEAD);
+ e0.forceDrops = false; // CraftBukkit
((Leashable) e0).setLeashData((Leashable.a) null);
}
}
@@ -119,7 +131,7 @@
@@ -120,7 +132,7 @@
}
default void dropLeash(boolean flag, boolean flag1) {
@@ -61,27 +61,27 @@
}
private static <E extends Entity & Leashable> void dropLeash(E e0, boolean flag, boolean flag1) {
@@ -128,7 +140,9 @@
if (leashable_a != null && leashable_a.leashHolder != null) {
((Leashable) e0).setLeashData((Leashable.a) null);
if (!e0.level().isClientSide && flag1) {
+ e0.forceDrops = true; // CraftBukkit
e0.spawnAtLocation((IMaterial) Items.LEAD);
+ e0.forceDrops = false; // CraftBukkit
}
@@ -134,7 +146,9 @@
WorldServer worldserver = (WorldServer) world;
if (flag) {
@@ -153,7 +167,8 @@
if (flag1) {
+ e0.forceDrops = true; // CraftBukkit
e0.spawnAtLocation(worldserver, (IMaterial) Items.LEAD);
+ e0.forceDrops = false; // CraftBukkit
}
if (flag) {
@@ -154,7 +168,8 @@
if (leashable_a != null && leashable_a.leashHolder != null) {
if (!e0.isAlive() || !leashable_a.leashHolder.isAlive()) {
- dropLeash(e0, true, true);
+ e0.level().getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(e0.getBukkitEntity(), (!e0.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit
+ dropLeash(e0, true, !e0.pluginRemoved); // CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin
- dropLeash(e0, true, worldserver.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS));
+ worldserver.getCraftServer().getPluginManager().callEvent(new EntityUnleashEvent(e0.getBukkitEntity(), (!e0.isAlive()) ? UnleashReason.PLAYER_UNLEASH : UnleashReason.HOLDER_GONE)); // CraftBukkit
+ dropLeash(e0, true, worldserver.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS) && !e0.pluginRemoved); // CraftBukkit - SPIGOT-7487: Don't drop leash, when the holder was removed by a plugin
}
Entity entity = ((Leashable) e0).getLeashHolder();
@@ -183,13 +198,18 @@
@@ -184,13 +199,18 @@
}
default void leashTooFarBehaviour() {
@@ -101,7 +101,7 @@
}
private static <E extends Entity & Leashable> void legacyElasticRangeLeashBehaviour(E e0, Entity entity, float f) {
@@ -201,7 +221,7 @@
@@ -202,7 +222,7 @@
}
default void setLeashedTo(Entity entity, boolean flag) {
@@ -110,7 +110,7 @@
}
private static <E extends Entity & Leashable> void setLeashedTo(E e0, Entity entity, boolean flag) {
@@ -232,7 +252,7 @@
@@ -233,7 +253,7 @@
@Nullable
default Entity getLeashHolder() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.java
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetForget.java
@@ -8,6 +8,12 @@
@@ -7,6 +7,12 @@
import net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder;
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
@@ -13,8 +13,8 @@
public class BehaviorAttackTargetForget {
private static final int TIMEOUT_TO_GET_WITHIN_ATTACK_RANGE = 200;
@@ -41,6 +47,17 @@
if (entityinsentient.canAttack(entityliving) && (!flag || !isTiredOfTryingToReachTarget(entityinsentient, behaviorbuilder_b.tryGet(memoryaccessor1))) && entityliving.isAlive() && entityliving.level() == entityinsentient.level() && !predicate.test(entityliving)) {
@@ -40,6 +46,17 @@
if (entityinsentient.canAttack(entityliving) && (!flag || !isTiredOfTryingToReachTarget(entityinsentient, behaviorbuilder_b.tryGet(memoryaccessor1))) && entityliving.isAlive() && entityliving.level() == entityinsentient.level() && !behaviorattacktargetforget_a.test(worldserver, entityliving)) {
return true;
} else {
+ // CraftBukkit start
@@ -28,6 +28,6 @@
+ return true;
+ }
+ // CraftBukkit end
biconsumer.accept(entityinsentient, entityliving);
behaviorattacktargetforget_b.accept(worldserver, entityinsentient, entityliving);
memoryaccessor.erase();
return true;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.java
+++ b/net/minecraft/world/entity/ai/behavior/BehaviorAttackTargetSet.java
@@ -8,6 +8,13 @@
@@ -7,6 +7,13 @@
import net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder;
import net.minecraft.world.entity.ai.memory.MemoryModuleType;
@@ -14,7 +14,7 @@
public class BehaviorAttackTargetSet {
public BehaviorAttackTargetSet() {}
@@ -35,6 +42,17 @@
@@ -34,6 +41,17 @@
if (!entityinsentient.canAttack(entityliving)) {
return false;
} else {

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()) && entityliving.canPickUpLoot()) {
+ // 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

@@ -15,7 +15,7 @@
public static final int TIME_OUT_DURATION = 160;
@@ -63,6 +70,13 @@
return this.ramTargeting.test(entitycreature, entityliving);
return this.ramTargeting.test(worldserver, entitycreature, entityliving);
});
}).ifPresent((entityliving) -> {
+ // CraftBukkit start

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.java
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalBreakDoor.java
@@ -71,6 +71,12 @@
@@ -72,6 +72,12 @@
}
if (this.breakTime == this.getDoorBreakTime() && this.isValidDifficulty(this.mob.level().getDifficulty())) {

View File

@@ -15,8 +15,8 @@
BlockPosition blockposition = this.mob.blockPosition();
if (PathfinderGoalEatTile.IS_TALL_GRASS.test(this.level.getBlockState(blockposition))) {
- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.defaultBlockState(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit
- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition, Blocks.AIR.defaultBlockState(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit
this.level.destroyBlock(blockposition, false);
}
@@ -24,8 +24,8 @@
BlockPosition blockposition1 = blockposition.below();
if (this.level.getBlockState(blockposition1).is(Blocks.GRASS_BLOCK)) {
- if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition1, Blocks.AIR.defaultBlockState(), !this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit
- if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
+ if (CraftEventFactory.callEntityChangeBlockEvent(this.mob, blockposition1, Blocks.AIR.defaultBlockState(), !getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING))) { // CraftBukkit
this.level.levelEvent(2001, blockposition1, Block.getId(Blocks.GRASS_BLOCK.defaultBlockState()));
this.level.setBlock(blockposition1, Blocks.DIRT.defaultBlockState(), 2);
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.java
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalRemoveBlock.java
@@ -21,6 +21,11 @@
@@ -22,6 +22,11 @@
import net.minecraft.world.level.chunk.status.ChunkStatus;
import net.minecraft.world.phys.Vec3D;
@@ -12,7 +12,7 @@
public class PathfinderGoalRemoveBlock extends PathfinderGoalGotoTarget {
private final Block blockToRemove;
@@ -96,6 +101,11 @@
@@ -97,6 +102,11 @@
}
if (this.ticksSinceReachedGoal > 60) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.java
+++ b/net/minecraft/world/entity/ai/goal/PathfinderGoalTempt.java
@@ -10,6 +10,13 @@
@@ -11,6 +11,13 @@
import net.minecraft.world.entity.player.EntityHuman;
import net.minecraft.world.item.ItemStack;
@@ -13,8 +13,8 @@
+
public class PathfinderGoalTempt extends PathfinderGoal {
private static final PathfinderTargetCondition TEMP_TARGETING = PathfinderTargetCondition.forNonCombat().range(10.0D).ignoreLineOfSight();
@@ -22,7 +29,7 @@
private static final PathfinderTargetCondition TEMPT_TARGETING = PathfinderTargetCondition.forNonCombat().ignoreLineOfSight();
@@ -23,7 +30,7 @@
private double pRotX;
private double pRotY;
@Nullable
@@ -23,10 +23,10 @@
private int calmDown;
private boolean isRunning;
private final Predicate<ItemStack> items;
@@ -44,6 +51,15 @@
@@ -47,6 +54,15 @@
return false;
} else {
this.player = this.mob.level().getNearestPlayer(this.targetingConditions, this.mob);
this.player = getServerLevel((Entity) this.mob).getNearestPlayer(this.targetingConditions.range(this.mob.getAttributeValue(GenericAttributes.TEMPT_RANGE)), this.mob);
+ // CraftBukkit start
+ if (this.player != null) {
+ EntityTargetLivingEntityEvent event = CraftEventFactory.callEntityTargetLivingEvent(this.mob, this.player, EntityTargetEvent.TargetReason.TEMPT);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.java
+++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalDefendVillage.java
@@ -58,7 +58,7 @@
@@ -61,7 +61,7 @@
@Override
public void start() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.java
+++ b/net/minecraft/world/entity/ai/goal/target/PathfinderGoalNearestAttackableTarget.java
@@ -67,7 +67,7 @@
@@ -70,7 +70,7 @@
@Override
public void start() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/ai/sensing/TemptingSensor.java
+++ b/net/minecraft/world/entity/ai/sensing/TemptingSensor.java
@@ -18,6 +18,14 @@
@@ -19,6 +19,14 @@
import net.minecraft.world.entity.player.EntityHuman;
import net.minecraft.world.item.ItemStack;
@@ -14,17 +14,17 @@
+
public class TemptingSensor extends Sensor<EntityCreature> {
public static final int TEMPTATION_RANGE = 10;
@@ -30,7 +38,7 @@
private static final PathfinderTargetCondition TEMPT_TARGETING = PathfinderTargetCondition.forNonCombat().ignoreLineOfSight();
@@ -31,7 +39,7 @@
protected void doTick(WorldServer worldserver, EntityCreature entitycreature) {
BehaviorController<?> behaviorcontroller = entitycreature.getBrain();
PathfinderTargetCondition pathfindertargetcondition = TemptingSensor.TEMPT_TARGETING.copy().range((double) ((float) entitycreature.getAttributeValue(GenericAttributes.TEMPT_RANGE)));
- Stream stream = worldserver.players().stream().filter(IEntitySelector.NO_SPECTATORS).filter((entityplayer) -> {
+ Stream<net.minecraft.server.level.EntityPlayer> stream = worldserver.players().stream().filter(IEntitySelector.NO_SPECTATORS).filter((entityplayer) -> { // CraftBukkit - decompile error
return TemptingSensor.TEMPT_TARGETING.test(entitycreature, entityplayer);
}).filter((entityplayer) -> {
return entitycreature.closerThan(entityplayer, 10.0D);
@@ -44,7 +52,17 @@
return pathfindertargetcondition.test(worldserver, entitycreature, entityplayer);
}).filter(this::playerHoldingTemptation).filter((entityplayer) -> {
return !entitycreature.hasPassenger((Entity) entityplayer);
@@ -43,7 +51,17 @@
if (!list.isEmpty()) {
EntityHuman entityhuman = (EntityHuman) list.get(0);

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/ambient/EntityBat.java
+++ b/net/minecraft/world/entity/ambient/EntityBat.java
@@ -27,6 +27,10 @@
import net.minecraft.world.level.block.state.IBlockData;
@@ -30,6 +30,10 @@
import net.minecraft.world.level.levelgen.HeightMap;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
@@ -11,37 +11,37 @@
public class EntityBat extends EntityAmbient {
public static final float FLAP_LENGTH_SECONDS = 0.5F;
@@ -141,13 +145,13 @@
@@ -144,13 +148,13 @@
this.yHeadRot = (float) this.random.nextInt(360);
}
- if (this.level().getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null) {
+ if (this.level().getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
- if (worldserver.getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null) {
+ if (worldserver.getNearestPlayer(EntityBat.BAT_RESTING_TARGETING, this) != null && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
this.setResting(false);
if (!flag) {
this.level().levelEvent((EntityHuman) null, 1025, blockposition, 0);
worldserver.levelEvent((EntityHuman) null, 1025, blockposition, 0);
}
}
- } else {
+ } else if (CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
this.setResting(false);
if (!flag) {
this.level().levelEvent((EntityHuman) null, 1025, blockposition, 0);
@@ -174,7 +178,7 @@
worldserver.levelEvent((EntityHuman) null, 1025, blockposition, 0);
@@ -177,7 +181,7 @@
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) && CraftEventFactory.handleBatToggleSleepEvent(this, false)) { // CraftBukkit - Call BatToggleSleepEvent
- if (this.random.nextInt(100) == 0 && worldserver.getBlockState(blockposition1).isRedstoneConductor(worldserver, blockposition1)) {
+ if (this.random.nextInt(100) == 0 && worldserver.getBlockState(blockposition1).isRedstoneConductor(worldserver, blockposition1) && CraftEventFactory.handleBatToggleSleepEvent(this, false)) { // CraftBukkit - Call BatToggleSleepEvent
this.setResting(true);
}
}
@@ -199,7 +203,7 @@
if (this.isInvulnerableTo(damagesource)) {
@@ -202,7 +206,7 @@
if (this.isInvulnerableTo(worldserver, damagesource)) {
return false;
} else {
- if (!this.level().isClientSide && this.isResting()) {
+ if (!this.level().isClientSide && this.isResting() && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
- if (this.isResting()) {
+ if (this.isResting() && CraftEventFactory.handleBatToggleSleepEvent(this, true)) { // CraftBukkit - Call BatToggleSleepEvent
this.setResting(false);
}

View File

@@ -45,6 +45,6 @@
- t0.discard();
+ t0.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
return Optional.of(EnumInteractionResult.sidedSuccess(world.isClientSide));
return Optional.of(EnumInteractionResult.SUCCESS);
} else {
return Optional.empty();

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,20 @@
@@ -35,12 +35,20 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.pathfinder.PathType;
@@ -21,25 +21,25 @@
protected EntityAnimal(EntityTypes<? extends EntityAnimal> entitytypes, World world) {
super(entitytypes, world);
@@ -72,9 +80,15 @@
@@ -82,9 +90,15 @@
}
@Override
- protected void actuallyHurt(DamageSource damagesource, float f) {
- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) {
+ // CraftBukkit start - void -> boolean
+ public boolean actuallyHurt(DamageSource damagesource, float f, EntityDamageEvent event) {
+ boolean damageResult = super.actuallyHurt(damagesource, f, event);
+ public boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) {
+ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event);
+ if (!damageResult) {
+ return false;
+ }
this.resetLove();
- super.actuallyHurt(damagesource, f);
- super.actuallyHurt(worldserver, damagesource, f);
+ return true;
+ // CraftBukkit end
}
@Override
@@ -162,10 +176,17 @@
@@ -188,10 +202,17 @@
}
public void setInLove(@Nullable EntityHuman entityhuman) {
@@ -58,7 +58,7 @@
this.level().broadcastEntityEvent(this, (byte) 18);
}
@@ -207,12 +228,29 @@
@@ -233,12 +254,29 @@
if (entityageable != null) {
entityageable.setBaby(true);
entityageable.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
@@ -90,7 +90,7 @@
Optional.ofNullable(this.getLoveCause()).or(() -> {
return Optional.ofNullable(entityanimal.getLoveCause());
}).ifPresent((entityplayer) -> {
@@ -225,7 +263,11 @@
@@ -251,7 +289,11 @@
entityanimal.resetLove();
worldserver.broadcastEntityEvent(this, (byte) 18);
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityBee.java
+++ b/net/minecraft/world/entity/animal/EntityBee.java
@@ -87,6 +87,12 @@
@@ -89,6 +89,12 @@
import net.minecraft.world.level.pathfinder.PathType;
import net.minecraft.world.phys.Vec3D;
@@ -13,7 +13,7 @@
public class EntityBee extends EntityAnimal implements IEntityAngerable, EntityBird {
public static final float FLAP_DEGREES_PER_TICK = 120.32113F;
@@ -186,12 +192,19 @@
@@ -194,12 +200,19 @@
@Override
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
@@ -35,18 +35,18 @@
nbttagcompound.put("flower_pos", GameProfileSerializer.writeBlockPos(this.getSavedFlowerPos()));
}
@@ -205,8 +218,8 @@
@Override
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
@@ -219,8 +232,8 @@
this.ticksWithoutNectarSinceExitingHive = nbttagcompound.getInt("TicksSincePollination");
this.stayOutOfHiveCountdown = nbttagcompound.getInt("CannotEnterHiveTicks");
this.numCropsGrownSincePollination = nbttagcompound.getInt("CropsGrownSincePollination");
- this.hivePos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "hive_pos").orElse((Object) null);
- this.savedFlowerPos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "flower_pos").orElse((Object) null);
+ this.hivePos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "hive_pos").orElse(null); // CraftBukkit - decompile error
+ this.savedFlowerPos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "flower_pos").orElse(null); // CraftBukkit - decompile error
super.readAdditionalSaveData(nbttagcompound);
this.setHasNectar(nbttagcompound.getBoolean("HasNectar"));
this.setHasStung(nbttagcompound.getBoolean("HasStung"));
@@ -243,7 +256,7 @@
this.readPersistentAngerSaveData(this.level(), nbttagcompound);
}
@@ -244,7 +257,7 @@
}
if (b0 > 0) {
@@ -55,24 +55,32 @@
}
}
@@ -636,11 +649,14 @@
if (this.isInvulnerableTo(damagesource)) {
@@ -502,7 +515,7 @@
@Nullable
TileEntityBeehive getBeehiveBlockEntity() {
- return this.hivePos == null ? null : (this.isTooFarAway(this.hivePos) ? null : (TileEntityBeehive) this.level().getBlockEntity(this.hivePos, TileEntityTypes.BEEHIVE).orElse((Object) null));
+ return this.hivePos == null ? null : (this.isTooFarAway(this.hivePos) ? null : (TileEntityBeehive) this.level().getBlockEntity(this.hivePos, TileEntityTypes.BEEHIVE).orElse(null)); // CraftBukkit - decompile error
}
boolean isHiveValid() {
@@ -638,8 +651,14 @@
if (this.isInvulnerableTo(worldserver, damagesource)) {
return false;
} else {
- if (!this.level().isClientSide) {
+ // CraftBukkit start - Only stop pollinating if entity was damaged
+ boolean result = super.hurt(damagesource, f);
+ if (result && !this.level().isClientSide) {
+ boolean result = super.hurtServer(worldserver, damagesource, f);
+ if (!result) {
+ return result;
+ }
+ // CraftBukkit end
this.beePollinateGoal.stopPollinating();
}
- return super.hurt(damagesource, f);
this.beePollinateGoal.stopPollinating();
- return super.hurtServer(worldserver, damagesource, f);
+ return result; // CraftBukkit
}
}
@@ -992,7 +1008,7 @@
@@ -1048,7 +1067,7 @@
e() {
super();
@@ -81,7 +89,7 @@
this.blacklistedTargets = Lists.newArrayList();
this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE));
}
@@ -1109,7 +1125,7 @@
@@ -1162,7 +1181,7 @@
f() {
super();
@@ -90,7 +98,7 @@
this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE));
}
@@ -1209,7 +1225,7 @@
@@ -1267,7 +1286,7 @@
}
}
@@ -99,7 +107,7 @@
EntityBee.this.level().levelEvent(2011, blockposition, 15);
EntityBee.this.level().setBlockAndUpdate(blockposition, iblockdata1);
EntityBee.this.incrementNumCropsGrownSincePollination();
@@ -1282,7 +1298,7 @@
@@ -1344,7 +1363,7 @@
@Override
protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) {
if (entityinsentient instanceof EntityBee && this.mob.hasLineOfSight(entityliving)) {
@@ -108,7 +116,7 @@
}
}
@@ -1291,7 +1307,7 @@
@@ -1353,7 +1372,7 @@
private static class c extends PathfinderGoalNearestAttackableTarget<EntityHuman> {
c(EntityBee entitybee) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityCat.java
+++ b/net/minecraft/world/entity/animal/EntityCat.java
@@ -181,10 +181,10 @@
@@ -174,10 +174,10 @@
@Override
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.readAdditionalSaveData(nbttagcompound);
@@ -12,8 +12,8 @@
+ IRegistry<CatVariant> iregistry = BuiltInRegistries.CAT_VARIANT; // CraftBukkit - decompile error
Objects.requireNonNull(iregistry);
optional.flatMap(iregistry::getHolder).ifPresent(this::setVariant);
@@ -452,7 +452,7 @@
optional.flatMap(iregistry::get).ifPresent(this::setVariant);
@@ -463,7 +463,7 @@
}
private void tryToTame(EntityHuman entityhuman) {
@@ -22,7 +22,7 @@
this.tame(entityhuman);
this.setOrderedToSit(true);
this.level().broadcastEntityEvent(this, (byte) 7);
@@ -470,7 +470,7 @@
@@ -481,7 +481,7 @@
private static class PathfinderGoalTemptChance extends PathfinderGoalTempt {
@Nullable
@@ -31,24 +31,24 @@
private final EntityCat cat;
public PathfinderGoalTemptChance(EntityCat entitycat, double d0, Predicate<ItemStack> predicate, boolean flag) {
@@ -611,7 +611,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));
@@ -615,7 +615,15 @@
this.cat.randomTeleport((double) (blockposition_mutableblockposition.getX() + randomsource.nextInt(11) - 5), (double) (blockposition_mutableblockposition.getY() + randomsource.nextInt(5) - 2), (double) (blockposition_mutableblockposition.getZ() + randomsource.nextInt(11) - 5), false);
blockposition_mutableblockposition.set(this.cat.blockPosition());
this.cat.dropFromGiftLootTable(getServerLevel((Entity) this.cat), LootTables.CAT_MORNING_GIFT, (worldserver, itemstack) -> {
- worldserver.addFreshEntity(new EntityItem(worldserver, (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(worldserver, (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);
+ if (event.isCancelled()) {
+ continue;
+ return;
+ }
+ this.cat.level().addFreshEntity(entityitem);
+ worldserver.addFreshEntity(entityitem);
+ // CraftBukkit end
}
});
}
@@ -643,10 +651,10 @@
@@ -646,10 +654,10 @@
private final EntityCat cat;
public a(EntityCat entitycat, Class<T> oclass, float f, double d0, double d1) {

View File

@@ -1,12 +1,15 @@
--- a/net/minecraft/world/entity/animal/EntityChicken.java
+++ b/net/minecraft/world/entity/animal/EntityChicken.java
@@ -98,7 +98,9 @@
this.flap += this.flapping * 2.0F;
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);
+ this.forceDrops = false; // CraftBukkit
this.gameEvent(GameEvent.ENTITY_PLACE);
this.eggTime = this.random.nextInt(6000) + 6000;
}
@@ -99,10 +99,12 @@
if (world instanceof WorldServer worldserver) {
if (this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) {
+ this.forceDrops = true; // CraftBukkit
if (this.dropFromGiftLootTable(worldserver, LootTables.CHICKEN_LAY, this::spawnAtLocation)) {
this.playSound(SoundEffects.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
this.gameEvent(GameEvent.ENTITY_PLACE);
}
+ this.forceDrops = false; // CraftBukkit
this.eggTime = this.random.nextInt(6000) + 6000;
}

View File

@@ -30,4 +30,4 @@
+ ItemStack itemstack1 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
entityhuman.setItemInHand(enumhand, itemstack1);
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);
return EnumInteractionResult.SUCCESS;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityDolphin.java
+++ b/net/minecraft/world/entity/animal/EntityDolphin.java
@@ -59,8 +59,20 @@
@@ -62,8 +62,20 @@
import net.minecraft.world.level.pathfinder.PathMode;
import net.minecraft.world.phys.Vec3D;
@@ -10,7 +10,7 @@
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public class EntityDolphin extends EntityWaterAnimal {
public class EntityDolphin extends AgeableWaterCreature {
+ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
+ @Override
@@ -21,7 +21,7 @@
private static final DataWatcherObject<BlockPosition> TREASURE_POS = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BLOCK_POS);
private static final DataWatcherObject<Boolean> GOT_FISH = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BOOLEAN);
private static final DataWatcherObject<Integer> MOISTNESS_LEVEL = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.INT);
@@ -176,7 +188,7 @@
@@ -200,7 +212,7 @@
@Override
public int getMaxAirSupply() {
@@ -30,7 +30,7 @@
}
@Override
@@ -212,11 +224,17 @@
@@ -234,11 +246,17 @@
ItemStack itemstack = entityitem.getItem();
if (this.canHoldItem(itemstack)) {
@@ -49,7 +49,7 @@
}
}
@@ -467,7 +485,7 @@
@@ -495,7 +513,7 @@
@Override
public void start() {
@@ -58,7 +58,7 @@
}
@Override
@@ -486,7 +504,7 @@
@@ -514,7 +532,7 @@
}
if (this.player.isSwimming() && this.player.level().random.nextInt(6) == 0) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityFox.java
+++ b/net/minecraft/world/entity/animal/EntityFox.java
@@ -93,6 +93,10 @@
@@ -91,6 +91,10 @@
import net.minecraft.world.level.pathfinder.PathType;
import net.minecraft.world.phys.Vec3D;
@@ -11,8 +11,8 @@
public class EntityFox extends EntityAnimal implements VariantHolder<EntityFox.Type> {
private static final DataWatcherObject<Integer> DATA_TYPE_ID = DataWatcher.defineId(EntityFox.class, DataWatcherRegistry.INT);
@@ -518,7 +522,8 @@
protected void pickUpItem(EntityItem entityitem) {
@@ -503,7 +507,8 @@
protected void pickUpItem(WorldServer worldserver, EntityItem entityitem) {
ItemStack itemstack = entityitem.getItem();
- if (this.canHoldItem(itemstack)) {
@@ -21,7 +21,7 @@
int i = itemstack.getCount();
if (i > 1) {
@@ -530,7 +535,7 @@
@@ -515,7 +520,7 @@
this.setItemSlot(EnumItemSlot.MAINHAND, itemstack.split(1));
this.setGuaranteedDrop(EnumItemSlot.MAINHAND);
this.take(entityitem, itemstack.getCount());
@@ -30,7 +30,7 @@
this.ticksSinceEaten = 0;
}
@@ -868,6 +873,16 @@
@@ -853,6 +858,16 @@
if (entityplayer1 != null && entityplayer != entityplayer1) {
entityfox.addTrustedUUID(entityplayer1.getUUID());
}
@@ -47,7 +47,7 @@
if (entityplayer2 != null) {
entityplayer2.awardStat(StatisticList.ANIMALS_BRED);
@@ -878,12 +893,14 @@
@@ -863,12 +878,14 @@
this.partner.setAge(6000);
this.animal.resetLove();
this.partner.resetLove();
@@ -56,7 +56,7 @@
- worldserver.addFreshEntityWithPassengers(entityfox);
+ worldserver.addFreshEntityWithPassengers(entityfox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
this.level.broadcastEntityEvent(this.animal, (byte) 18);
if (this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
- this.level.addFreshEntity(new EntityExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), this.animal.getRandom().nextInt(7) + 1));
+ // CraftBukkit start - use event experience
+ if (experience > 0) {
@@ -66,7 +66,7 @@
}
}
@@ -1279,6 +1296,11 @@
@@ -1264,6 +1281,11 @@
int i = (Integer) iblockdata.getValue(BlockSweetBerryBush.AGE);
iblockdata.setValue(BlockSweetBerryBush.AGE, 1);
@@ -78,12 +78,12 @@
int j = 1 + EntityFox.this.level().random.nextInt(2) + (i == 3 ? 1 : 0);
ItemStack itemstack = EntityFox.this.getItemBySlot(EnumItemSlot.MAINHAND);
@@ -1436,7 +1458,7 @@
private EntityLiving trustedLastHurt;
private int timestamp;
- public a(final Class oclass, final boolean flag, final boolean flag1, @Nullable final Predicate predicate) {
+ public a(final Class oclass, final boolean flag, final boolean flag1, @Nullable final Predicate<EntityLiving> predicate) { // CraftBukkit - decompile error
super(EntityFox.this, oclass, 10, flag, flag1, predicate);
@@ -1494,7 +1516,7 @@
}
public static EntityFox.Type byName(String s) {
- return (EntityFox.Type) EntityFox.Type.CODEC.byName(s, (Enum) EntityFox.Type.RED);
+ return (EntityFox.Type) EntityFox.Type.CODEC.byName(s, EntityFox.Type.RED); // CraftBukkit - decompile error
}
public static EntityFox.Type byId(int i) {

View File

@@ -1,66 +1,59 @@
--- a/net/minecraft/world/entity/animal/EntityMushroomCow.java
+++ b/net/minecraft/world/entity/animal/EntityMushroomCow.java
@@ -42,6 +42,14 @@
import net.minecraft.world.level.block.state.IBlockData;
@@ -44,6 +44,13 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.storage.loot.LootTables;
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityDropItemEvent;
+import org.bukkit.event.entity.EntityRemoveEvent;
+import org.bukkit.event.entity.EntityTransformEvent;
+// CraftBukkit end
+
public class EntityMushroomCow extends EntityCow implements IShearable, VariantHolder<EntityMushroomCow.Type> {
private static final DataWatcherObject<String> DATA_TYPE = DataWatcher.defineId(EntityMushroomCow.class, DataWatcherRegistry.STRING);
@@ -114,6 +122,11 @@
this.playSound(soundeffect, 1.0F, 1.0F);
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);
} else if (itemstack.is(Items.SHEARS) && this.readyForShearing()) {
+ // CraftBukkit start
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
this.shear(SoundCategory.PLAYERS);
this.gameEvent(GameEvent.SHEAR, entityhuman);
if (!this.level().isClientSide) {
@@ -157,7 +170,7 @@
@@ -121,6 +128,11 @@
if (world instanceof WorldServer) {
WorldServer worldserver = (WorldServer) world;
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);
- this.discard();
+ // this.discard(); // CraftBukkit - moved down
entitycow.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), this.getXRot());
entitycow.setHealth(this.getHealth());
entitycow.yBodyRot = this.yBodyRot;
@@ -171,10 +184,25 @@
}
entitycow.setInvulnerable(this.isInvulnerable());
- this.level().addFreshEntity(entitycow);
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) {
+ return;
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
+ return EnumInteractionResult.PASS;
+ }
+ this.level().addFreshEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED);
+
+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - from above and add Bukkit remove cause
+ // 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.shear(worldserver, SoundCategory.PLAYERS, itemstack);
this.gameEvent(GameEvent.SHEAR, entityhuman);
itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand));
@@ -162,11 +174,19 @@
worldserver.sendParticles(Particles.EXPLOSION, this.getX(), this.getY(0.5D), this.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_MOOSHROOM, itemstack, (worldserver1, itemstack1) -> {
for (int i = 0; i < itemstack1.getCount(); ++i) {
- worldserver1.addFreshEntity(new EntityItem(this.level(), this.getX(), this.getY(1.0D), this.getZ(), itemstack1.copyWithCount(1)));
+ // 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(), itemstack1.copyWithCount(1));
+ EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
+ Bukkit.getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ continue;
+ }
+ this.level().addFreshEntity(entityitem);
+ worldserver1.addFreshEntity(entityitem);
+ // CraftBukkit end
}
}
});
- });
+ }, EntityTransformEvent.TransformReason.SHEARED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); // CraftBukkit
}
@Override
@@ -262,7 +282,7 @@
}
static EntityMushroomCow.Type byName(String s) {
- return (EntityMushroomCow.Type) EntityMushroomCow.Type.CODEC.byName(s, (Enum) EntityMushroomCow.Type.RED);
+ return (EntityMushroomCow.Type) EntityMushroomCow.Type.CODEC.byName(s, EntityMushroomCow.Type.RED); // CraftBukkit - decompile error
}
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityOcelot.java
+++ b/net/minecraft/world/entity/animal/EntityOcelot.java
@@ -168,7 +168,7 @@
@@ -167,7 +167,7 @@
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) {
@@ -9,7 +9,7 @@
this.setTrusting(true);
this.spawnTrustingParticles(true);
this.level().broadcastEntityEvent(this, (byte) 41);
@@ -299,10 +299,10 @@
@@ -298,10 +298,10 @@
private final EntityOcelot ocelot;
public a(EntityOcelot entityocelot, Class<T> oclass, float f, double d0, double d1) {

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/animal/EntityPanda.java
+++ b/net/minecraft/world/entity/animal/EntityPanda.java
@@ -73,6 +73,12 @@
import net.minecraft.world.level.storage.loot.parameters.LootContextParameters;
@@ -69,6 +69,12 @@
import net.minecraft.world.level.storage.loot.LootTables;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start;
@@ -13,12 +13,12 @@
public class EntityPanda extends EntityAnimal {
private static final DataWatcherObject<Integer> UNHAPPY_COUNTER = DataWatcher.defineId(EntityPanda.class, DataWatcherRegistry.INT);
@@ -558,14 +564,14 @@
@@ -541,14 +547,14 @@
@Override
protected void pickUpItem(EntityItem entityitem) {
- if (this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PANDA_ITEMS.test(entityitem)) {
+ if (!CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !(this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PANDA_ITEMS.test(entityitem))).isCancelled()) { // CraftBukkit
protected void pickUpItem(WorldServer worldserver, EntityItem entityitem) {
- if (this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && canPickUpAndEat(entityitem)) {
+ if (!CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !(this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && canPickUpAndEat(entityitem))).isCancelled()) { // CraftBukkit
this.onItemPickup(entityitem);
ItemStack itemstack = entityitem.getItem();
@@ -30,7 +30,16 @@
}
}
@@ -889,10 +895,10 @@
@@ -772,7 +778,7 @@
}
public static EntityPanda.Gene byName(String s) {
- return (EntityPanda.Gene) EntityPanda.Gene.CODEC.byName(s, (Enum) EntityPanda.Gene.NORMAL);
+ return (EntityPanda.Gene) EntityPanda.Gene.CODEC.byName(s, EntityPanda.Gene.NORMAL); // CraftBukkit - decompile error
}
public static EntityPanda.Gene getRandom(RandomSource randomsource) {
@@ -876,10 +882,10 @@
private final EntityPanda panda;
public c(EntityPanda entitypanda, Class<T> oclass, float f, double d0, double d1) {
@@ -44,7 +53,7 @@
this.panda = entitypanda;
}
@@ -1131,7 +1137,7 @@
@@ -1116,7 +1122,7 @@
@Override
protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) {
if (entityinsentient instanceof EntityPanda && entityinsentient.isAggressive()) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityParrot.java
+++ b/net/minecraft/world/entity/animal/EntityParrot.java
@@ -248,7 +248,7 @@
@@ -250,7 +250,7 @@
}
if (!this.level().isClientSide) {
@@ -9,16 +9,16 @@
this.tame(entityhuman);
this.level().broadcastEntityEvent(this, (byte) 7);
} else {
@@ -269,7 +269,7 @@
@@ -271,7 +271,7 @@
}
} else {
itemstack.consume(1, entityhuman);
this.usePlayerItem(entityhuman, enumhand, itemstack);
- this.addEffect(new MobEffect(MobEffects.POISON, 900));
+ this.addEffect(new MobEffect(MobEffects.POISON, 900), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit
if (entityhuman.isCreative() || !this.isInvulnerable()) {
this.hurt(this.damageSources().playerAttack(entityhuman), Float.MAX_VALUE);
}
@@ -363,7 +363,7 @@
@@ -365,7 +365,7 @@
@Override
public boolean isPushable() {
@@ -27,19 +27,18 @@
}
@Override
@@ -378,11 +378,14 @@
if (this.isInvulnerableTo(damagesource)) {
@@ -380,8 +380,14 @@
if (this.isInvulnerableTo(worldserver, damagesource)) {
return false;
} else {
- if (!this.level().isClientSide) {
+ // CraftBukkit start
+ boolean result = super.hurt(damagesource, f);
+ if (!this.level().isClientSide && result) {
+ // CraftBukkit end
this.setOrderedToSit(false);
}
- return super.hurt(damagesource, f);
+ boolean result = super.hurtServer(worldserver, damagesource, f);
+ if (!result) {
+ return result;
+ }
+ // CraftBukkit end
this.setOrderedToSit(false);
- return super.hurtServer(worldserver, damagesource, f);
+ return result; // CraftBukkit
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityPig.java
+++ b/net/minecraft/world/entity/animal/EntityPig.java
@@ -49,6 +49,11 @@
@@ -50,6 +50,11 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
@@ -12,20 +12,19 @@
public class EntityPig extends EntityAnimal implements ISteerable, ISaddleable {
private static final DataWatcherObject<Boolean> DATA_SADDLE_ID = DataWatcher.defineId(EntityPig.class, DataWatcherRegistry.BOOLEAN);
@@ -253,8 +258,14 @@
@@ -247,7 +252,14 @@
}
entitypigzombie.setPersistenceRequired();
- worldserver.addFreshEntity(entitypigzombie);
- this.discard();
+ // CraftBukkit start
+ if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) {
+ return;
+ }
+ // CraftBukkit - added a reason for spawning this creature
+ worldserver.addFreshEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
+ // CraftBukkit end
+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
} else {
entitypigzombie1.setPersistenceRequired();
- });
+ // CraftBukkit start
+ }, null, null);
+ if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) {
+ return;
+ }
+ worldserver.addFreshEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
+ // CraftBukkit end
if (entitypigzombie == null) {
super.thunderHit(worldserver, entitylightning);
}

View File

@@ -1,20 +1,20 @@
--- a/net/minecraft/world/entity/animal/EntityPufferFish.java
+++ b/net/minecraft/world/entity/animal/EntityPufferFish.java
@@ -150,7 +150,7 @@
@@ -155,7 +155,7 @@
int i = this.getPuffState();
if (entityinsentient.hurt(this.damageSources().mobAttack(this), (float) (1 + i))) {
if (entityinsentient.hurtServer(worldserver, this.damageSources().mobAttack(this), (float) (1 + i))) {
- entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this);
+ entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
this.playSound(SoundEffects.PUFFER_FISH_STING, 1.0F, 1.0F);
}
@@ -165,7 +165,7 @@
((EntityPlayer) entityhuman).connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.PUFFER_FISH_STING, 0.0F));
}
@@ -171,7 +171,7 @@
entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.PUFFER_FISH_STING, 0.0F));
}
- entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this);
+ entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
- entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this);
+ entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
}
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityRabbit.java
+++ b/net/minecraft/world/entity/animal/EntityRabbit.java
@@ -67,6 +67,10 @@
@@ -66,6 +66,10 @@
import net.minecraft.world.level.pathfinder.PathEntity;
import net.minecraft.world.phys.Vec3D;
@@ -11,7 +11,7 @@
public class EntityRabbit extends EntityAnimal implements VariantHolder<EntityRabbit.Variant> {
public static final double STROLL_SPEED_MOD = 0.6D;
@@ -91,7 +95,6 @@
@@ -90,7 +94,6 @@
super(entitytypes, world);
this.jumpControl = new EntityRabbit.ControllerJumpRabbit(this);
this.moveControl = new EntityRabbit.ControllerMoveRabbit(this);
@@ -19,7 +19,7 @@
}
@Override
@@ -578,9 +581,19 @@
@@ -577,9 +580,19 @@
int i = (Integer) iblockdata.getValue(BlockCarrots.AGE);
if (i == 0) {

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/animal/EntitySheep.java
+++ b/net/minecraft/world/entity/animal/EntitySheep.java
@@ -63,6 +63,12 @@
import net.minecraft.world.level.storage.loot.LootTable;
@@ -57,6 +57,12 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.storage.loot.LootTables;
+// CraftBukkit start
@@ -13,29 +13,29 @@
public class EntitySheep extends EntityAnimal implements IShearable {
private static final int EAT_ANIMATION_TICKS = 40;
@@ -250,6 +256,11 @@
@@ -167,6 +173,11 @@
WorldServer worldserver = (WorldServer) world;
if (itemstack.is(Items.SHEARS)) {
if (!this.level().isClientSide && this.readyForShearing()) {
+ // CraftBukkit start
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
this.shear(SoundCategory.PLAYERS);
this.gameEvent(GameEvent.SHEAR, entityhuman);
itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand));
@@ -269,7 +280,9 @@
int i = 1 + this.random.nextInt(3);
if (this.readyForShearing()) {
+ // CraftBukkit start
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
this.shear(worldserver, SoundCategory.PLAYERS, itemstack);
this.gameEvent(GameEvent.SHEAR, entityhuman);
itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand));
@@ -185,7 +196,9 @@
worldserver.playSound((EntityHuman) null, (Entity) this, SoundEffects.SHEEP_SHEAR, soundcategory, 1.0F, 1.0F);
this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_SHEEP, itemstack, (worldserver1, itemstack1) -> {
for (int i = 0; i < itemstack1.getCount(); ++i) {
+ this.forceDrops = true; // CraftBukkit
EntityItem entityitem = this.spawnAtLocation(worldserver1, itemstack1.copyWithCount(1), 1.0F);
+ this.forceDrops = false; // CraftBukkit
for (int j = 0; j < i; ++j) {
+ this.forceDrops = true; // CraftBukkit
EntityItem entityitem = this.spawnAtLocation((IMaterial) EntitySheep.ITEM_BY_DYE.get(this.getColor()), 1);
+ this.forceDrops = false; // CraftBukkit
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)));
@@ -362,6 +375,12 @@
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)));
@@ -280,6 +293,12 @@
@Override
public void ate() {
@@ -48,12 +48,12 @@
super.ate();
this.setSheared(false);
if (this.isBaby()) {
@@ -381,7 +400,7 @@
EnumColor enumcolor = ((EntitySheep) entityanimal).getColor();
EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor();
@@ -299,7 +318,7 @@
EnumColor enumcolor = entitysheep.getColor();
EnumColor enumcolor1 = entitysheep1.getColor();
CraftingInput craftinginput = makeCraftInput(enumcolor, enumcolor1);
- Optional optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, craftinginput, this.level()).map((recipeholder) -> {
+ Optional<Item> optional = this.level().getRecipeManager().getRecipeFor(Recipes.CRAFTING, craftinginput, this.level()).map((recipeholder) -> { // CraftBukkit - decompile error
return ((RecipeCrafting) recipeholder.value()).assemble(craftinginput, this.level().registryAccess());
- Optional optional = worldserver.recipeAccess().getRecipeFor(Recipes.CRAFTING, craftinginput, worldserver).map((recipeholder) -> {
+ Optional<Item> optional = worldserver.recipeAccess().getRecipeFor(Recipes.CRAFTING, craftinginput, worldserver).map((recipeholder) -> { // CraftBukkit - decompile error
return ((RecipeCrafting) recipeholder.value()).assemble(craftinginput, worldserver.registryAccess());
}).map(ItemStack::getItem);

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/animal/EntitySnowman.java
+++ b/net/minecraft/world/entity/animal/EntitySnowman.java
@@ -40,6 +40,10 @@
import net.minecraft.world.level.gameevent.GameEvent;
@@ -43,6 +43,10 @@
import net.minecraft.world.level.storage.loot.LootTables;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
@@ -11,16 +11,16 @@
public class EntitySnowman extends EntityGolem implements IShearable, IRangedEntity {
private static final DataWatcherObject<Byte> DATA_PUMPKIN_ID = DataWatcher.defineId(EntitySnowman.class, DataWatcherRegistry.BYTE);
@@ -95,7 +99,7 @@
super.aiStep();
if (!this.level().isClientSide) {
@@ -100,7 +104,7 @@
if (world instanceof WorldServer worldserver) {
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 - DamageSources.ON_FIRE -> CraftEventFactory.MELTING
- this.hurtServer(worldserver, this.damageSources().onFire(), 1.0F);
+ this.hurtServer(worldserver, this.damageSources().melting(), 1.0F); // CraftBukkit - DamageSources.ON_FIRE -> CraftEventFactory.MELTING
}
if (!this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
@@ -111,7 +115,11 @@
if (!worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
@@ -116,7 +120,11 @@
BlockPosition blockposition = new BlockPosition(j, k, l);
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
@@ -33,25 +33,25 @@
this.level().gameEvent((Holder) GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(this, iblockdata));
}
}
@@ -138,6 +146,11 @@
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
@@ -153,6 +161,11 @@
if (world instanceof WorldServer) {
WorldServer worldserver = (WorldServer) world;
if (itemstack.is(Items.SHEARS) && this.readyForShearing()) {
+ // CraftBukkit start
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
this.shear(SoundCategory.PLAYERS);
this.gameEvent(GameEvent.SHEAR, entityhuman);
if (!this.level().isClientSide) {
@@ -155,7 +168,9 @@
this.level().playSound((EntityHuman) null, (Entity) this, SoundEffects.SNOW_GOLEM_SHEAR, soundcategory, 1.0F, 1.0F);
if (!this.level().isClientSide()) {
this.setPumpkin(false);
+ // CraftBukkit start
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
this.shear(worldserver, SoundCategory.PLAYERS, itemstack);
this.gameEvent(GameEvent.SHEAR, entityhuman);
itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand));
@@ -169,7 +182,9 @@
worldserver.playSound((EntityHuman) null, (Entity) this, SoundEffects.SNOW_GOLEM_SHEAR, soundcategory, 1.0F, 1.0F);
this.setPumpkin(false);
this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_SNOW_GOLEM, itemstack, (worldserver1, itemstack1) -> {
+ this.forceDrops = true; // CraftBukkit
this.spawnAtLocation(new ItemStack(Items.CARVED_PUMPKIN), this.getEyeHeight());
this.spawnAtLocation(worldserver1, itemstack1, this.getEyeHeight());
+ this.forceDrops = false; // CraftBukkit
}
});
}

View File

@@ -1,25 +1,25 @@
--- a/net/minecraft/world/entity/animal/EntityTurtle.java
+++ b/net/minecraft/world/entity/animal/EntityTurtle.java
@@ -305,7 +305,9 @@
protected void ageBoundaryReached() {
super.ageBoundaryReached();
if (!this.isBaby() && this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
+ this.forceDrops = true; // CraftBukkit
this.spawnAtLocation(Items.TURTLE_SCUTE, 1);
+ this.forceDrops = false; // CraftBukkit
}
@@ -310,7 +310,9 @@
WorldServer worldserver = (WorldServer) world;
}
@@ -332,7 +334,7 @@
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
+ this.forceDrops = true; // CraftBukkit
this.spawnAtLocation(worldserver, Items.TURTLE_SCUTE, 1);
+ this.forceDrops = false; // CraftBukkit
}
}
}
@@ -339,7 +341,7 @@
@Override
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
- this.hurt(this.damageSources().lightningBolt(), Float.MAX_VALUE);
+ this.hurt(this.damageSources().lightningBolt().customEntityDamager(entitylightning), Float.MAX_VALUE); // CraftBukkit
- this.hurtServer(worldserver, this.damageSources().lightningBolt(), Float.MAX_VALUE);
+ this.hurtServer(worldserver, this.damageSources().lightningBolt().customEntityDamager(entitylightning), Float.MAX_VALUE); // CraftBukkit
}
@Override
@@ -489,12 +491,14 @@
@@ -496,12 +498,14 @@
} else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) {
World world = this.turtle.level();

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityWolf.java
+++ b/net/minecraft/world/entity/animal/EntityWolf.java
@@ -90,6 +90,13 @@
@@ -86,6 +86,13 @@
import net.minecraft.world.level.pathfinder.PathType;
import net.minecraft.world.phys.Vec3D;
@@ -14,32 +14,31 @@
public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable, VariantHolder<Holder<WolfVariant>> {
private static final DataWatcherObject<Boolean> DATA_INTERESTED_ID = DataWatcher.defineId(EntityWolf.class, DataWatcherRegistry.BOOLEAN);
@@ -360,11 +367,14 @@
if (this.isInvulnerableTo(damagesource)) {
@@ -345,8 +352,14 @@
if (this.isInvulnerableTo(worldserver, damagesource)) {
return false;
} else {
- if (!this.level().isClientSide) {
+ // CraftBukkit start
+ boolean result = super.hurt(damagesource, f);
+ if (!this.level().isClientSide && result) {
+ // CraftBukkit end
this.setOrderedToSit(false);
}
- return super.hurt(damagesource, f);
+ boolean result = super.hurtServer(worldserver, damagesource, f);
+ if (!result) {
+ return result;
+ }
+ // CraftBukkit end
this.setOrderedToSit(false);
- return super.hurtServer(worldserver, damagesource, f);
+ return result; // CraftBukkit
}
}
@@ -374,10 +384,15 @@
@@ -356,10 +369,15 @@
}
@Override
- protected void actuallyHurt(DamageSource damagesource, float f) {
+ public boolean actuallyHurt(DamageSource damagesource, float f, EntityDamageEvent event) { // CraftBukkit - void -> boolean
- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) {
+ public boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) { // CraftBukkit - void -> boolean
if (!this.canArmorAbsorb(damagesource)) {
- super.actuallyHurt(damagesource, f);
+ return super.actuallyHurt(damagesource, f, event); // CraftBukkit
- super.actuallyHurt(worldserver, damagesource, f);
+ return super.actuallyHurt(worldserver, damagesource, f, event); // CraftBukkit
} else {
+ // CraftBukkit start - SPIGOT-7815: if the damage was cancelled, no need to run the wolf armor behaviour
+ if (event.isCancelled()) {
@@ -49,7 +48,7 @@
ItemStack itemstack = this.getBodyArmorItem();
int i = itemstack.getDamageValue();
int j = itemstack.getMaxDamage();
@@ -395,6 +410,7 @@
@@ -371,6 +389,7 @@
}
}
@@ -57,7 +56,7 @@
}
private boolean canArmorAbsorb(DamageSource damagesource) {
@@ -405,7 +421,7 @@
@@ -381,7 +400,7 @@
protected void applyTamingSideEffects() {
if (this.isTame()) {
this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(40.0D);
@@ -66,35 +65,35 @@
} else {
this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(8.0D);
}
@@ -432,7 +448,7 @@
@@ -404,7 +423,7 @@
FoodInfo foodinfo = (FoodInfo) itemstack.get(DataComponents.FOOD);
float f = foodinfo != null ? (float) foodinfo.nutrition() : 1.0F;
- this.heal(2.0F * f);
+ this.heal(2.0F * f, EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
return EnumInteractionResult.sidedSuccess(this.level().isClientSide());
return EnumInteractionResult.SUCCESS;
} else {
if (item instanceof ItemDye) {
@@ -463,7 +479,9 @@
this.playSound(SoundEffects.ARMOR_UNEQUIP_WOLF);
itemstack1 = this.getBodyArmorItem();
this.setBodyArmorItem(ItemStack.EMPTY);
+ this.forceDrops = true; // CraftBukkit
this.spawnAtLocation(itemstack1);
+ this.forceDrops = false; // CraftBukkit
@@ -440,7 +459,9 @@
if (world instanceof WorldServer) {
WorldServer worldserver = (WorldServer) world;
+ this.forceDrops = true; // CraftBukkit
this.spawnAtLocation(worldserver, itemstack1);
+ this.forceDrops = false; // CraftBukkit
}
return EnumInteractionResult.SUCCESS;
} else if (((RecipeItemStack) ((ArmorMaterial) EnumArmorMaterial.ARMADILLO.value()).repairIngredient().get()).test(itemstack) && this.isInSittingPose() && this.hasArmor() && this.isOwnedBy(entityhuman) && this.getBodyArmorItem().isDamaged()) {
itemstack.shrink(1);
@@ -480,7 +498,7 @@
@@ -459,7 +480,7 @@
this.setOrderedToSit(!this.isOrderedToSit());
this.jumping = false;
this.navigation.stop();
- this.setTarget((EntityLiving) null);
+ this.setTarget((EntityLiving) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason
return EnumInteractionResult.SUCCESS_NO_ITEM_USED;
return EnumInteractionResult.SUCCESS.withoutItem();
} else {
return enuminteractionresult;
@@ -498,7 +516,8 @@
@@ -477,7 +498,8 @@
}
private void tryToTame(EntityHuman entityhuman) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/allay/Allay.java
+++ b/net/minecraft/world/entity/animal/allay/Allay.java
@@ -101,6 +101,7 @@
@@ -103,6 +103,7 @@
private float dancingAnimationTicks;
private float spinningAnimationTicks;
private float spinningAnimationTicks0;
@@ -8,7 +8,7 @@
public Allay(EntityTypes<? extends Allay> entitytypes, World world) {
super(entitytypes, world);
@@ -112,6 +113,12 @@
@@ -114,6 +115,12 @@
this.dynamicJukeboxListener = new DynamicGameEventListener<>(new Allay.a(this.vibrationUser.getPositionSource(), ((GameEvent) GameEvent.JUKEBOX_PLAY.value()).notificationRadius()));
}
@@ -21,7 +21,7 @@
@Override
protected BehaviorController.b<Allay> brainProvider() {
return BehaviorController.provider(Allay.MEMORY_TYPES, Allay.SENSOR_TYPES);
@@ -124,7 +131,7 @@
@@ -126,7 +133,7 @@
@Override
public BehaviorController<Allay> getBrain() {
@@ -30,7 +30,7 @@
}
public static AttributeProvider.Builder createAttributes() {
@@ -225,7 +232,7 @@
@@ -229,7 +236,7 @@
public void aiStep() {
super.aiStep();
if (!this.level().isClientSide && this.isAlive() && this.tickCount % 10 == 0) {
@@ -39,10 +39,10 @@
}
if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) {
@@ -295,7 +302,12 @@
@@ -299,7 +306,12 @@
ItemStack itemstack1 = this.getItemInHand(EnumHand.MAIN_HAND);
if (this.isDancing() && this.isDuplicationItem(itemstack) && this.canDuplicate()) {
if (this.isDancing() && itemstack.is(TagsItem.DUPLICATES_ALLAYS) && this.canDuplicate()) {
- this.duplicateAllay();
+ // CraftBukkit start - handle cancel duplication
+ Allay allay = this.duplicateAllay();
@@ -53,7 +53,7 @@
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);
@@ -306,7 +318,7 @@
@@ -310,7 +322,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);
@@ -62,7 +62,7 @@
return EnumInteractionResult.SUCCESS;
} else if (!itemstack1.isEmpty() && enumhand == EnumHand.MAIN_HAND && itemstack.isEmpty()) {
this.setItemSlot(EnumItemSlot.MAINHAND, ItemStack.EMPTY);
@@ -407,6 +419,7 @@
@@ -411,6 +423,7 @@
}
private boolean shouldStopDancing() {
@@ -70,16 +70,16 @@
return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), (double) ((GameEvent) GameEvent.JUKEBOX_PLAY.value()).notificationRadius()) || !this.level().getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX);
}
@@ -500,7 +513,7 @@
return Allay.DUPLICATION_ITEM.test(itemstack);
@@ -502,7 +515,7 @@
}
- public void duplicateAllay() {
+ public Allay duplicateAllay() { // CraftBukkit - return allay
Allay allay = (Allay) EntityTypes.ALLAY.create(this.level());
Allay allay = (Allay) EntityTypes.ALLAY.create(this.level(), EntitySpawnReason.BREEDING);
if (allay != null) {
@@ -508,9 +521,9 @@
@@ -510,9 +523,9 @@
allay.setPersistenceRequired();
allay.resetDuplicationCooldown();
this.resetDuplicationCooldown();

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java
+++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java
@@ -47,6 +47,10 @@
import net.minecraft.world.level.block.state.IBlockData;
@@ -48,6 +48,10 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.storage.loot.LootTables;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityDamageEvent;
@@ -11,33 +11,35 @@
public class Armadillo extends EntityAnimal {
public static final float BABY_SCALE = 0.6F;
@@ -132,14 +136,16 @@
@Override
protected void customServerAiStep() {
this.level().getProfiler().push("armadilloBrain");
- this.brain.tick((WorldServer) this.level(), this);
+ ((BehaviorController<Armadillo>) this.brain).tick((WorldServer) this.level(), this); // CraftBukkit - decompile error
this.level().getProfiler().pop();
this.level().getProfiler().push("armadilloActivityUpdate");
@@ -135,16 +139,18 @@
GameProfilerFiller gameprofilerfiller = Profiler.get();
gameprofilerfiller.push("armadilloBrain");
- this.brain.tick(worldserver, this);
+ ((BehaviorController<Armadillo>) this.brain).tick(worldserver, this); // CraftBukkit - decompile error
gameprofilerfiller.pop();
gameprofilerfiller.push("armadilloActivityUpdate");
ArmadilloAi.updateActivity(this);
this.level().getProfiler().pop();
gameprofilerfiller.pop();
if (this.isAlive() && !this.isBaby() && --this.scuteTime <= 0) {
this.playSound(SoundEffects.ARMADILLO_SCUTE_DROP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
+ this.forceDrops = true; // CraftBukkit
this.spawnAtLocation((IMaterial) Items.ARMADILLO_SCUTE);
if (this.dropFromGiftLootTable(worldserver, LootTables.ARMADILLO_SHED, this::spawnAtLocation)) {
this.playSound(SoundEffects.ARMADILLO_SCUTE_DROP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
this.gameEvent(GameEvent.ENTITY_PLACE);
}
+ this.forceDrops = false; // CraftBukkit
this.gameEvent(GameEvent.ENTITY_PLACE);
this.scuteTime = this.pickNextScuteDropTime();
}
@@ -286,8 +292,13 @@
@@ -291,8 +297,13 @@
}
@Override
- protected void actuallyHurt(DamageSource damagesource, float f) {
- super.actuallyHurt(damagesource, f);
- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) {
- super.actuallyHurt(worldserver, damagesource, f);
+ // CraftBukkit start - void -> boolean
+ public boolean actuallyHurt(DamageSource damagesource, float f, EntityDamageEvent event) {
+ boolean damageResult = super.actuallyHurt(damagesource, f, event);
+ public boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) {
+ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event);
+ if (!damageResult) {
+ return false;
+ }
@@ -45,7 +47,7 @@
if (!this.isNoAi() && !this.isDeadOrDying()) {
if (damagesource.getEntity() instanceof EntityLiving) {
this.getBrain().setMemoryWithExpiry(MemoryModuleType.DANGER_DETECTED_RECENTLY, true, 80L);
@@ -299,6 +310,7 @@
@@ -304,6 +315,7 @@
}
}
@@ -53,13 +55,22 @@
}
@Override
@@ -326,7 +338,9 @@
if (this.isBaby()) {
return false;
} else {
+ this.forceDrops = true; // CraftBukkit
this.spawnAtLocation(new ItemStack(Items.ARMADILLO_SCUTE));
+ this.forceDrops = false; // CraftBukkit
this.gameEvent(GameEvent.ENTITY_INTERACT);
this.playSound(SoundEffects.ARMADILLO_BRUSH);
return true;
@@ -327,7 +339,9 @@
if (world instanceof WorldServer) {
WorldServer worldserver = (WorldServer) world;
+ this.forceDrops = true; // CraftBukkit
this.spawnAtLocation(worldserver, new ItemStack(Items.ARMADILLO_SCUTE));
+ this.forceDrops = false; // CraftBukkit
this.gameEvent(GameEvent.ENTITY_INTERACT);
this.playSound(SoundEffects.ARMADILLO_BRUSH);
}
@@ -431,7 +445,7 @@
}
public static Armadillo.a fromName(String s) {
- return (Armadillo.a) Armadillo.a.CODEC.byName(s, (Enum) Armadillo.a.IDLE);
+ return (Armadillo.a) Armadillo.a.CODEC.byName(s, Armadillo.a.IDLE); // CraftBukkit - decompile error
}
@Override

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java
+++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java
@@ -68,9 +68,16 @@
@@ -67,10 +67,17 @@
public class Axolotl extends EntityAnimal implements LerpingModel, VariantHolder<Axolotl.Variant>, Bucketable {
public class Axolotl extends EntityAnimal implements VariantHolder<Axolotl.Variant>, Bucketable {
+ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
+ @Override
@@ -11,6 +11,7 @@
+ }
+ // CraftBukkit end
public static final int TOTAL_PLAYDEAD_TIME = 200;
private static final int POSE_ANIMATION_TICKS = 10;
protected static final ImmutableList<? extends SensorType<? extends Sensor<? super Axolotl>>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_ADULT, SensorType.HURT_BY, SensorType.AXOLOTL_ATTACKABLES, SensorType.AXOLOTL_TEMPTATIONS);
- protected static final ImmutableList<? extends MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.BREED_TARGET, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT, new MemoryModuleType[]{MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.PLAY_DEAD_TICKS, MemoryModuleType.NEAREST_ATTACKABLE, MemoryModuleType.TEMPTING_PLAYER, MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, MemoryModuleType.IS_TEMPTED, MemoryModuleType.HAS_HUNTING_COOLDOWN, MemoryModuleType.IS_PANICKING});
+ // CraftBukkit - decompile error
@@ -18,7 +19,7 @@
private static final DataWatcherObject<Integer> DATA_VARIANT = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.INT);
private static final DataWatcherObject<Boolean> DATA_PLAYING_DEAD = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN);
private static final DataWatcherObject<Boolean> FROM_BUCKET = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN);
@@ -187,7 +194,7 @@
@@ -210,7 +217,7 @@
@Override
public int getMaxAirSupply() {
@@ -27,7 +28,7 @@
}
@Override
@@ -391,7 +398,7 @@
@@ -414,7 +421,7 @@
int i = mobeffect != null ? mobeffect.getDuration() : 0;
int j = Math.min(2400, 100 + i);
@@ -36,7 +37,7 @@
}
entityhuman.removeEffect(MobEffects.DIG_SLOWDOWN);
@@ -441,7 +448,7 @@
@@ -464,7 +471,7 @@
@Override
public BehaviorController<Axolotl> getBrain() {

View File

@@ -8,32 +8,32 @@
+import org.bukkit.event.entity.EntityDamageEvent;
+// CraftBukkit end
+
public class Camel extends EntityHorseAbstract implements IJumpable, ISaddleable {
public class Camel extends EntityHorseAbstract {
public static final float BABY_SCALE = 0.45F;
@@ -141,7 +145,7 @@
@Override
protected void customServerAiStep() {
this.level().getProfiler().push("camelBrain");
@@ -143,7 +147,7 @@
GameProfilerFiller gameprofilerfiller = Profiler.get();
gameprofilerfiller.push("camelBrain");
- BehaviorController<?> behaviorcontroller = this.getBrain();
+ BehaviorController<Camel> behaviorcontroller = (BehaviorController<Camel>) this.getBrain(); // CraftBukkit - decompile error
behaviorcontroller.tick((WorldServer) this.level(), this);
this.level().getProfiler().pop();
@@ -452,9 +456,15 @@
behaviorcontroller.tick(worldserver, this);
gameprofilerfiller.pop();
@@ -454,9 +458,15 @@
}
@Override
- protected void actuallyHurt(DamageSource damagesource, float f) {
- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) {
+ // CraftBukkit start - void -> boolean
+ public boolean actuallyHurt(DamageSource damagesource, float f, EntityDamageEvent event) {
+ boolean damageResult = super.actuallyHurt(damagesource, f, event);
+ public boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) {
+ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event);
+ if (!damageResult) {
+ return false;
+ }
+ // CraftBukkit end
this.standUpInstantly();
- super.actuallyHurt(damagesource, f);
- super.actuallyHurt(worldserver, damagesource, f);
+ return true; // CraftBukkit
}

View File

@@ -22,7 +22,7 @@
}
@@ -85,7 +89,7 @@
if (entity.isAlive()) {
frog.doHurtTarget(entity);
frog.doHurtTarget(worldserver, entity);
if (!entity.isAlive()) {
- entity.remove(Entity.RemovalReason.KILLED);
+ entity.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause

View File

@@ -1,17 +1,6 @@
--- a/net/minecraft/world/entity/animal/frog/Tadpole.java
+++ b/net/minecraft/world/entity/animal/frog/Tadpole.java
@@ -38,6 +38,10 @@
import net.minecraft.world.item.component.CustomData;
import net.minecraft.world.level.World;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public class Tadpole extends EntityFish {
@VisibleForTesting
@@ -71,7 +75,7 @@
@@ -74,7 +74,7 @@
@Override
public BehaviorController<Tadpole> getBrain() {
@@ -20,22 +9,23 @@
}
@Override
@@ -232,10 +236,16 @@
}
@@ -225,12 +225,17 @@
World world = this.level();
if (world instanceof WorldServer worldserver) {
- this.convertTo(EntityTypes.FROG, ConversionParams.single(this, false, false), (frog) -> {
+ Frog converted = this.convertTo(EntityTypes.FROG, ConversionParams.single(this, false, false), (frog) -> { // CraftBukkit
frog.finalizeSpawn(worldserver, this.level().getCurrentDifficultyAt(frog.blockPosition()), EntitySpawnReason.CONVERSION, (GroupDataEntity) null);
frog.setPersistenceRequired();
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTransformEvent(this, frog, org.bukkit.event.entity.EntityTransformEvent.TransformReason.METAMORPHOSIS).isCancelled()) {
+ this.setAge(0); // Sets the age to 0 for avoid a loop if the event is canceled
+ return;
+ }
+ // CraftBukkit end
frog.fudgePositionAfterSizeChange(this.getDimensions(this.getPose()));
this.playSound(SoundEffects.TADPOLE_GROW_UP, 0.15F, 1.0F);
- worldserver.addFreshEntityWithPassengers(frog);
- this.discard();
+ worldserver.addFreshEntityWithPassengers(frog, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.METAMORPHOSIS); // CraftBukkit - add SpawnReason
+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
}
- });
+ // CraftBukkit start
+ }, org.bukkit.event.entity.EntityTransformEvent.TransformReason.METAMORPHOSIS, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.METAMORPHOSIS);
+ if (converted == null) {
+ this.setAge(0); // Sets the age to 0 for avoid a loop if the event is canceled
+ }
+ // CraftBukkit end
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/goat/Goat.java
+++ b/net/minecraft/world/entity/animal/goat/Goat.java
@@ -55,6 +55,12 @@
@@ -54,6 +54,12 @@
import net.minecraft.world.level.pathfinder.PathType;
import net.minecraft.world.phys.Vec3D;
@@ -13,7 +13,7 @@
public class Goat extends EntityAnimal {
public static final EntitySize LONG_JUMPING_DIMENSIONS = EntitySize.scalable(0.9F, 1.3F).scale(0.7F);
@@ -182,7 +188,7 @@
@@ -184,7 +190,7 @@
@Override
public BehaviorController<Goat> getBrain() {
@@ -22,7 +22,7 @@
}
@Override
@@ -225,8 +231,15 @@
@@ -229,8 +235,15 @@
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
if (itemstack.is(Items.BUCKET) && !this.isBaby()) {
@@ -38,4 +38,4 @@
+ ItemStack itemstack1 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
entityhuman.setItemInHand(enumhand, itemstack1);
return EnumInteractionResult.sidedSuccess(this.level().isClientSide);
return EnumInteractionResult.SUCCESS;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java
+++ b/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java
@@ -81,6 +81,18 @@
@@ -79,6 +79,18 @@
import net.minecraft.world.phys.Vec3D;
import net.minecraft.world.ticks.ContainerSingleItem;
@@ -19,7 +19,7 @@
public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, HasCustomInventoryScreen, OwnableEntity, IJumpable, ISaddleable {
public static final int EQUIPMENT_SLOT_OFFSET = 400;
@@ -158,7 +170,53 @@
@@ -167,7 +179,53 @@
public boolean stillValid(EntityHuman entityhuman) {
return entityhuman.getVehicle() == EntityHorseAbstract.this || entityhuman.canInteractWithEntity((Entity) EntityHorseAbstract.this, 4.0D);
}
@@ -73,7 +73,7 @@
protected EntityHorseAbstract(EntityTypes<? extends EntityHorseAbstract> entitytypes, World world) {
super(entitytypes, world);
@@ -353,7 +411,7 @@
@@ -366,7 +424,7 @@
public void createInventory() {
InventorySubcontainer inventorysubcontainer = this.inventory;
@@ -82,7 +82,7 @@
if (inventorysubcontainer != null) {
inventorysubcontainer.removeListener(this);
int i = Math.min(inventorysubcontainer.getContainerSize(), this.inventory.getContainerSize());
@@ -457,7 +515,7 @@
@@ -470,7 +528,7 @@
}
public int getMaxTemper() {
@@ -91,7 +91,7 @@
}
@Override
@@ -528,7 +586,7 @@
@@ -541,7 +599,7 @@
}
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
@@ -100,16 +100,16 @@
flag = true;
}
@@ -602,7 +660,7 @@
super.aiStep();
if (!this.level().isClientSide && this.isAlive()) {
if (this.random.nextInt(900) == 0 && this.deathTime == 0) {
- this.heal(1.0F);
+ this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
}
@@ -618,7 +676,7 @@
if (world instanceof WorldServer worldserver) {
if (this.isAlive()) {
if (this.random.nextInt(900) == 0 && this.deathTime == 0) {
- this.heal(1.0F);
+ this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
}
if (this.canEatGrass()) {
@@ -864,6 +922,7 @@
if (this.canEatGrass()) {
@@ -883,6 +941,7 @@
if (this.getOwnerUUID() != null) {
nbttagcompound.putUUID("Owner", this.getOwnerUUID());
}
@@ -117,7 +117,7 @@
if (!this.inventory.getItem(0).isEmpty()) {
nbttagcompound.put("SaddleItem", this.inventory.getItem(0).save(this.registryAccess()));
@@ -891,6 +950,11 @@
@@ -910,6 +969,11 @@
if (uuid != null) {
this.setOwnerUUID(uuid);
}
@@ -129,7 +129,7 @@
if (nbttagcompound.contains("SaddleItem", 10)) {
ItemStack itemstack = (ItemStack) ItemStack.parse(this.registryAccess(), nbttagcompound.getCompound("SaddleItem")).orElse(ItemStack.EMPTY);
@@ -993,6 +1057,17 @@
@@ -1012,6 +1076,17 @@
@Override
public void handleStartJump(int i) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/horse/EntityLlama.java
+++ b/net/minecraft/world/entity/animal/horse/EntityLlama.java
@@ -84,6 +84,11 @@
@@ -82,6 +82,11 @@
return false;
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.java
+++ b/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.java
@@ -19,6 +19,10 @@
@@ -22,6 +22,10 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.WorldAccess;
@@ -11,7 +11,7 @@
public class EntityLlamaTrader extends EntityLlama {
private int despawnDelay = 47999;
@@ -87,7 +91,7 @@
@@ -94,7 +98,7 @@
this.despawnDelay = this.isLeashedToWanderingTrader() ? ((EntityVillagerTrader) this.getLeashHolder()).getDespawnDelay() - 1 : this.despawnDelay - 1;
if (this.despawnDelay <= 0) {
this.dropLeash(true, false);
@@ -20,7 +20,7 @@
}
}
@@ -153,7 +157,7 @@
@@ -160,7 +164,7 @@
@Override
public void start() {

View File

@@ -1,20 +1,20 @@
--- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java
+++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java
@@ -274,6 +274,13 @@
ItemStack itemstack = (ItemStack) iterator.next();
EntityItem entityitem = new EntityItem(worldserver, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack);
@@ -267,6 +267,13 @@
this.dropFromGiftLootTable(worldserver, LootTables.SNIFFER_DIGGING, (worldserver1, itemstack) -> {
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()) {
+ continue;
+ }
+ // CraftBukkit end
entityitem.setDefaultPickUpDelay();
worldserver.addFreshEntity(entityitem);
}
@@ -313,7 +320,7 @@
+ // 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();
worldserver1.addFreshEntity(entityitem);
});
@@ -308,7 +315,7 @@
List<GlobalPos> list = (List) this.getExploredPositions().limit(20L).collect(Collectors.toList());
list.add(0, GlobalPos.of(this.level().dimension(), blockposition));
@@ -23,7 +23,7 @@
return this;
}
@@ -454,7 +461,7 @@
@@ -444,7 +451,7 @@
@Override
public BehaviorController<Sniffer> getBrain() {

View File

@@ -26,10 +26,10 @@
}
}
@@ -94,12 +104,26 @@
@@ -99,12 +109,26 @@
return false;
} else {
if (!this.isRemoved() && !this.level().isClientSide) {
if (!this.isRemoved()) {
- this.remove(Entity.RemovalReason.KILLED);
+ // CraftBukkit start - All non-living entities need this
+ if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false)) {
@@ -39,7 +39,7 @@
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);
- worldserver.explode(this, damagesource1, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), 6.0F, false, World.a.BLOCK);
+ // CraftBukkit start
+ ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent(this, 6.0F, false);
+ if (event.isCancelled()) {
@@ -47,11 +47,11 @@
+ }
+
+ this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause
+ this.level().explode(this, damagesource1, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.BLOCK);
+ worldserver.explode(this, damagesource1, (ExplosionDamageCalculator) null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.BLOCK);
+ } else {
+ this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
}
+ // CraftBukkit end
this.onDestroyedBy(damagesource);
this.onDestroyedBy(worldserver, damagesource);
}

View File

@@ -1,12 +1,13 @@
--- a/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java
+++ b/net/minecraft/world/entity/boss/enderdragon/EntityEnderDragon.java
@@ -52,6 +52,21 @@
@@ -52,6 +52,22 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
+// CraftBukkit start
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.level.Explosion;
+import net.minecraft.world.level.ServerExplosion;
+import net.minecraft.world.level.block.Block;
+import net.minecraft.world.level.block.entity.TileEntity;
+import net.minecraft.world.level.storage.loot.LootParams;
@@ -22,7 +23,7 @@
public class EntityEnderDragon extends EntityInsentient implements IMonster {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -89,6 +104,7 @@
@@ -88,6 +104,7 @@
private final PathPoint[] nodes;
private final int[] nodeAdjacency;
private final Path openSet;
@@ -30,15 +31,15 @@
public EntityEnderDragon(EntityTypes<? extends EntityEnderDragon> entitytypes, World world) {
super(EntityTypes.ENDER_DRAGON, world);
@@ -110,6 +126,7 @@
@@ -108,6 +125,7 @@
this.setHealth(this.getMaxHealth());
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, Particles.EXPLOSION, Particles.EXPLOSION_EMITTER, SoundEffects.GENERIC_EXPLODE); // CraftBukkit
+ this.explosionSource = new ServerExplosion(world.getMinecraftWorld(), this, null, null, new Vec3D(Double.NaN, Double.NaN, Double.NaN), Float.NaN, true, Explosion.Effect.DESTROY); // CraftBukkit
}
public void setDragonFight(EnderDragonBattle enderdragonbattle) {
@@ -257,7 +274,7 @@
@@ -218,7 +236,7 @@
Vec3D vec3d1 = idragoncontroller.getFlyTargetLocation();
@@ -47,7 +48,7 @@
double d0 = vec3d1.x - this.getX();
double d1 = vec3d1.y - this.getY();
double d2 = vec3d1.z - this.getZ();
@@ -404,7 +421,14 @@
@@ -379,7 +397,14 @@
if (this.nearestCrystal.isRemoved()) {
this.nearestCrystal = null;
} else if (this.tickCount % 10 == 0 && this.getHealth() < this.getMaxHealth()) {
@@ -63,7 +64,7 @@
}
}
@@ -489,6 +513,9 @@
@@ -458,6 +483,9 @@
int j1 = MathHelper.floor(axisalignedbb.maxZ);
boolean flag = false;
boolean flag1 = false;
@@ -73,20 +74,20 @@
for (int k1 = i; k1 <= l; ++k1) {
for (int l1 = j; l1 <= i1; ++l1) {
@@ -498,7 +525,11 @@
@@ -467,7 +495,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 (worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && !iblockdata.is(TagsBlock.DRAGON_IMMUNE)) {
- flag1 = worldserver.removeBlock(blockposition, false) || flag1;
+ // CraftBukkit start - Add blocks to list rather than destroying them
+ // flag1 = this.level().removeBlock(blockposition, false) || flag1;
+ // flag1 = worldserver.removeBlock(blockposition, false) || flag1;
+ flag1 = true;
+ destroyedBlocks.add(CraftBlock.at(this.level(), blockposition));
+ destroyedBlocks.add(CraftBlock.at(worldserver, blockposition));
+ // CraftBukkit end
} else {
flag = true;
}
@@ -507,6 +538,49 @@
@@ -476,6 +508,49 @@
}
}
@@ -126,7 +127,7 @@
+ });
+ craftBlock.getNMS().spawnAfterBreak((WorldServer) this.level(), blockposition, ItemStack.EMPTY, false);
+ }
+ nmsBlock.wasExploded(this.level(), blockposition, explosionSource);
+ nmsBlock.wasExploded((WorldServer) this.level(), blockposition, explosionSource);
+
+ this.level().removeBlock(blockposition, false);
+ }
@@ -136,24 +137,24 @@
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));
@@ -562,7 +636,7 @@
@@ -531,7 +606,7 @@
@Override
public void kill() {
public void kill(WorldServer worldserver) {
- this.remove(Entity.RemovalReason.KILLED);
+ this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
this.gameEvent(GameEvent.ENTITY_DIE);
if (this.dragonFight != null) {
this.dragonFight.updateDragon(this);
@@ -571,6 +645,21 @@
@@ -540,6 +615,21 @@
}
+ // CraftBukkit start - SPIGOT-2420: Special case, the ender dragon drops 12000 xp for the first kill and 500 xp for every other kill and this over time.
+ @Override
+ public int getExpReward(Entity entity) {
+ public int getExpReward(WorldServer worldserver, Entity entity) {
+ // CraftBukkit - Moved from #tickDeath method
+ boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT);
+ boolean flag = worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT);
+ short short0 = 500;
+
+ if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) {
@@ -167,13 +168,12 @@
@Override
protected void tickDeath() {
if (this.dragonFight != null) {
@@ -586,15 +675,20 @@
@@ -555,16 +645,21 @@
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);
short short0 = 500;
if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) {
@@ -183,31 +183,35 @@
+ int short0 = expToDrop;
+ // CraftBukkit end
if (this.level() instanceof WorldServer) {
- if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && flag) {
World world = this.level();
if (world instanceof WorldServer worldserver) {
- if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
+ 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.position(), MathHelper.floor((float) short0 * 0.08F));
}
@@ -605,7 +699,7 @@
@@ -577,8 +672,8 @@
if (this.dragonDeathTime == 200) {
world = this.level();
if (world instanceof WorldServer) {
- worldserver = (WorldServer) world;
- if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
+ WorldServer worldserver = (WorldServer) world; // CraftBukkit - decompile error
+ if (true) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp
EntityExperienceOrb.award(worldserver, this.position(), MathHelper.floor((float) short0 * 0.2F));
}
this.move(EnumMoveType.SELF, new Vec3D(0.0D, 0.10000000149011612D, 0.0D));
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));
@@ -586,7 +681,7 @@
this.dragonFight.setDragonKilled(this);
}
- this.remove(Entity.RemovalReason.KILLED);
+ this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
this.gameEvent(GameEvent.ENTITY_DIE);
}
@@ -613,7 +707,7 @@
this.dragonFight.setDragonKilled(this);
}
- this.remove(Entity.RemovalReason.KILLED);
+ this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
this.gameEvent(GameEvent.ENTITY_DIE);
}
@@ -826,6 +920,7 @@
@@ -800,6 +895,7 @@
super.addAdditionalSaveData(nbttagcompound);
nbttagcompound.putInt("DragonPhase", this.phaseManager.getCurrentPhase().getPhase().getId());
nbttagcompound.putInt("DragonDeathTime", this.dragonDeathTime);
@@ -215,7 +219,7 @@
}
@Override
@@ -839,6 +934,11 @@
@@ -813,6 +909,11 @@
this.dragonDeathTime = nbttagcompound.getInt("DragonDeathTime");
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerLandedFlame.java
+++ b/net/minecraft/world/entity/boss/enderdragon/phases/DragonControllerLandedFlame.java
@@ -10,6 +10,10 @@
@@ -11,6 +11,10 @@
import net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon;
import net.minecraft.world.phys.Vec3D;
@@ -11,7 +11,7 @@
public class DragonControllerLandedFlame extends AbstractDragonControllerLanded {
private static final int FLAME_DURATION = 200;
@@ -99,7 +103,7 @@
@@ -100,7 +104,7 @@
@Override
public void end() {
if (this.flame != null) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/boss/wither/EntityWither.java
+++ b/net/minecraft/world/entity/boss/wither/EntityWither.java
@@ -59,6 +59,18 @@
@@ -57,6 +57,18 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.phys.Vec3D;
@@ -16,29 +16,29 @@
+import org.bukkit.event.entity.ExplosionPrimeEvent;
+// CraftBukkit end
+
public class EntityWither extends EntityMonster implements PowerableMob, IRangedEntity {
public class EntityWither extends EntityMonster implements IRangedEntity {
private static final DataWatcherObject<Integer> DATA_TARGET_A = DataWatcher.defineId(EntityWither.class, DataWatcherRegistry.INT);
@@ -255,15 +267,40 @@
@@ -253,15 +265,40 @@
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);
- worldserver.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);
+ // worldserver.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);
+ worldserver.getCraftServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled()) {
+ this.level().explode(this, this.getX(), this.getEyeY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB);
+ worldserver.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);
- worldserver.globalLevelEvent(1023, this.blockPosition(), 0);
+ // CraftBukkit start - Use relative location for far away sounds
+ // this.level().globalLevelEvent(1023, new BlockPosition(this), 0);
+ int viewDistance = ((WorldServer) this.level()).getCraftServer().getViewDistance() * 16;
+ // worldserver.globalLevelEvent(1023, new BlockPosition(this), 0);
+ int viewDistance = worldserver.getCraftServer().getViewDistance() * 16;
+ for (EntityPlayer player : (List<EntityPlayer>) MinecraftServer.getServer().getPlayerList().players) {
+ double deltaX = this.getX() - player.getX();
+ double deltaZ = this.getZ() - player.getZ();
@@ -63,7 +63,7 @@
}
} else {
@@ -308,6 +345,7 @@
@@ -306,6 +343,7 @@
if (!list.isEmpty()) {
EntityLiving entityliving1 = (EntityLiving) list.get(this.random.nextInt(list.size()));
@@ -71,8 +71,8 @@
this.setAlternativeTarget(i, entityliving1.getId());
}
}
@@ -334,6 +372,11 @@
IBlockData iblockdata = this.level().getBlockState(blockposition);
@@ -332,6 +370,11 @@
IBlockData iblockdata = worldserver.getBlockState(blockposition);
if (canDestroy(iblockdata)) {
+ // CraftBukkit start
@@ -80,10 +80,10 @@
+ continue;
+ }
+ // CraftBukkit end
flag = this.level().destroyBlock(blockposition, true, this) || flag;
flag = worldserver.destroyBlock(blockposition, true, this) || flag;
}
}
@@ -345,7 +388,7 @@
@@ -343,7 +386,7 @@
}
if (this.tickCount % 20 == 0) {
@@ -92,7 +92,7 @@
}
this.bossEvent.setProgress(this.getHealth() / this.getMaxHealth());
@@ -502,7 +545,7 @@
@@ -500,7 +543,7 @@
@Override
public void checkDespawn() {
if (this.level().getDifficulty() == EnumDifficulty.PEACEFUL && this.shouldDespawnInPeaceful()) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/decoration/BlockAttachedEntity.java
+++ b/net/minecraft/world/entity/decoration/BlockAttachedEntity.java
@@ -15,6 +15,15 @@
@@ -18,6 +18,15 @@
import net.minecraft.world.phys.Vec3D;
import org.slf4j.Logger;
@@ -16,7 +16,7 @@
public abstract class BlockAttachedEntity extends Entity {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -39,7 +48,25 @@
@@ -44,7 +53,25 @@
if (this.checkInterval++ == 100) {
this.checkInterval = 0;
if (!this.isRemoved() && !this.survives()) {
@@ -40,13 +40,13 @@
+ }
+ // CraftBukkit end
+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
this.dropItem((Entity) null);
this.dropItem(worldserver, (Entity) null);
}
}
@@ -69,6 +96,22 @@
@@ -81,6 +108,22 @@
return false;
} else {
if (!this.isRemoved() && !this.level().isClientSide) {
if (!this.isRemoved()) {
+ // CraftBukkit start - fire break events
+ Entity damager = (damagesource.isDirect()) ? damagesource.getDirectEntity() : damagesource.getEntity();
+ HangingBreakEvent event;
@@ -63,37 +63,36 @@
+ }
+ // CraftBukkit end
+
this.kill();
this.kill(worldserver);
this.markHurt();
this.dropItem(damagesource.getEntity());
@@ -81,6 +124,18 @@
@Override
public void move(EnumMoveType enummovetype, Vec3D vec3d) {
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);
+
+ if (this.isRemoved() || event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
+
this.kill();
this.dropItem((Entity) null);
}
@@ -89,13 +144,22 @@
this.dropItem(worldserver, damagesource.getEntity());
@@ -101,6 +144,16 @@
@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
this.kill();
this.dropItem((Entity) null);
}
if (world instanceof WorldServer worldserver) {
if (!this.isRemoved() && vec3d.lengthSqr() > 0.0D) {
+ // 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);
+
+ if (this.isRemoved() || event.isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
+
this.kill(worldserver);
this.dropItem(worldserver, (Entity) null);
}
@@ -113,7 +166,7 @@
World world = this.level();
if (world instanceof WorldServer worldserver) {
- if (!this.isRemoved() && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) {
+ if (false && !this.isRemoved() && d0 * d0 + d1 * d1 + d2 * d2 > 0.0D) { // CraftBukkit - not needed
this.kill(worldserver);
this.dropItem(worldserver, (Entity) null);
}
@@ -121,6 +174,15 @@
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/decoration/EntityArmorStand.java
+++ b/net/minecraft/world/entity/decoration/EntityArmorStand.java
@@ -46,6 +46,16 @@
@@ -48,6 +48,16 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
@@ -17,7 +17,7 @@
public class EntityArmorStand extends EntityLiving {
public static final int WOBBLE_TIME = 5;
@@ -111,6 +121,13 @@
@@ -123,6 +133,13 @@
return createLivingAttributes().add(GenericAttributes.STEP_HEIGHT, 0.0D);
}
@@ -31,7 +31,7 @@
@Override
public void refreshDimensions() {
double d0 = this.getX();
@@ -171,13 +188,20 @@
@@ -183,13 +200,20 @@
@Override
public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
@@ -54,9 +54,9 @@
}
}
@@ -407,7 +431,25 @@
@@ -412,7 +436,25 @@
return false;
} else if (itemstack1.isEmpty() && (this.disabledSlots & 1 << enumitemslot.getFilterFlag() + 16) != 0) {
} else if (itemstack1.isEmpty() && (this.disabledSlots & 1 << enumitemslot.getFilterBit(16)) != 0) {
return false;
- } else if (entityhuman.hasInfiniteMaterials() && itemstack1.isEmpty() && !itemstack.isEmpty()) {
+ // CraftBukkit start
@@ -81,7 +81,7 @@
this.setItemSlot(enumitemslot, itemstack.copyWithCount(1));
return true;
} else if (!itemstack.isEmpty() && itemstack.getCount() > 1) {
@@ -422,6 +464,7 @@
@@ -427,6 +469,7 @@
entityhuman.setItemInHand(enumhand, itemstack1);
return true;
}
@@ -89,60 +89,60 @@
}
@Override
@@ -435,12 +478,22 @@
WorldServer worldserver = (WorldServer) world;
@@ -436,12 +479,22 @@
} else if (!worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) && damagesource.getEntity() instanceof EntityInsentient) {
return false;
} else if (damagesource.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) {
- this.kill(worldserver);
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
+ return false;
+ }
+ this.kill(worldserver, damagesource); // CraftBukkit
+ // CraftBukkit end
return false;
- } else if (!this.isInvulnerableTo(worldserver, damagesource) && !this.invisible && !this.isMarker()) {
+ } else if (!this.isInvulnerableTo(worldserver, damagesource) && (true || !this.invisible) && !this.isMarker()) { // CraftBukkit
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, true, this.invisible)) {
+ return false;
+ }
+ // CraftBukkit end
if (damagesource.is(DamageTypeTags.IS_EXPLOSION)) {
this.brokenByAnything(worldserver, damagesource);
- this.kill(worldserver);
+ this.kill(worldserver, damagesource); // CraftBukkit
return false;
} else if (damagesource.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) {
if (this.isOnFire()) {
@@ -474,7 +527,7 @@
if (damagesource.isCreativePlayer()) {
this.playBrokenSound();
this.showBreakingParticles();
- this.kill(worldserver);
+ this.kill(worldserver, damagesource); // CraftBukkit
return true;
} else {
long i = worldserver.getGameTime();
@@ -486,7 +539,7 @@
} else {
this.brokenByPlayer(worldserver, damagesource);
this.showBreakingParticles();
- this.kill(worldserver);
+ this.discard(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - SPIGOT-4890: remain as this.discard() since above damagesource method will call death event
}
if (damagesource.is(DamageTypeTags.BYPASSES_INVULNERABILITY)) {
- this.kill();
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
+ return false;
+ }
+ this.kill(damagesource); // CraftBukkit
+ // CraftBukkit end
return false;
- } else if (!this.isInvulnerableTo(damagesource) && !this.invisible && !this.isMarker()) {
+ } else if (!this.isInvulnerableTo(damagesource) && (true || !this.invisible) && !this.isMarker()) { // CraftBukkit
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, true, this.invisible)) {
+ return false;
+ }
+ // CraftBukkit end
if (damagesource.is(DamageTypeTags.IS_EXPLOSION)) {
this.brokenByAnything(worldserver, damagesource);
- this.kill();
+ this.kill(damagesource); // CraftBukkit
return false;
} else if (damagesource.is(DamageTypeTags.IGNITES_ARMOR_STANDS)) {
if (this.isOnFire()) {
@@ -473,7 +526,7 @@
if (damagesource.isCreativePlayer()) {
this.playBrokenSound();
this.showBreakingParticles();
- this.kill();
+ this.kill(damagesource); // CraftBukkit
return true;
} else {
long i = worldserver.getGameTime();
@@ -485,7 +538,7 @@
} else {
this.brokenByPlayer(worldserver, damagesource);
this.showBreakingParticles();
- this.kill();
+ this.discard(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - SPIGOT-4890: remain as this.discard() since above damagesource method will call death event
}
return true;
@@ -539,7 +592,7 @@
return true;
@@ -536,7 +589,7 @@
f1 -= f;
if (f1 <= 0.5F) {
this.brokenByAnything(worldserver, damagesource);
- this.kill();
+ this.kill(damagesource); // CraftBukkit
- this.kill(worldserver);
+ this.kill(worldserver, damagesource); // CraftBukkit
} else {
this.setHealth(f1);
this.gameEvent(GameEvent.ENTITY_DAMAGE, damagesource.getEntity());
@@ -551,13 +604,13 @@
@@ -548,13 +601,13 @@
ItemStack itemstack = new ItemStack(Items.ARMOR_STAND);
itemstack.set(DataComponents.CUSTOM_NAME, this.getCustomName());
@@ -158,7 +158,7 @@
ItemStack itemstack;
int i;
@@ -565,7 +618,7 @@
@@ -562,7 +615,7 @@
for (i = 0; i < this.handItems.size(); ++i) {
itemstack = (ItemStack) this.handItems.get(i);
if (!itemstack.isEmpty()) {
@@ -167,7 +167,7 @@
this.handItems.set(i, ItemStack.EMPTY);
}
}
@@ -573,10 +626,11 @@
@@ -570,10 +623,11 @@
for (i = 0; i < this.armorItems.size(); ++i) {
itemstack = (ItemStack) this.armorItems.get(i);
if (!itemstack.isEmpty()) {
@@ -180,7 +180,7 @@
}
@@ -667,9 +721,23 @@
@@ -664,9 +718,23 @@
return this.isSmall();
}
@@ -192,13 +192,13 @@
+ // CraftBukkit end
+
@Override
public void kill() {
public void kill(WorldServer worldserver) {
- this.remove(Entity.RemovalReason.KILLED);
+ // CraftBukkit start - pass DamageSource for kill
+ this.kill(null);
+ this.kill(worldserver, null);
+ }
+
+ public void kill(DamageSource damageSource) {
+ public void kill(WorldServer worldserver, DamageSource damageSource) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, (damageSource == null ? this.damageSources().genericKill() : damageSource), drops); // CraftBukkit - call event
+ this.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
+ // CraftBukkit end

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/decoration/EntityItemFrame.java
+++ b/net/minecraft/world/entity/decoration/EntityItemFrame.java
@@ -90,6 +90,12 @@
@@ -91,6 +91,12 @@
@Override
protected AxisAlignedBB calculateBoundingBox(BlockPosition blockposition, EnumDirection enumdirection) {
@@ -13,19 +13,19 @@
float f = 0.46875F;
Vec3D vec3d = Vec3D.atCenterOf(blockposition).relative(enumdirection, -0.46875D);
EnumDirection.EnumAxis enumdirection_enumaxis = enumdirection.getAxis();
@@ -143,6 +149,11 @@
return false;
} else if (!damagesource.is(DamageTypeTags.IS_EXPLOSION) && !this.getItem().isEmpty()) {
if (!this.level().isClientSide) {
@@ -155,6 +161,11 @@
if (this.isInvulnerableToBase(damagesource)) {
return false;
} else if (this.shouldDamageDropItem(damagesource)) {
+ // CraftBukkit start - fire EntityDamageEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false) || this.isRemoved()) {
+ return true;
+ }
+ // CraftBukkit end
this.dropItem(damagesource.getEntity(), false);
this.dropItem(worldserver, damagesource.getEntity(), false);
this.gameEvent(GameEvent.BLOCK_CHANGE, damagesource.getEntity());
this.playSound(this.getRemoveItemSound(), 1.0F, 1.0F);
@@ -255,13 +266,19 @@
@@ -267,13 +278,19 @@
}
public void setItem(ItemStack itemstack, boolean flag) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/decoration/EntityLeash.java
+++ b/net/minecraft/world/entity/decoration/EntityLeash.java
@@ -26,6 +26,13 @@
@@ -27,6 +27,13 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
@@ -14,7 +14,7 @@
public class EntityLeash extends BlockAttachedEntity {
public static final double OFFSET_Y = 0.375D;
@@ -84,6 +91,15 @@
@@ -85,6 +92,15 @@
Leashable leashable = (Leashable) iterator.next();
if (leashable.getLeashHolder() == entityhuman) {
@@ -30,7 +30,7 @@
leashable.setLeashedTo(this, true);
flag = true;
}
@@ -92,18 +108,34 @@
@@ -93,18 +109,34 @@
boolean flag1 = false;
if (!flag) {

View File

@@ -1,15 +1,15 @@
--- a/net/minecraft/world/entity/decoration/EntityPainting.java
+++ b/net/minecraft/world/entity/decoration/EntityPainting.java
@@ -71,7 +71,7 @@
@@ -72,7 +72,7 @@
public static Optional<EntityPainting> create(World world, BlockPosition blockposition, EnumDirection enumdirection) {
EntityPainting entitypainting = new EntityPainting(world, blockposition);
List<Holder<PaintingVariant>> list = new ArrayList();
- Iterable iterable = world.registryAccess().registryOrThrow(Registries.PAINTING_VARIANT).getTagOrEmpty(PaintingVariantTags.PLACEABLE);
+ Iterable<Holder<PaintingVariant>> iterable = world.registryAccess().registryOrThrow(Registries.PAINTING_VARIANT).getTagOrEmpty(PaintingVariantTags.PLACEABLE); // CraftBukkit - decompile error
- Iterable iterable = world.registryAccess().lookupOrThrow(Registries.PAINTING_VARIANT).getTagOrEmpty(PaintingVariantTags.PLACEABLE);
+ Iterable<Holder<PaintingVariant>> iterable = world.registryAccess().lookupOrThrow(Registries.PAINTING_VARIANT).getTagOrEmpty(PaintingVariantTags.PLACEABLE); // CraftBukkit - decompile error
Objects.requireNonNull(list);
iterable.forEach(list::add);
@@ -137,22 +137,32 @@
@@ -138,22 +138,32 @@
@Override
protected AxisAlignedBB calculateBoundingBox(BlockPosition blockposition, EnumDirection enumdirection) {

View File

@@ -31,7 +31,7 @@
return entityfallingblock;
}
@@ -130,7 +142,7 @@
@@ -139,7 +151,7 @@
@Override
public void tick() {
if (this.blockState.isAir()) {
@@ -40,52 +40,52 @@
} else {
Block block = this.blockState.getBlock();
@@ -159,7 +171,7 @@
this.spawnAtLocation((IMaterial) block);
@@ -174,7 +186,7 @@
this.spawnAtLocation(worldserver, (IMaterial) block);
}
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
}
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
}
} else {
IBlockData iblockdata = this.level().getBlockState(blockposition);
@@ -176,9 +188,15 @@
this.blockState = (IBlockData) this.blockState.setValue(BlockProperties.WATERLOGGED, true);
}
+ // CraftBukkit start
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.blockState)) {
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // SPIGOT-6586 called before the event in previous versions
+ 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)));
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN);
if (block instanceof Fallable) {
((Fallable) block).onLand(this.level(), blockposition, this.blockState, iblockdata, this);
} else {
IBlockData iblockdata = this.level().getBlockState(blockposition);
@@ -191,9 +203,15 @@
this.blockState = (IBlockData) this.blockState.setValue(BlockProperties.WATERLOGGED, true);
}
@@ -206,19 +224,19 @@
+ // CraftBukkit start
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, this.blockState)) {
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // SPIGOT-6586 called before the event in previous versions
+ 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)));
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
if (block instanceof Fallable) {
((Fallable) block).onLand(this.level(), blockposition, this.blockState, iblockdata, this);
}
@@ -221,19 +239,19 @@
}
}
} else if (this.dropItem && worldserver.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
this.callOnBrokenAfterFall(block, blockposition);
this.spawnAtLocation(worldserver, (IMaterial) block);
}
} else if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
} else {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
this.callOnBrokenAfterFall(block, blockposition);
this.spawnAtLocation((IMaterial) block);
if (this.dropItem && worldserver.getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
this.callOnBrokenAfterFall(block, blockposition);
this.spawnAtLocation(worldserver, (IMaterial) block);
}
}
} else {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
if (this.dropItem && this.level().getGameRules().getBoolean(GameRules.RULE_DOENTITYDROPS)) {
this.callOnBrokenAfterFall(block, blockposition);
this.spawnAtLocation((IMaterial) block);
}
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
this.callOnBrokenAfterFall(block, blockposition);
}
} else {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
this.callOnBrokenAfterFall(block, blockposition);
}
}

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/item/EntityItem.java
+++ b/net/minecraft/world/entity/item/EntityItem.java
@@ -34,6 +34,15 @@
import net.minecraft.world.level.portal.DimensionTransition;
import net.minecraft.world.level.portal.TeleportTransition;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
@@ -44,7 +44,7 @@
this.xo = this.getX();
this.yo = this.getY();
@@ -187,9 +200,11 @@
@@ -188,9 +201,11 @@
this.mergeWithNeighbours();
}
@@ -56,7 +56,7 @@
this.hasImpulse |= this.updateInWaterStateAndDoFluidPushing();
if (!this.level().isClientSide) {
@@ -201,7 +216,13 @@
@@ -202,7 +217,13 @@
}
if (!this.level().isClientSide && this.age >= 6000) {
@@ -71,7 +71,7 @@
}
}
@@ -284,11 +305,16 @@
@@ -287,11 +308,16 @@
}
private static void merge(EntityItem entityitem, ItemStack itemstack, EntityItem entityitem1, ItemStack itemstack1) {
@@ -89,9 +89,9 @@
}
}
@@ -309,12 +335,17 @@
} else if (this.level().isClientSide) {
return true;
@@ -320,12 +346,17 @@
} else if (!this.getItem().canBeHurtBy(damagesource)) {
return false;
} else {
+ // CraftBukkit start
+ if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f)) {
@@ -108,7 +108,7 @@
}
return true;
@@ -366,7 +397,7 @@
@@ -382,7 +413,7 @@
}
if (this.getItem().isEmpty()) {
@@ -117,7 +117,7 @@
}
}
@@ -378,10 +409,50 @@
@@ -394,10 +425,50 @@
Item item = itemstack.getItem();
int i = itemstack.getCount();

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/item/EntityTNTPrimed.java
+++ b/net/minecraft/world/entity/item/EntityTNTPrimed.java
@@ -24,6 +24,12 @@
@@ -27,6 +27,12 @@
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.portal.DimensionTransition;
import net.minecraft.world.level.portal.TeleportTransition;
+// CraftBukkit start;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@@ -13,16 +13,15 @@
public class EntityTNTPrimed extends Entity implements TraceableEntity {
private static final DataWatcherObject<Integer> DATA_FUSE_ID = DataWatcher.defineId(EntityTNTPrimed.class, DataWatcherRegistry.INT);
@@ -45,6 +51,8 @@
@Nullable
@@ -51,6 +57,7 @@
public EntityLiving owner;
private boolean usedPortal;
+ public float yield = 4; // CraftBukkit - add field
public float explosionPower;
+ public boolean isIncendiary = false; // CraftBukkit - add field
public EntityTNTPrimed(EntityTypes<? extends EntityTNTPrimed> entitytypes, World world) {
super(entitytypes, world);
@@ -99,10 +107,13 @@
@@ -107,10 +114,13 @@
this.setFuse(i);
if (i <= 0) {
@@ -37,19 +36,17 @@
} else {
this.updateInWaterStateAndDoFluidPushing();
if (this.level().isClientSide) {
@@ -113,9 +124,14 @@
@@ -121,7 +131,13 @@
}
private void explode() {
- float f = 4.0F;
- this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? EntityTNTPrimed.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), this.getY(0.0625D), this.getZ(), this.explosionPower, false, World.a.TNT);
+ // CraftBukkit start
+ // float f = 4.0F;
+ ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive)this.getBukkitEntity());
- this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? EntityTNTPrimed.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), this.getY(0.0625D), this.getZ(), 4.0F, false, World.a.TNT);
+ if (!event.isCancelled()) {
+ this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? EntityTNTPrimed.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT);
+ ExplosionPrimeEvent event = CraftEventFactory.callExplosionPrimeEvent((org.bukkit.entity.Explosive) this.getBukkitEntity());
+ if (event.isCancelled()) {
+ return;
+ }
+ this.level().explode(this, Explosion.getDefaultDamageSource(this.level(), this), this.usedPortal ? EntityTNTPrimed.USED_PORTAL_DAMAGE_CALCULATOR : null, this.getX(), this.getY(0.0625D), this.getZ(), event.getRadius(), event.getFire(), World.a.TNT);
+ // CraftBukkit end
}

View File

@@ -1,15 +1,15 @@
--- a/net/minecraft/world/entity/monster/Bogged.java
+++ b/net/minecraft/world/entity/monster/Bogged.java
@@ -79,6 +79,12 @@
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
if (world instanceof WorldServer) {
WorldServer worldserver = (WorldServer) world;
if (itemstack.is(Items.SHEARS) && this.readyForShearing()) {
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
+ this.getEntityData().markDirty(Bogged.DATA_SHEARED); // CraftBukkit - mark dirty to restore sheared state to clients
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
this.shear(SoundCategory.PLAYERS);
this.gameEvent(GameEvent.SHEAR, entityhuman);
if (!this.level().isClientSide) {
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
+ this.getEntityData().markDirty(Bogged.DATA_SHEARED); // CraftBukkit - mark dirty to restore sheared state to clients
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
this.shear(worldserver, SoundCategory.PLAYERS, itemstack);
this.gameEvent(GameEvent.SHEAR, entityhuman);
itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand));

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityCaveSpider.java
+++ b/net/minecraft/world/entity/monster/EntityCaveSpider.java
@@ -39,7 +39,7 @@
@@ -40,7 +40,7 @@
}
if (b0 > 0) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityCreeper.java
+++ b/net/minecraft/world/entity/monster/EntityCreeper.java
@@ -43,6 +43,13 @@
@@ -42,6 +42,13 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.gameevent.GameEvent;
@@ -11,10 +11,10 @@
+import org.bukkit.event.entity.ExplosionPrimeEvent;
+// CraftBukkit end
+
public class EntityCreeper extends EntityMonster implements PowerableMob {
public class EntityCreeper extends EntityMonster {
private static final DataWatcherObject<Integer> DATA_SWELL_DIR = DataWatcher.defineId(EntityCreeper.class, DataWatcherRegistry.INT);
@@ -53,6 +60,7 @@
@@ -52,6 +59,7 @@
public int maxSwell = 30;
public int explosionRadius = 3;
private int droppedSkulls;
@@ -22,7 +22,7 @@
public EntityCreeper(EntityTypes<? extends EntityCreeper> entitytypes, World world) {
super(entitytypes, world);
@@ -216,9 +224,20 @@
@@ -214,9 +222,20 @@
@Override
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
super.thunderHit(worldserver, entitylightning);
@@ -43,7 +43,7 @@
@Override
protected EnumInteractionResult mobInteract(EntityHuman entityhuman, EnumHand enumhand) {
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
@@ -228,8 +247,9 @@
@@ -226,8 +245,9 @@
this.level().playSound(entityhuman, this.getX(), this.getY(), this.getZ(), soundeffect, this.getSoundSource(), 1.0F, this.random.nextFloat() * 0.4F + 0.8F);
if (!this.level().isClientSide) {
@@ -55,7 +55,7 @@
} else {
itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand));
@@ -246,11 +266,20 @@
if (!this.level().isClientSide) {
if (world instanceof WorldServer worldserver) {
float f = this.isPowered() ? 2.0F : 1.0F;
+ // CraftBukkit start
@@ -63,10 +63,10 @@
+ if (!event.isCancelled()) {
+ // CraftBukkit end
this.dead = true;
- this.level().explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, World.a.MOB);
+ this.level().explode(this, net.minecraft.world.level.Explosion.getDefaultDamageSource(this.level(), this).customCausingEntityDamager(this.entityIgniter), null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); // CraftBukkit
- worldserver.explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionRadius * f, World.a.MOB);
+ worldserver.explode(this, net.minecraft.world.level.Explosion.getDefaultDamageSource(this.level(), this).customCausingEntityDamager(this.entityIgniter), null, this.getX(), this.getY(), this.getZ(), event.getRadius(), event.getFire(), World.a.MOB); // CraftBukkit
this.spawnLingeringCloud();
this.triggerOnDeathMobEffects(Entity.RemovalReason.KILLED);
this.triggerOnDeathMobEffects(worldserver, Entity.RemovalReason.KILLED);
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause
+ // CraftBukkit start

View File

@@ -1,11 +0,0 @@
--- a/net/minecraft/world/entity/monster/EntityDrowned.java
+++ b/net/minecraft/world/entity/monster/EntityDrowned.java
@@ -247,7 +247,7 @@
@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)
double d0 = entityliving.getX() - this.getX();
double d1 = entityliving.getY(0.3333333333333333D) - entitythrowntrident.getY();
double d2 = entityliving.getZ() - this.getZ();

View File

@@ -39,7 +39,7 @@
}
@@ -479,9 +495,11 @@
@@ -466,9 +482,11 @@
if (iblockdata2 != null) {
iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level(), blockposition);
if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) {
@@ -51,7 +51,7 @@
}
}
@@ -520,9 +538,11 @@
@@ -507,9 +525,11 @@
boolean flag = movingobjectpositionblock.getBlockPos().equals(blockposition);
if (iblockdata.is(TagsBlock.ENDERMAN_HOLDABLE) && flag) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityEvoker.java
+++ b/net/minecraft/world/entity/monster/EntityEvoker.java
@@ -213,7 +213,7 @@
@@ -212,7 +212,7 @@
worldserver.getScoreboard().addPlayerToTeam(entityvex.getScoreboardName(), scoreboardteam);
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityGhast.java
+++ b/net/minecraft/world/entity/monster/EntityGhast.java
@@ -332,6 +332,8 @@
@@ -333,6 +333,8 @@
EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.ghast, vec3d1.normalize(), this.ghast.getExplosionPower());

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityGuardian.java
+++ b/net/minecraft/world/entity/monster/EntityGuardian.java
@@ -59,6 +59,7 @@
@@ -60,6 +60,7 @@
private boolean clientSideTouchedGround;
@Nullable
public PathfinderGoalRandomStroll randomStrollGoal;
@@ -8,7 +8,7 @@
public EntityGuardian(EntityTypes<? extends EntityGuardian> entitytypes, World world) {
super(entitytypes, world);
@@ -74,7 +75,7 @@
@@ -75,7 +76,7 @@
PathfinderGoalMoveTowardsRestriction pathfindergoalmovetowardsrestriction = new PathfinderGoalMoveTowardsRestriction(this, 1.0D);
this.randomStrollGoal = new PathfinderGoalRandomStroll(this, 1.0D, 80);

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/entity/monster/EntityGuardianElder.java
+++ b/net/minecraft/world/entity/monster/EntityGuardianElder.java
@@ -67,7 +67,7 @@
super.customServerAiStep();
super.customServerAiStep(worldserver);
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, this.position(), 50.0D, mobeffect, 1200);
+ List<EntityPlayer> list = MobEffectUtil.addEffectToPlayersAround(worldserver, 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,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityIllagerIllusioner.java
+++ b/net/minecraft/world/entity/monster/EntityIllagerIllusioner.java
@@ -217,7 +217,7 @@
@@ -218,7 +218,7 @@
@Override
protected void performSpellCasting() {
@@ -9,7 +9,7 @@
}
@Nullable
@@ -268,7 +268,7 @@
@@ -269,7 +269,7 @@
@Override
protected void performSpellCasting() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityIllagerWizard.java
+++ b/net/minecraft/world/entity/monster/EntityIllagerWizard.java
@@ -17,6 +17,10 @@
@@ -18,6 +18,10 @@
import net.minecraft.world.entity.ai.goal.PathfinderGoal;
import net.minecraft.world.level.World;
@@ -11,7 +11,7 @@
public abstract class EntityIllagerWizard extends EntityIllagerAbstract {
private static final DataWatcherObject<Byte> DATA_SPELL_CASTING_ID = DataWatcher.defineId(EntityIllagerWizard.class, DataWatcherRegistry.BYTE);
@@ -158,6 +162,11 @@
@@ -159,6 +163,11 @@
public void tick() {
--this.attackWarmupDelay;
if (this.attackWarmupDelay == 0) {

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/monster/EntityPhantom.java
+++ b/net/minecraft/world/entity/monster/EntityPhantom.java
@@ -521,14 +521,14 @@
List<EntityHuman> list = EntityPhantom.this.level().getNearbyPlayers(this.attackTargeting, EntityPhantom.this, EntityPhantom.this.getBoundingBox().inflate(16.0D, 64.0D, 16.0D));
@@ -522,14 +522,14 @@
List<EntityHuman> list = worldserver.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());
@@ -11,7 +11,7 @@
while (iterator.hasNext()) {
EntityHuman entityhuman = (EntityHuman) iterator.next();
if (EntityPhantom.this.canAttack(entityhuman, PathfinderTargetCondition.DEFAULT)) {
if (EntityPhantom.this.canAttack(worldserver, entityhuman, PathfinderTargetCondition.DEFAULT)) {
- EntityPhantom.this.setTarget(entityhuman);
+ EntityPhantom.this.setTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit - reason
return true;

View File

@@ -41,4 +41,4 @@
+ // CraftBukkit end
}
public static boolean checkZombifiedPiglinSpawnRules(EntityTypes<EntityPigZombie> entitytypes, GeneratorAccess generatoraccess, EnumMobSpawn enummobspawn, BlockPosition blockposition, RandomSource randomsource) {
public static boolean checkZombifiedPiglinSpawnRules(EntityTypes<EntityPigZombie> entitytypes, GeneratorAccess generatoraccess, EntitySpawnReason entityspawnreason, BlockPosition blockposition, RandomSource randomsource) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityPillager.java
+++ b/net/minecraft/world/entity/monster/EntityPillager.java
@@ -48,6 +48,10 @@
@@ -50,6 +50,10 @@
import net.minecraft.world.level.World;
import net.minecraft.world.level.WorldAccess;
@@ -11,7 +11,7 @@
public class EntityPillager extends EntityIllagerAbstract implements ICrossbow, InventoryCarrier {
private static final DataWatcherObject<Boolean> IS_CHARGING_CROSSBOW = DataWatcher.defineId(EntityPillager.class, DataWatcherRegistry.BOOLEAN);
@@ -195,7 +199,7 @@
@@ -198,7 +202,7 @@
ItemStack itemstack1 = this.inventory.addItem(itemstack);
if (itemstack1.isEmpty()) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityRavager.java
+++ b/net/minecraft/world/entity/monster/EntityRavager.java
@@ -43,6 +43,10 @@
@@ -45,6 +45,10 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
@@ -10,16 +10,16 @@
+
public class EntityRavager extends EntityRaider {
private static final Predicate<Entity> NO_RAVAGER_AND_ALIVE = (entity) -> {
@@ -147,6 +151,11 @@
Block block = iblockdata.getBlock();
private static final Predicate<Entity> ROAR_TARGET_WITH_GRIEFING = (entity) -> {
@@ -161,6 +165,11 @@
Block block = iblockdata.getBlock();
if (block instanceof BlockLeaves) {
+ // CraftBukkit start
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState())) {
+ continue;
+ }
+ // CraftBukkit end
flag = this.level().destroyBlock(blockposition, true, this) || flag;
if (block instanceof BlockLeaves) {
+ // CraftBukkit start
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState())) {
+ continue;
+ }
+ // CraftBukkit end
flag = worldserver.destroyBlock(blockposition, true, this) || flag;
}
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityShulker.java
+++ b/net/minecraft/world/entity/monster/EntityShulker.java
@@ -58,6 +58,12 @@
@@ -59,6 +59,12 @@
import net.minecraft.world.phys.Vec3D;
import org.joml.Vector3f;
@@ -13,7 +13,7 @@
public class EntityShulker extends EntityGolem implements VariantHolder<Optional<EnumColor>>, IMonster {
private static final MinecraftKey COVERED_ARMOR_MODIFIER_ID = MinecraftKey.withDefaultNamespace("covered");
@@ -401,6 +407,14 @@
@@ -402,6 +408,14 @@
EnumDirection enumdirection = this.findAttachableSurface(blockposition1);
if (enumdirection != null) {
@@ -28,7 +28,7 @@
this.unRide();
this.setAttachFace(enumdirection);
this.playSound(SoundEffects.SHULKER_TELEPORT, 1.0F, 1.0F);
@@ -471,7 +485,7 @@
@@ -472,7 +486,7 @@
if (entityshulker != null) {
entityshulker.setVariant(this.getVariant());
entityshulker.moveTo(vec3d);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntitySilverfish.java
+++ b/net/minecraft/world/entity/monster/EntitySilverfish.java
@@ -30,6 +30,11 @@
@@ -31,6 +31,11 @@
import net.minecraft.world.level.block.BlockMonsterEggs;
import net.minecraft.world.level.block.state.IBlockData;
@@ -12,7 +12,7 @@
public class EntitySilverfish extends EntityMonster {
@Nullable
@@ -157,6 +162,11 @@
@@ -160,6 +165,11 @@
Block block = iblockdata.getBlock();
if (block instanceof BlockMonsterEggs) {
@@ -21,10 +21,10 @@
+ continue;
+ }
+ // CraftBukkit end
if (world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
if (getServerLevel(world).getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
world.destroyBlock(blockposition1, true, this.silverfish);
} else {
@@ -226,9 +236,14 @@
@@ -229,9 +239,14 @@
IBlockData iblockdata = world.getBlockState(blockposition);
if (BlockMonsterEggs.isCompatibleHostBlock(iblockdata)) {

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/entity/monster/EntitySkeleton.java
+++ b/net/minecraft/world/entity/monster/EntitySkeleton.java
@@ -91,7 +91,7 @@
@@ -99,7 +99,7 @@
this.level().levelEvent((EntityHuman) null, 1048, this.blockPosition(), 0);
}
- });
+ }, org.bukkit.event.entity.EntityTransformEvent.TransformReason.FROZEN, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.FROZEN); // CraftBukkit - add spawn and transform reasons
}
protected void doFreezeConversion() {
- 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);
}
@Override

View File

@@ -1,23 +1,21 @@
--- a/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java
+++ b/net/minecraft/world/entity/monster/EntitySkeletonAbstract.java
@@ -204,8 +204,19 @@
double d3 = Math.sqrt(d0 * d0 + d2 * d2);
@@ -207,7 +207,17 @@
World world = this.level();
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()) {
+ event.getProjectile().remove();
+ return;
+ }
if (world instanceof WorldServer worldserver) {
- IProjectile.spawnProjectileUsingShoot(entityarrow, worldserver, itemstack1, d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - worldserver.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()) {
+ event.getProjectile().remove();
+ return;
+ }
+
+ if (event.getProjectile() == entityarrow.getBukkitEntity()) {
+ 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
}
+ if (event.getProjectile() == entityarrow.getBukkitEntity()) {
+ IProjectile.spawnProjectileUsingShoot(entityarrow, worldserver, itemstack1, d0, d1 + d3 * 0.20000000298023224D, d2, 1.6F, (float) (14 - worldserver.getDifficulty().getId() * 4));
+ }
+ // CraftBukkit end
}
protected EntityArrow getArrow(ItemStack itemstack, float f, @Nullable ItemStack itemstack1) {
this.playSound(SoundEffects.SKELETON_SHOOT, 1.0F, 1.0F / (this.getRandom().nextFloat() * 0.4F + 0.8F));

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/monster/EntitySlime.java
+++ b/net/minecraft/world/entity/monster/EntitySlime.java
@@ -45,6 +45,15 @@
import net.minecraft.world.level.levelgen.SeededRandom;
@@ -47,6 +47,15 @@
import net.minecraft.world.phys.Vec3D;
import net.minecraft.world.scores.ScoreboardTeam;
+// CraftBukkit start
+import java.util.ArrayList;
@@ -16,7 +16,7 @@
public class EntitySlime extends EntityInsentient implements IMonster {
private static final DataWatcherObject<Integer> ID_SIZE = DataWatcher.defineId(EntitySlime.class, DataWatcherRegistry.INT);
@@ -195,11 +204,18 @@
@@ -197,11 +206,18 @@
@Override
public EntityTypes<? extends EntitySlime> getType() {
@@ -36,9 +36,9 @@
int i = this.getSize();
if (!this.level().isClientSide && i > 1 && this.isDeadOrDying()) {
@@ -210,6 +226,19 @@
int j = i / 2;
@@ -211,18 +227,45 @@
int k = 2 + this.random.nextInt(3);
ScoreboardTeam scoreboardteam = this.getTeam();
+ // CraftBukkit start
+ SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), k);
@@ -56,19 +56,24 @@
for (int l = 0; l < k; ++l) {
float f2 = ((float) (l % 2) - 0.5F) * f1;
float f3 = ((float) (l / 2) - 0.5F) * f1;
@@ -225,12 +254,21 @@
entityslime.setInvulnerable(this.isInvulnerable());
- this.convertTo(this.getType(), new ConversionParams(ConversionType.SPLIT_ON_DEATH, false, false, scoreboardteam), EntitySpawnReason.TRIGGERED, (entityslime) -> {
+ EntitySlime converted = this.convertTo(this.getType(), new ConversionParams(ConversionType.SPLIT_ON_DEATH, false, false, scoreboardteam), EntitySpawnReason.TRIGGERED, (entityslime) -> { // CraftBukkit
entityslime.setSize(j, true);
entityslime.moveTo(this.getX() + (double) f2, this.getY() + 0.5D, this.getZ() + (double) f3, this.random.nextFloat() * 360.0F, 0.0F);
- this.level().addFreshEntity(entityslime);
+ slimes.add(entityslime); // CraftBukkit
}
}
- });
+ // CraftBukkit start
+ }, null, null);
+ if (converted != null) {
+ slimes.add(converted);
+ }
+ // CraftBukkit end
+ }
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, slimes, EntityTransformEvent.TransformReason.SPLIT).isCancelled()) {
+ super.remove(entity_removalreason, cause); // CraftBukkit - add Bukkit remove cause
+ return;
+ }
}
+ for (EntityLiving living : slimes) {
+ this.level().addFreshEntity(living, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
+ }

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityStrider.java
+++ b/net/minecraft/world/entity/monster/EntityStrider.java
@@ -351,7 +351,14 @@
@@ -350,7 +350,14 @@
boolean flag2 = flag1;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityVex.java
+++ b/net/minecraft/world/entity/monster/EntityVex.java
@@ -383,7 +383,7 @@
@@ -381,7 +381,7 @@
@Override
public void start() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityWitch.java
+++ b/net/minecraft/world/entity/monster/EntityWitch.java
@@ -125,7 +125,7 @@
@@ -126,7 +126,7 @@
PotionContents potioncontents = (PotionContents) itemstack.get(DataComponents.POTION_CONTENTS);
if (itemstack.is(Items.POTION) && potioncontents != null) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityZombie.java
+++ b/net/minecraft/world/entity/monster/EntityZombie.java
@@ -65,6 +65,15 @@
@@ -67,6 +67,15 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData;
@@ -16,7 +16,7 @@
public class EntityZombie extends EntityMonster {
private static final MinecraftKey SPEED_MODIFIER_BABY_ID = MinecraftKey.withDefaultNamespace("baby");
@@ -89,6 +98,7 @@
@@ -91,6 +100,7 @@
private boolean canBreakDoors;
private int inWaterTime;
public int conversionTime;
@@ -24,7 +24,7 @@
public EntityZombie(EntityTypes<? extends EntityZombie> entitytypes, World world) {
super(entitytypes, world);
@@ -205,7 +215,10 @@
@@ -203,7 +213,10 @@
public void tick() {
if (!this.level().isClientSide && this.isAlive() && !this.isNoAi()) {
if (this.isUnderWaterConverting()) {
@@ -36,7 +36,7 @@
if (this.conversionTime < 0) {
this.doUnderWaterConversion();
}
@@ -222,6 +235,7 @@
@@ -220,6 +233,7 @@
}
super.tick();
@@ -44,7 +44,7 @@
}
@Override
@@ -256,6 +270,7 @@
@@ -254,6 +268,7 @@
}
public void startUnderWaterConversion(int i) {
@@ -52,36 +52,65 @@
this.conversionTime = i;
this.getEntityData().set(EntityZombie.DATA_DROWNED_CONVERSION_ID, true);
}
@@ -269,11 +284,15 @@
@@ -267,26 +282,39 @@
}
protected void convertToZombieType(EntityTypes<? extends EntityZombie> entitytypes) {
- EntityZombie entityzombie = (EntityZombie) this.convertTo(entitytypes, true);
+ EntityZombie entityzombie = (EntityZombie) this.convertTo(entitytypes, true, EntityTransformEvent.TransformReason.DROWNED, CreatureSpawnEvent.SpawnReason.DROWNED);
if (entityzombie != null) {
- this.convertTo(entitytypes, ConversionParams.single(this, true, true), (entityzombie) -> {
+ EntityZombie converted = this.convertTo(entitytypes, ConversionParams.single(this, true, true), (entityzombie) -> { // CraftBukkit
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 {
+ ((Zombie) getBukkitEntity()).setConversionTime(-1);
+ // CraftBukkit end
}
- });
+ // CraftBukkit start
+ }, EntityTransformEvent.TransformReason.DROWNED, CreatureSpawnEvent.SpawnReason.DROWNED);
+ if (converted == null) {
+ ((Zombie) getBukkitEntity()).setConversionTime(-1); // CraftBukkit - SPIGOT-5208: End conversion to stop event spam
+ }
+ // CraftBukkit end
}
@@ -312,9 +331,9 @@
if (EntityPositionTypes.isSpawnPositionOk(entitytypes, this.level(), blockposition) && EntityPositionTypes.checkSpawnRules(entitytypes, worldserver, EnumMobSpawn.REINFORCEMENT, blockposition, this.level().random)) {
@VisibleForTesting
public boolean convertVillagerToZombieVillager(WorldServer worldserver, EntityVillager entityvillager) {
+ // CraftBukkit start
+ return convertVillagerToZombieVillager(worldserver, entityvillager, this.blockPosition(), this.isSilent(), EntityTransformEvent.TransformReason.INFECTION, CreatureSpawnEvent.SpawnReason.INFECTION) != null;
+ }
+
+ public static EntityZombieVillager convertVillagerToZombieVillager(WorldServer worldserver, EntityVillager entityvillager, net.minecraft.core.BlockPosition blockPosition, boolean silent, EntityTransformEvent.TransformReason transformReason, CreatureSpawnEvent.SpawnReason spawnReason) {
+ // CraftBukkit end
EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, ConversionParams.single(entityvillager, true, true), (entityzombievillager1) -> {
entityzombievillager1.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombievillager1.blockPosition()), EntitySpawnReason.CONVERSION, new EntityZombie.GroupDataZombie(false, true));
entityzombievillager1.setVillagerData(entityvillager.getVillagerData());
entityzombievillager1.setGossips((NBTBase) entityvillager.getGossips().store(DynamicOpsNBT.INSTANCE));
entityzombievillager1.setTradeOffers(entityvillager.getOffers().copy());
entityzombievillager1.setVillagerXp(entityvillager.getVillagerXp());
- if (!this.isSilent()) {
- worldserver.levelEvent((EntityHuman) null, 1026, this.blockPosition(), 0);
+ // CraftBukkit start
+ if (!silent) {
+ worldserver.levelEvent((EntityHuman) null, 1026, blockPosition, 0);
}
- });
+ }, transformReason, spawnReason);
- return entityzombievillager != null;
+ return entityzombievillager;
+ // CraftBukkit end
}
protected boolean isSunSensitive() {
@@ -324,9 +352,9 @@
if (EntityPositionTypes.isSpawnPositionOk(entitytypes, worldserver, blockposition) && EntityPositionTypes.checkSpawnRules(entitytypes, worldserver, EntitySpawnReason.REINFORCEMENT, blockposition, worldserver.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 (!worldserver.hasNearbyAlivePlayer((double) i1, (double) j1, (double) k1, 7.0D) && worldserver.isUnobstructed(entityzombie) && worldserver.noCollision((Entity) entityzombie) && (entityzombie.canSpawnInLiquids() || !worldserver.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);
entityzombie.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombie.blockPosition()), EntitySpawnReason.REINFORCEMENT, (GroupDataEntity) null);
- worldserver.addFreshEntityWithPassengers(entityzombie);
+ worldserver.addFreshEntityWithPassengers(entityzombie, CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit
AttributeModifiable attributemodifiable = this.getAttribute(GenericAttributes.SPAWN_REINFORCEMENTS_CHANCE);
AttributeModifier attributemodifier = attributemodifiable.getModifier(EntityZombie.REINFORCEMENT_CALLER_CHARGE_ID);
double d0 = attributemodifier != null ? attributemodifier.amount() : 0.0D;
@@ -340,7 +359,14 @@
@@ -352,7 +380,14 @@
float f = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty();
if (this.getMainHandItem().isEmpty() && this.isOnFire() && this.random.nextFloat() < f * 0.3F) {
@@ -97,50 +126,17 @@
}
}
@@ -415,8 +441,17 @@
if (worldserver.getDifficulty() != EnumDifficulty.HARD && this.random.nextBoolean()) {
return flag;
}
+ // CraftBukkit start
+ flag = zombifyVillager(worldserver, entityvillager, this.blockPosition(), this.isSilent(), CreatureSpawnEvent.SpawnReason.INFECTION) == null;
+ }
- EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false);
+ return flag;
+ }
+
+ public static EntityZombieVillager zombifyVillager(WorldServer worldserver, EntityVillager entityvillager, net.minecraft.core.BlockPosition blockPosition, boolean silent, CreatureSpawnEvent.SpawnReason spawnReason) {
+ {
+ EntityZombieVillager entityzombievillager = (EntityZombieVillager) entityvillager.convertTo(EntityTypes.ZOMBIE_VILLAGER, false, EntityTransformEvent.TransformReason.INFECTION, spawnReason);
+ // CraftBukkit end
if (entityzombievillager != null) {
entityzombievillager.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entityzombievillager.blockPosition()), EnumMobSpawn.CONVERSION, new EntityZombie.GroupDataZombie(false, true));
@@ -424,15 +459,17 @@
entityzombievillager.setGossips((NBTBase) entityvillager.getGossips().store(DynamicOpsNBT.INSTANCE));
entityzombievillager.setTradeOffers(entityvillager.getOffers().copy());
entityzombievillager.setVillagerXp(entityvillager.getVillagerXp());
- if (!this.isSilent()) {
- worldserver.levelEvent((EntityHuman) null, 1026, this.blockPosition(), 0);
+ // CraftBukkit start
+ if (!silent) {
+ worldserver.levelEvent((EntityHuman) null, 1026, blockPosition, 0);
}
- flag = false;
+ // flag = false;
}
- }
- return flag;
+ return entityzombievillager;
+ }
+ // CraftBukkit end
}
@@ -385,7 +420,7 @@
@Override
@@ -483,7 +520,7 @@
entitychicken1.finalizeSpawn(worldaccess, difficultydamagescaler, EnumMobSpawn.JOCKEY, (GroupDataEntity) null);
public EntityTypes<? extends EntityZombie> getType() {
- return super.getType();
+ return (EntityTypes<? extends EntityZombie>) super.getType(); // CraftBukkit - decompile error
}
protected boolean canSpawnInLiquids() {
@@ -496,7 +531,7 @@
entitychicken1.finalizeSpawn(worldaccess, difficultydamagescaler, EntitySpawnReason.JOCKEY, (GroupDataEntity) null);
entitychicken1.setChickenJockey(true);
this.startRiding(entitychicken1);
- worldaccess.addFreshEntity(entitychicken1);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/EntityZombieHusk.java
+++ b/net/minecraft/world/entity/monster/EntityZombieHusk.java
@@ -58,7 +58,7 @@
@@ -59,7 +59,7 @@
if (flag && this.getMainHandItem().isEmpty() && entity instanceof EntityLiving) {
float f = this.level().getCurrentDifficultyAt(this.blockPosition()).getEffectiveDifficulty();

View File

@@ -1,11 +1,12 @@
--- a/net/minecraft/world/entity/monster/EntityZombieVillager.java
+++ b/net/minecraft/world/entity/monster/EntityZombieVillager.java
@@ -51,6 +51,13 @@
@@ -52,6 +52,14 @@
import net.minecraft.world.level.block.state.IBlockData;
import org.slf4j.Logger;
+// CraftBukkit start
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.world.entity.npc.EntityVillager;
+import org.bukkit.entity.ZombieVillager;
+import org.bukkit.event.entity.CreatureSpawnEvent;
+import org.bukkit.event.entity.EntityTransformEvent;
@@ -14,7 +15,7 @@
public class EntityZombieVillager extends EntityZombie implements VillagerDataHolder {
private static final Logger LOGGER = LogUtils.getLogger();
@@ -68,6 +75,7 @@
@@ -69,6 +77,7 @@
@Nullable
private MerchantRecipeList tradeOffers;
private int villagerXp;
@@ -22,7 +23,7 @@
public EntityZombieVillager(EntityTypes<? extends EntityZombieVillager> entitytypes, World world) {
super(entitytypes, world);
@@ -86,7 +94,7 @@
@@ -87,7 +96,7 @@
@Override
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.addAdditionalSaveData(nbttagcompound);
@@ -31,7 +32,7 @@
Logger logger = EntityZombieVillager.LOGGER;
Objects.requireNonNull(logger);
@@ -121,7 +129,7 @@
@@ -122,7 +131,7 @@
}
if (nbttagcompound.contains("Offers")) {
@@ -40,7 +41,7 @@
Logger logger1 = EntityZombieVillager.LOGGER;
Objects.requireNonNull(logger1);
@@ -148,6 +156,10 @@
@@ -149,6 +158,10 @@
public void tick() {
if (!this.level().isClientSide && this.isAlive() && this.isConverting()) {
int i = this.getConversionProgress();
@@ -51,7 +52,7 @@
this.villagerConversionTime -= i;
if (this.villagerConversionTime <= 0) {
@@ -156,6 +168,7 @@
@@ -157,6 +170,7 @@
}
super.tick();
@@ -59,7 +60,7 @@
}
@Override
@@ -196,8 +209,10 @@
@@ -197,8 +211,10 @@
this.conversionStarter = uuid;
this.villagerConversionTime = i;
this.getEntityData().set(EntityZombieVillager.DATA_CONVERTING_ID, true);
@@ -72,29 +73,20 @@
this.level().broadcastEntityEvent(this, (byte) 16);
}
@@ -214,12 +229,20 @@
@@ -215,10 +231,11 @@
}
private void finishConversion(WorldServer worldserver) {
- EntityVillager entityvillager = (EntityVillager) this.convertTo(EntityTypes.VILLAGER, false);
+ // CraftBukkit start
+ EntityVillager entityvillager = (EntityVillager) this.convertTo(EntityTypes.VILLAGER, false, EntityTransformEvent.TransformReason.CURED, CreatureSpawnEvent.SpawnReason.CURED);
+ if (entityvillager == null) {
+ ((ZombieVillager) getBukkitEntity()).setConversionTime(-1); // SPIGOT-5208: End conversion to stop event spam
+ return;
+ }
+ // CraftBukkit end
if (entityvillager != null) {
+ this.forceDrops = true; // CraftBukkit
Iterator iterator = this.dropPreservedEquipment((itemstack) -> {
- this.convertTo(EntityTypes.VILLAGER, ConversionParams.single(this, false, false), (entityvillager) -> {
+ EntityVillager converted = this.convertTo(EntityTypes.VILLAGER, ConversionParams.single(this, false, false), (entityvillager) -> { // CraftBukkit
Iterator iterator = this.dropPreservedEquipment(worldserver, (itemstack) -> {
return !EnchantmentManager.has(itemstack, EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE);
}).iterator();
+ this.forceDrops = false; // CraftBukkit
while (iterator.hasNext()) {
EnumItemSlot enumitemslot = (EnumItemSlot) iterator.next();
@@ -249,7 +272,7 @@
@@ -248,12 +265,16 @@
}
}
@@ -103,3 +95,14 @@
if (!this.isSilent()) {
worldserver.levelEvent((EntityHuman) null, 1027, this.blockPosition(), 0);
}
-
- });
+ // CraftBukkit start
+ }, EntityTransformEvent.TransformReason.CURED, CreatureSpawnEvent.SpawnReason.CURED);
+ if (converted == null) {
+ ((ZombieVillager) getBukkitEntity()).setConversionTime(-1); // SPIGOT-5208: End conversion to stop event spam
+ }
+ // CraftBukkit end
}
@VisibleForTesting

View File

@@ -0,0 +1,20 @@
--- a/net/minecraft/world/entity/monster/creaking/CreakingTransient.java
+++ b/net/minecraft/world/entity/monster/creaking/CreakingTransient.java
@@ -97,7 +97,7 @@
}
}
- this.setRemoved(Entity.RemovalReason.DISCARDED);
+ this.setRemoved(Entity.RemovalReason.DISCARDED, null); // CraftBukkit - add Bukkit remove cause
return;
}
}
@@ -149,7 +149,7 @@
}
}
- this.remove(Entity.RemovalReason.DISCARDED);
+ this.remove(Entity.RemovalReason.DISCARDED, null); // CraftBukkit - add Bukkit remove cause
}
@Override

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/piglin/EntityPiglin.java
+++ b/net/minecraft/world/entity/monster/piglin/EntityPiglin.java
@@ -54,6 +54,18 @@
@@ -57,6 +57,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);
@@ -73,6 +85,10 @@
@@ -76,6 +88,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);
@@ -91,6 +107,14 @@
@@ -94,6 +110,14 @@
}
this.writeInventoryToTag(nbttagcompound, this.registryAccess());
@@ -45,18 +45,18 @@
}
@Override
@@ -99,6 +123,10 @@
@@ -102,6 +126,10 @@
this.setBaby(nbttagcompound.getBoolean("IsBaby"));
this.setCannotHunt(nbttagcompound.getBoolean("CannotHunt"));
this.readInventoryFromTag(nbttagcompound, this.registryAccess());
+ // CraftBukkit start
+ this.allowedBarterItems = nbttagcompound.getList("Bukkit.BarterList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(BuiltInRegistries.ITEM::get).collect(Collectors.toCollection(HashSet::new));
+ this.interestItems = nbttagcompound.getList("Bukkit.InterestList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(BuiltInRegistries.ITEM::get).collect(Collectors.toCollection(HashSet::new));
+ this.allowedBarterItems = nbttagcompound.getList("Bukkit.BarterList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(BuiltInRegistries.ITEM::getValue).collect(Collectors.toCollection(HashSet::new));
+ this.interestItems = nbttagcompound.getList("Bukkit.InterestList", 8).stream().map(NBTBase::getAsString).map(MinecraftKey::tryParse).map(BuiltInRegistries.ITEM::getValue).collect(Collectors.toCollection(HashSet::new));
+ // CraftBukkit end
}
@VisibleForDebug
@@ -216,7 +244,7 @@
@@ -221,7 +249,7 @@
@Override
public BehaviorController<EntityPiglin> getBrain() {
@@ -65,7 +65,7 @@
}
@Override
@@ -349,7 +377,7 @@
@@ -366,7 +394,7 @@
}
protected void holdInOffHand(ItemStack itemstack) {
@@ -74,7 +74,7 @@
this.setItemSlot(EnumItemSlot.OFFHAND, itemstack);
this.setGuaranteedDrop(EnumItemSlot.OFFHAND);
} else {
@@ -375,8 +403,8 @@
@@ -392,8 +420,8 @@
if (EnchantmentManager.has(itemstack1, EnchantmentEffectComponents.PREVENT_ARMOR_CHANGE)) {
return false;
} else {
@@ -83,9 +83,9 @@
+ boolean flag = PiglinAI.isLovedItem(itemstack, this) || itemstack.is(Items.CROSSBOW); // CraftBukkit
+ boolean flag1 = PiglinAI.isLovedItem(itemstack1, this) || itemstack1.is(Items.CROSSBOW); // CraftBukkit
return flag && !flag1 ? true : (!flag && flag1 ? false : (this.isAdult() && !itemstack.is(Items.CROSSBOW) && itemstack1.is(Items.CROSSBOW) ? false : super.canReplaceCurrentItem(itemstack, itemstack1)));
return flag && !flag1 ? true : (!flag && flag1 ? false : (this.isAdult() && !itemstack.is(Items.CROSSBOW) && itemstack1.is(Items.CROSSBOW) ? false : super.canReplaceCurrentItem(itemstack, itemstack1, enumitemslot)));
}
@@ -405,7 +433,7 @@
@@ -422,7 +450,7 @@
@Override
protected SoundEffect getAmbientSound() {

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.java
+++ b/net/minecraft/world/entity/monster/piglin/EntityPiglinAbstract.java
@@ -94,7 +94,7 @@
@@ -102,7 +102,7 @@
protected void finishConversion(WorldServer worldserver) {
this.convertTo(EntityTypes.ZOMBIFIED_PIGLIN, ConversionParams.single(this, true, true), (entitypigzombie) -> {
entitypigzombie.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0));
- });
+ }, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED); // CraftBukkit - add spawn and transform reasons
}
protected void finishConversion(WorldServer worldserver) {
- EntityPigZombie entitypigzombie = (EntityPigZombie) this.convertTo(EntityTypes.ZOMBIFIED_PIGLIN, true);
+ EntityPigZombie entitypigzombie = (EntityPigZombie) this.convertTo(EntityTypes.ZOMBIFIED_PIGLIN, true, org.bukkit.event.entity.EntityTransformEvent.TransformReason.PIGLIN_ZOMBIFIED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.PIGLIN_ZOMBIFIED); // CraftBukkit - add spawn and transform reasons
if (entitypigzombie != null) {
entitypigzombie.addEffect(new MobEffect(MobEffects.CONFUSION, 200, 0));
public boolean isAdult() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/piglin/PiglinAI.java
+++ b/net/minecraft/world/entity/monster/piglin/PiglinAI.java
@@ -74,6 +74,14 @@
@@ -72,6 +72,14 @@
import net.minecraft.world.level.storage.loot.parameters.LootContextParameters;
import net.minecraft.world.phys.Vec3D;
@@ -15,7 +15,7 @@
public class PiglinAI {
public static final int REPELLENT_DETECTION_RANGE_HORIZONTAL = 8;
@@ -164,7 +172,8 @@
@@ -166,7 +174,8 @@
}
private static void initRideHoglinActivity(BehaviorController<EntityPiglin> behaviorcontroller) {
@@ -25,7 +25,7 @@
return true;
}), 1)).build())), BehaviorStopRiding.create(8, PiglinAI::wantsToStopRiding)), MemoryModuleType.RIDE_TARGET);
}
@@ -174,7 +183,7 @@
@@ -176,7 +185,7 @@
}
private static BehaviorGateSingle<EntityLiving> createIdleLookBehaviors() {
@@ -34,7 +34,7 @@
}
private static BehaviorGateSingle<EntityPiglin> createIdleMovementBehaviors() {
@@ -195,13 +204,13 @@
@@ -197,13 +206,13 @@
protected static void updateActivity(EntityPiglin entitypiglin) {
BehaviorController<EntityPiglin> behaviorcontroller = entitypiglin.getBrain();
@@ -51,7 +51,7 @@
Objects.requireNonNull(entitypiglin);
optional.ifPresent(entitypiglin::makeSound);
@@ -233,23 +242,27 @@
@@ -235,23 +244,27 @@
stopWalking(entitypiglin);
ItemStack itemstack;
@@ -74,17 +74,17 @@
- if (isLovedItem(itemstack)) {
+ if (isLovedItem(itemstack, entitypiglin)) { // CraftBukkit - Changes to allow for custom payment in bartering
entitypiglin.getBrain().eraseMemory(MemoryModuleType.TIME_TRYING_TO_REACH_ADMIRE_ITEM);
holdInOffhand(entitypiglin, itemstack);
holdInOffhand(worldserver, entitypiglin, itemstack);
admireGoldItem(entitypiglin);
} else if (isFood(itemstack) && !hasEatenRecently(entitypiglin)) {
eat(entitypiglin);
} else {
- boolean flag = !entitypiglin.equipItemIfPossible(itemstack).equals(ItemStack.EMPTY);
+ boolean flag = !entitypiglin.equipItemIfPossible(itemstack, entityitem).equals(ItemStack.EMPTY); // CraftBukkit
- boolean flag = !entitypiglin.equipItemIfPossible(worldserver, itemstack).equals(ItemStack.EMPTY);
+ boolean flag = !entitypiglin.equipItemIfPossible(worldserver, itemstack, entityitem).equals(ItemStack.EMPTY); // CraftBukkit
if (!flag) {
putInInventory(entitypiglin, itemstack);
@@ -270,7 +283,7 @@
@@ -272,7 +285,7 @@
ItemStack itemstack1 = itemstack.split(1);
if (itemstack.isEmpty()) {
@@ -93,7 +93,7 @@
} else {
entityitem.setItem(itemstack);
}
@@ -285,9 +298,14 @@
@@ -287,9 +300,14 @@
boolean flag1;
if (entitypiglin.isAdult()) {
@@ -108,9 +108,9 @@
+ }
+ // CraftBukkit end
} else if (!flag1) {
boolean flag2 = !entitypiglin.equipItemIfPossible(itemstack).isEmpty();
boolean flag2 = !entitypiglin.equipItemIfPossible(worldserver, itemstack).isEmpty();
@@ -300,7 +318,7 @@
@@ -302,7 +320,7 @@
if (!flag1) {
ItemStack itemstack1 = entitypiglin.getMainHandItem();
@@ -119,7 +119,7 @@
putInInventory(entitypiglin, itemstack1);
} else {
throwItems(entitypiglin, Collections.singletonList(itemstack1));
@@ -377,7 +395,7 @@
@@ -379,7 +397,7 @@
return false;
} else if (isAdmiringDisabled(entitypiglin) && entitypiglin.getBrain().hasMemoryValue(MemoryModuleType.ATTACK_TARGET)) {
return false;
@@ -128,7 +128,7 @@
return isNotHoldingLovedItemInOffHand(entitypiglin);
} else {
boolean flag = entitypiglin.canAddToInventory(itemstack);
@@ -386,6 +404,12 @@
@@ -388,6 +406,12 @@
}
}
@@ -141,7 +141,7 @@
protected static boolean isLovedItem(ItemStack itemstack) {
return itemstack.is(TagsItem.PIGLIN_LOVED);
}
@@ -479,7 +503,7 @@
@@ -481,7 +505,7 @@
}
protected static boolean canAdmire(EntityPiglin entitypiglin, ItemStack itemstack) {
@@ -149,8 +149,8 @@
+ return !isAdmiringDisabled(entitypiglin) && !isAdmiringItem(entitypiglin) && entitypiglin.isAdult() && isBarterCurrency(itemstack, entitypiglin); // CraftBukkit
}
protected static void wasHurtBy(EntityPiglin entitypiglin, EntityLiving entityliving) {
@@ -736,6 +760,12 @@
protected static void wasHurtBy(WorldServer worldserver, EntityPiglin entitypiglin, EntityLiving entityliving) {
@@ -735,6 +759,12 @@
return entitypiglin.getBrain().hasMemoryValue(MemoryModuleType.ADMIRING_ITEM);
}
@@ -163,7 +163,7 @@
private static boolean isBarterCurrency(ItemStack itemstack) {
return itemstack.is(PiglinAI.BARTERING_ITEM);
}
@@ -773,7 +803,7 @@
@@ -772,7 +802,7 @@
}
private static boolean isNotHoldingLovedItemInOffHand(EntityPiglin entitypiglin) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/monster/warden/Warden.java
+++ b/net/minecraft/world/entity/monster/warden/Warden.java
@@ -372,7 +372,7 @@
@@ -375,7 +375,7 @@
@Override
public BehaviorController<Warden> getBrain() {
@@ -9,7 +9,7 @@
}
@Override
@@ -409,7 +409,7 @@
@@ -412,7 +412,7 @@
public static void applyDarknessAround(WorldServer worldserver, Vec3D vec3d, @Nullable Entity entity, int i) {
MobEffect mobeffect = new MobEffect(MobEffects.DARKNESS, 260, 0, false, false);
@@ -18,7 +18,7 @@
}
@Override
@@ -544,7 +544,7 @@
@@ -547,7 +547,7 @@
public void setAttackTarget(EntityLiving entityliving) {
this.getBrain().eraseMemory(MemoryModuleType.ROAR_TARGET);
@@ -27,7 +27,7 @@
this.getBrain().eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
SonicBoom.setCooldown(this, 200);
}
@@ -579,12 +579,12 @@
@@ -582,12 +582,12 @@
@Override
protected NavigationAbstract createNavigation(World world) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/npc/EntityVillager.java
+++ b/net/minecraft/world/entity/npc/EntityVillager.java
@@ -92,6 +92,15 @@
@@ -93,6 +93,15 @@
import net.minecraft.world.phys.AxisAlignedBB;
import org.slf4j.Logger;
@@ -25,7 +25,7 @@
}
@Override
@@ -233,7 +242,7 @@
@@ -235,7 +244,7 @@
this.increaseProfessionLevelOnUpdate = false;
}
@@ -34,7 +34,7 @@
}
}
@@ -363,7 +372,13 @@
@@ -360,7 +369,13 @@
while (iterator.hasNext()) {
MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
@@ -49,7 +49,7 @@
}
this.resendOffersToTradingPlayer();
@@ -432,7 +447,13 @@
@@ -429,7 +444,13 @@
while (iterator.hasNext()) {
MerchantRecipe merchantrecipe = (MerchantRecipe) iterator.next();
@@ -64,7 +64,7 @@
}
}
@@ -492,7 +513,7 @@
@@ -489,7 +510,7 @@
@Override
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.addAdditionalSaveData(nbttagcompound);
@@ -73,7 +73,7 @@
Logger logger = EntityVillager.LOGGER;
Objects.requireNonNull(logger);
@@ -515,7 +536,7 @@
@@ -512,7 +533,7 @@
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.readAdditionalSaveData(nbttagcompound);
if (nbttagcompound.contains("VillagerData", 10)) {
@@ -82,33 +82,25 @@
Logger logger = EntityVillager.LOGGER;
Objects.requireNonNull(logger);
@@ -828,9 +849,14 @@
}
entitywitch.setPersistenceRequired();
- worldserver.addFreshEntityWithPassengers(entitywitch);
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, entitywitch, EntityTransformEvent.TransformReason.LIGHTNING).isCancelled()) {
+ return;
+ }
+ worldserver.addFreshEntityWithPassengers(entitywitch, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
+ // CraftBukkit end
@@ -808,7 +829,7 @@
entitywitch1.finalizeSpawn(worldserver, worldserver.getCurrentDifficultyAt(entitywitch1.blockPosition()), EntitySpawnReason.CONVERSION, (GroupDataEntity) null);
entitywitch1.setPersistenceRequired();
this.releaseAllPois();
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
} else {
- });
+ }, EntityTransformEvent.TransformReason.LIGHTNING, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING); // CraftBukkit
if (entitywitch == null) {
super.thunderHit(worldserver, entitylightning);
}
@@ -927,7 +953,7 @@
}).limit(5L).collect(Collectors.toList());
@@ -906,7 +927,7 @@
}).limit(5L).toList();
if (list1.size() >= j) {
- if (!SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EnumMobSpawn.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM).isEmpty()) {
+ if (!SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EnumMobSpawn.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE).isEmpty()) { // CraftBukkit
- if (!SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM).isEmpty()) {
+ if (!SpawnUtil.trySpawnMob(EntityTypes.IRON_GOLEM, EntitySpawnReason.MOB_SUMMONED, worldserver, this.blockPosition(), 10, 8, 6, SpawnUtil.a.LEGACY_IRON_GOLEM, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.VILLAGE_DEFENSE).isEmpty()) { // CraftBukkit
list.forEach(SensorGolemLastSeen::golemDetected);
}
}
@@ -984,7 +1010,7 @@
@@ -963,7 +984,7 @@
@Override
public void startSleeping(BlockPosition blockposition) {
super.startSleeping(blockposition);
@@ -117,7 +109,7 @@
this.brain.eraseMemory(MemoryModuleType.WALK_TARGET);
this.brain.eraseMemory(MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE);
}
@@ -992,7 +1018,7 @@
@@ -971,7 +992,7 @@
@Override
public void stopSleeping() {
super.stopSleeping();

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/npc/EntityVillagerTrader.java
+++ b/net/minecraft/world/entity/npc/EntityVillagerTrader.java
@@ -47,6 +47,14 @@
@@ -48,6 +48,14 @@
import net.minecraft.world.phys.Vec3D;
import org.apache.commons.lang3.tuple.Pair;
@@ -12,10 +12,10 @@
+import org.bukkit.event.entity.VillagerAcquireTradeEvent;
+// CraftBukkit end
+
public class EntityVillagerTrader extends EntityVillagerAbstract {
public class EntityVillagerTrader extends EntityVillagerAbstract implements Consumable.b {
private static final int NUMBER_OF_TRADE_OFFERS = 5;
@@ -56,6 +64,7 @@
@@ -57,6 +65,7 @@
public EntityVillagerTrader(EntityTypes<? extends EntityVillagerTrader> entitytypes, World world) {
super(entitytypes, world);
@@ -23,7 +23,7 @@
}
@Override
@@ -136,7 +145,16 @@
@@ -137,7 +146,16 @@
MerchantRecipe merchantrecipe = villagertrades_imerchantrecipeoption.getOffer(this, this.random);
if (merchantrecipe != null) {
@@ -41,7 +41,7 @@
}
}
@@ -243,7 +261,7 @@
@@ -244,7 +262,7 @@
private void maybeDespawn() {
if (this.despawnDelay > 0 && !this.isTrading() && --this.despawnDelay == 0) {

Some files were not shown because too many files have changed in this diff Show More