readd removal cause for thrown eggs

This commit is contained in:
Lulu13022002 2024-12-15 23:07:15 +01:00
parent f5cd5989a4
commit ec57b99bf5
No known key found for this signature in database
GPG key ID: 491C8F0B8ACDEB01
22 changed files with 96 additions and 82 deletions

View file

@ -102,7 +102,7 @@
+ if (!super.hurtServer(level, damageSource, amount)) return false; // CraftBukkit - Only stop pollinating if entity was damaged + if (!super.hurtServer(level, damageSource, amount)) return false; // CraftBukkit - Only stop pollinating if entity was damaged
this.beePollinateGoal.stopPollinating(); this.beePollinateGoal.stopPollinating();
- return super.hurtServer(level, damageSource, amount); - 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
} }
} }

View file

@ -183,7 +183,7 @@
if (this.level() instanceof ServerLevel serverLevel) { if (this.level() instanceof ServerLevel serverLevel) {
- if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { - if (this.dragonDeathTime > 150 && this.dragonDeathTime % 5 == 0 && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
- ExperienceOrb.award(serverLevel, this.position(), Mth.floor(i * 0.08F)); - 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 + 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 + for (net.minecraft.server.level.ServerPlayer player : serverLevel.getPlayersForGlobalSoundGamerule()) { // Paper - respect global sound events gamerule
+ double deltaX = this.getX() - player.getX(); + double deltaX = this.getX() - player.getX();
+ double deltaZ = this.getZ() - player.getZ(); + 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 + 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 (!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 deltaLength = Math.sqrt(distanceSquared);
+ double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; + double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance;
+ double relativeZ = player.getZ() + (deltaZ / 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 { + } 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 + // CraftBukkit end
@ -260,7 +260,7 @@
float max = Math.max((float)Math.sqrt(heightmapPos.distToCenterSqr(this.position())) / 4.0F, 1.0F); float max = Math.max((float)Math.sqrt(heightmapPos.distToCenterSqr(this.position())) / 4.0F, 1.0F);
float f = 6.0F / max; float f = 6.0F / max;
float xRot = this.getXRot(); float xRot = this.getXRot();
@@ -883,4 +_,20 @@ @@ -883,4 +_,19 @@
protected float sanitizeScale(float scale) { protected float sanitizeScale(float scale) {
return 1.0F; return 1.0F;
} }
@ -270,14 +270,13 @@
+ public int getExpReward(ServerLevel worldserver, Entity entity) { + public int getExpReward(ServerLevel worldserver, Entity entity) {
+ // CraftBukkit - Moved from #tickDeath method + // CraftBukkit - Moved from #tickDeath method
+ boolean flag = worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT); + boolean flag = worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT);
+ short short0 = 500; + int i = 500;
+ +
+ if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) { + if (this.dragonFight != null && !this.dragonFight.hasPreviouslyKilledDragon()) {
+ short0 = 12000; + i = 12000;
+ } + }
+ +
+ return flag ? short0 : 0; + return flag ? i : 0;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
+
} }

View file

@ -34,16 +34,16 @@
+ for (ServerPlayer player : level.getPlayersForGlobalSoundGamerule()) { // Paper - respect global sound events gamerule + for (ServerPlayer player : level.getPlayersForGlobalSoundGamerule()) { // Paper - respect global sound events gamerule
+ double deltaX = this.getX() - player.getX(); + double deltaX = this.getX() - player.getX();
+ double deltaZ = this.getZ() - player.getZ(); + 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 + 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 (!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 deltaLength = Math.sqrt(distanceSquared);
+ double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance; + double relativeX = player.getX() + (deltaX / deltaLength) * viewDistance;
+ double relativeZ = player.getZ() + (deltaZ / 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 { + } 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 + // CraftBukkit end

View file

@ -9,7 +9,7 @@
protected BlockPos pos; protected BlockPos pos;
protected BlockAttachedEntity(EntityType<? extends BlockAttachedEntity> entityType, Level level) { protected BlockAttachedEntity(EntityType<? extends BlockAttachedEntity> entityType, Level level) {
@@ -38,10 +_,29 @@ @@ -38,10 +_,26 @@
public void tick() { public void tick() {
if (this.level() instanceof ServerLevel serverLevel) { if (this.level() instanceof ServerLevel serverLevel) {
this.checkBelowWorld(); this.checkBelowWorld();
@ -18,12 +18,9 @@
this.checkInterval = 0; this.checkInterval = 0;
if (!this.isRemoved() && !this.survives()) { if (!this.isRemoved() && !this.survives()) {
- this.discard(); - this.discard();
+ // this.discard();
+ // CraftBukkit start - fire break events + // CraftBukkit start - fire break events
+ net.minecraft.world.level.block.state.BlockState material = this.level().getBlockState(this.blockPosition()); + final org.bukkit.event.hanging.HangingBreakEvent.RemoveCause cause;
+ org.bukkit.event.hanging.HangingBreakEvent.RemoveCause cause; + if (!this.level().getBlockState(this.blockPosition()).isAir()) {
+
+ if (!material.isAir()) {
+ // TODO: This feels insufficient to catch 100% of suffocation cases + // TODO: This feels insufficient to catch 100% of suffocation cases
+ cause = org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.OBSTRUCTION; + cause = org.bukkit.event.hanging.HangingBreakEvent.RemoveCause.OBSTRUCTION;
+ } else { + } else {

View file

@ -128,7 +128,7 @@
} }
compound.putBoolean("CancelDrop", this.cancelDrop); 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 @Override

View file

@ -51,7 +51,7 @@
f = this.level().getBlockState(this.getBlockPosBelowThatAffectsMyMovement()).getBlock().getFriction() * 0.98F; 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 + // Spigot start - copied from above
+ @Override + @Override
+ public void inactiveTick() { + public void inactiveTick() {
+ // Paper start - remove anti tick skipping measures / wall time - copied from above
+ if (this.pickupDelay > 0 && this.pickupDelay != 32767) { + if (this.pickupDelay > 0 && this.pickupDelay != 32767) {
+ --this.pickupDelay; + --this.pickupDelay;
+ } + }
+ if (this.age != -32768) { + if (this.age != -32768) {
+ ++this.age; + ++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 + if (!this.level().isClientSide && this.age >= this.despawnRate) { // Spigot // Paper - Alternative item-despawn-rate
+ // CraftBukkit start - fire ItemDespawnEvent + // CraftBukkit start - fire ItemDespawnEvent
@ -202,7 +200,7 @@
if (this.getItem().isEmpty()) { if (this.getItem().isEmpty()) {
- this.discard(); - this.discard();
+ this.discard(null); // CraftBukkit - add Bukkit remove cause + this.discard(null); // CraftBukkit - add Bukkit remove cause
} }
} }

View file

@ -1,17 +1,30 @@
--- a/net/minecraft/world/entity/monster/AbstractSkeleton.java --- a/net/minecraft/world/entity/monster/AbstractSkeleton.java
+++ b/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); AbstractSkeleton.this.setAggressive(true);
} }
}; };
+ // Paper start - shouldBurnInDay API + private boolean shouldBurnInDay = true; // Paper - shouldBurnInDay API
+ private boolean shouldBurnInDay = true;
+ public boolean shouldBurnInDay() { return shouldBurnInDay; }
+ public void setShouldBurnInDay(boolean shouldBurnInDay) { this.shouldBurnInDay = shouldBurnInDay; }
+ // Paper end - shouldBurnInDay API
protected AbstractSkeleton(EntityType<? extends AbstractSkeleton> entityType, Level level) { protected AbstractSkeleton(EntityType<? extends AbstractSkeleton> entityType, Level level) {
super(entityType, 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 @@ @@ -97,7 +_,7 @@
@Override @Override

View file

@ -1,5 +1,13 @@
--- a/net/minecraft/world/entity/monster/Slime.java --- a/net/minecraft/world/entity/monster/Slime.java
+++ b/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<? extends Slime> entityType, Level level) {
super(entityType, level);
@@ -110,6 +_,7 @@ @@ -110,6 +_,7 @@
super.addAdditionalSaveData(compound); super.addAdditionalSaveData(compound);
compound.putInt("Size", this.getSize() - 1); compound.putInt("Size", this.getSize() - 1);
@ -114,6 +122,23 @@
return checkMobSpawnRules(entityType, level, spawnReason, pos, random); 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 @@ @@ -367,7 +_,16 @@
@Override @Override
public boolean canUse() { public boolean canUse() {
@ -202,18 +227,3 @@
} }
if (this.slime.getMoveControl() instanceof Slime.SlimeMoveControl slimeMoveControl) { 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
}

View file

@ -14,7 +14,7 @@
@Override @Override
public boolean canBeAffected(MobEffectInstance potioneffect) { public boolean canBeAffected(MobEffectInstance potioneffect) {
- return !potioneffect.is(MobEffects.POISON) && super.canBeAffected(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() { public boolean isClimbing() {

View file

@ -6,7 +6,7 @@
PotionContents potionContents = mainHandItem.get(DataComponents.POTION_CONTENTS); PotionContents potionContents = mainHandItem.get(DataComponents.POTION_CONTENTS);
+ // Paper start - WitchConsumePotionEvent + // Paper start - WitchConsumePotionEvent
+ if (mainHandItem.is(Items.POTION)) { + 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; + potionContents = event.callEvent() ? org.bukkit.craftbukkit.inventory.CraftItemStack.unwrap(event.getPotion()).get(DataComponents.POTION_CONTENTS) : null;
+ } + }
+ // Paper end - WitchConsumePotionEvent + // Paper end - WitchConsumePotionEvent
@ -55,13 +55,13 @@
+ this.usingTime = this.getMainHandItem().getUseDuration(this); + this.usingTime = this.getMainHandItem().getUseDuration(this);
+ this.setUsingItem(true); + this.setUsingItem(true);
+ if (!this.isSilent()) { + 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); + attribute.removeModifier(Witch.SPEED_MODIFIER_DRINKING_ID);
+ attributemodifiable.addTransientModifier(Witch.SPEED_MODIFIER_DRINKING); + attribute.addTransientModifier(Witch.SPEED_MODIFIER_DRINKING);
+ } + }
+ // Paper end + // Paper end
+ +
@ -73,7 +73,7 @@
if (this.level() instanceof ServerLevel serverLevel) { if (this.level() instanceof ServerLevel serverLevel) {
ItemStack itemStack = PotionContents.createItemStack(Items.SPLASH_POTION, holder); ItemStack itemStack = PotionContents.createItemStack(Items.SPLASH_POTION, holder);
+ // Paper start - WitchThrowPotionEvent + // 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()) { + if (!event.callEvent()) {
+ return; + return;
+ } + }

View file

@ -11,7 +11,7 @@
private static final ResourceLocation REINFORCEMENT_CALLER_CHARGE_ID = ResourceLocation.withDefaultNamespace("reinforcement_caller_charge"); private static final ResourceLocation REINFORCEMENT_CALLER_CHARGE_ID = ResourceLocation.withDefaultNamespace("reinforcement_caller_charge");
private static final AttributeModifier ZOMBIE_REINFORCEMENT_CALLEE_CHARGE = new AttributeModifier( private static final AttributeModifier ZOMBIE_REINFORCEMENT_CALLEE_CHARGE = new AttributeModifier(
ResourceLocation.withDefaultNamespace("reinforcement_callee_charge"), -0.05F, AttributeModifier.Operation.ADD_VALUE 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 EntityDimensions BABY_DIMENSIONS = EntityType.ZOMBIE.getDimensions().scale(0.5F).withEyeHeight(0.93F);
private static final float BREAK_DOOR_CHANCE = 0.1F; private static final float BREAK_DOOR_CHANCE = 0.1F;
public static final Predicate<Difficulty> DOOR_BREAKING_PREDICATE = difficulty -> difficulty == Difficulty.HARD; public static final Predicate<Difficulty> DOOR_BREAKING_PREDICATE = difficulty -> difficulty == Difficulty.HARD;
@ -20,7 +20,6 @@
private boolean canBreakDoors; private boolean canBreakDoors;
private int inWaterTime; private int inWaterTime;
public int conversionTime; 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 + private boolean shouldBurnInDay = true; // Paper - Add more Zombie API
public Zombie(EntityType<? extends Zombie> entityType, Level level) { public Zombie(EntityType<? extends Zombie> 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 @@ @@ -251,7 +_,14 @@
super.aiStep(); super.aiStep();
} }
@ -111,7 +102,7 @@
- zombie -> zombie.handleAttributes(zombie.level().getCurrentDifficultyAt(zombie.blockPosition()).getSpecialMultiplier()) - zombie -> zombie.handleAttributes(zombie.level().getCurrentDifficultyAt(zombie.blockPosition()).getSpecialMultiplier())
- ); - );
+ // CraftBukkit start + // 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); + org.bukkit.event.entity.EntityTransformEvent.TransformReason.DROWNED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DROWNED);
+ if (converted == null) { + if (converted == null) {
+ ((org.bukkit.entity.Zombie) this.getBukkitEntity()).setConversionTime(-1); // CraftBukkit - SPIGOT-5208: End conversion to stop event spam + ((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) { public boolean killedEntity(ServerLevel level, LivingEntity entity) {
boolean flag = super.killedEntity(level, entity); boolean flag = super.killedEntity(level, entity);
- if ((level.getDifficulty() == Difficulty.NORMAL || level.getDifficulty() == Difficulty.HARD) && entity instanceof Villager villager) { - 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 (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()) { if (level.getDifficulty() != Difficulty.HARD && this.random.nextBoolean()) {
return flag; return flag;

View file

@ -13,7 +13,7 @@
this.goalSelector.addGoal(2, new ZombieAttackGoal(this, 1.0, false)); this.goalSelector.addGoal(2, new ZombieAttackGoal(this, 1.0, false));
this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0)); this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0));
- this.targetSelector.addGoal(1, new HurtByTargetGoal(this).setAlertOthers()); - 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(2, new NearestAttackableTargetGoal<>(this, Player.class, 10, true, false, this::isAngryAt));
this.targetSelector.addGoal(3, new ResetUniversalAngerTargetGoal<>(this, true)); this.targetSelector.addGoal(3, new ResetUniversalAngerTargetGoal<>(this, true));
} }
@ -52,7 +52,7 @@
+ this.level().getCraftServer().getPluginManager().callEvent(event); + this.level().getCraftServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) { + if (event.isCancelled()) {
+ this.setPersistentAngerTarget(null); + this.setPersistentAngerTarget(null);
+ pathfinderGoalHurtByTarget.stop(); // Paper - fix PigZombieAngerEvent cancellation + this.pathfinderGoalHurtByTarget.stop(); // Paper - fix PigZombieAngerEvent cancellation
+ return; + return;
+ } + }
+ this.setRemainingPersistentAngerTime(event.getNewAnger()); + this.setRemainingPersistentAngerTime(event.getNewAnger());

View file

@ -21,7 +21,7 @@
- if (itemEntity.getItem().is(Items.GOLD_NUGGET)) { - if (itemEntity.getItem().is(Items.GOLD_NUGGET)) {
+ // CraftBukkit start + // CraftBukkit start
+ // Paper start - EntityPickupItemEvent fixes; fix event firing twice + // 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; + 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 + piglin.onItemPickup(itemEntity); // Paper - moved from Piglin#pickUpItem - call prior to item entity modification
+ // Paper end + // Paper end

View file

@ -55,7 +55,7 @@
+ offer.increaseUses(); + offer.increaseUses();
+ } + }
+ if (event == null || event.isRewardingExp()) { + if (event == null || event.isRewardingExp()) {
+ this.rewardTradeXp(offer); + this.rewardTradeXp(offer);
+ } + }
+ this.notifyTrade(offer); + this.notifyTrade(offer);
+ } + }

View file

@ -22,7 +22,7 @@
+ // Spigot Start + // Spigot Start
+ @Override + @Override
+ public void inactiveTick() { + 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()) { + if (this.level().spigotConfig.tickInactiveVillagers && this.isEffectiveAi()) {
+ this.customServerAiStep((ServerLevel) this.level()); + this.customServerAiStep((ServerLevel) this.level());
+ } + }

View file

@ -14,7 +14,7 @@
- serverLevelData.setWanderingTraderSpawnChance(this.spawnChance); - serverLevelData.setWanderingTraderSpawnChance(this.spawnChance);
- } - }
+ // Paper start - Add Wandering Trader spawn rate config options + // Paper start - Add Wandering Trader spawn rate config options
+ this.tickDelay = Integer.MIN_VALUE; + this.tickDelay = Integer.MIN_VALUE;
+ // this.spawnDelay = serverLevelData.getWanderingTraderSpawnDelay(); + // this.spawnDelay = serverLevelData.getWanderingTraderSpawnDelay();
+ // this.spawnChance = serverLevelData.getWanderingTraderSpawnChance(); + // this.spawnChance = serverLevelData.getWanderingTraderSpawnChance();
+ // if (this.spawnDelay == 0 && this.spawnChance == 0) { + // if (this.spawnDelay == 0 && this.spawnChance == 0) {
@ -81,7 +81,7 @@
this.serverLevelData.setWanderingTraderId(wanderingTrader.getUUID()); this.serverLevelData.setWanderingTraderId(wanderingTrader.getUUID());
- wanderingTrader.setDespawnDelay(48000); - 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.setWanderTarget(blockPos1);
wanderingTrader.restrictTo(blockPos1, 16); wanderingTrader.restrictTo(blockPos1, 16);
return true; return true;

View file

@ -204,7 +204,7 @@
+ ItemStack itemstack = this.getPickupItem(); + ItemStack itemstack = this.getPickupItem();
+ if (this.pickup == Pickup.ALLOWED && !itemstack.isEmpty() && entity.getInventory().canHold(itemstack) > 0) { + 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); + 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 + // event.setCancelled(!entityhuman.canPickUpLoot); TODO
+ this.level().getCraftServer().getPluginManager().callEvent(event); + this.level().getCraftServer().getPluginManager().callEvent(event);
+ +

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/projectile/ThrownEgg.java --- a/net/minecraft/world/entity/projectile/ThrownEgg.java
+++ b/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) { protected void onHit(HitResult result) {
super.onHit(result); super.onHit(result);
if (!this.level().isClientSide) { 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
}
}

View file

@ -6,8 +6,8 @@
if (!level.isClientSide) { if (!level.isClientSide) {
- contents.forEach(itemStack -> level.addFreshEntity(new ItemEntity(level, container.getX(), container.getY(), container.getZ(), itemStack))); - contents.forEach(itemStack -> level.addFreshEntity(new ItemEntity(level, container.getX(), container.getY(), container.getZ(), itemStack)));
+ // Paper start - call EntityDropItemEvent + // Paper start - call EntityDropItemEvent
+ contents.forEach(stack -> { + contents.forEach(itemStack -> {
+ ItemEntity droppedItem = new ItemEntity(level, container.getX(), container.getY(), container.getZ(), stack); + 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()); + org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(container.getBukkitEntity(), (org.bukkit.entity.Item) droppedItem.getBukkitEntity());
+ if (event.callEvent()) { + if (event.callEvent()) {
+ level.addFreshEntity(droppedItem); + level.addFreshEntity(droppedItem);

View file

@ -9,7 +9,7 @@
+ java.util.Optional<Boolean> status = entity.randomTeleport(d, d1, d2, true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT); + java.util.Optional<Boolean> status = entity.randomTeleport(d, d1, d2, true, org.bukkit.event.player.PlayerTeleportEvent.TeleportCause.CHORUS_FRUIT);
+ +
+ // teleport event was canceled, no more tries + // teleport event was canceled, no more tries
+ if (!status.isPresent()) break; + if (status.isEmpty()) break;
+ if (status.get()) { + if (status.get()) {
+ // CraftBukkit end + // CraftBukkit end
level.gameEvent(GameEvent.TELEPORT, vec3, GameEvent.Context.of(entity)); level.gameEvent(GameEvent.TELEPORT, vec3, GameEvent.Context.of(entity));

View file

@ -16,7 +16,7 @@
default -> 0; default -> 0;
}; };
} }
@@ -57,14 +_,50 @@ @@ -57,14 +_,49 @@
break; break;
case 1: case 1:
BrewingStandBlockEntity.this.fuel = value; BrewingStandBlockEntity.this.fuel = value;
@ -36,7 +36,6 @@
} }
}; };
+ // CraftBukkit start - add fields and methods + // CraftBukkit start - add fields and methods
+ // private int lastTick = MinecraftServer.currentTick; // Paper - remove anti tick skipping measures / wall time
+ public java.util.List<org.bukkit.entity.HumanEntity> transaction = new java.util.ArrayList<>(); + public java.util.List<org.bukkit.entity.HumanEntity> transaction = new java.util.ArrayList<>();
+ private int maxStack = MAX_STACK; + private int maxStack = MAX_STACK;
+ +

View file

@ -10,8 +10,8 @@ import org.bukkit.inventory.ItemStack;
public class CraftItem extends CraftEntity implements Item { public class CraftItem extends CraftEntity implements Item {
// Paper start // Paper start
private final static int NO_AGE_TIME = (int) Short.MIN_VALUE; private final static int NO_AGE_TIME = Short.MIN_VALUE;
private final static int NO_PICKUP_TIME = (int) Short.MAX_VALUE; private final static int NO_PICKUP_TIME = Short.MAX_VALUE;
// Paper end // Paper end
public CraftItem(CraftServer server, ItemEntity entity) { public CraftItem(CraftServer server, ItemEntity entity) {