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

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/EntityArrow.java
+++ b/net/minecraft/world/entity/projectile/EntityArrow.java
@@ -52,6 +52,13 @@
@@ -51,6 +51,13 @@
import net.minecraft.world.phys.Vec3D;
import net.minecraft.world.phys.shapes.VoxelShape;
@@ -29,7 +29,7 @@
this.pickupItemStack = itemstack.copy();
this.setCustomName((IChatBaseComponent) itemstack.get(DataComponents.CUSTOM_NAME));
Unit unit = (Unit) itemstack.remove(DataComponents.INTANGIBLE_PROJECTILE);
@@ -116,8 +130,8 @@
@@ -112,8 +126,8 @@
}
protected EntityArrow(EntityTypes<? extends EntityArrow> entitytypes, EntityLiving entityliving, World world, ItemStack itemstack, @Nullable ItemStack itemstack1) {
@@ -40,16 +40,16 @@
}
public void setSoundEvent(SoundEffect soundeffect) {
@@ -242,7 +256,7 @@
}
@@ -276,7 +290,7 @@
if (object != null && !flag) {
- ProjectileDeflection projectiledeflection = this.hitTargetOrDeflectSelf((MovingObjectPosition) object);
+ ProjectileDeflection projectiledeflection = this.preHitTargetOrDeflectSelf((MovingObjectPosition) object); // CraftBukkit - projectile hit event
this.hasImpulse = true;
if (projectiledeflection != ProjectileDeflection.NONE) {
@@ -333,7 +347,7 @@
if (movingobjectpositionentity == null) {
if (this.isAlive() && movingobjectpositionblock.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) {
- this.hitTargetOrDeflectSelf(movingobjectpositionblock);
+ this.preHitTargetOrDeflectSelf(movingobjectpositionblock); // CraftBukkit - projectile hit event
this.hasImpulse = true;
}
} else {
@@ -356,7 +370,7 @@
protected void tickDespawn() {
++this.life;
if (this.life >= 1200) {
@@ -58,7 +58,7 @@
}
}
@@ -380,7 +394,7 @@
@@ -408,7 +422,7 @@
}
if (this.piercingIgnoreEntityIds.size() >= this.getPierceLevel() + 1) {
@@ -67,7 +67,7 @@
return;
}
@@ -401,7 +415,13 @@
@@ -429,7 +443,13 @@
int k = entity.getRemainingFireTicks();
if (this.isOnFire() && !flag) {
@@ -81,8 +81,8 @@
+ // CraftBukkit end
}
if (entity.hurt(damagesource, (float) i)) {
@@ -447,7 +467,7 @@
if (entity.hurtOrSimulate(damagesource, (float) i)) {
@@ -475,7 +495,7 @@
this.playSound(this.soundEvent, 1.0F, 1.2F / (this.random.nextFloat() * 0.2F + 0.9F));
if (this.getPierceLevel() <= 0) {
@@ -91,16 +91,16 @@
}
} else {
entity.setRemainingFireTicks(k);
@@ -458,7 +478,7 @@
this.spawnAtLocation(this.getPickupItem(), 0.1F);
}
@@ -491,7 +511,7 @@
this.spawnAtLocation(worldserver2, this.getPickupItem(), 0.1F);
}
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
}
}
@@ -614,7 +634,7 @@
@@ -660,7 +680,7 @@
}
if (nbttagcompound.contains("weapon", 10)) {
@@ -109,7 +109,7 @@
} else {
this.firedFromWeapon = null;
}
@@ -627,34 +647,31 @@
@@ -673,34 +693,31 @@
Entity entity1 = entity;
byte b0 = 0;
@@ -156,10 +156,10 @@
}
this.pickup = entityarrow_pickupstatus;
@@ -663,9 +680,24 @@
@@ -709,9 +726,24 @@
@Override
public void playerTouch(EntityHuman entityhuman) {
if (!this.level().isClientSide && (this.inGround || this.isNoPhysics()) && this.shakeTime <= 0) {
if (!this.level().isClientSide && (this.isInGround() || this.isNoPhysics()) && this.shakeTime <= 0) {
- if (this.tryPickup(entityhuman)) {
+ // CraftBukkit start
+ ItemStack itemstack = this.getPickupItem();

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/EntityDragonFireball.java
+++ b/net/minecraft/world/entity/projectile/EntityDragonFireball.java
@@ -16,6 +16,10 @@
@@ -15,6 +15,10 @@
import net.minecraft.world.phys.MovingObjectPositionEntity;
import net.minecraft.world.phys.Vec3D;
@@ -11,7 +11,7 @@
public class EntityDragonFireball extends EntityFireball {
public static final float SPLASH_RANGE = 4.0F;
@@ -62,7 +66,7 @@
@@ -61,7 +65,7 @@
this.level().levelEvent(2006, this.blockPosition(), this.isSilent() ? -1 : 1);
this.level().addFreshEntity(entityareaeffectcloud);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/EntityEgg.java
+++ b/net/minecraft/world/entity/projectile/EntityEgg.java
@@ -12,6 +12,16 @@
@@ -14,6 +14,16 @@
import net.minecraft.world.phys.MovingObjectPosition;
import net.minecraft.world.phys.MovingObjectPositionEntity;
@@ -17,7 +17,7 @@
public class EntityEgg extends EntityProjectileThrowable {
private static final EntitySize ZERO_SIZED_DIMENSIONS = EntitySize.fixed(0.0F, 0.0F);
@@ -50,30 +60,58 @@
@@ -52,30 +62,58 @@
protected void onHit(MovingObjectPosition movingobjectposition) {
super.onHit(movingobjectposition);
if (!this.level().isClientSide) {
@@ -54,7 +54,7 @@
+ // CraftBukkit end
+
for (int i = 0; i < b0; ++i) {
- EntityChicken entitychicken = (EntityChicken) EntityTypes.CHICKEN.create(this.level());
- EntityChicken entitychicken = (EntityChicken) EntityTypes.CHICKEN.create(this.level(), EntitySpawnReason.TRIGGERED);
+ Entity entitychicken = this.level().getWorld().makeEntity(new org.bukkit.Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass()); // CraftBukkit
if (entitychicken != null) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/EntityEnderPearl.java
+++ b/net/minecraft/world/entity/projectile/EntityEnderPearl.java
@@ -21,6 +21,13 @@
@@ -29,6 +29,13 @@
import net.minecraft.world.phys.MovingObjectPositionEntity;
import net.minecraft.world.phys.Vec3D;
@@ -13,20 +13,20 @@
+
public class EntityEnderPearl extends EntityProjectileThrowable {
public EntityEnderPearl(EntityTypes<? extends EntityEnderPearl> entitytypes, World world) {
@@ -65,19 +72,26 @@
private long ticketTimer = 0L;
@@ -140,12 +147,19 @@
EntityPlayer entityplayer = (EntityPlayer) entity;
if (entityplayer.connection.isAcceptingMessages()) {
+ // CraftBukkit start
+ Entity tp = entity.changeDimension(new DimensionTransition(worldserver, this.position(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), DimensionTransition.DO_NOTHING, PlayerTeleportEvent.TeleportCause.ENDER_PEARL));
+ if (tp == null) {
+ EntityPlayer entityplayer1 = entityplayer.teleport(new TeleportTransition(worldserver, vec3d, Vec3D.ZERO, 0.0F, 0.0F, Relative.union(Relative.ROTATION, Relative.DELTA), TeleportTransition.DO_NOTHING, PlayerTeleportEvent.TeleportCause.ENDER_PEARL));
+ if (entityplayer1 == null) {
+ this.discard(EntityRemoveEvent.Cause.HIT);
+ return;
+ }
+ // CraftBukkit end
if (this.random.nextFloat() < 0.05F && worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBSPAWNING)) {
EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(worldserver);
EntityEndermite entityendermite = (EntityEndermite) EntityTypes.ENDERMITE.create(worldserver, EntitySpawnReason.TRIGGERED);
if (entityendermite != null) {
entityendermite.moveTo(entity.getX(), entity.getY(), entity.getZ(), entity.getYRot(), entity.getXRot());
@@ -35,17 +35,23 @@
}
}
- entity.changeDimension(new DimensionTransition(worldserver, this.position(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), DimensionTransition.DO_NOTHING));
+ // entity.changeDimension(new DimensionTransition(worldserver, this.position(), entity.getDeltaMovement(), entity.getYRot(), entity.getXRot(), DimensionTransition.DO_NOTHING)); // CraftBukkit - moved up
entity.resetFallDistance();
entityplayer.resetCurrentImpulseContext();
- entity.hurt(this.damageSources().fall(), 5.0F);
+ entity.hurt(this.damageSources().fall().customEntityDamager(this), 5.0F); // CraftBukkit
this.playSound(worldserver, this.position());
}
} else {
@@ -86,11 +100,11 @@
this.playSound(worldserver, this.position());
@@ -153,12 +167,12 @@
entity.setPortalCooldown();
}
- EntityPlayer entityplayer1 = entityplayer.teleport(new TeleportTransition(worldserver, vec3d, Vec3D.ZERO, 0.0F, 0.0F, Relative.union(Relative.ROTATION, Relative.DELTA), TeleportTransition.DO_NOTHING));
+ // EntityPlayer entityplayer1 = entityplayer.teleport(new TeleportTransition(worldserver, vec3d, Vec3D.ZERO, 0.0F, 0.0F, Relative.union(Relative.ROTATION, Relative.DELTA), TeleportTransition.DO_NOTHING)); // CraftBukkit - moved up
if (entityplayer1 != null) {
entityplayer1.resetFallDistance();
entityplayer1.resetCurrentImpulseContext();
- entityplayer1.hurtServer(entityplayer.serverLevel(), this.damageSources().enderPearl(), 5.0F);
+ entityplayer1.hurtServer(entityplayer.serverLevel(), this.damageSources().enderPearl().customEntityDamager(this), 5.0F); // CraftBukkit
}
this.playSound(worldserver, vec3d);
@@ -173,11 +187,11 @@
this.playSound(worldserver, vec3d);
}
- this.discard();
@@ -58,21 +64,21 @@
return;
}
}
@@ -116,7 +130,7 @@
Entity entity = this.getOwner();
if (entity instanceof EntityPlayer && !entity.isAlive() && this.level().getGameRules().getBoolean(GameRules.RULE_ENDER_PEARLS_VANISH_ON_DEATH)) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
} else {
super.tick();
}
@@ -129,7 +143,7 @@
@@ -210,7 +224,7 @@
entity = this.getOwner();
if (entity instanceof EntityPlayer entityplayer) {
if (!entity.isAlive() && entityplayer.serverLevel().getGameRules().getBoolean(GameRules.RULE_ENDER_PEARLS_VANISH_ON_DEATH)) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
break label30;
}
}
@@ -248,7 +262,7 @@
@Override
public boolean canChangeDimensions(World world, World world1) {
- if (world.dimension() == World.END) {
+ if (world.getTypeKey() == WorldDimension.END) { // CraftBukkit
public boolean canTeleport(World world, World world1) {
- if (world.dimension() == World.END && world1.dimension() == World.OVERWORLD) {
+ if (world.getTypeKey() == WorldDimension.END && world1.getTypeKey() == WorldDimension.OVERWORLD) { // CraftBukkit
Entity entity = this.getOwner();
if (entity instanceof EntityPlayer) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/EntityEnderSignal.java
+++ b/net/minecraft/world/entity/projectile/EntityEnderSignal.java
@@ -16,6 +16,10 @@
@@ -18,6 +18,10 @@
import net.minecraft.world.level.World;
import net.minecraft.world.phys.Vec3D;
@@ -10,8 +10,8 @@
+
public class EntityEnderSignal extends Entity implements ItemSupplier {
private static final DataWatcherObject<ItemStack> DATA_ITEM_STACK = DataWatcher.defineId(EntityEnderSignal.class, DataWatcherRegistry.ITEM_STACK);
@@ -146,7 +150,7 @@
private static final float MIN_CAMERA_DISTANCE_SQUARED = 12.25F;
@@ -153,7 +157,7 @@
++this.life;
if (this.life > 80 && !this.level().isClientSide) {
this.playSound(SoundEffects.ENDER_EYE_DEATH, 1.0F, 1.0F);
@@ -20,7 +20,7 @@
if (this.surviveAfterDeath) {
this.level().addFreshEntity(new EntityItem(this.level(), this.getX(), this.getY(), this.getZ(), this.getItem()));
} else {
@@ -167,7 +171,12 @@
@@ -174,7 +178,12 @@
@Override
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
if (nbttagcompound.contains("Item", 10)) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/EntityFireball.java
+++ b/net/minecraft/world/entity/projectile/EntityFireball.java
@@ -18,11 +18,17 @@
@@ -19,11 +19,17 @@
import net.minecraft.world.phys.MovingObjectPosition;
import net.minecraft.world.phys.Vec3D;
@@ -18,21 +18,21 @@
protected EntityFireball(EntityTypes<? extends EntityFireball> entitytypes, World world) {
super(entitytypes, world);
@@ -71,7 +77,7 @@
Entity entity = this.getOwner();
@@ -73,7 +79,7 @@
this.applyInertia();
if (!this.level().isClientSide && (entity != null && entity.isRemoved() || !this.level().hasChunkAt(this.blockPosition()))) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
} else {
super.tick();
if (this.shouldBurn()) {
@@ -81,7 +87,7 @@
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity, this.getClipType());
Vec3D vec3d;
@@ -93,7 +99,7 @@
}
if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) {
if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS && this.isAlive()) {
- this.hitTargetOrDeflectSelf(movingobjectposition);
+ this.preHitTargetOrDeflectSelf(movingobjectposition); // CraftBukkit - projectile hit event
}
this.checkInsideBlocks();
this.createParticleTrail();

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/EntityFireballFireball.java
+++ b/net/minecraft/world/entity/projectile/EntityFireballFireball.java
@@ -58,7 +58,12 @@
@@ -61,7 +61,12 @@
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.readAdditionalSaveData(nbttagcompound);
if (nbttagcompound.contains("Item", 10)) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/EntityFireworks.java
+++ b/net/minecraft/world/entity/projectile/EntityFireworks.java
@@ -32,6 +32,10 @@
@@ -33,6 +33,10 @@
import net.minecraft.world.phys.MovingObjectPositionEntity;
import net.minecraft.world.phys.Vec3D;
@@ -11,59 +11,60 @@
public class EntityFireworks extends IProjectile implements ItemSupplier {
public static final DataWatcherObject<ItemStack> DATA_ID_FIREWORKS_ITEM = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.ITEM_STACK);
@@ -148,7 +152,7 @@
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity);
@@ -152,7 +156,7 @@
}
if (!this.noPhysics) {
if (!this.noPhysics && this.isAlive() && movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) {
- this.hitTargetOrDeflectSelf(movingobjectposition);
+ this.preHitTargetOrDeflectSelf(movingobjectposition); // CraftBukkit - projectile hit event
this.hasImpulse = true;
}
@@ -163,7 +167,11 @@
@@ -172,7 +176,11 @@
if (world instanceof WorldServer) {
WorldServer worldserver = (WorldServer) world;
- this.explode(worldserver);
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) {
+ this.explode(worldserver);
+ }
+ // CraftBukkit end
}
}
if (!this.level().isClientSide && this.life > this.lifetime) {
- this.explode();
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) {
+ this.explode();
+ }
+ // CraftBukkit end
}
}
@@ -172,14 +180,18 @@
this.level().broadcastEntityEvent(this, (byte) 17);
@@ -182,7 +190,7 @@
worldserver.broadcastEntityEvent(this, (byte) 17);
this.gameEvent(GameEvent.EXPLODE, this.getOwner());
this.dealExplosionDamage();
this.dealExplosionDamage(worldserver);
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.EXPLODE); // CraftBukkit - add Bukkit remove cause
}
@Override
protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) {
super.onHitEntity(movingobjectpositionentity);
if (!this.level().isClientSide) {
- this.explode();
@@ -191,7 +199,11 @@
World world = this.level();
if (world instanceof WorldServer worldserver) {
- this.explode(worldserver);
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) {
+ this.explode();
+ this.explode(worldserver);
+ }
+ // CraftBukkit end
}
}
@@ -205,7 +217,11 @@
@@ -189,7 +201,11 @@
this.level().getBlockState(blockposition).entityInside(this.level(), blockposition, this);
if (!this.level().isClientSide() && this.hasExplosion()) {
- this.explode();
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) {
+ this.explode();
+ }
+ // CraftBukkit end
if (world instanceof WorldServer worldserver) {
if (this.hasExplosion()) {
- this.explode(worldserver);
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callFireworkExplodeEvent(this).isCancelled()) {
+ this.explode(worldserver);
+ }
+ // CraftBukkit end
}
}
super.onHitBlock(movingobjectpositionblock);

View File

@@ -33,7 +33,7 @@
private EntityFishingHook(EntityTypes<? extends EntityFishingHook> entitytypes, World world, int i, int j) {
super(entitytypes, world);
this.syncronizedRandom = RandomSource.create();
@@ -148,12 +167,12 @@
@@ -152,12 +171,12 @@
EntityHuman entityhuman = this.getPlayerOwner();
if (entityhuman == null) {
@@ -48,7 +48,7 @@
return;
}
} else {
@@ -254,7 +273,7 @@
@@ -259,7 +278,7 @@
if (!entityhuman.isRemoved() && entityhuman.isAlive() && (flag || flag1) && this.distanceToSqr((Entity) entityhuman) <= 1024.0D) {
return false;
} else {
@@ -57,7 +57,7 @@
return true;
}
}
@@ -262,7 +281,7 @@
@@ -267,7 +286,7 @@
private void checkCollision() {
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity);
@@ -66,7 +66,7 @@
}
@Override
@@ -295,11 +314,11 @@
@@ -300,11 +319,11 @@
int i = 1;
BlockPosition blockposition1 = blockposition.above();
@@ -80,7 +80,7 @@
--i;
}
@@ -309,6 +328,10 @@
@@ -314,6 +333,10 @@
this.timeUntilLured = 0;
this.timeUntilHooked = 0;
this.getEntityData().set(EntityFishingHook.DATA_BITING, false);
@@ -91,7 +91,7 @@
}
} else {
float f;
@@ -342,6 +365,13 @@
@@ -347,6 +370,13 @@
worldserver.sendParticles(Particles.FISHING, d0, d1, d2, 0, (double) (-f4), 0.01D, (double) f3, 1.0D);
}
} else {
@@ -105,7 +105,7 @@
this.playSound(SoundEffects.FISHING_BOBBER_SPLASH, 0.25F, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
double d3 = this.getY() + 0.5D;
@@ -374,12 +404,16 @@
@@ -379,12 +409,16 @@
}
if (this.timeUntilLured <= 0) {
@@ -126,7 +126,7 @@
}
}
@@ -447,6 +481,14 @@
@@ -452,6 +486,14 @@
int i = 0;
if (this.hookedIn != null) {
@@ -141,7 +141,7 @@
this.pullEntity(this.hookedIn);
CriterionTriggers.FISHING_ROD_HOOKED.trigger((EntityPlayer) entityhuman, itemstack, this, Collections.emptyList());
this.level().broadcastEntityEvent(this, (byte) 31);
@@ -462,6 +504,15 @@
@@ -467,6 +509,15 @@
while (iterator.hasNext()) {
ItemStack itemstack1 = (ItemStack) iterator.next();
EntityItem entityitem = new EntityItem(this.level(), this.getX(), this.getY(), this.getZ(), itemstack1);
@@ -157,7 +157,7 @@
double d0 = entityhuman.getX() - this.getX();
double d1 = entityhuman.getY() - this.getY();
double d2 = entityhuman.getZ() - this.getZ();
@@ -469,7 +520,11 @@
@@ -474,7 +525,11 @@
entityitem.setDeltaMovement(d0 * 0.1D, d1 * 0.1D + Math.sqrt(Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2)) * 0.08D, d2 * 0.1D);
this.level().addFreshEntity(entityitem);
@@ -170,7 +170,7 @@
if (itemstack1.is(TagsItem.FISHES)) {
entityhuman.awardStat(StatisticList.FISH_CAUGHT, 1);
}
@@ -479,10 +534,27 @@
@@ -484,10 +539,27 @@
}
if (this.onGround()) {
@@ -199,7 +199,7 @@
return i;
} else {
return 0;
@@ -515,8 +587,15 @@
@@ -520,8 +592,15 @@
@Override
public void remove(Entity.RemovalReason entity_removalreason) {
@@ -216,3 +216,12 @@
}
@Override
@@ -575,7 +654,7 @@
int i = packetplayoutspawnentity.getData();
EntityFishingHook.LOGGER.error("Failed to recreate fishing hook on client. {} (id: {}) is not a valid owner.", this.level().getEntity(i), i);
- this.discard();
+ this.discard(null); // CraftBukkit - add Bukkit remove cause
}
}

View File

@@ -15,19 +15,19 @@
public EntityLargeFireball(EntityTypes<? extends EntityLargeFireball> entitytypes, World world) {
super(entitytypes, world);
+ isIncendiary = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit
+ isIncendiary = (world instanceof WorldServer worldserver) && worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit
}
public EntityLargeFireball(World world, EntityLiving entityliving, Vec3D vec3d, int i) {
super(EntityTypes.FIREBALL, entityliving, vec3d, world);
this.explosionPower = i;
+ isIncendiary = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit
+ isIncendiary = (world instanceof WorldServer worldserver) && worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING); // CraftBukkit
}
@Override
@@ -32,8 +39,16 @@
if (!this.level().isClientSide) {
boolean flag = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING);
@@ -34,8 +41,16 @@
if (world instanceof WorldServer worldserver) {
boolean flag = worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING);
- this.level().explode(this, this.getX(), this.getY(), this.getZ(), (float) this.explosionPower, flag, World.a.MOB);
- this.discard();
@@ -44,7 +44,7 @@
}
}
@@ -63,7 +78,8 @@
@@ -65,7 +80,8 @@
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
super.readAdditionalSaveData(nbttagcompound);
if (nbttagcompound.contains("ExplosionPower", 99)) {

View File

@@ -32,7 +32,7 @@
} else {
this.setDeltaMovement(vec3d.scale(0.9900000095367432D));
this.applyGravity();
@@ -86,7 +90,7 @@
@@ -83,7 +87,7 @@
protected void onHitBlock(MovingObjectPositionBlock movingobjectpositionblock) {
super.onHitBlock(movingobjectpositionblock);
if (!this.level().isClientSide) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/EntityPotion.java
+++ b/net/minecraft/world/entity/projectile/EntityPotion.java
@@ -34,6 +34,18 @@
@@ -35,6 +35,18 @@
import net.minecraft.world.phys.MovingObjectPositionBlock;
import net.minecraft.world.phys.MovingObjectPositionEntity;
@@ -16,45 +16,45 @@
+import org.bukkit.event.entity.EntityRemoveEvent;
+// CraftBukkit end
+
public class EntityPotion extends EntityProjectileThrowable implements ItemSupplier {
public class EntityPotion extends EntityProjectileThrowable {
public static final double SPLASH_RANGE = 4.0D;
@@ -98,18 +110,18 @@
@@ -101,18 +113,18 @@
if (potioncontents.is(Potions.WATER)) {
this.applyWater();
this.applyWater(worldserver);
- } else if (potioncontents.hasEffects()) {
+ } else if (true || potioncontents.hasEffects()) { // CraftBukkit - Call event even if no effects to apply
if (this.isLingering()) {
- this.makeAreaOfEffectCloud(potioncontents);
+ this.makeAreaOfEffectCloud(potioncontents, movingobjectposition); // CraftBukkit - Pass MovingObjectPosition
} else {
- this.applySplash(potioncontents.getAllEffects(), movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY ? ((MovingObjectPositionEntity) movingobjectposition).getEntity() : null);
+ this.applySplash(potioncontents.getAllEffects(), movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY ? ((MovingObjectPositionEntity) movingobjectposition).getEntity() : null, movingobjectposition); // CraftBukkit - Pass MovingObjectPosition
- this.applySplash(worldserver, potioncontents.getAllEffects(), movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY ? ((MovingObjectPositionEntity) movingobjectposition).getEntity() : null);
+ this.applySplash(worldserver, potioncontents.getAllEffects(), movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY ? ((MovingObjectPositionEntity) movingobjectposition).getEntity() : null, movingobjectposition); // CraftBukkit - Pass MovingObjectPosition
}
}
int i = potioncontents.potion().isPresent() && ((PotionRegistry) ((Holder) potioncontents.potion().get()).value()).hasInstantEffects() ? 2007 : 2002;
this.level().levelEvent(i, this.blockPosition(), potioncontents.getColor());
worldserver.levelEvent(i, this.blockPosition(), potioncontents.getColor());
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause
}
}
@@ -144,9 +156,10 @@
@@ -147,9 +159,10 @@
}
- private void applySplash(Iterable<MobEffect> iterable, @Nullable Entity entity) {
+ private void applySplash(Iterable<MobEffect> iterable, @Nullable Entity entity, MovingObjectPosition position) { // CraftBukkit - Pass MovingObjectPosition
- private void applySplash(WorldServer worldserver, Iterable<MobEffect> iterable, @Nullable Entity entity) {
+ private void applySplash(WorldServer worldserver, Iterable<MobEffect> iterable, @Nullable Entity entity, MovingObjectPosition position) { // CraftBukkit - Pass MovingObjectPosition
AxisAlignedBB axisalignedbb = this.getBoundingBox().inflate(4.0D, 2.0D, 4.0D);
List<EntityLiving> list = this.level().getEntitiesOfClass(EntityLiving.class, axisalignedbb);
List<EntityLiving> list = worldserver.getEntitiesOfClass(EntityLiving.class, axisalignedbb);
+ Map<LivingEntity, Double> affected = new HashMap<LivingEntity, Double>(); // CraftBukkit
if (!list.isEmpty()) {
Entity entity1 = this.getEffectSource();
@@ -167,24 +180,50 @@
@@ -170,24 +183,50 @@
d1 = 1.0D - Math.sqrt(d0) / 4.0D;
}
@@ -78,7 +78,7 @@
+ }
- if (((MobEffectList) holder.value()).isInstantenous()) {
- ((MobEffectList) holder.value()).applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect.getAmplifier(), d1);
- ((MobEffectList) holder.value()).applyInstantenousEffect(worldserver, this, this.getOwner(), entityliving, mobeffect.getAmplifier(), d1);
- } else {
- int i = mobeffect.mapDuration((j) -> {
- return (int) (d1 * (double) j + 0.5D);
@@ -108,7 +108,7 @@
+ // CraftBukkit end
+
+ if (((MobEffectList) holder.value()).isInstantenous()) {
+ ((MobEffectList) holder.value()).applyInstantenousEffect(this, this.getOwner(), entityliving, mobeffect.getAmplifier(), d1);
+ ((MobEffectList) holder.value()).applyInstantenousEffect(worldserver, this, this.getOwner(), entityliving, mobeffect.getAmplifier(), d1);
+ } else {
+ int i = mobeffect.mapDuration((j) -> {
+ return (int) (d1 * (double) j + 0.5D);
@@ -120,7 +120,7 @@
}
}
}
@@ -193,7 +232,7 @@
@@ -196,7 +235,7 @@
}
@@ -129,7 +129,7 @@
EntityAreaEffectCloud entityareaeffectcloud = new EntityAreaEffectCloud(this.level(), this.getX(), this.getY(), this.getZ());
Entity entity = this.getOwner();
@@ -206,7 +245,14 @@
@@ -209,7 +248,14 @@
entityareaeffectcloud.setWaitTime(10);
entityareaeffectcloud.setRadiusPerTick(-entityareaeffectcloud.getRadius() / (float) entityareaeffectcloud.getDuration());
entityareaeffectcloud.setPotionContents(potioncontents);
@@ -145,7 +145,7 @@
}
public boolean isLingering() {
@@ -217,13 +263,25 @@
@@ -220,13 +266,25 @@
IBlockData iblockdata = this.level().getBlockState(blockposition);
if (iblockdata.is(TagsBlock.FIRE)) {

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/entity/projectile/EntityProjectile.java
+++ b/net/minecraft/world/entity/projectile/EntityProjectile.java
@@ -46,7 +46,7 @@
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity);
if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) {
@@ -63,7 +63,7 @@
this.applyEffectsFromBlocks();
super.tick();
if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS && this.isAlive()) {
- this.hitTargetOrDeflectSelf(movingobjectposition);
+ this.preHitTargetOrDeflectSelf(movingobjectposition); // CraftBukkit - projectile hit event
}
this.checkInsideBlocks();
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/EntityProjectileThrowable.java
+++ b/net/minecraft/world/entity/projectile/EntityProjectileThrowable.java
@@ -32,6 +32,12 @@
@@ -34,6 +34,12 @@
protected abstract Item getDefaultItem();

View File

@@ -42,16 +42,16 @@
}
}
@@ -230,7 +247,7 @@
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity);
if (movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) {
- this.hitTargetOrDeflectSelf(movingobjectposition);
+ this.preHitTargetOrDeflectSelf(movingobjectposition); // CraftBukkit - projectile hit event
}
@@ -239,7 +256,7 @@
}
@@ -307,7 +324,7 @@
if (movingobjectposition != null && this.isAlive() && movingobjectposition.getType() != MovingObjectPosition.EnumMovingObjectType.MISS) {
- this.hitTargetOrDeflectSelf(movingobjectposition);
+ this.preHitTargetOrDeflectSelf(movingobjectposition); // CraftBukkit - projectile hit event
}
ProjectileHelper.rotateTowardsMovement(this, 0.5F);
@@ -312,7 +329,7 @@
if (entity instanceof EntityLiving) {
EntityLiving entityliving1 = (EntityLiving) entity;
@@ -60,7 +60,7 @@
}
}
@@ -321,14 +338,20 @@
@@ -326,14 +343,20 @@
}
private void destroy() {
@@ -83,20 +83,19 @@
}
@Override
@@ -338,10 +361,15 @@
@@ -348,9 +371,14 @@
@Override
public boolean hurt(DamageSource damagesource, float f) {
public boolean hurtServer(WorldServer worldserver, DamageSource damagesource, float f) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, damagesource, f, false)) {
+ return false;
+ }
+ // CraftBukkit end
if (!this.level().isClientSide) {
this.playSound(SoundEffects.SHULKER_BULLET_HURT, 1.0F, 1.0F);
((WorldServer) this.level()).sendParticles(Particles.CRIT, this.getX(), this.getY(), this.getZ(), 15, 0.2D, 0.2D, 0.2D, 0.0D);
- this.destroy();
+ this.destroy(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
}
this.playSound(SoundEffects.SHULKER_BULLET_HURT, 1.0F, 1.0F);
worldserver.sendParticles(Particles.CRIT, this.getX(), this.getY(), this.getZ(), 15, 0.2D, 0.2D, 0.2D, 0.0D);
- this.destroy();
+ this.destroy(EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
return true;
}

View File

@@ -18,7 +18,7 @@
super(EntityTypes.SMALL_FIREBALL, entityliving, vec3d, world);
+ // CraftBukkit start
+ if (this.getOwner() != null && this.getOwner() instanceof EntityInsentient) {
+ isIncendiary = this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING);
+ isIncendiary = (world instanceof WorldServer worldserver) && worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING);
+ }
+ // CraftBukkit end
}
@@ -39,12 +39,12 @@
+ // CraftBukkit end
DamageSource damagesource = this.damageSources().fireball(this, entity1);
if (!entity.hurt(damagesource, 5.0F)) {
@@ -58,10 +75,10 @@
if (!this.level().isClientSide) {
if (!entity.hurtServer(worldserver, damagesource, 5.0F)) {
@@ -60,10 +77,10 @@
if (world instanceof WorldServer worldserver) {
Entity entity = this.getOwner();
- if (!(entity instanceof EntityInsentient) || this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
- if (!(entity instanceof EntityInsentient) || worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
+ if (isIncendiary) { // CraftBukkit
BlockPosition blockposition = movingobjectpositionblock.getBlockPos().relative(movingobjectpositionblock.getDirection());
@@ -53,7 +53,7 @@
this.level().setBlockAndUpdate(blockposition, BlockFireAbstract.getState(this.level(), blockposition));
}
}
@@ -73,7 +90,7 @@
@@ -75,7 +92,7 @@
protected void onHit(MovingObjectPosition movingobjectposition) {
super.onHit(movingobjectposition);
if (!this.level().isClientSide) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/EntityThrownExpBottle.java
+++ b/net/minecraft/world/entity/projectile/EntityThrownExpBottle.java
@@ -11,6 +11,10 @@
@@ -12,6 +12,10 @@
import net.minecraft.world.level.World;
import net.minecraft.world.phys.MovingObjectPosition;
@@ -11,7 +11,7 @@
public class EntityThrownExpBottle extends EntityProjectileThrowable {
public EntityThrownExpBottle(EntityTypes<? extends EntityThrownExpBottle> entitytypes, World world) {
@@ -39,11 +43,20 @@
@@ -40,11 +44,20 @@
protected void onHit(MovingObjectPosition movingobjectposition) {
super.onHit(movingobjectposition);
if (this.level() instanceof WorldServer) {

View File

@@ -11,21 +11,25 @@
public class EntityThrownTrident extends EntityArrow {
private static final DataWatcherObject<Byte> ID_LOYALTY = DataWatcher.defineId(EntityThrownTrident.class, DataWatcherRegistry.BYTE);
@@ -69,7 +73,7 @@
this.spawnAtLocation(this.getPickupItem(), 0.1F);
@@ -75,10 +79,10 @@
}
}
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DROP); // CraftBukkit - add Bukkit remove cause
} else {
this.setNoPhysics(true);
Vec3D vec3d = entity.getEyePosition().subtract(this.position());
@@ -129,7 +133,7 @@
if (!(entity instanceof EntityHuman) && this.position().distanceTo(entity.getEyePosition()) < (double) entity.getBbWidth() + 1.0D) {
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
return;
}
@@ -136,7 +140,7 @@
world = this.level();
if (world instanceof WorldServer) {
- worldserver = (WorldServer) world;
+ WorldServer worldserver = (WorldServer) world; // CraftBukkit - decompile error
EnchantmentManager.doPostAttackEffectsWithItemSource(worldserver, entity, damagesource, this.getWeaponItem());
}
EnchantmentManager.doPostAttackEffectsWithItemSourceOnBreak(worldserver, entity, damagesource, this.getWeaponItem(), (item) -> {
this.kill(worldserver);
});

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/IProjectile.java
+++ b/net/minecraft/world/entity/projectile/IProjectile.java
@@ -30,6 +30,10 @@
@@ -36,6 +36,10 @@
import net.minecraft.world.phys.MovingObjectPositionEntity;
import net.minecraft.world.phys.Vec3D;
@@ -11,7 +11,7 @@
public abstract class IProjectile extends Entity implements TraceableEntity {
@Nullable
@@ -41,6 +45,10 @@
@@ -47,6 +51,10 @@
@Nullable
private Entity lastDeflectedBy;
@@ -22,7 +22,7 @@
IProjectile(EntityTypes<? extends IProjectile> entitytypes, World world) {
super(entitytypes, world);
}
@@ -50,6 +58,7 @@
@@ -56,6 +64,7 @@
this.ownerUUID = entity.getUUID();
this.cachedOwner = entity;
}
@@ -30,8 +30,17 @@
}
@@ -177,6 +186,17 @@
this.setDeltaMovement(this.getDeltaMovement().add(vec3d.x, entity.onGround() ? 0.0D : vec3d.y, vec3d.z));
@@ -213,7 +222,7 @@
public static <T extends IProjectile> T spawnProjectile(T t0, WorldServer worldserver, ItemStack itemstack, Consumer<T> consumer) {
consumer.accept(t0);
- worldserver.addFreshEntity(t0);
+ if (worldserver.addFreshEntity(t0)) // CraftBukkit
t0.applyOnProjectileSpawned(worldserver, itemstack);
return t0;
}
@@ -232,6 +241,17 @@
}
+ // CraftBukkit start - call projectile hit event
@@ -48,7 +57,7 @@
protected ProjectileDeflection hitTargetOrDeflectSelf(MovingObjectPosition movingobjectposition) {
if (movingobjectposition.getType() == MovingObjectPosition.EnumMovingObjectType.ENTITY) {
MovingObjectPositionEntity movingobjectpositionentity = (MovingObjectPositionEntity) movingobjectposition;
@@ -237,6 +257,11 @@
@@ -309,6 +329,11 @@
protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) {}
protected void onHitBlock(MovingObjectPositionBlock movingobjectpositionblock) {

View File

@@ -10,8 +10,8 @@
+
public abstract class AbstractWindCharge extends EntityFireball implements ItemSupplier {
public static final ExplosionDamageCalculator EXPLOSION_DAMAGE_CALCULATOR = new SimpleExplosionDamageCalculator(true, false, Optional.empty(), BuiltInRegistries.BLOCK.getTag(TagsBlock.BLOCKS_WIND_CHARGE_EXPLOSIONS).map(Function.identity()));
@@ -113,7 +117,7 @@
public static final ExplosionDamageCalculator EXPLOSION_DAMAGE_CALCULATOR = new SimpleExplosionDamageCalculator(true, false, Optional.empty(), BuiltInRegistries.BLOCK.get(TagsBlock.BLOCKS_WIND_CHARGE_EXPLOSIONS).map(Function.identity()));
@@ -111,7 +115,7 @@
Vec3D vec3d1 = movingobjectpositionblock.getLocation().add(vec3d);
this.explode(vec3d1);
@@ -20,7 +20,7 @@
}
}
@@ -122,7 +126,7 @@
@@ -120,7 +124,7 @@
protected void onHit(MovingObjectPosition movingobjectposition) {
super.onHit(movingobjectposition);
if (!this.level().isClientSide) {
@@ -29,9 +29,9 @@
}
}
@@ -157,7 +161,7 @@
@@ -155,7 +159,7 @@
public void tick() {
if (!this.level().isClientSide && this.getBlockY() > this.level().getMaxBuildHeight() + 30) {
if (!this.level().isClientSide && this.getBlockY() > this.level().getMaxY() + 30) {
this.explode(this.position());
- this.discard();
+ this.discard(EntityRemoveEvent.Cause.OUT_OF_WORLD); // CraftBukkit - add Bukkit remove cause