Co-authored-by: Bjarne Koll <git@lynxplay.dev>
Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: Lulu13022002 <41980282+Lulu13022002@users.noreply.github.com>
Co-authored-by: MiniDigger | Martin <admin@minidigger.dev>
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
Co-authored-by: Noah van der Aa <ndvdaa@gmail.com>
Co-authored-by: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Spottedleaf <Spottedleaf@users.noreply.github.com>
Co-authored-by: Tamion <70228790+notTamion@users.noreply.github.com>
Co-authored-by: Warrior <50800980+Warriorrrr@users.noreply.github.com>
This commit is contained in:
Nassim Jahnke
2025-04-12 17:26:44 +02:00
parent 0767902699
commit f00727c57e
2092 changed files with 50551 additions and 48729 deletions

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/entity/animal/Cow.java
+++ b/net/minecraft/world/entity/animal/Cow.java
@@ -88,8 +_,15 @@
--- a/net/minecraft/world/entity/animal/AbstractCow.java
+++ b/net/minecraft/world/entity/animal/AbstractCow.java
@@ -84,8 +_,15 @@
public InteractionResult mobInteract(Player player, InteractionHand hand) {
ItemStack itemInHand = player.getItemInHand(hand);
if (itemInHand.is(Items.BUCKET) && !this.isBaby()) {
+ // CraftBukkit start - Got milk?
+ org.bukkit.event.player.PlayerBucketFillEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketFillEvent((ServerLevel) player.level(), player, this.blockPosition(), this.blockPosition(), null, itemInHand, Items.MILK_BUCKET, hand);
+ org.bukkit.event.player.PlayerBucketFillEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketFillEvent(player.level(), player, this.blockPosition(), this.blockPosition(), null, itemInHand, Items.MILK_BUCKET, hand);
+ if (event.isCancelled()) {
+ player.containerMenu.sendAllDataToRemote(); // Paper - Fix inventory desync
+ return InteractionResult.PASS;

View File

@@ -1,14 +1,14 @@
--- a/net/minecraft/world/entity/animal/Animal.java
+++ b/net/minecraft/world/entity/animal/Animal.java
@@ -39,6 +_,7 @@
public int inLove;
@@ -41,6 +_,7 @@
public int inLove = 0;
@Nullable
public UUID loveCause;
+ public ItemStack breedItem; // CraftBukkit - Add breedItem variable
+ public @Nullable ItemStack breedItem; // CraftBukkit - Add breedItem variable
protected Animal(EntityType<? extends Animal> entityType, Level level) {
super(entityType, level);
@@ -78,9 +_,13 @@
@@ -80,9 +_,13 @@
}
@Override
@@ -35,7 +35,7 @@
this.playEatingSound();
return InteractionResult.SUCCESS_SERVER;
}
@@ -176,11 +_,26 @@
@@ -176,8 +_,23 @@
return this.inLove <= 0;
}
@@ -45,6 +45,7 @@
+ // Paper start - Fix EntityBreedEvent copying
+ this.setInLove(player, null);
+ }
+
+ public void setInLove(@Nullable Player player, @Nullable ItemStack breedItemCopy) {
+ if (breedItemCopy != null) this.breedItem = breedItemCopy;
+ // Paper end - Fix EntityBreedEvent copying
@@ -59,17 +60,13 @@
if (player != null) {
this.loveCause = player.getUUID();
}
+ // Paper - Fix EntityBreedEvent copying; set breed item in better place
this.level().broadcastEntityEvent(this, (byte)18);
}
@@ -220,23 +_,44 @@
@@ -220,23 +_,45 @@
if (breedOffspring != null) {
breedOffspring.setBaby(true);
breedOffspring.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
breedOffspring.snapTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
- this.finalizeSpawnChildFromBreeding(level, mate, breedOffspring);
- level.addFreshEntityWithPassengers(breedOffspring);
+ // CraftBukkit start - call EntityBreedEvent
+ // CraftBukkit start - Call EntityBreedEvent
+ ServerPlayer breeder = Optional.ofNullable(this.getLoveCause()).or(() -> Optional.ofNullable(mate.getLoveCause())).orElse(null);
+ int experience = this.getRandom().nextInt(7) + 1;
+ org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(breedOffspring, this, mate, breeder, this.breedItem, experience);
@@ -79,29 +76,30 @@
+ return;
+ }
+ experience = entityBreedEvent.getExperience();
+
+ this.finalizeSpawnChildFromBreeding(level, mate, breedOffspring, experience);
+ level.addFreshEntityWithPassengers(breedOffspring, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING);
+ // CraftBukkit end - call EntityBreedEvent
+ // CraftBukkit end - Call EntityBreedEvent
}
}
public void finalizeSpawnChildFromBreeding(ServerLevel level, Animal animal, @Nullable AgeableMob baby) {
- Optional.ofNullable(this.getLoveCause()).or(() -> Optional.ofNullable(animal.getLoveCause())).ifPresent(player -> {
+ // CraftBukkit start - call EntityBreedEvent
+ // CraftBukkit start - Call EntityBreedEvent
+ this.finalizeSpawnChildFromBreeding(level, animal, baby, this.getRandom().nextInt(7) + 1);
+ }
+
+ public void finalizeSpawnChildFromBreeding(ServerLevel level, Animal animal, @Nullable AgeableMob baby, int experience) {
+ // CraftBukkit end - call EntityBreedEvent
+ // Paper start - call EntityBreedEvent
+ // CraftBukkit end - Call EntityBreedEvent
+ // Paper start - Call EntityBreedEvent
+ ServerPlayer player = this.getLoveCause();
+ if (player == null) player = animal.getLoveCause();
+ if (player != null) {
+ // Paper end - call EntityBreedEvent
+ // Paper end - Call EntityBreedEvent
player.awardStat(Stats.ANIMALS_BRED);
CriteriaTriggers.BRED_ANIMALS.trigger(player, this, animal, baby);
- });
+ } // Paper - call EntityBreedEvent
+ } // Paper - Call EntityBreedEvent
this.setAge(6000);
animal.setAge(6000);
this.resetLove();
@@ -109,8 +107,8 @@
level.broadcastEntityEvent(this, (byte)18);
- if (level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
- level.addFreshEntity(new ExperienceOrb(level, this.getX(), this.getY(), this.getZ(), this.getRandom().nextInt(7) + 1));
+ if (experience > 0 && level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - call EntityBreedEvent
+ level.addFreshEntity(new ExperienceOrb(level, this.getX(), this.getY(), this.getZ(), experience, org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, player, baby)); // Paper - call EntityBreedEvent, add spawn context
+ if (experience > 0 && level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) { // Paper - Call EntityBreedEvent
+ level.addFreshEntity(new ExperienceOrb(level, this.getX(), this.getY(), this.getZ(), experience, org.bukkit.entity.ExperienceOrb.SpawnReason.BREED, player, baby)); // Paper - Call EntityBreedEvent, add spawn context
}
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/Bee.java
+++ b/net/minecraft/world/entity/animal/Bee.java
@@ -141,10 +_,26 @@
@@ -145,10 +_,26 @@
Bee.BeeGoToHiveGoal goToHiveGoal;
private Bee.BeeGoToKnownFlowerGoal goToKnownFlowerGoal;
private int underWaterTicks;
@@ -28,7 +28,7 @@
this.lookControl = new Bee.BeeLookControl(this);
this.setPathfindingMalus(PathType.DANGER_FIRE, -1.0F);
this.setPathfindingMalus(PathType.WATER, -1.0F);
@@ -191,12 +_,19 @@
@@ -195,9 +_,18 @@
@Override
public void addAdditionalSaveData(CompoundTag compound) {
@@ -37,20 +37,17 @@
+ }
+
+ @Override
+ public void addAdditionalSaveData(CompoundTag compound, boolean includeAll) {
+ public void addAdditionalSaveData(CompoundTag compound, boolean saveAll) {
+ // CraftBukkit end
super.addAdditionalSaveData(compound);
- if (this.hasHive()) {
+ if (includeAll && this.hasHive()) { // CraftBukkit - selectively save hive
compound.put("hive_pos", NbtUtils.writeBlockPos(this.getHivePos()));
}
- if (this.hasSavedFlowerPos()) {
+ if (includeAll && this.hasSavedFlowerPos()) { // CraftBukkit - selectively save hive
compound.put("flower_pos", NbtUtils.writeBlockPos(this.getSavedFlowerPos()));
}
@@ -237,7 +_,7 @@
+ if (saveAll) { // Paper
compound.storeNullable("hive_pos", BlockPos.CODEC, this.hivePos);
compound.storeNullable("flower_pos", BlockPos.CODEC, this.savedFlowerPos);
+ } // Paper
compound.putBoolean("HasNectar", this.hasNectar());
compound.putBoolean("HasStung", this.hasStung());
compound.putInt("TicksSincePollination", this.ticksWithoutNectarSinceExitingHive);
@@ -235,7 +_,7 @@
}
if (i > 0) {
@@ -59,7 +56,7 @@
}
}
@@ -492,7 +_,11 @@
@@ -490,7 +_,11 @@
if (this.hivePos == null) {
return null;
} else {
@@ -72,7 +69,7 @@
}
}
@@ -525,6 +_,7 @@
@@ -523,6 +_,7 @@
}
public void setRolling(boolean isRolling) {
@@ -80,7 +77,7 @@
this.setFlag(2, isRolling);
}
@@ -581,7 +_,7 @@
@@ -579,7 +_,7 @@
if (beeInteractionEffect != null) {
this.usePlayerItem(player, hand, itemInHand);
if (!this.level().isClientSide) {
@@ -89,7 +86,7 @@
}
return InteractionResult.SUCCESS;
@@ -650,8 +_,9 @@
@@ -648,8 +_,9 @@
if (this.isInvulnerableTo(level, damageSource)) {
return false;
} else {
@@ -100,7 +97,7 @@
}
}
@@ -772,7 +_,7 @@
@@ -770,7 +_,7 @@
@VisibleForDebug
public class BeeGoToHiveGoal extends Bee.BaseBeeGoal {
public static final int MAX_TRAVELLING_TICKS = 2400;
@@ -109,7 +106,7 @@
private static final int MAX_BLACKLISTED_TARGETS = 3;
final List<BlockPos> blacklistedTargets = Lists.newArrayList();
@Nullable
@@ -888,7 +_,7 @@
@@ -886,7 +_,7 @@
public class BeeGoToKnownFlowerGoal extends Bee.BaseBeeGoal {
private static final int MAX_TRAVELLING_TICKS = 2400;
@@ -118,7 +115,7 @@
BeeGoToKnownFlowerGoal() {
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
@@ -986,7 +_,7 @@
@@ -983,7 +_,7 @@
}
}
@@ -127,16 +124,16 @@
Bee.this.level().levelEvent(2011, blockPos, 15);
Bee.this.level().setBlockAndUpdate(blockPos, blockState1);
Bee.this.incrementNumCropsGrownSincePollination();
@@ -1010,7 +_,7 @@
@@ -1007,7 +_,7 @@
@Override
protected void alertOther(Mob mob, LivingEntity target) {
if (mob instanceof Bee && this.mob.hasLineOfSight(target)) {
- mob.setTarget(target);
+ mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason
+ mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY); // CraftBukkit - reason
}
}
}
@@ -1168,7 +_,7 @@
@@ -1165,7 +_,7 @@
Bee.this.dropFlower();
this.pollinating = false;
Bee.this.remainingCooldownBeforeLocatingNewFlower = 200;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/Bucketable.java
+++ b/net/minecraft/world/entity/animal/Bucketable.java
@@ -88,9 +_,19 @@
@@ -71,9 +_,19 @@
static <T extends LivingEntity & Bucketable> Optional<InteractionResult> bucketMobPickup(Player player, InteractionHand hand, T entity) {
ItemStack itemInHand = player.getItemInHand(hand);
if (itemInHand.getItem() == Items.WATER_BUCKET && entity.isAlive()) {
@@ -21,7 +21,7 @@
ItemStack itemStack = ItemUtils.createFilledResult(itemInHand, player, bucketItemStack, false);
player.setItemInHand(hand, itemStack);
Level level = entity.level();
@@ -98,7 +_,7 @@
@@ -81,7 +_,7 @@
CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayer)player, bucketItemStack);
}

View File

@@ -1,15 +1,6 @@
--- a/net/minecraft/world/entity/animal/Cat.java
+++ b/net/minecraft/world/entity/animal/Cat.java
@@ -342,7 +_,7 @@
TagKey<CatVariant> tagKey = flag ? CatVariantTags.FULL_MOON_SPAWNS : CatVariantTags.DEFAULT_SPAWNS;
BuiltInRegistries.CAT_VARIANT.getRandomElementOf(tagKey, level.getRandom()).ifPresent(this::setVariant);
ServerLevel level1 = level.getLevel();
- if (level1.structureManager().getStructureWithPieceAt(this.blockPosition(), StructureTags.CATS_SPAWN_AS_BLACK).isValid()) {
+ if (level1.structureManager().getStructureWithPieceAt(this.blockPosition(), StructureTags.CATS_SPAWN_AS_BLACK, level).isValid()) { // Paper - Fix swamp hut cat generation deadlock
this.setVariant(BuiltInRegistries.CAT_VARIANT.getOrThrow(CatVariant.ALL_BLACK));
this.setPersistenceRequired();
}
@@ -359,6 +_,11 @@
@@ -372,6 +_,11 @@
if (item instanceof DyeItem dyeItem) {
DyeColor dyeColor = dyeItem.getDyeColor();
if (dyeColor != this.getCollarColor()) {
@@ -21,7 +12,7 @@
if (!this.level().isClientSide()) {
this.setCollarColor(dyeColor);
itemInHand.consume(1, player);
@@ -371,7 +_,7 @@
@@ -384,7 +_,7 @@
if (!this.level().isClientSide()) {
this.usePlayerItem(player, hand, itemInHand);
FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD);
@@ -30,7 +21,7 @@
this.playEatingSound();
}
@@ -433,7 +_,7 @@
@@ -446,7 +_,7 @@
}
private void tryToTame(Player player) {
@@ -39,32 +30,32 @@
this.tame(player);
this.setOrderedToSit(true);
this.level().broadcastEntityEvent(this, (byte)7);
@@ -567,15 +_,20 @@
@@ -580,15 +_,20 @@
.dropFromGiftLootTable(
getServerLevel(this.cat),
BuiltInLootTables.CAT_MORNING_GIFT,
- (serverLevel, itemStack) -> serverLevel.addFreshEntity(
- (level, stack) -> level.addFreshEntity(
- new ItemEntity(
+ (serverLevel, itemStack) -> {
+ // CraftBukkit start
+ ItemEntity item = new ItemEntity(
serverLevel,
+ // CraftBukkit start
+ (level, stack) -> {
+ final ItemEntity item = new ItemEntity(
level,
(double)mutableBlockPos.getX() - Mth.sin(this.cat.yBodyRot * (float) (Math.PI / 180.0)),
mutableBlockPos.getY(),
(double)mutableBlockPos.getZ() + Mth.cos(this.cat.yBodyRot * (float) (Math.PI / 180.0)),
itemStack
stack
- )
- )
+ );
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.cat.getBukkitEntity(), (org.bukkit.entity.Item) item.getBukkitEntity());
+ if (!event.callEvent()) return;
+ serverLevel.addFreshEntity(item);
+ // CraftBukkit end
+ level.addFreshEntity(item);
+ }
+ // CraftBukkit end
);
}
@@ -602,7 +_,7 @@
@@ -615,7 +_,7 @@
static class CatTemptGoal extends TemptGoal {
@Nullable

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/Chicken.java
+++ b/net/minecraft/world/entity/animal/Chicken.java
@@ -91,10 +_,12 @@
@@ -111,10 +_,12 @@
this.flap = this.flap + this.flapping * 2.0F;
if (this.level() instanceof ServerLevel serverLevel && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/Dolphin.java
+++ b/net/minecraft/world/entity/animal/Dolphin.java
@@ -96,6 +_,13 @@
@@ -98,6 +_,13 @@
return EntityType.DOLPHIN.create(level, EntitySpawnReason.BREEDING);
}
@@ -14,7 +14,7 @@
@Override
public float getAgeScale() {
return this.isBaby() ? 0.65F : 1.0F;
@@ -196,7 +_,7 @@
@@ -182,7 +_,7 @@
@Override
public int getMaxAirSupply() {
@@ -23,7 +23,7 @@
}
@Override
@@ -229,11 +_,15 @@
@@ -215,11 +_,15 @@
if (this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty()) {
ItemStack item = entity.getItem();
if (this.canHoldItem(item)) {
@@ -40,7 +40,7 @@
}
}
}
@@ -497,7 +_,7 @@
@@ -486,7 +_,7 @@
@Override
public void start() {
@@ -49,7 +49,7 @@
}
@Override
@@ -516,7 +_,7 @@
@@ -505,7 +_,7 @@
}
if (this.player.isSwimming() && this.player.level().random.nextInt(6) == 0) {
@@ -58,7 +58,7 @@
}
}
}
@@ -586,7 +_,7 @@
@@ -575,7 +_,7 @@
0.3F * Mth.cos(Dolphin.this.getYRot() * (float) (Math.PI / 180.0)) * Mth.cos(Dolphin.this.getXRot() * (float) (Math.PI / 180.0))
+ Mth.sin(f1) * f2
);

View File

@@ -1,15 +1,15 @@
--- a/net/minecraft/world/entity/animal/Fox.java
+++ b/net/minecraft/world/entity/animal/Fox.java
@@ -413,7 +_,7 @@
this.setSleeping(compound.getBoolean("Sleeping"));
this.setVariant(Fox.Variant.byName(compound.getString("Type")));
- this.setSitting(compound.getBoolean("Sitting"));
+ this.setSitting(compound.getBoolean("Sitting"), false); // Paper - Add EntityToggleSitEvent
this.setIsCrouching(compound.getBoolean("Crouching"));
@@ -429,7 +_,7 @@
compound.read("Trusted", TRUSTED_LIST_CODEC).orElse(List.of()).forEach(this::addTrustedEntity);
this.setSleeping(compound.getBooleanOr("Sleeping", false));
this.setVariant(compound.read("Type", Fox.Variant.CODEC).orElse(Fox.Variant.DEFAULT));
- this.setSitting(compound.getBooleanOr("Sitting", false));
+ this.setSitting(compound.getBooleanOr("Sitting", false), false); // Paper - Add EntityToggleSitEvent
this.setIsCrouching(compound.getBooleanOr("Crouching", false));
if (this.level() instanceof ServerLevel) {
this.setTargetGoals();
@@ -425,6 +_,12 @@
@@ -446,6 +_,12 @@
}
public void setSitting(boolean sitting) {
@@ -22,7 +22,7 @@
this.setFlag(1, sitting);
}
@@ -484,19 +_,20 @@
@@ -505,19 +_,20 @@
itemEntity.setPickUpDelay(40);
itemEntity.setThrower(this);
this.playSound(SoundEvents.FOX_SPIT, 1.0F, 1.0F);
@@ -46,7 +46,7 @@
int count = item.getCount();
if (count > 1) {
this.dropItemStack(item.split(count - 1));
@@ -507,7 +_,7 @@
@@ -528,7 +_,7 @@
this.setItemSlot(EquipmentSlot.MAINHAND, item.split(1));
this.setGuaranteedDrop(EquipmentSlot.MAINHAND);
this.take(entity, item.getCount());
@@ -55,8 +55,23 @@
this.ticksSinceEaten = 0;
}
}
@@ -671,15 +_,33 @@
return this.getTrustedUUIDs().contains(uuid);
@@ -623,12 +_,12 @@
}
@Override
- public void setTarget(@Nullable LivingEntity livingEntity) {
+ public boolean setTarget(@Nullable LivingEntity livingEntity, @Nullable org.bukkit.event.entity.EntityTargetEvent.TargetReason reason) { // CraftBukkit
if (this.isDefending() && livingEntity == null) {
this.setDefending(false);
}
- super.setTarget(livingEntity);
+ return super.setTarget(livingEntity, reason); // CraftBukkit
}
void wakeUp() {
@@ -692,15 +_,33 @@
return this.getTrustedEntities().anyMatch(entityReference -> entityReference.matches(entity));
}
- @Override
@@ -93,13 +108,13 @@
}
public static boolean isPathClear(Fox fox, LivingEntity livingEntity) {
@@ -853,6 +_,18 @@
if (loveCause1 != null && loveCause != loveCause1) {
fox.addTrustedUUID(loveCause1.getUUID());
@@ -876,6 +_,19 @@
fox.addTrustedEntity(loveCause1);
}
+ // CraftBukkit start - call EntityBreedEvent
+ fox.setAge(-24000);
+ fox.moveTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F);
+ fox.snapTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F);
+ int experience = this.animal.getRandom().nextInt(7) + 1;
+ org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(fox, this.animal, this.partner, loveCause, this.animal.breedItem, experience);
+ if (entityBreedEvent.isCancelled()) {
@@ -109,15 +124,16 @@
+ }
+ experience = entityBreedEvent.getExperience();
+ // CraftBukkit end - call EntityBreedEvent
+
if (serverPlayer != null) {
serverPlayer.awardStat(Stats.ANIMALS_BRED);
@@ -863,14 +_,12 @@
CriteriaTriggers.BRED_ANIMALS.trigger(serverPlayer, this.animal, this.partner, fox);
@@ -885,14 +_,12 @@
this.partner.setAge(6000);
this.animal.resetLove();
this.partner.resetLove();
- fox.setAge(-24000);
- fox.moveTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F);
- fox.snapTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F);
- serverLevel.addFreshEntityWithPassengers(fox);
+ serverLevel.addFreshEntityWithPassengers(fox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
this.level.broadcastEntityEvent(this.animal, (byte)18);
@@ -130,10 +146,10 @@
);
}
}
@@ -934,6 +_,7 @@
@@ -956,6 +_,7 @@
private void pickSweetBerries(BlockState state) {
int ageValue = state.getValue(SweetBerryBushBlock.AGE);
state.setValue(SweetBerryBushBlock.AGE, Integer.valueOf(1));
state.setValue(SweetBerryBushBlock.AGE, 1);
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(Fox.this, this.blockPos, state.setValue(SweetBerryBushBlock.AGE, 1))) return; // CraftBukkit - call EntityChangeBlockEvent
int i = 1 + Fox.this.level().random.nextInt(2) + (ageValue == 3 ? 1 : 0);
ItemStack itemBySlot = Fox.this.getItemBySlot(EquipmentSlot.MAINHAND);

View File

@@ -1,15 +1,15 @@
--- a/net/minecraft/world/entity/animal/IronGolem.java
+++ b/net/minecraft/world/entity/animal/IronGolem.java
@@ -104,7 +_,7 @@
@@ -105,7 +_,7 @@
@Override
protected void doPush(Entity entity) {
if (entity instanceof Enemy && !(entity instanceof Creeper) && this.getRandom().nextInt(20) == 0) {
- this.setTarget((LivingEntity)entity);
+ this.setTarget((LivingEntity)entity, org.bukkit.event.entity.EntityTargetLivingEntityEvent.TargetReason.COLLISION, true); // CraftBukkit - set reason
+ this.setTarget((LivingEntity)entity, org.bukkit.event.entity.EntityTargetLivingEntityEvent.TargetReason.COLLISION); // CraftBukkit - set reason
}
super.doPush(entity);
@@ -303,7 +_,7 @@
@@ -304,7 +_,7 @@
BlockPos blockPos = this.blockPosition();
BlockPos blockPos1 = blockPos.below();
BlockState blockState = level.getBlockState(blockPos1);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/MushroomCow.java
+++ b/net/minecraft/world/entity/animal/MushroomCow.java
@@ -110,7 +_,17 @@
@@ -116,7 +_,17 @@
return InteractionResult.SUCCESS;
} else if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) {
if (this.level() instanceof ServerLevel serverLevel) {
@@ -19,7 +19,7 @@
this.gameEvent(GameEvent.SHEAR, player);
itemInHand.hurtAndBreak(1, player, getSlotForHand(hand));
}
@@ -163,15 +_,31 @@
@@ -169,15 +_,31 @@
@Override
public void shear(ServerLevel level, SoundSource soundSource, ItemStack shears) {
@@ -40,11 +40,11 @@
+ public void shear(ServerLevel level, SoundSource soundSource, ItemStack shears, java.util.List<ItemStack> drops) {
+ // Paper end
level.playSound(null, this, SoundEvents.MOOSHROOM_SHEAR, soundSource, 1.0F, 1.0F);
this.convertTo(EntityType.COW, ConversionParams.single(this, false, false), mob -> {
this.convertTo(EntityType.COW, ConversionParams.single(this, false, false), cow -> {
level.sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(0.5), this.getZ(), 1, 0.0, 0.0, 0.0, 0.0);
- this.dropFromShearingLootTable(level, BuiltInLootTables.SHEAR_MOOSHROOM, shears, (serverLevel, itemStack) -> {
- for (int i = 0; i < itemStack.getCount(); i++) {
- serverLevel.addFreshEntity(new ItemEntity(this.level(), this.getX(), this.getY(1.0), this.getZ(), itemStack.copyWithCount(1)));
- this.dropFromShearingLootTable(level, BuiltInLootTables.SHEAR_MOOSHROOM, shears, (serverLevel, stack) -> {
- for (int i = 0; i < stack.getCount(); i++) {
- serverLevel.addFreshEntity(new ItemEntity(this.level(), this.getX(), this.getY(1.0), this.getZ(), stack.copyWithCount(1)));
- }
+ // Paper start - custom shear drops; moved drop generation to separate method
+ drops.forEach(drop -> {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/Ocelot.java
+++ b/net/minecraft/world/entity/animal/Ocelot.java
@@ -125,7 +_,7 @@
@@ -126,7 +_,7 @@
@Override
public boolean removeWhenFarAway(double distanceToClosestPlayer) {
@@ -9,7 +9,7 @@
}
public static AttributeSupplier.Builder createAttributes() {
@@ -159,7 +_,7 @@
@@ -160,7 +_,7 @@
if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemInHand) && player.distanceToSqr(this) < 9.0) {
this.usePlayerItem(player, hand, itemInHand);
if (!this.level().isClientSide) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/Panda.java
+++ b/net/minecraft/world/entity/animal/Panda.java
@@ -127,6 +_,7 @@
@@ -128,6 +_,7 @@
}
public void sit(boolean sitting) {
@@ -8,7 +8,7 @@
this.setFlag(8, sitting);
}
@@ -516,24 +_,28 @@
@@ -517,24 +_,28 @@
for (Panda panda : level.getEntitiesOfClass(Panda.class, this.getBoundingBox().inflate(10.0))) {
if (!panda.isBaby() && panda.onGround() && !panda.isInWater() && panda.canPerformAction()) {
@@ -39,7 +39,7 @@
}
}
@@ -624,8 +_,9 @@
@@ -625,8 +_,9 @@
this.usePlayerItem(player, hand, itemInHand);
this.ageUp((int)(-this.getAge() / 20 * 0.1F), true);
} else if (!this.level().isClientSide && this.getAge() == 0 && this.canFallInLove()) {
@@ -50,7 +50,7 @@
} else {
if (!(this.level() instanceof ServerLevel serverLevel) || this.isSitting() || this.isInWater()) {
return InteractionResult.PASS;
@@ -635,7 +_,9 @@
@@ -636,7 +_,9 @@
this.eat(true);
ItemStack itemBySlot = this.getItemBySlot(EquipmentSlot.MAINHAND);
if (!itemBySlot.isEmpty() && !player.hasInfiniteMaterials()) {
@@ -60,16 +60,16 @@
}
this.setItemSlot(EquipmentSlot.MAINHAND, new ItemStack(itemInHand.getItem(), 1));
@@ -861,7 +_,7 @@
@@ -858,7 +_,7 @@
@Override
protected void alertOther(Mob mob, LivingEntity target) {
if (mob instanceof Panda && mob.isAggressive()) {
- mob.setTarget(target);
+ mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit
+ mob.setTarget(target, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY); // CraftBukkit
}
}
}
@@ -1090,7 +_,9 @@
@@ -1087,7 +_,9 @@
public void stop() {
ItemStack itemBySlot = Panda.this.getItemBySlot(EquipmentSlot.MAINHAND);
if (!itemBySlot.isEmpty()) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/Parrot.java
+++ b/net/minecraft/world/entity/animal/Parrot.java
@@ -257,7 +_,7 @@
@@ -262,7 +_,7 @@
}
if (!this.level().isClientSide) {
@@ -9,7 +9,7 @@
this.tame(player);
this.level().broadcastEntityEvent(this, (byte)7);
} else {
@@ -278,7 +_,7 @@
@@ -283,7 +_,7 @@
}
} else {
this.usePlayerItem(player, hand, itemInHand);
@@ -18,7 +18,7 @@
if (player.isCreative() || !this.isInvulnerable()) {
this.hurt(this.damageSources().playerAttack(player), Float.MAX_VALUE);
}
@@ -373,8 +_,8 @@
@@ -378,8 +_,8 @@
}
@Override
@@ -29,7 +29,7 @@
}
@Override
@@ -389,8 +_,13 @@
@@ -394,8 +_,13 @@
if (this.isInvulnerableTo(level, damageSource)) {
return false;
} else {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/Pufferfish.java
+++ b/net/minecraft/world/entity/animal/Pufferfish.java
@@ -95,24 +_,36 @@
@@ -96,24 +_,36 @@
public void tick() {
if (!this.level().isClientSide && this.isAlive() && this.isEffectiveAi()) {
if (this.inflateCounter > 0) {
@@ -37,7 +37,7 @@
this.deflateTimer++;
}
}
@@ -136,7 +_,7 @@
@@ -137,7 +_,7 @@
private void touch(ServerLevel level, Mob mob) {
int puffState = this.getPuffState();
if (mob.hurtServer(level, this.damageSources().mobAttack(this), 1 + puffState)) {
@@ -46,7 +46,7 @@
this.playSound(SoundEvents.PUFFER_FISH_STING, 1.0F, 1.0F);
}
}
@@ -151,7 +_,7 @@
@@ -152,7 +_,7 @@
serverPlayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.PUFFER_FISH_STING, 0.0F));
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/Rabbit.java
+++ b/net/minecraft/world/entity/animal/Rabbit.java
@@ -88,7 +_,7 @@
@@ -95,7 +_,7 @@
super(entityType, level);
this.jumpControl = new Rabbit.RabbitJumpControl(this);
this.moveControl = new Rabbit.RabbitMoveControl(this);
@@ -9,7 +9,7 @@
}
@Override
@@ -561,9 +_,11 @@
@@ -588,9 +_,11 @@
if (this.canRaid && block instanceof CarrotBlock) {
int ageValue = blockState.getValue(CarrotBlock.AGE);
if (ageValue == 0) {
@@ -18,6 +18,6 @@
level.destroyBlock(blockPos, true, this.rabbit);
} else {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockPos, blockState.setValue(CarrotBlock.AGE, ageValue - 1))) return; // CraftBukkit // Paper - fix wrong block state
level.setBlock(blockPos, blockState.setValue(CarrotBlock.AGE, Integer.valueOf(ageValue - 1)), 2);
level.setBlock(blockPos, blockState.setValue(CarrotBlock.AGE, ageValue - 1), 2);
level.gameEvent(GameEvent.BLOCK_CHANGE, blockPos, GameEvent.Context.of(this.rabbit));
level.levelEvent(2001, blockPos, Block.getId(blockState));

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/SnowGolem.java
+++ b/net/minecraft/world/entity/animal/SnowGolem.java
@@ -92,7 +_,7 @@
@@ -91,7 +_,7 @@
super.aiStep();
if (this.level() instanceof ServerLevel serverLevel) {
if (this.level().getBiome(this.blockPosition()).is(BiomeTags.SNOW_GOLEM_MELTS)) {
@@ -9,16 +9,16 @@
}
if (!serverLevel.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
@@ -107,7 +_,7 @@
@@ -106,7 +_,7 @@
int floor2 = Mth.floor(this.getZ() + (i / 2 % 2 * 2 - 1) * 0.25F);
BlockPos blockPos = new BlockPos(floor, floor1, floor2);
if (this.level().getBlockState(blockPos).isAir() && blockState.canSurvive(this.level(), blockPos)) {
- this.level().setBlockAndUpdate(blockPos, blockState);
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level(), blockPos, blockState, this)) continue; // CraftBukkit
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level(), blockPos, blockState, 3, this)) continue; // CraftBukkit
this.level().gameEvent(GameEvent.BLOCK_PLACE, blockPos, GameEvent.Context.of(this, blockState));
}
}
@@ -135,7 +_,19 @@
@@ -134,7 +_,19 @@
ItemStack itemInHand = player.getItemInHand(hand);
if (itemInHand.is(Items.SHEARS) && this.readyForShearing()) {
if (this.level() instanceof ServerLevel serverLevel) {
@@ -39,7 +39,7 @@
this.gameEvent(GameEvent.SHEAR, player);
itemInHand.hurtAndBreak(1, player, getSlotForHand(hand));
}
@@ -148,11 +_,29 @@
@@ -147,11 +_,29 @@
@Override
public void shear(ServerLevel level, SoundSource soundSource, ItemStack shears) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/Turtle.java
+++ b/net/minecraft/world/entity/animal/Turtle.java
@@ -303,7 +_,9 @@
@@ -259,7 +_,9 @@
protected void ageBoundaryReached() {
super.ageBoundaryReached();
if (!this.isBaby() && this.level() instanceof ServerLevel serverLevel && serverLevel.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
@@ -10,7 +10,7 @@
}
}
@@ -328,7 +_,7 @@
@@ -284,7 +_,7 @@
@Override
public void thunderHit(ServerLevel level, LightningBolt lightning) {
@@ -19,7 +19,7 @@
}
@Override
@@ -355,6 +_,10 @@
@@ -311,6 +_,10 @@
if (loveCause == null && this.partner.getLoveCause() != null) {
loveCause = this.partner.getLoveCause();
}
@@ -30,7 +30,7 @@
if (loveCause != null) {
loveCause.awardStat(Stats.ANIMALS_BRED);
@@ -368,7 +_,7 @@
@@ -324,7 +_,7 @@
this.partner.resetLove();
RandomSource random = this.animal.getRandom();
if (getServerLevel(this.level).getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
@@ -39,34 +39,32 @@
}
}
}
@@ -392,7 +_,7 @@
@@ -347,7 +_,7 @@
&& (
this.turtle.hasEgg()
|| this.turtle.getRandom().nextInt(reducedTickDelay(700)) == 0
&& !this.turtle.getHomePos().closerToCenterThan(this.turtle.position(), 64.0)
|| this.turtle.getRandom().nextInt(reducedTickDelay(700)) == 0 && !this.turtle.homePos.closerToCenterThan(this.turtle.position(), 64.0)
- );
+ ) && new com.destroystokyo.paper.event.entity.TurtleGoHomeEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity()).callEvent(); // Paper - Turtle API
}
@Override
@@ -500,16 +_,22 @@
@@ -455,14 +_,20 @@
BlockPos blockPos = this.turtle.blockPosition();
if (!this.turtle.isInWater() && this.isReachedTarget()) {
if (this.turtle.layEggCounter < 1) {
- this.turtle.setLayingEgg(true);
+ this.turtle.setLayingEgg(new com.destroystokyo.paper.event.entity.TurtleStartDiggingEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), io.papermc.paper.util.MCUtil.toLocation(this.turtle.level(), this.blockPos)).callEvent()); // Paper - Turtle API
+ this.turtle.setLayingEgg(new com.destroystokyo.paper.event.entity.TurtleStartDiggingEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.blockPos, this.turtle.level())).callEvent()); // Paper - Turtle API
} else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) {
+ // Paper start - Turtle API
+ int eggCount = this.turtle.random.nextInt(4) + 1;
+ com.destroystokyo.paper.event.entity.TurtleLayEggEvent layEggEvent = new com.destroystokyo.paper.event.entity.TurtleLayEggEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), io.papermc.paper.util.MCUtil.toLocation(this.turtle.level(), this.blockPos.above()), eggCount);
+ com.destroystokyo.paper.event.entity.TurtleLayEggEvent layEggEvent = new com.destroystokyo.paper.event.entity.TurtleLayEggEvent((org.bukkit.entity.Turtle) this.turtle.getBukkitEntity(), org.bukkit.craftbukkit.util.CraftLocation.toBukkit(this.blockPos.above(), this.turtle.level()), eggCount);
+ if (layEggEvent.callEvent() && org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, layEggEvent.getEggCount()))) {
+ // Paper end - Turtle API
Level level = this.turtle.level();
level.playSound(null, blockPos, SoundEvents.TURTLE_LAY_EGG, SoundSource.BLOCKS, 0.3F, 0.9F + level.random.nextFloat() * 0.2F);
BlockPos blockPos1 = this.blockPos.above();
BlockState blockState = Blocks.TURTLE_EGG
.defaultBlockState()
- .setValue(TurtleEggBlock.EGGS, Integer.valueOf(this.turtle.random.nextInt(4) + 1));
+ .setValue(TurtleEggBlock.EGGS, layEggEvent.getEggCount()); // Paper
- BlockState blockState = Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, this.turtle.random.nextInt(4) + 1);
+ BlockState blockState = Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, layEggEvent.getEggCount()); // Paper
level.setBlock(blockPos1, blockState, 3);
level.gameEvent(GameEvent.BLOCK_PLACE, blockPos1, GameEvent.Context.of(this.turtle, blockState));
+ } // CraftBukkit

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/WaterAnimal.java
+++ b/net/minecraft/world/entity/animal/WaterAnimal.java
@@ -70,6 +_,10 @@
@@ -72,6 +_,10 @@
) {
int seaLevel = level.getSeaLevel();
int i = seaLevel - 13;

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/allay/Allay.java
+++ b/net/minecraft/world/entity/animal/allay/Allay.java
@@ -118,6 +_,7 @@
@@ -116,6 +_,7 @@
private float dancingAnimationTicks;
private float spinningAnimationTicks;
private float spinningAnimationTicks0;
@@ -8,7 +8,7 @@
public Allay(EntityType<? extends Allay> entityType, Level level) {
super(entityType, level);
@@ -131,6 +_,12 @@
@@ -129,6 +_,12 @@
);
}
@@ -21,7 +21,7 @@
@Override
protected Brain.Provider<Allay> brainProvider() {
return Brain.provider(MEMORY_TYPES, SENSOR_TYPES);
@@ -252,7 +_,7 @@
@@ -248,7 +_,7 @@
public void aiStep() {
super.aiStep();
if (!this.level().isClientSide && this.isAlive() && this.tickCount % 10 == 0) {
@@ -30,7 +30,7 @@
}
if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) {
@@ -320,7 +_,12 @@
@@ -316,7 +_,12 @@
ItemStack itemInHand = player.getItemInHand(hand);
ItemStack itemInHand1 = this.getItemInHand(InteractionHand.MAIN_HAND);
if (this.isDancing() && itemInHand.is(ItemTags.DUPLICATES_ALLAYS) && this.canDuplicate()) {
@@ -44,7 +44,7 @@
this.level().broadcastEntityEvent(this, (byte)18);
this.level().playSound(player, this, SoundEvents.AMETHYST_BLOCK_CHIME, SoundSource.NEUTRAL, 2.0F, 1.0F);
this.removeInteractionItem(player, itemInHand);
@@ -425,6 +_,7 @@
@@ -421,6 +_,7 @@
}
private boolean shouldStopDancing() {
@@ -52,24 +52,24 @@
return this.jukeboxPos == null
|| !this.jukeboxPos.closerToCenterThan(this.position(), GameEvent.JUKEBOX_PLAY.value().notificationRadius())
|| !this.level().getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX);
@@ -489,7 +_,7 @@
.ifPresent(data -> this.vibrationData = data);
}
- this.duplicationCooldown = compound.getInt("DuplicationCooldown");
+ this.duplicationCooldown = compound.getLong("DuplicationCooldown"); // Paper - Load as long
this.entityData.set(DATA_CAN_DUPLICATE, compound.getBoolean("CanDuplicate"));
@@ -475,7 +_,7 @@
this.readInventoryFromTag(compound, this.registryAccess());
RegistryOps<Tag> registryOps = this.registryAccess().createSerializationContext(NbtOps.INSTANCE);
this.vibrationData = compound.read("listener", VibrationSystem.Data.CODEC, registryOps).orElseGet(VibrationSystem.Data::new);
- this.setDuplicationCooldown(compound.getIntOr("DuplicationCooldown", 0));
+ this.setDuplicationCooldown(compound.getLongOr("DuplicationCooldown", 0)); // Paper - Load as long
}
@@ -508,15 +_,17 @@
}
@Override
@@ -494,15 +_,17 @@
this.entityData.set(DATA_CAN_DUPLICATE, duplicationCooldown == 0L);
}
- public void duplicateAllay() {
+ @Nullable public Allay duplicateAllay() { // CraftBukkit - return allay
Allay allay = EntityType.ALLAY.create(this.level(), EntitySpawnReason.BREEDING);
if (allay != null) {
allay.moveTo(this.position());
allay.snapTo(this.position());
allay.setPersistenceRequired();
allay.resetDuplicationCooldown();
this.resetDuplicationCooldown();

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java
+++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java
@@ -141,10 +_,12 @@
@@ -142,10 +_,12 @@
ArmadilloAi.updateActivity(this);
profilerFiller.pop();
if (this.isAlive() && !this.isBaby() && --this.scuteTime <= 0) {
@@ -13,7 +13,7 @@
this.scuteTime = this.pickNextScuteDropTime();
}
@@ -283,8 +_,11 @@
@@ -282,8 +_,11 @@
}
@Override
@@ -27,7 +27,7 @@
if (!this.isNoAi() && !this.isDeadOrDying()) {
if (damageSource.getEntity() instanceof LivingEntity) {
this.getBrain().setMemoryWithExpiry(MemoryModuleType.DANGER_DETECTED_RECENTLY, true, 80L);
@@ -295,6 +_,7 @@
@@ -294,6 +_,7 @@
this.rollOut();
}
}
@@ -35,7 +35,7 @@
}
@Override
@@ -313,7 +_,9 @@
@@ -312,7 +_,9 @@
return false;
} else {
if (this.level() instanceof ServerLevel serverLevel) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java
+++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java
@@ -226,7 +_,7 @@
@@ -231,7 +_,7 @@
@Override
public int getMaxAirSupply() {
@@ -8,8 +8,8 @@
+ return this.maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
}
@Override
@@ -426,10 +_,10 @@
public Axolotl.Variant getVariant() {
@@ -449,10 +_,10 @@
if (effect == null || effect.endsWithin(2399)) {
int i = effect != null ? effect.getDuration() : 0;
int min = Math.min(2400, 100 + i);
@@ -17,12 +17,12 @@
+ player.addEffect(new MobEffectInstance(MobEffects.REGENERATION, min, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AXOLOTL); // CraftBukkit
}
- player.removeEffect(MobEffects.DIG_SLOWDOWN);
+ player.removeEffect(MobEffects.DIG_SLOWDOWN, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AXOLOTL); // Paper - Add missing effect cause
- player.removeEffect(MobEffects.MINING_FATIGUE);
+ player.removeEffect(MobEffects.MINING_FATIGUE, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AXOLOTL); // Paper - Add missing effect cause
}
@Override
@@ -521,6 +_,13 @@
@@ -544,6 +_,13 @@
) {
return level.getBlockState(pos.below()).is(BlockTags.AXOLOTLS_SPAWNABLE_ON);
}
@@ -30,7 +30,7 @@
+ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
+ @Override
+ public int getDefaultMaxAirSupply() {
+ return Axolotl.AXOLOTL_TOTAL_AIR_SUPPLY;
+ return AXOLOTL_TOTAL_AIR_SUPPLY;
+ }
+ // CraftBukkit end

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/camel/Camel.java
+++ b/net/minecraft/world/entity/animal/camel/Camel.java
@@ -386,12 +_,12 @@
@@ -398,12 +_,12 @@
} else {
boolean flag = this.getHealth() < this.getMaxHealth();
if (flag) {
@@ -15,7 +15,7 @@
}
boolean isBaby = this.isBaby();
@@ -451,9 +_,13 @@
@@ -463,9 +_,13 @@
}
@Override
@@ -31,7 +31,7 @@
}
@Override
@@ -554,7 +_,7 @@
@@ -566,7 +_,7 @@
}
public void sitDown() {
@@ -40,7 +40,7 @@
this.makeSound(SoundEvents.CAMEL_SIT);
this.setPose(Pose.SITTING);
this.gameEvent(GameEvent.ENTITY_ACTION);
@@ -563,7 +_,7 @@
@@ -575,7 +_,7 @@
}
public void standUp() {
@@ -49,7 +49,7 @@
this.makeSound(SoundEvents.CAMEL_STAND);
this.setPose(Pose.STANDING);
this.gameEvent(GameEvent.ENTITY_ACTION);
@@ -572,6 +_,7 @@
@@ -584,6 +_,7 @@
}
public void standUpInstantly() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/frog/Frog.java
+++ b/net/minecraft/world/entity/animal/frog/Frog.java
@@ -270,7 +_,12 @@
@@ -287,7 +_,12 @@
@Override
public void spawnChildFromBreeding(ServerLevel level, Animal mate) {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/frog/Tadpole.java
+++ b/net/minecraft/world/entity/animal/frog/Tadpole.java
@@ -62,6 +_,7 @@
@@ -63,6 +_,7 @@
MemoryModuleType.BREED_TARGET,
MemoryModuleType.IS_PANICKING
);
@@ -8,7 +8,7 @@
public Tadpole(EntityType<? extends AbstractFish> entityType, Level level) {
super(entityType, level);
@@ -113,7 +_,7 @@
@@ -114,7 +_,7 @@
@Override
public void aiStep() {
super.aiStep();
@@ -17,7 +17,7 @@
this.setAge(this.age + 1);
}
}
@@ -122,12 +_,14 @@
@@ -123,12 +_,14 @@
public void addAdditionalSaveData(CompoundTag compound) {
super.addAdditionalSaveData(compound);
compound.putInt("Age", this.age);
@@ -27,12 +27,12 @@
@Override
public void readAdditionalSaveData(CompoundTag compound) {
super.readAdditionalSaveData(compound);
this.setAge(compound.getInt("Age"));
+ this.ageLocked = compound.getBoolean("AgeLocked"); // Paper
this.setAge(compound.getIntOr("Age", 0));
+ this.ageLocked = compound.getBooleanOr("AgeLocked", false); // Paper
}
@Nullable
@@ -177,7 +_,12 @@
@@ -178,13 +_,19 @@
@Override
public void saveToBucketTag(ItemStack stack) {
Bucketable.saveDefaultDataToBucketTag(this, stack);
@@ -46,15 +46,14 @@
}
@Override
@@ -186,6 +_,7 @@
if (tag.contains("Age")) {
this.setAge(tag.getInt("Age"));
}
+ this.ageLocked = tag.getBoolean("AgeLocked"); // Paper
public void loadFromBucketTag(CompoundTag tag) {
Bucketable.loadDefaultDataFromBucketTag(this, tag);
tag.getInt("Age").ifPresent(this::setAge);
+ this.ageLocked = tag.getBooleanOr("AgeLocked", false); // Paper
}
@Override
@@ -217,6 +_,7 @@
@@ -216,6 +_,7 @@
}
private void ageUp(int offset) {
@@ -62,7 +61,7 @@
this.setAge(this.age + offset * 20);
}
@@ -229,12 +_,17 @@
@@ -228,12 +_,17 @@
private void ageUp() {
if (this.level() instanceof ServerLevel serverLevel) {

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/entity/animal/goat/Goat.java
+++ b/net/minecraft/world/entity/animal/goat/Goat.java
@@ -231,13 +_,22 @@
@@ -234,13 +_,22 @@
public InteractionResult mobInteract(Player player, InteractionHand hand) {
ItemStack itemInHand = player.getItemInHand(hand);
if (itemInHand.is(Items.BUCKET) && !this.isBaby()) {
+ // CraftBukkit start - Got milk?
+ org.bukkit.event.player.PlayerBucketFillEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketFillEvent((ServerLevel) player.level(), player, this.blockPosition(), this.blockPosition(), null, itemInHand, Items.MILK_BUCKET, hand);
+ org.bukkit.event.player.PlayerBucketFillEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerBucketFillEvent(player.level(), player, this.blockPosition(), this.blockPosition(), null, itemInHand, Items.MILK_BUCKET, hand);
+
+ if (event.isCancelled()) {
+ player.containerMenu.sendAllDataToRemote(); // Paper - Fix inventory desync
@@ -25,7 +25,7 @@
this.playEatingSound();
}
@@ -349,8 +_,7 @@
@@ -352,8 +_,7 @@
double d1 = Mth.randomBetween(this.random, 0.3F, 0.7F);
double d2 = Mth.randomBetween(this.random, -0.2F, 0.2F);
ItemEntity itemEntity = new ItemEntity(this.level(), vec3.x(), vec3.y(), vec3.z(), itemStack, d, d1, d2);
@@ -35,7 +35,7 @@
}
}
@@ -381,4 +_,15 @@
@@ -384,4 +_,15 @@
) {
return level.getBlockState(pos.below()).is(BlockTags.GOATS_SPAWNABLE_ON) && isBrightEnoughToSpawn(level, pos);
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java
+++ b/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java
@@ -69,6 +_,12 @@
@@ -70,6 +_,12 @@
super.dropEquipment(level);
if (this.hasChest()) {
this.spawnAtLocation(level, Blocks.CHEST);

View File

@@ -1,78 +1,14 @@
--- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java
+++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java
@@ -77,6 +_,17 @@
import net.minecraft.world.phys.Vec3;
import net.minecraft.world.ticks.ContainerSingleItem;
+// CraftBukkit start
+import java.util.Arrays;
+import java.util.List;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.event.entity.EntityRegainHealthEvent;
+import org.bukkit.inventory.InventoryHolder;
+// CraftBukkit end
+
public abstract class AbstractHorse extends Animal implements ContainerListener, HasCustomInventoryScreen, OwnableEntity, PlayerRideableJumping, Saddleable {
public static final int EQUIPMENT_SLOT_OFFSET = 400;
public static final int CHEST_SLOT_OFFSET = 499;
@@ -145,7 +_,53 @@
public boolean stillValid(Player player) {
return player.getVehicle() == AbstractHorse.this || player.canInteractWithEntity(AbstractHorse.this, 4.0);
}
+
+ // CraftBukkit start - add fields and methods
+ public final List<HumanEntity> transaction = new java.util.ArrayList<>();
+ private int maxStack = MAX_STACK;
+
+ @Override
+ public List<ItemStack> getContents() {
+ return Arrays.asList(this.getTheItem());
+ }
+
+ @Override
+ public void onOpen(CraftHumanEntity player) {
+ this.transaction.add(player);
+ }
+
+ @Override
+ public void onClose(CraftHumanEntity player) {
+ this.transaction.remove(player);
+ }
+
+ @Override
+ public List<HumanEntity> getViewers() {
+ return this.transaction;
+ }
+
+ @Override
+ public int getMaxStackSize() {
+ return this.maxStack;
+ }
+
+ @Override
+ public void setMaxStackSize(int size) {
+ this.maxStack = size;
+ }
+
+ @Override
+ public InventoryHolder getOwner() {
+ return (org.bukkit.entity.AbstractHorse) AbstractHorse.this.getBukkitEntity();
+ }
+
+ @Override
+ public Location getLocation() {
+ return AbstractHorse.this.getBukkitEntity().getLocation();
+ }
+ // CraftBukkit end
};
@@ -122,6 +_,7 @@
protected int gallopSoundCounter;
@Nullable
public EntityReference<LivingEntity> owner;
+ public int maxDomestication = 100; // CraftBukkit - store max domestication value
protected AbstractHorse(EntityType<? extends AbstractHorse> entityType, Level level) {
super(entityType, level);
@@ -284,7 +_,7 @@
@@ -250,7 +_,7 @@
}
@Override
@@ -81,25 +17,25 @@
return !this.isVehicle();
}
@@ -340,7 +_,7 @@
@@ -301,7 +_,7 @@
public void createInventory() {
SimpleContainer simpleContainer = this.inventory;
- this.inventory = new SimpleContainer(this.getInventorySize());
+ this.inventory = new SimpleContainer(this.getInventorySize(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit
if (simpleContainer != null) {
simpleContainer.removeListener(this);
int min = Math.min(simpleContainer.getContainerSize(), this.inventory.getContainerSize());
@@ -448,7 +_,7 @@
@@ -395,7 +_,7 @@
}
public int getMaxTemper() {
- return 100;
+ return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100
+ return this.maxDomestication; // CraftBukkit - return stored max domestication instead
}
@Override
@@ -503,7 +_,7 @@
@@ -450,7 +_,7 @@
i1 = 5;
if (!this.level().isClientSide && this.isTamed() && this.getAge() == 0 && !this.isInLove()) {
flag = true;
@@ -108,7 +44,7 @@
}
} else if (stack.is(Items.GOLDEN_APPLE) || stack.is(Items.ENCHANTED_GOLDEN_APPLE)) {
f = 10.0F;
@@ -511,12 +_,12 @@
@@ -458,12 +_,12 @@
i1 = 10;
if (!this.level().isClientSide && this.isTamed() && this.getAge() == 0 && !this.isInLove()) {
flag = true;
@@ -119,20 +55,20 @@
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
- this.heal(f);
+ this.heal(f, EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
+ this.heal(f, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
flag = true;
}
@@ -587,7 +_,7 @@
@@ -534,7 +_,7 @@
super.aiStep();
if (this.level() instanceof ServerLevel serverLevel && this.isAlive()) {
if (this.random.nextInt(900) == 0 && this.deathTime == 0) {
- this.heal(1.0F);
+ this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
+ this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
}
if (this.canEatGrass()) {
@@ -690,6 +_,16 @@
@@ -637,6 +_,16 @@
}
}
@@ -149,7 +85,7 @@
@Override
public InteractionResult mobInteract(Player player, InteractionHand hand) {
if (this.isVehicle() || this.isBaby()) {
@@ -727,6 +_,12 @@
@@ -674,6 +_,12 @@
this.setFlag(16, eating);
}
@@ -162,27 +98,23 @@
public void setStanding(boolean standing) {
if (standing) {
this.setEating(false);
@@ -838,6 +_,7 @@
if (this.getOwnerUUID() != null) {
compound.putUUID("Owner", this.getOwnerUUID());
@@ -785,6 +_,7 @@
if (this.owner != null) {
this.owner.store(compound, "Owner");
}
+ compound.putInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit
+ compound.putInt("Bukkit.MaxDomestication", this.maxDomestication); // Paper - max domestication
}
if (!this.inventory.getItem(0).isEmpty()) {
compound.put("SaddleItem", this.inventory.getItem(0).save(this.registryAccess()));
@@ -862,6 +_,11 @@
if (uuid != null) {
this.setOwnerUUID(uuid);
}
+ // CraftBukkit start
+ if (compound.contains("Bukkit.MaxDomestication")) {
+ this.maxDomestication = compound.getInt("Bukkit.MaxDomestication");
+ }
+ // CraftBukkit end
@Override
@@ -795,6 +_,7 @@
this.setTemper(compound.getIntOr("Temper", 0));
this.setTamed(compound.getBooleanOr("Tame", false));
this.owner = EntityReference.readWithOldOwnerConversion(compound, "Owner", this.level());
+ this.maxDomestication = compound.getIntOr("Bukkit.MaxDomestication", this instanceof Llama ? 30 : 100); // Paper - max domestication
}
if (compound.contains("SaddleItem", 10)) {
ItemStack itemStack = ItemStack.parse(this.registryAccess(), compound.getCompound("SaddleItem")).orElse(ItemStack.EMPTY);
@@ -959,6 +_,17 @@
@Override
@@ -883,6 +_,17 @@
@Override
public void handleStartJump(int jumpPower) {
@@ -193,7 +125,7 @@
+ } else {
+ power = 0.4F + 0.4F * (float) jumpPower / 90.0F;
+ }
+ if (!CraftEventFactory.callHorseJumpEvent(this, power)) {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callHorseJumpEvent(this, power)) {
+ return;
+ }
+ // CraftBukkit end

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/horse/Llama.java
+++ b/net/minecraft/world/entity/animal/horse/Llama.java
@@ -71,17 +_,23 @@
@@ -76,17 +_,23 @@
@Nullable
private Llama caravanHead;
@Nullable
@@ -25,7 +25,7 @@
private void setStrength(int strength) {
this.entityData.set(DATA_STRENGTH_ID, Math.max(1, Math.min(5, strength)));
}
@@ -168,12 +_,12 @@
@@ -193,12 +_,12 @@
f = 10.0F;
if (this.isTamed() && this.getAge() == 0 && this.canFallInLove()) {
flag = true;
@@ -40,7 +40,7 @@
flag = true;
}
@@ -295,7 +_,7 @@
@@ -312,7 +_,7 @@
@Override
public int getMaxTemper() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/horse/SkeletonHorse.java
+++ b/net/minecraft/world/entity/animal/horse/SkeletonHorse.java
@@ -122,7 +_,7 @@
@@ -124,7 +_,7 @@
public void aiStep() {
super.aiStep();
if (this.isTrap() && this.trapTime++ >= 18000) {

View File

@@ -25,7 +25,7 @@
this.horse.setTamed(true);
@@ -39,11 +_,11 @@
if (lightningBolt != null) {
lightningBolt.moveTo(this.horse.getX(), this.horse.getY(), this.horse.getZ());
lightningBolt.snapTo(this.horse.getX(), this.horse.getY(), this.horse.getZ());
lightningBolt.setVisualOnly(true);
- serverLevel.addFreshEntity(lightningBolt);
+ serverLevel.strikeLightning(lightningBolt, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRAP); // CraftBukkit

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/horse/TraderLlama.java
+++ b/net/minecraft/world/entity/animal/horse/TraderLlama.java
@@ -89,7 +_,7 @@
@@ -88,7 +_,7 @@
this.despawnDelay = this.isLeashedToWanderingTrader() ? ((WanderingTrader)this.getLeashHolder()).getDespawnDelay() - 1 : this.despawnDelay - 1;
if (this.despawnDelay <= 0) {
this.removeLeash();
@@ -9,12 +9,12 @@
}
}
}
@@ -148,7 +_,7 @@
@@ -147,7 +_,7 @@
@Override
public void start() {
- this.mob.setTarget(this.ownerLastHurtBy);
+ this.mob.setTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit
+ this.mob.setTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER); // CraftBukkit
Entity leashHolder = this.llama.getLeashHolder();
if (leashHolder instanceof WanderingTrader) {
this.timestamp = ((WanderingTrader)leashHolder).getLastHurtByMobTimestamp();

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/Sheep.java
+++ b/net/minecraft/world/entity/animal/Sheep.java
@@ -158,7 +_,19 @@
--- a/net/minecraft/world/entity/animal/sheep/Sheep.java
+++ b/net/minecraft/world/entity/animal/sheep/Sheep.java
@@ -161,7 +_,19 @@
ItemStack itemInHand = player.getItemInHand(hand);
if (itemInHand.is(Items.SHEARS)) {
if (this.level() instanceof ServerLevel serverLevel && this.readyForShearing()) {
@@ -21,7 +21,7 @@
this.gameEvent(GameEvent.SHEAR, player);
itemInHand.hurtAndBreak(1, player, getSlotForHand(hand));
return InteractionResult.SUCCESS_SERVER;
@@ -172,14 +_,28 @@
@@ -175,14 +_,28 @@
@Override
public void shear(ServerLevel level, SoundSource soundSource, ItemStack shears) {
@@ -57,7 +57,7 @@
if (itemEntity != null) {
itemEntity.setDeltaMovement(
itemEntity.getDeltaMovement()
@@ -287,6 +_,7 @@
@@ -302,6 +_,7 @@
@Override
public void ate() {

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/Wolf.java
+++ b/net/minecraft/world/entity/animal/Wolf.java
@@ -344,8 +_,9 @@
--- a/net/minecraft/world/entity/animal/wolf/Wolf.java
+++ b/net/minecraft/world/entity/animal/wolf/Wolf.java
@@ -400,16 +_,18 @@
if (this.isInvulnerableTo(level, damageSource)) {
return false;
} else {
@@ -11,9 +11,6 @@
}
}
@@ -355,10 +_,11 @@
}
@Override
- protected void actuallyHurt(ServerLevel level, DamageSource damageSource, float amount) {
+ public boolean actuallyHurt(ServerLevel level, DamageSource damageSource, float amount, org.bukkit.event.entity.EntityDamageEvent event) { // CraftBukkit - void -> boolean
@@ -25,7 +22,7 @@
ItemStack bodyArmorItem = this.getBodyArmorItem();
int damageValue = bodyArmorItem.getDamageValue();
int maxDamage = bodyArmorItem.getMaxDamage();
@@ -378,6 +_,7 @@
@@ -429,6 +_,7 @@
);
}
}
@@ -33,7 +30,7 @@
}
private boolean canArmorAbsorb(DamageSource damageSource) {
@@ -388,7 +_,7 @@
@@ -439,7 +_,7 @@
protected void applyTamingSideEffects() {
if (this.isTame()) {
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(40.0);
@@ -42,7 +39,7 @@
} else {
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(8.0);
}
@@ -408,7 +_,7 @@
@@ -459,7 +_,7 @@
this.usePlayerItem(player, hand, itemInHand);
FoodProperties foodProperties = itemInHand.get(DataComponents.FOOD);
float f = foodProperties != null ? foodProperties.nutrition() : 1.0F;
@@ -51,16 +48,16 @@
return InteractionResult.SUCCESS;
}
@@ -441,7 +_,7 @@
@@ -492,7 +_,7 @@
this.setOrderedToSit(!this.isOrderedToSit());
this.jumping = false;
this.navigation.stop();
- this.setTarget(null);
+ this.setTarget(null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason
+ this.setTarget(null, org.bukkit.event.entity.EntityTargetEvent.TargetReason.FORGOT_TARGET); // CraftBukkit - reason
return InteractionResult.SUCCESS.withoutItem();
}
@@ -453,7 +_,9 @@
@@ -504,7 +_,9 @@
ItemStack bodyArmorItem = this.getBodyArmorItem();
this.setBodyArmorItem(ItemStack.EMPTY);
if (this.level() instanceof ServerLevel serverLevel) {
@@ -70,7 +67,7 @@
}
return InteractionResult.SUCCESS;
@@ -461,6 +_,13 @@
@@ -512,6 +_,13 @@
DyeColor dyeColor = dyeItem.getDyeColor();
if (dyeColor != this.getCollarColor()) {
@@ -84,7 +81,7 @@
this.setCollarColor(dyeColor);
itemInHand.consume(1, player);
return InteractionResult.SUCCESS;
@@ -475,7 +_,7 @@
@@ -526,7 +_,7 @@
}
private void tryToTame(Player player) {