From ec57b99bf5f9eb178ac229d2ec2fe6163f7a347a Mon Sep 17 00:00:00 2001 From: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com> Date: Sun, 15 Dec 2024 23:07:15 +0100 Subject: [PATCH] readd removal cause for thrown eggs --- .../world/entity/animal/Bee.java.patch | 2 +- .../boss/enderdragon/EnderDragon.java.patch | 19 +++++---- .../entity/boss/wither/WitherBoss.java.patch | 8 ++-- .../decoration/BlockAttachedEntity.java.patch | 9 ++--- .../entity/item/FallingBlockEntity.java.patch | 2 +- .../world/entity/item/ItemEntity.java.patch | 6 +-- .../monster/AbstractSkeleton.java.patch | 25 +++++++++--- .../world/entity/monster/Slime.java.patch | 40 ++++++++++++------- .../world/entity/monster/Spider.java.patch | 2 +- .../world/entity/monster/Witch.java.patch | 12 +++--- .../world/entity/monster/Zombie.java.patch | 15 ++----- .../entity/monster/ZombifiedPiglin.java.patch | 4 +- .../entity/monster/piglin/PiglinAi.java.patch | 2 +- .../entity/npc/AbstractVillager.java.patch | 2 +- .../world/entity/npc/Villager.java.patch | 2 +- .../npc/WanderingTraderSpawner.java.patch | 4 +- .../projectile/AbstractArrow.java.patch | 2 +- .../entity/projectile/ThrownEgg.java.patch | 9 ++++- .../minecraft/world/item/ItemUtils.java.patch | 4 +- .../TeleportRandomlyConsumeEffect.java.patch | 2 +- .../entity/BrewingStandBlockEntity.java.patch | 3 +- .../bukkit/craftbukkit/entity/CraftItem.java | 4 +- 22 files changed, 96 insertions(+), 82 deletions(-) diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch index 3891fbabb2..d8e007e816 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/Bee.java.patch @@ -102,7 +102,7 @@ + if (!super.hurtServer(level, damageSource, amount)) return false; // CraftBukkit - Only stop pollinating if entity was damaged this.beePollinateGoal.stopPollinating(); - return super.hurtServer(level, damageSource, amount); -+ return true; // CraftBukkit - Only stop pollinating if entity was damaged ++ return true; // CraftBukkit - Only stop pollinating if entity was damaged } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch index beddc1e044..48b66a876e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/enderdragon/EnderDragon.java.patch @@ -183,7 +183,7 @@ if (this.level() instanceof ServerLevel serverLevel) { - if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { - ExperienceOrb.award(serverLevel, this.position(), Mth.floor(i * 0.08F)); -+ if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp ++ if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0) { // CraftBukkit - SPIGOT-2420: Already checked for the game rule when calculating the xp + ExperienceOrb.award(serverLevel, this.position(), Mth.floor(i * 0.08F), org.bukkit.entity.ExperienceOrb.SpawnReason.ENTITY_DEATH, this.lastHurtByPlayer, this); // Paper } @@ -195,16 +195,16 @@ + for (net.minecraft.server.level.ServerPlayer player : serverLevel.getPlayersForGlobalSoundGamerule()) { // Paper - respect global sound events gamerule + double deltaX = this.getX() - player.getX(); + double deltaZ = this.getZ() - player.getZ(); -+ double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; ++ double distanceSquared = Mth.square(deltaX) + Mth.square(deltaZ); + final double soundRadiusSquared = serverLevel.getGlobalSoundRangeSquared(config -> config.dragonDeathSoundRadius); // Paper - respect global sound events gamerule + if (!serverLevel.getGameRules().getBoolean(GameRules.RULE_GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared) continue; // Paper - respect global sound events gamerule -+ if (distanceSquared > viewDistance * viewDistance) { ++ if (distanceSquared > Mth.square(viewDistance)) { + double deltaLength = Math.sqrt(distanceSquared); + double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; + double relativeZ = player.getZ() + (deltaZ / deltaLength) * viewDistance; -+ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1028, new BlockPos((int) relativeX, (int) this.getY(), (int) relativeZ), 0, true)); ++ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(net.minecraft.world.level.block.LevelEvent.SOUND_DRAGON_DEATH, new BlockPos((int) relativeX, (int) this.getY(), (int) relativeZ), 0, true)); + } else { -+ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(1028, new BlockPos((int) this.getX(), (int) this.getY(), (int) this.getZ()), 0, true)); ++ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(net.minecraft.world.level.block.LevelEvent.SOUND_DRAGON_DEATH, new BlockPos((int) this.getX(), (int) this.getY(), (int) this.getZ()), 0, true)); + } + } + // CraftBukkit end @@ -260,7 +260,7 @@ float max = Math.max((float)Math.sqrt(heightmapPos.distToCenterSqr(this.position())) / 4.0F, 1.0F); float f = 6.0F / max; float xRot = this.getXRot(); -@@ -883,4 +_,20 @@ +@@ -883,4 +_,19 @@ protected float sanitizeScale(float scale) { return 1.0F; } @@ -270,14 +270,13 @@ + public int getExpReward(ServerLevel worldserver, Entity entity) { + // CraftBukkit - Moved from #tickDeath method + boolean flag = worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT); -+ short short0 = 500; ++ int i = 500; + + if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) { -+ short0 = 12000; ++ i = 12000; + } + -+ return flag ? short0 : 0; ++ return flag ? i : 0; + } + // CraftBukkit end -+ } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch index b4eaea2841..9d6f177cef 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/boss/wither/WitherBoss.java.patch @@ -34,16 +34,16 @@ + for (ServerPlayer player : level.getPlayersForGlobalSoundGamerule()) { // Paper - respect global sound events gamerule + double deltaX = this.getX() - player.getX(); + double deltaZ = this.getZ() - player.getZ(); -+ double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; ++ double distanceSquared = Mth.square(deltaX) + Mth.square(deltaZ); + final double soundRadiusSquared = level.getGlobalSoundRangeSquared(config -> config.witherSpawnSoundRadius); // Paper - respect global sound events gamerule + if (!level.getGameRules().getBoolean(GameRules.RULE_GLOBAL_SOUND_EVENTS) && distanceSquared > soundRadiusSquared) continue; // Spigot // Paper - respect global sound events gamerule -+ if (distanceSquared > viewDistance * viewDistance) { ++ if (distanceSquared > Mth.square(viewDistance)) { + double deltaLength = Math.sqrt(distanceSquared); + double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; + double relativeZ = player.getZ() + (deltaZ / deltaLength) * viewDistance; -+ player.connection.send(new ClientboundLevelEventPacket(1023, new BlockPos((int) relativeX, (int) this.getY(), (int) relativeZ), 0, true)); ++ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(net.minecraft.world.level.block.LevelEvent.SOUND_WITHER_BOSS_SPAWN, new BlockPos((int) relativeX, (int) this.getY(), (int) relativeZ), 0, true)); + } else { -+ player.connection.send(new ClientboundLevelEventPacket(1023, this.blockPosition(), 0, true)); ++ player.connection.send(new net.minecraft.network.protocol.game.ClientboundLevelEventPacket(net.minecraft.world.level.block.LevelEvent.SOUND_WITHER_BOSS_SPAWN, this.blockPosition(), 0, true)); + } + } + // CraftBukkit end diff --git a/paper-server/patches/sources/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch index a5583937ae..55a016fcd9 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/decoration/BlockAttachedEntity.java.patch @@ -9,7 +9,7 @@ protected BlockPos pos; protected BlockAttachedEntity(EntityType entityType, Level level) { -@@ -38,10 +_,29 @@ +@@ -38,10 +_,26 @@ public void tick() { if (this.level() instanceof ServerLevel serverLevel) { this.checkBelowWorld(); @@ -18,12 +18,9 @@ this.checkInterval = 0; if (!this.isRemoved() && !this.survives()) { - this.discard(); -+ // this.discard(); + // CraftBukkit start - fire break events -+ net.minecraft.world.level.block.state.BlockState material = this.level().getBlockState(this.blockPosition()); -+ org.bukkit.event.hanging.HangingBreakEvent.RemoveCause cause; -+ -+ if (!material.isAir()) { ++ final org.bukkit.event.hanging.HangingBreakEvent.RemoveCause cause; ++ if (!this.level().getBlockState(this.blockPosition()).isAir()) { + // TODO: This feels insufficient to catch 100% of suffocation cases + cause = org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.OBSTRUCTION; + } else { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch index 32fc663482..5b8f2129c4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/item/FallingBlockEntity.java.patch @@ -128,7 +128,7 @@ } compound.putBoolean("CancelDrop", this.cancelDrop); -+ if (!autoExpire) {compound.putBoolean("Paper.AutoExpire", false);} // Paper - Expand FallingBlock API ++ if (!this.autoExpire) compound.putBoolean("Paper.AutoExpire", false); // Paper - Expand FallingBlock API } @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch index 5db64d6e7d..7e9f5a0f27 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/item/ItemEntity.java.patch @@ -51,7 +51,7 @@ f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F; } -@@ -184,11 +_,42 @@ +@@ -184,11 +_,40 @@ } } @@ -75,14 +75,12 @@ + // Spigot start - copied from above + @Override + public void inactiveTick() { -+ // Paper start - remove anti tick skipping measures / wall time - copied from above + if (this.pickupDelay > 0 && this.pickupDelay != 32767) { + --this.pickupDelay; + } + if (this.age != -32768) { + ++this.age; + } -+ // Paper end - remove anti tick skipping measures / wall time - copied from above + + if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper - Alternative item-despawn-rate + // CraftBukkit start - fire ItemDespawnEvent @@ -202,7 +200,7 @@ if (this.getItem().isEmpty()) { - this.discard(); -+ this.discard(null); // CraftBukkit - add Bukkit remove cause ++ this.discard(null); // CraftBukkit - add Bukkit remove cause } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch index 35bee18fdb..50e3f4e66b 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/AbstractSkeleton.java.patch @@ -1,17 +1,30 @@ --- a/net/minecraft/world/entity/monster/AbstractSkeleton.java +++ b/net/minecraft/world/entity/monster/AbstractSkeleton.java -@@ -64,6 +_,11 @@ +@@ -64,6 +_,7 @@ AbstractSkeleton.this.setAggressive(true); } }; -+ // Paper start - shouldBurnInDay API -+ private boolean shouldBurnInDay = true; -+ public boolean shouldBurnInDay() { return shouldBurnInDay; } -+ public void setShouldBurnInDay(boolean shouldBurnInDay) { this.shouldBurnInDay = shouldBurnInDay; } -+ // Paper end - shouldBurnInDay API ++ private boolean shouldBurnInDay = true; // Paper - shouldBurnInDay API protected AbstractSkeleton(EntityType entityType, Level level) { super(entityType, level); +@@ -88,6 +_,16 @@ + return Monster.createMonsterAttributes().add(Attributes.MOVEMENT_SPEED, 0.25); + } + ++ // Paper start - shouldBurnInDay API ++ public boolean shouldBurnInDay() { ++ return this.shouldBurnInDay; ++ } ++ ++ public void setShouldBurnInDay(boolean shouldBurnInDay) { ++ this.shouldBurnInDay = shouldBurnInDay; ++ } ++ // Paper end - shouldBurnInDay API ++ + @Override + protected void playStepSound(BlockPos pos, BlockState block) { + this.playSound(this.getStepSound(), 0.15F, 1.0F); @@ -97,7 +_,7 @@ @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch index 2d78bee973..fc7af2dd2c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Slime.java.patch @@ -1,5 +1,13 @@ --- a/net/minecraft/world/entity/monster/Slime.java +++ b/net/minecraft/world/entity/monster/Slime.java +@@ -56,6 +_,7 @@ + public float squish; + public float oSquish; + private boolean wasOnGround; ++ private boolean canWander = true; // Paper - Slime pathfinder events + + public Slime(EntityType entityType, Level level) { + super(entityType, level); @@ -110,6 +_,7 @@ super.addAdditionalSaveData(compound); compound.putInt("Size", this.getSize() - 1); @@ -114,6 +122,23 @@ return checkMobSpawnRules(entityType, level, spawnReason, pos, random); } } +@@ -355,6 +_,16 @@ + return super.getDefaultDimensions(pose).scale(this.getSize()); + } + ++ // Paper start - Slime pathfinder events ++ public boolean canWander() { ++ return this.canWander; ++ } ++ ++ public void setWander(boolean canWander) { ++ this.canWander = canWander; ++ } ++ // Paper end - Slime pathfinder events ++ + static class SlimeAttackGoal extends Goal { + private final Slime slime; + private int growTiredTimer; @@ -367,7 +_,16 @@ @Override public boolean canUse() { @@ -202,18 +227,3 @@ } if (this.slime.getMoveControl() instanceof Slime.SlimeMoveControl slimeMoveControl) { -@@ -536,4 +_,14 @@ - } - } - } -+ // Paper start - Slime pathfinder events -+ private boolean canWander = true; -+ public boolean canWander() { -+ return canWander; -+ } -+ -+ public void setWander(boolean canWander) { -+ this.canWander = canWander; -+ } -+ // Paper end - Slime pathfinder events - } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch index 8bf70bc126..cbaaaef4ef 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Spider.java.patch @@ -14,7 +14,7 @@ @Override public boolean canBeAffected(MobEffectInstance potioneffect) { - return !potioneffect.is(MobEffects.POISON) && super.canBeAffected(potioneffect); -+ return potioneffect.is(MobEffects.POISON) && this.level().paperConfig().entities.mobEffects.spidersImmuneToPoisonEffect ? false : super.canBeAffected(potioneffect); // Paper - Add config for mobs immune to default effects ++ return (!potioneffect.is(MobEffects.POISON) || !this.level().paperConfig().entities.mobEffects.spidersImmuneToPoisonEffect) && super.canBeAffected(potioneffect); // Paper - Add config for mobs immune to default effects } public boolean isClimbing() { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch index e1dbaaaa93..d7a8e9a59e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Witch.java.patch @@ -6,7 +6,7 @@ PotionContents potionContents = mainHandItem.get(DataComponents.POTION_CONTENTS); + // Paper start - WitchConsumePotionEvent + if (mainHandItem.is(Items.POTION)) { -+ com.destroystokyo.paper.event.entity.WitchConsumePotionEvent event = new com.destroystokyo.paper.event.entity.WitchConsumePotionEvent((org.bukkit.entity.Witch) this.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); ++ com.destroystokyo.paper.event.entity.WitchConsumePotionEvent event = new com.destroystokyo.paper.event.entity.WitchConsumePotionEvent((org.bukkit.entity.Witch) this.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(mainHandItem)); + potionContents = event.callEvent() ? org.bukkit.craftbukkit.inventory.CraftItemStack.unwrap(event.getPotion()).get(DataComponents.POTION_CONTENTS) : null; + } + // Paper end - WitchConsumePotionEvent @@ -55,13 +55,13 @@ + this.usingTime = this.getMainHandItem().getUseDuration(this); + this.setUsingItem(true); + if (!this.isSilent()) { -+ this.level().playSound((Player) null, this.getX(), this.getY(), this.getZ(), SoundEvents.WITCH_DRINK, this.getSoundSource(), 1.0F, 0.8F + this.random.nextFloat() * 0.4F); ++ this.level().playSound(null, this.getX(), this.getY(), this.getZ(), SoundEvents.WITCH_DRINK, this.getSoundSource(), 1.0F, 0.8F + this.random.nextFloat() * 0.4F); + } + -+ AttributeInstance attributemodifiable = this.getAttribute(Attributes.MOVEMENT_SPEED); ++ AttributeInstance attribute = this.getAttribute(Attributes.MOVEMENT_SPEED); + -+ attributemodifiable.removeModifier(Witch.SPEED_MODIFIER_DRINKING_ID); -+ attributemodifiable.addTransientModifier(Witch.SPEED_MODIFIER_DRINKING); ++ attribute.removeModifier(Witch.SPEED_MODIFIER_DRINKING_ID); ++ attribute.addTransientModifier(Witch.SPEED_MODIFIER_DRINKING); + } + // Paper end + @@ -73,7 +73,7 @@ if (this.level() instanceof ServerLevel serverLevel) { ItemStack itemStack = PotionContents.createItemStack(Items.SPLASH_POTION, holder); + // Paper start - WitchThrowPotionEvent -+ com.destroystokyo.paper.event.entity.WitchThrowPotionEvent event = new com.destroystokyo.paper.event.entity.WitchThrowPotionEvent((org.bukkit.entity.Witch) this.getBukkitEntity(), (org.bukkit.entity.LivingEntity) target.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemstack)); ++ com.destroystokyo.paper.event.entity.WitchThrowPotionEvent event = new com.destroystokyo.paper.event.entity.WitchThrowPotionEvent((org.bukkit.entity.Witch) this.getBukkitEntity(), (org.bukkit.entity.LivingEntity) target.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack)); + if (!event.callEvent()) { + return; + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch index 1b2d06c538..b70be66183 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Zombie.java.patch @@ -11,7 +11,7 @@ private static final ResourceLocation REINFORCEMENT_CALLER_CHARGE_ID = ResourceLocation.withDefaultNamespace("reinforcement_caller_charge"); private static final AttributeModifier ZOMBIE_REINFORCEMENT_CALLEE_CHARGE = new AttributeModifier( ResourceLocation.withDefaultNamespace("reinforcement_callee_charge"), -0.05F, AttributeModifier.Operation.ADD_VALUE -@@ -87,13 +_,16 @@ +@@ -87,13 +_,15 @@ private static final EntityDimensions BABY_DIMENSIONS = EntityType.ZOMBIE.getDimensions().scale(0.5F).withEyeHeight(0.93F); private static final float BREAK_DOOR_CHANCE = 0.1F; public static final Predicate DOOR_BREAKING_PREDICATE = difficulty -> difficulty == Difficulty.HARD; @@ -20,7 +20,6 @@ private boolean canBreakDoors; private int inWaterTime; public int conversionTime; -+ // private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field // Paper - remove anti tick skipping measures / wall time + private boolean shouldBurnInDay = true; // Paper - Add more Zombie API public Zombie(EntityType entityType, Level level) { @@ -77,14 +76,6 @@ } } } -@@ -221,6 +_,7 @@ - } - - super.tick(); -+ // this.lastTick = MinecraftServer.currentTick; // CraftBukkit // Paper - remove anti tick skipping measures / wall time - } - - @Override @@ -251,7 +_,14 @@ super.aiStep(); } @@ -111,7 +102,7 @@ - zombie -> zombie.handleAttributes(zombie.level().getCurrentDifficultyAt(zombie.blockPosition()).getSpecialMultiplier()) - ); + // CraftBukkit start -+ zombie -> {zombie.handleAttributes(zombie.level().getCurrentDifficultyAt(zombie.blockPosition()).getSpecialMultiplier());}, ++ zombie -> { zombie.handleAttributes(zombie.level().getCurrentDifficultyAt(zombie.blockPosition()).getSpecialMultiplier()); }, + org.bukkit.event.entity.EntityTransformEvent.TransformReason.DROWNED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DROWNED); + if (converted == null) { + ((org.bukkit.entity.Zombie) this.getBukkitEntity()).setConversionTime(-1); // CraftBukkit - SPIGOT-5208: End conversion to stop event spam @@ -214,7 +205,7 @@ public boolean killedEntity(ServerLevel level, LivingEntity entity) { boolean flag = super.killedEntity(level, entity); - if ((level.getDifficulty() == Difficulty.NORMAL || level.getDifficulty() == Difficulty.HARD) && entity instanceof Villager villager) { -+ final double fallbackChance = level.getDifficulty() == Difficulty.HARD ? 100d : level.getDifficulty() == Difficulty.NORMAL ? 50d : 0d; // Paper - Configurable chance of villager zombie infection ++ final double fallbackChance = level.getDifficulty() == Difficulty.HARD ? 100 : level.getDifficulty() == Difficulty.NORMAL ? 50 : 0; // Paper - Configurable chance of villager zombie infection + if (this.random.nextDouble() * 100 < level.paperConfig().entities.behavior.zombieVillagerInfectionChance.or(fallbackChance) && entity instanceof Villager villager) { // Paper - Configurable chance of villager zombie infection if (level.getDifficulty() != Difficulty.HARD && this.random.nextBoolean()) { return flag; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch index dca58ab24d..ea135560b2 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombifiedPiglin.java.patch @@ -13,7 +13,7 @@ this.goalSelector.addGoal(2, new ZombieAttackGoal(this, 1.0, false)); this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0)); - this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setAlertOthers()); -+ this.targetSelector.addGoal(1, pathfinderGoalHurtByTarget = (new HurtByTargetGoal(this)).setAlertOthers()); // Paper - fix PigZombieAngerEvent cancellation ++ this.targetSelector.addGoal(1, this.pathfinderGoalHurtByTarget = (new HurtByTargetGoal(this)).setAlertOthers()); // Paper - fix PigZombieAngerEvent cancellation this.targetSelector.addGoal(2, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, this::isAngryAt)); this.targetSelector.addGoal(3, new ResetUniversalAngerTargetGoal<>(this, true)); } @@ -52,7 +52,7 @@ + this.level().getCraftServer().getPluginManager().callEvent(event); + if (event.isCancelled()) { + this.setPersistentAngerTarget(null); -+ pathfinderGoalHurtByTarget.stop(); // Paper - fix PigZombieAngerEvent cancellation ++ this.pathfinderGoalHurtByTarget.stop(); // Paper - fix PigZombieAngerEvent cancellation + return; + } + this.setRemainingPersistentAngerTime(event.getNewAnger()); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch index 524c238be3..467622eb81 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/piglin/PiglinAi.java.patch @@ -21,7 +21,7 @@ - if (itemEntity.getItem().is(Items.GOLD_NUGGET)) { + // CraftBukkit start + // Paper start - EntityPickupItemEvent fixes; fix event firing twice -+ if (itemEntity.getItem().is(Items.GOLD_NUGGET)/* && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(piglin, itemEntity, 0, false).isCancelled()*/) { // Paper ++ if (itemEntity.getItem().is(Items.GOLD_NUGGET)) { // Paper + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(piglin, itemEntity, 0, false).isCancelled()) return; + piglin.onItemPickup(itemEntity); // Paper - moved from Piglin#pickUpItem - call prior to item entity modification + // Paper end diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch index 458bc1fb33..06aabb0b2f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/AbstractVillager.java.patch @@ -55,7 +55,7 @@ + offer.increaseUses(); + } + if (event == null || event.isRewardingExp()) { -+ this.rewardTradeXp(offer); ++ this.rewardTradeXp(offer); + } + this.notifyTrade(offer); + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch index a650c82715..7c58286a0c 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/Villager.java.patch @@ -22,7 +22,7 @@ + // Spigot Start + @Override + public void inactiveTick() { -+ // SPIGOT-3874, SPIGOT-3894, SPIGOT-3846, SPIGOT-5286 :( ++ // SPIGOT-3874, SPIGOT-3894, SPIGOT-3846, SPIGOT-5286 :( + if (this.level().spigotConfig.tickInactiveVillagers && this.isEffectiveAi()) { + this.customServerAiStep((ServerLevel) this.level()); + } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch index 8884c9e247..61198c578a 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/npc/WanderingTraderSpawner.java.patch @@ -14,7 +14,7 @@ - serverLevelData.setWanderingTraderSpawnChance(this.spawnChance); - } + // Paper start - Add Wandering Trader spawn rate config options -+ this.tickDelay = Integer.MIN_VALUE; ++ this.tickDelay = Integer.MIN_VALUE; + // this.spawnDelay = serverLevelData.getWanderingTraderSpawnDelay(); + // this.spawnChance = serverLevelData.getWanderingTraderSpawnChance(); + // if (this.spawnDelay == 0 && this.spawnChance == 0) { @@ -81,7 +81,7 @@ this.serverLevelData.setWanderingTraderId(wanderingTrader.getUUID()); - wanderingTrader.setDespawnDelay(48000); -+ //wanderingTrader.setDespawnDelay(48000); // CraftBukkit - moved to EntityVillagerTrader constructor. This lets the value be modified by plugins on CreatureSpawnEvent ++ // wanderingTrader.setDespawnDelay(48000); // Paper - moved above, modifiable by plugins on CreatureSpawnEvent wanderingTrader.setWanderTarget(blockPos1); wanderingTrader.restrictTo(blockPos1, 16); return true; diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch index e6732700cf..337fa022f4 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/AbstractArrow.java.patch @@ -204,7 +204,7 @@ + ItemStack itemstack = this.getPickupItem(); + if (this.pickup == Pickup.ALLOWED && !itemstack.isEmpty() && entity.getInventory().canHold(itemstack) > 0) { + ItemEntity item = new ItemEntity(this.level(), this.getX(), this.getY(), this.getZ(), itemstack); -+ org.bukkit.event.player.PlayerPickupArrowEvent event = new org.bukkit.event.player.PlayerPickupArrowEvent((org.bukkit.entity.Player) entity.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.level().getCraftServer(), item), (org.bukkit.entity.AbstractArrow) this.getBukkitEntity()); ++ org.bukkit.event.player.PlayerPickupArrowEvent event = new org.bukkit.event.player.PlayerPickupArrowEvent((org.bukkit.entity.Player) entity.getBukkitEntity(), (org.bukkit.entity.Item) item.getBukkitEntity(), (org.bukkit.entity.AbstractArrow) this.getBukkitEntity()); + // event.setCancelled(!entityhuman.canPickUpLoot); TODO + this.level().getCraftServer().getPluginManager().callEvent(event); + diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch index 4c2c2ef103..a19b02d297 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownEgg.java.patch @@ -1,6 +1,6 @@ --- a/net/minecraft/world/entity/projectile/ThrownEgg.java +++ b/net/minecraft/world/entity/projectile/ThrownEgg.java -@@ -59,22 +_,56 @@ +@@ -59,28 +_,62 @@ protected void onHit(HitResult result) { super.onHit(result); if (!this.level().isClientSide) { @@ -61,3 +61,10 @@ } } } + + this.level().broadcastEntityEvent(this, (byte)3); +- this.discard(); ++ this.discard(org.bukkit.event.entity.EntityRemoveEvent.Cause.HIT); // CraftBukkit - add Bukkit remove cause + } + } + diff --git a/paper-server/patches/sources/net/minecraft/world/item/ItemUtils.java.patch b/paper-server/patches/sources/net/minecraft/world/item/ItemUtils.java.patch index 0956357249..0f2be6fd1c 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/ItemUtils.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/ItemUtils.java.patch @@ -6,8 +6,8 @@ if (!level.isClientSide) { - contents.forEach(itemStack -> level.addFreshEntity(new ItemEntity(level, container.getX(), container.getY(), container.getZ(), itemStack))); + // Paper start - call EntityDropItemEvent -+ contents.forEach(stack -> { -+ ItemEntity droppedItem = new ItemEntity(level, container.getX(), container.getY(), container.getZ(), stack); ++ contents.forEach(itemStack -> { ++ ItemEntity droppedItem = new ItemEntity(level, container.getX(), container.getY(), container.getZ(), itemStack); + org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(container.getBukkitEntity(), (org.bukkit.entity.Item) droppedItem.getBukkitEntity()); + if (event.callEvent()) { + level.addFreshEntity(droppedItem); diff --git a/paper-server/patches/sources/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java.patch b/paper-server/patches/sources/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java.patch index 9a43ef7d58..36547c65ef 100644 --- a/paper-server/patches/sources/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/item/consume_effects/TeleportRandomlyConsumeEffect.java.patch @@ -9,7 +9,7 @@ + java.util.Optional status = entity.randomTeleport(d, d1, d2, true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT); + + // teleport event was canceled, no more tries -+ if (!status.isPresent()) break; ++ if (status.isEmpty()) break; + if (status.get()) { + // CraftBukkit end level.gameEvent(GameEvent.TELEPORT, vec3, GameEvent.Context.of(entity)); diff --git a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch index f3cb6d6470..e470fbe622 100644 --- a/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/level/block/entity/BrewingStandBlockEntity.java.patch @@ -16,7 +16,7 @@ default -> 0; }; } -@@ -57,14 +_,50 @@ +@@ -57,14 +_,49 @@ break; case 1: BrewingStandBlockEntity.this.fuel = value; @@ -36,7 +36,6 @@ } }; + // CraftBukkit start - add fields and methods -+ // private int lastTick = MinecraftServer.currentTick; // Paper - remove anti tick skipping measures / wall time + public java.util.List transaction = new java.util.ArrayList<>(); + private int maxStack = MAX_STACK; + diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java index 30d62ee4d5..7a3d982b13 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftItem.java @@ -10,8 +10,8 @@ import org.bukkit.inventory.ItemStack; public class CraftItem extends CraftEntity implements Item { // Paper start - private final static int NO_AGE_TIME = (int) Short.MIN_VALUE; - private final static int NO_PICKUP_TIME = (int) Short.MAX_VALUE; + private final static int NO_AGE_TIME = Short.MIN_VALUE; + private final static int NO_PICKUP_TIME = Short.MAX_VALUE; // Paper end public CraftItem(CraftServer server, ItemEntity entity) {