From df822c00c9df97ccca518bdf618fb0a189e8c9c8 Mon Sep 17 00:00:00 2001 From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com> Date: Mon, 21 Jun 2021 23:56:07 -0400 Subject: [PATCH] Missing Entity API == AT == public net.minecraft.world.entity.animal.Fox isDefending()Z public net.minecraft.world.entity.animal.Fox setDefending(Z)V public net.minecraft.world.entity.animal.Fox setFaceplanted(Z)V public net.minecraft.world.entity.animal.Panda getEatCounter()I public net.minecraft.world.entity.animal.Panda setEatCounter(I)V public net.minecraft.world.entity.animal.Bee isRolling()Z public net.minecraft.world.entity.animal.Bee setRolling(Z)V public net.minecraft.world.entity.animal.Bee numCropsGrownSincePollination public net.minecraft.world.entity.animal.Bee ticksWithoutNectarSinceExitingHive public net.minecraft.world.entity.monster.piglin.Piglin isChargingCrossbow()Z public net.minecraft.world.entity.ambient.Bat targetPosition public net.minecraft.world.entity.monster.Ravager attackTick public net.minecraft.world.entity.monster.Ravager stunnedTick public net.minecraft.world.entity.monster.Ravager roarTick public net.minecraft.world.entity.vehicle.MinecartTNT explode(D)V public net.minecraft.world.entity.vehicle.MinecartTNT fuse public net.minecraft.world.entity.monster.Endermite life public net.minecraft.world.entity.projectile.AbstractArrow soundEvent public net.minecraft.world.entity.monster.Phantom anchorPoint public net.minecraft.world.entity.npc.WanderingTrader getWanderTarget()Lnet/minecraft/core/BlockPos; public net.minecraft.world.entity.animal.AbstractSchoolingFish leader public net.minecraft.world.entity.animal.AbstractSchoolingFish schoolSize public net.minecraft.world.entity.animal.Rabbit moreCarrotTicks public net.minecraft.world.entity.AreaEffectCloud ownerUUID public net.minecraft.world.entity.animal.MushroomCow stewEffects public net.minecraft.world.entity.Entity FLAG_INVISIBLE public net.minecraft.world.entity.animal.Cat setRelaxStateOne(Z)V public net.minecraft.world.entity.animal.Cat isRelaxStateOne()Z Co-authored-by: Nassim Jahnke Co-authored-by: Jake Potrebic Co-authored-by: William Blake Galbreath Co-authored-by: SoSeDiK Co-authored-by: booky10 Co-authored-by: Amin Co-authored-by: TrollyLoki Co-authored-by: FireInstall Co-authored-by: maxcom1 <46265094+maxcom1@users.noreply.github.com> Co-authored-by: TotalledZebra --- .../animal/AbstractSchoolingFish.java.patch | 10 ++++ .../world/entity/animal/Bee.java.patch | 26 ++++++-- .../entity/animal/frog/Tadpole.java.patch | 60 ++++++++++++++++++- .../animal/horse/AbstractHorse.java.patch | 44 +++++++++++--- .../entity/animal/horse/Llama.java.patch | 24 +++++++- .../entity/boss/wither/WitherBoss.java.patch | 32 ++++++++-- .../world/entity/monster/EnderMan.java.patch | 25 ++++++-- .../world/entity/monster/Ghast.java.patch | 16 ++++- .../entity/monster/ZombieVillager.java.patch | 19 ++++-- .../projectile/ThrownTrident.java.patch | 23 ++++++- .../paper/entity/ai/MobGoalHelper.java | 2 +- .../paper/entity/PaperSchoolableFish.java | 52 ++++++++++++++++ .../entity/CraftAbstractHorse.java | 32 ++++++++++ .../entity/CraftAreaEffectCloud.java | 13 ++++ .../bukkit/craftbukkit/entity/CraftBat.java | 21 +++++++ .../bukkit/craftbukkit/entity/CraftBee.java | 38 ++++++++++++ .../bukkit/craftbukkit/entity/CraftCat.java | 22 +++++++ .../craftbukkit/entity/CraftChicken.java | 22 +++++++ .../bukkit/craftbukkit/entity/CraftCod.java | 2 +- .../craftbukkit/entity/CraftDolphin.java | 32 ++++++++++ .../entity/CraftEnderDragonPart.java | 7 +++ .../craftbukkit/entity/CraftEnderman.java | 22 +++++++ .../craftbukkit/entity/CraftEndermite.java | 11 ++++ .../craftbukkit/entity/CraftEntity.java | 23 +++++++ .../craftbukkit/entity/CraftFireball.java | 12 ++++ .../bukkit/craftbukkit/entity/CraftFox.java | 37 ++++++++++++ .../bukkit/craftbukkit/entity/CraftGhast.java | 13 ++++ .../craftbukkit/entity/CraftLivingEntity.java | 28 ++++++++- .../bukkit/craftbukkit/entity/CraftLlama.java | 32 ++++++++++ .../entity/CraftMinecartHopper.java | 16 +++++ .../bukkit/craftbukkit/entity/CraftMob.java | 12 ++++ .../bukkit/craftbukkit/entity/CraftPanda.java | 32 ++++++++++ .../craftbukkit/entity/CraftPhantom.java | 12 ++++ .../craftbukkit/entity/CraftPiglin.java | 33 ++++++++++ .../craftbukkit/entity/CraftPolarBear.java | 12 ++++ .../craftbukkit/entity/CraftRabbit.java | 11 ++++ .../craftbukkit/entity/CraftRavager.java | 31 ++++++++++ .../craftbukkit/entity/CraftSalmon.java | 2 +- .../craftbukkit/entity/CraftTNTPrimed.java | 13 ++++ .../craftbukkit/entity/CraftTadpole.java | 11 ++++ .../craftbukkit/entity/CraftTrident.java | 23 +++++++ .../craftbukkit/entity/CraftTropicalFish.java | 2 +- .../bukkit/craftbukkit/entity/CraftVex.java | 20 +++++++ .../entity/CraftVillagerZombie.java | 9 ++- .../entity/CraftWanderingTrader.java | 20 +++++++ .../craftbukkit/entity/CraftWarden.java | 7 +++ .../craftbukkit/entity/CraftWither.java | 32 ++++++++++ 47 files changed, 958 insertions(+), 40 deletions(-) create mode 100644 paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractSchoolingFish.java.patch create mode 100644 paper-server/src/main/java/io/papermc/paper/entity/PaperSchoolableFish.java diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractSchoolingFish.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractSchoolingFish.java.patch new file mode 100644 index 0000000000..69bd0b2aef --- /dev/null +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/AbstractSchoolingFish.java.patch @@ -0,0 +1,10 @@ +--- a/net/minecraft/world/entity/animal/AbstractSchoolingFish.java ++++ b/net/minecraft/world/entity/animal/AbstractSchoolingFish.java +@@ -51,6 +51,7 @@ + } + + public void stopFollowing() { ++ if (this.leader == null) return; // Avoid NPE, plugins can now set the leader and certain fish goals might cause this method to be called + this.leader.removeFollower(); + this.leader = null; + } 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 59e6087ef6..7fb1521e10 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 @@ -110,7 +110,21 @@ } boolean isHiveValid() { -@@ -671,8 +703,14 @@ +@@ -533,11 +565,13 @@ + this.setFlag(4, hasStung); + } + ++ public net.kyori.adventure.util.TriState rollingOverride = net.kyori.adventure.util.TriState.NOT_SET; // Paper - Rolling override + public boolean isRolling() { + return this.getFlag(2); + } + + public void setRolling(boolean nearTarget) { ++ nearTarget = rollingOverride.toBooleanOrElse(nearTarget); // Paper - Rolling override + this.setFlag(2, nearTarget); + } + +@@ -671,8 +705,14 @@ if (this.isInvulnerableTo(world, source)) { return false; } else { @@ -126,7 +140,7 @@ } } -@@ -1082,7 +1120,7 @@ +@@ -1082,7 +1122,7 @@ BeeGoToHiveGoal() { super(); @@ -135,7 +149,7 @@ this.blacklistedTargets = Lists.newArrayList(); this.setFlags(EnumSet.of(Goal.Flag.MOVE)); } -@@ -1196,7 +1234,7 @@ +@@ -1196,7 +1236,7 @@ BeeGoToKnownFlowerGoal() { super(); @@ -144,7 +158,7 @@ this.setFlags(EnumSet.of(Goal.Flag.MOVE)); } -@@ -1301,7 +1339,7 @@ +@@ -1301,7 +1341,7 @@ } } @@ -153,7 +167,7 @@ Bee.this.level().levelEvent(2011, blockposition, 15); Bee.this.level().setBlockAndUpdate(blockposition, iblockdata1); Bee.this.incrementNumCropsGrownSincePollination(); -@@ -1378,7 +1416,7 @@ +@@ -1378,7 +1418,7 @@ @Override protected void alertOther(Mob mob, LivingEntity target) { if (mob instanceof Bee && this.mob.hasLineOfSight(target)) { @@ -162,7 +176,7 @@ } } -@@ -1387,7 +1425,7 @@ +@@ -1387,7 +1427,7 @@ private static class BeeBecomeAngryTargetGoal extends NearestAttackableTargetGoal { BeeBecomeAngryTargetGoal(Bee bee) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch index b9bde411e8..636405ea80 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/frog/Tadpole.java.patch @@ -1,6 +1,14 @@ --- a/net/minecraft/world/entity/animal/frog/Tadpole.java +++ b/net/minecraft/world/entity/animal/frog/Tadpole.java -@@ -74,7 +74,7 @@ +@@ -50,6 +50,7 @@ + public int age; + protected static final ImmutableList>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_PLAYERS, SensorType.HURT_BY, SensorType.FROG_TEMPTATIONS); + protected static final ImmutableList> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.LOOK_TARGET, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.NEAREST_VISIBLE_ADULT, MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, MemoryModuleType.IS_TEMPTED, MemoryModuleType.TEMPTING_PLAYER, MemoryModuleType.BREED_TARGET, MemoryModuleType.IS_PANICKING); ++ public boolean ageLocked; // Paper + + public Tadpole(EntityType type, Level world) { + super(type, world); +@@ -74,7 +75,7 @@ @Override public Brain getBrain() { @@ -9,7 +17,55 @@ } @Override -@@ -225,12 +225,17 @@ +@@ -102,7 +103,7 @@ + @Override + public void aiStep() { + super.aiStep(); +- if (!this.level().isClientSide) { ++ if (!this.level().isClientSide && !this.ageLocked) { // Paper + this.setAge(this.age + 1); + } + +@@ -112,12 +113,14 @@ + public void addAdditionalSaveData(CompoundTag nbt) { + super.addAdditionalSaveData(nbt); + nbt.putInt("Age", this.age); ++ nbt.putBoolean("AgeLocked", this.ageLocked); // Paper + } + + @Override + public void readAdditionalSaveData(CompoundTag nbt) { + super.readAdditionalSaveData(nbt); + this.setAge(nbt.getInt("Age")); ++ this.ageLocked = nbt.getBoolean("AgeLocked"); // Paper + } + + @Nullable +@@ -169,6 +172,7 @@ + Bucketable.saveDefaultDataToBucketTag(this, stack); + CustomData.update(DataComponents.BUCKET_ENTITY_DATA, stack, (nbttagcompound) -> { + nbttagcompound.putInt("Age", this.getAge()); ++ nbttagcompound.putBoolean("AgeLocked", this.ageLocked); // Paper + }); + } + +@@ -179,6 +183,7 @@ + this.setAge(nbt.getInt("Age")); + } + ++ this.ageLocked = nbt.getBoolean("AgeLocked"); // Paper + } + + @Override +@@ -210,6 +215,7 @@ + } + + private void ageUp(int seconds) { ++ if (this.ageLocked) return; // Paper + this.setAge(this.age + seconds * 20); + } + +@@ -225,12 +231,17 @@ Level world = this.level(); if (world instanceof ServerLevel worldserver) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch index 81159c85e3..be0e10b03e 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/AbstractHorse.java.patch @@ -61,12 +61,12 @@ + @Override + public InventoryHolder getOwner() { + return (org.bukkit.entity.AbstractHorse) AbstractHorse.this.getBukkitEntity(); -+ } + } + + @Override + public Location getLocation() { + return AbstractHorse.this.getBukkitEntity().getLocation(); - } ++ } + // CraftBukkit end }; + public int maxDomestication = 100; // CraftBukkit - store max domestication value @@ -118,7 +118,36 @@ } if (this.canEatGrass()) { -@@ -883,6 +940,7 @@ +@@ -720,7 +777,16 @@ + } + } + ++ } ++ ++ // Paper start - Horse API ++ public void setMouthOpen(boolean open) { ++ this.setFlag(FLAG_OPEN_MOUTH, open); ++ } ++ public boolean isMouthOpen() { ++ return this.getFlag(FLAG_OPEN_MOUTH); + } ++ // Paper end - Horse API + + @Override + public InteractionResult mobInteract(Player player, InteractionHand hand) { +@@ -764,6 +830,11 @@ + this.setFlag(16, eatingGrass); + } + ++ // Paper start - Horse API ++ public void setForceStanding(boolean standing) { ++ this.setFlag(FLAG_STANDING, standing); ++ } ++ // Paper end - Horse API + public void setStanding(boolean angry) { + if (angry) { + this.setEating(false); +@@ -883,6 +954,7 @@ if (this.getOwnerUUID() != null) { nbt.putUUID("Owner", this.getOwnerUUID()); } @@ -126,20 +155,19 @@ if (!this.inventory.getItem(0).isEmpty()) { nbt.put("SaddleItem", this.inventory.getItem(0).save(this.registryAccess())); -@@ -909,7 +967,12 @@ - +@@ -910,6 +982,11 @@ if (uuid != null) { this.setOwnerUUID(uuid); -+ } + } + // CraftBukkit start + if (nbt.contains("Bukkit.MaxDomestication")) { + this.maxDomestication = nbt.getInt("Bukkit.MaxDomestication"); - } ++ } + // CraftBukkit end if (nbt.contains("SaddleItem", 10)) { ItemStack itemstack = (ItemStack) ItemStack.parse(this.registryAccess(), nbt.getCompound("SaddleItem")).orElse(ItemStack.EMPTY); -@@ -1012,6 +1075,17 @@ +@@ -1012,6 +1089,17 @@ @Override public void handleStartJump(int height) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/Llama.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/Llama.java.patch index 0abd6bf0a6..558ae1a67f 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/Llama.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/animal/horse/Llama.java.patch @@ -1,6 +1,19 @@ --- a/net/minecraft/world/entity/animal/horse/Llama.java +++ b/net/minecraft/world/entity/animal/horse/Llama.java -@@ -82,6 +82,11 @@ +@@ -71,17 +71,23 @@ + @Nullable + private Llama caravanHead; + @Nullable +- private Llama caravanTail; ++ public Llama caravanTail; // Paper + + public Llama(EntityType type, Level world) { + super(type, world); + this.getNavigation().setRequiredPathLength(40.0F); ++ this.maxDomestication = 30; // Paper - Missing entity API; configure max temper instead of a hardcoded value + } + + public boolean isTraderLlama() { return false; } @@ -12,3 +25,12 @@ private void setStrength(int strength) { this.entityData.set(Llama.DATA_STRENGTH_ID, Math.max(1, Math.min(5, strength))); } +@@ -289,7 +295,7 @@ + + @Override + public int getMaxTemper() { +- return 30; ++ return super.getMaxTemper(); // Paper - Missing entity API; delegate to parent + } + + @Override 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 f61485c525..b321572366 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 @@ -38,7 +38,20 @@ public class WitherBoss extends Monster implements RangedAttackMob { -@@ -252,15 +261,42 @@ +@@ -77,7 +86,12 @@ + return !entityliving.getType().is(EntityTypeTags.WITHER_FRIENDS) && entityliving.attackable(); + }; + private static final TargetingConditions TARGETING_CONDITIONS = TargetingConditions.forCombat().range(20.0D).selector(WitherBoss.LIVING_ENTITY_SELECTOR); ++ // Paper start ++ private boolean canPortal = false; + ++ public void setCanTravelThroughPortals(boolean canPortal) { this.canPortal = canPortal; } ++ // Paper end ++ + public WitherBoss(EntityType type, Level world) { + super(type, world); + this.bossEvent = (ServerBossEvent) (new ServerBossEvent(this.getDisplayName(), BossEvent.BossBarColor.PURPLE, BossEvent.BossBarOverlay.PROGRESS)).setDarkenScreen(true); +@@ -252,15 +266,42 @@ i = this.getInvulnerableTicks() - 1; this.bossEvent.setProgress(1.0F - (float) i / 220.0F); if (i <= 0) { @@ -84,7 +97,7 @@ } } else { -@@ -305,6 +341,7 @@ +@@ -305,6 +346,7 @@ if (!list.isEmpty()) { LivingEntity entityliving1 = (LivingEntity) list.get(this.random.nextInt(list.size())); @@ -92,7 +105,7 @@ this.setAlternativeTarget(i, entityliving1.getId()); } } -@@ -331,6 +368,11 @@ +@@ -331,6 +373,11 @@ BlockState iblockdata = world.getBlockState(blockposition); if (WitherBoss.canDestroy(iblockdata)) { @@ -104,7 +117,7 @@ flag = world.destroyBlock(blockposition, true, this) || flag; } } -@@ -342,7 +384,7 @@ +@@ -342,7 +389,7 @@ } if (this.tickCount % 20 == 0) { @@ -113,7 +126,7 @@ } this.bossEvent.setProgress(this.getHealth() / this.getMaxHealth()); -@@ -499,7 +541,7 @@ +@@ -499,7 +546,7 @@ @Override public void checkDespawn() { if (this.level().getDifficulty() == Difficulty.PEACEFUL && this.shouldDespawnInPeaceful()) { @@ -122,3 +135,12 @@ } else { this.noActionTime = 0; } +@@ -549,7 +596,7 @@ + + @Override + public boolean canUsePortal(boolean allowVehicles) { +- return false; ++ return this.canPortal; // Paper + } + + @Override diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch index 18ecd6803b..2af4387665 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/EnderMan.java.patch @@ -86,7 +86,24 @@ return flag1; } -@@ -457,7 +488,8 @@ +@@ -397,6 +428,16 @@ + this.entityData.set(EnderMan.DATA_STARED_AT, true); + } + ++ // Paper start ++ public void setCreepy(boolean creepy) { ++ this.entityData.set(EnderMan.DATA_CREEPY, creepy); ++ } ++ ++ public void setHasBeenStaredAt(boolean hasBeenStaredAt) { ++ this.entityData.set(EnderMan.DATA_STARED_AT, hasBeenStaredAt); ++ } ++ // Paper end ++ + @Override + public boolean requiresCustomPersistence() { + return super.requiresCustomPersistence() || this.getCarriedBlock() != null; +@@ -457,7 +498,8 @@ int j = Mth.floor(this.enderman.getY() + randomsource.nextDouble() * 2.0D); int k = Mth.floor(this.enderman.getZ() - 1.0D + randomsource.nextDouble() * 2.0D); BlockPos blockposition = new BlockPos(i, j, k); @@ -96,7 +113,7 @@ BlockPos blockposition1 = blockposition.below(); BlockState iblockdata1 = world.getBlockState(blockposition1); BlockState iblockdata2 = this.enderman.getCarriedBlock(); -@@ -465,9 +497,11 @@ +@@ -465,9 +507,11 @@ if (iblockdata2 != null) { iblockdata2 = Block.updateFromNeighbourShapes(iblockdata2, this.enderman.level(), blockposition); if (this.canPlaceBlock(world, blockposition, iblockdata2, iblockdata, iblockdata1, blockposition1)) { @@ -108,7 +125,7 @@ } } -@@ -499,16 +533,19 @@ +@@ -499,16 +543,19 @@ int j = Mth.floor(this.enderman.getY() + randomsource.nextDouble() * 3.0D); int k = Mth.floor(this.enderman.getZ() - 2.0D + randomsource.nextDouble() * 4.0D); BlockPos blockposition = new BlockPos(i, j, k); @@ -129,7 +146,7 @@ } } -@@ -592,7 +629,7 @@ +@@ -592,7 +639,7 @@ } else { if (this.target != null && !this.enderman.isPassenger()) { if (this.enderman.isBeingStaredBy((Player) this.target)) { diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ghast.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ghast.java.patch index 75afd666d6..e91f483915 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/Ghast.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/Ghast.java.patch @@ -1,6 +1,20 @@ --- a/net/minecraft/world/entity/monster/Ghast.java +++ b/net/minecraft/world/entity/monster/Ghast.java -@@ -333,6 +333,8 @@ +@@ -64,7 +64,13 @@ + + public int getExplosionPower() { + return this.explosionPower; ++ } ++ ++ // Paper start ++ public void setExplosionPower(int explosionPower) { ++ this.explosionPower = explosionPower; + } ++ // Paper end + + @Override + protected boolean shouldDespawnInPeaceful() { +@@ -333,6 +339,8 @@ LargeFireball entitylargefireball = new LargeFireball(world, this.ghast, vec3d1.normalize(), this.ghast.getExplosionPower()); diff --git a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch index afdd5098bb..f6d69ddf37 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/monster/ZombieVillager.java.patch @@ -81,20 +81,31 @@ } @Override -@@ -197,8 +210,10 @@ +@@ -194,12 +207,20 @@ + } + + public void startConverting(@Nullable UUID uuid, int delay) { ++ // Paper start - missing entity behaviour api - converting without entity event ++ this.startConverting(uuid, delay, true); ++ } ++ ++ public void startConverting(@Nullable UUID uuid, int delay, boolean broadcastEntityEvent) { ++ // Paper end - missing entity behaviour api - converting without entity event this.conversionStarter = uuid; this.villagerConversionTime = delay; this.getEntityData().set(ZombieVillager.DATA_CONVERTING_ID, true); - this.removeEffect(MobEffects.WEAKNESS); - this.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, delay, Math.min(this.level().getDifficulty().getId() - 1, 0))); +- this.level().broadcastEntityEvent(this, (byte) 16); + // CraftBukkit start + this.removeEffect(MobEffects.WEAKNESS, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); + this.addEffect(new MobEffectInstance(MobEffects.DAMAGE_BOOST, delay, Math.min(this.level().getDifficulty().getId() - 1, 0)), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); + // CraftBukkit end - this.level().broadcastEntityEvent(this, (byte) 16); ++ if (broadcastEntityEvent) this.level().broadcastEntityEvent(this, (byte) 16); // Paper - missing entity behaviour api - converting without entity event } -@@ -215,10 +230,11 @@ + @Override +@@ -215,10 +236,11 @@ } private void finishConversion(ServerLevel world) { @@ -107,7 +118,7 @@ while (iterator.hasNext()) { EquipmentSlot enumitemslot = (EquipmentSlot) iterator.next(); -@@ -248,12 +264,16 @@ +@@ -248,12 +270,16 @@ } } diff --git a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch index f49bdcfd6d..f459f09f46 100644 --- a/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch +++ b/paper-server/patches/sources/net/minecraft/world/entity/projectile/ThrownTrident.java.patch @@ -23,7 +23,28 @@ return; } -@@ -137,7 +140,7 @@ +@@ -111,6 +114,20 @@ + return (Boolean) this.entityData.get(ThrownTrident.ID_FOIL); + } + ++ // Paper start ++ public void setFoil(boolean foil) { ++ this.entityData.set(ThrownTrident.ID_FOIL, foil); ++ } ++ ++ public int getLoyalty() { ++ return this.entityData.get(ThrownTrident.ID_LOYALTY); ++ } ++ ++ public void setLoyalty(byte loyalty) { ++ this.entityData.set(ThrownTrident.ID_LOYALTY, loyalty); ++ } ++ // Paper end ++ + @Nullable + @Override + protected EntityHitResult findHitEntity(Vec3 currentPosition, Vec3 nextPosition) { +@@ -137,7 +154,7 @@ world = this.level(); if (world instanceof ServerLevel) { diff --git a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java index 99d0118061..6bdc683b5a 100644 --- a/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java +++ b/paper-server/src/main/java/com/destroystokyo/paper/entity/ai/MobGoalHelper.java @@ -164,7 +164,7 @@ public class MobGoalHelper { bukkitMap.put(net.minecraft.world.entity.monster.Endermite.class, Endermite.class); bukkitMap.put(net.minecraft.world.entity.monster.Evoker.class, Evoker.class); bukkitMap.put(AbstractFish.class, Fish.class); - bukkitMap.put(AbstractSchoolingFish.class, Fish.class); // close enough + bukkitMap.put(AbstractSchoolingFish.class, io.papermc.paper.entity.SchoolableFish.class); bukkitMap.put(FlyingMob.class, Flying.class); bukkitMap.put(net.minecraft.world.entity.animal.Fox.class, Fox.class); bukkitMap.put(net.minecraft.world.entity.monster.Ghast.class, Ghast.class); diff --git a/paper-server/src/main/java/io/papermc/paper/entity/PaperSchoolableFish.java b/paper-server/src/main/java/io/papermc/paper/entity/PaperSchoolableFish.java new file mode 100644 index 0000000000..41bf71d116 --- /dev/null +++ b/paper-server/src/main/java/io/papermc/paper/entity/PaperSchoolableFish.java @@ -0,0 +1,52 @@ +package io.papermc.paper.entity; + +import net.minecraft.world.entity.animal.AbstractSchoolingFish; +import org.bukkit.craftbukkit.CraftServer; +import org.bukkit.craftbukkit.entity.CraftFish; +import org.jetbrains.annotations.NotNull; + +public class PaperSchoolableFish extends CraftFish implements SchoolableFish { + + public PaperSchoolableFish(CraftServer server, AbstractSchoolingFish entity) { + super(server, entity); + } + + @Override + public AbstractSchoolingFish getHandle() { + return (AbstractSchoolingFish) super.getHandle(); + } + + @Override + public void startFollowing(@NotNull SchoolableFish fish) { + if (this.getHandle().isFollower()) { // If following a fish already, properly remove the old one + this.stopFollowing(); + } + + this.getHandle().startFollowing(((PaperSchoolableFish) fish).getHandle()); + } + + @Override + public void stopFollowing() { + this.getHandle().stopFollowing(); + } + + @Override + public int getSchoolSize() { + return this.getHandle().schoolSize; + } + + @Override + public int getMaxSchoolSize() { + return this.getHandle().getMaxSchoolSize(); + } + + @Override + public SchoolableFish getSchoolLeader() { + AbstractSchoolingFish leader = this.getHandle().leader; + if (leader == null) { + return null; + } + + return (SchoolableFish) leader.getBukkitEntity(); + } +} diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java index 3952e52b94..9bcc093151 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAbstractHorse.java @@ -114,4 +114,36 @@ public abstract class CraftAbstractHorse extends CraftAnimals implements Abstrac public AbstractHorseInventory getInventory() { return new CraftSaddledInventory(getHandle().inventory); } + + // Paper start - Horse API + @Override + public boolean isEatingGrass() { + return this.getHandle().isEating(); + } + + @Override + public void setEatingGrass(boolean eating) { + this.getHandle().setEating(eating); + } + + @Override + public boolean isRearing() { + return this.getHandle().isStanding(); + } + + @Override + public void setRearing(boolean rearing) { + this.getHandle().setForceStanding(rearing); + } + + @Override + public boolean isEating() { + return this.getHandle().isMouthOpen(); + } + + @Override + public void setEating(boolean eating) { + this.getHandle().setMouthOpen(eating); + } + // Paper end - Horse API } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java index 17bffb4545..6591513bb6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftAreaEffectCloud.java @@ -229,4 +229,17 @@ public class CraftAreaEffectCloud extends CraftEntity implements AreaEffectCloud this.getHandle().setOwner(null); } } + + // Paper start - owner API + @Override + public java.util.UUID getOwnerUniqueId() { + return this.getHandle().ownerUUID; + } + + @Override + public void setOwnerUniqueId(final java.util.UUID ownerUuid) { + this.getHandle().setOwner(null); + this.getHandle().ownerUUID = ownerUuid; + } + // Paper end } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java index b0a3531476..1bb72f2808 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBat.java @@ -27,4 +27,25 @@ public class CraftBat extends CraftAmbient implements Bat { public void setAwake(boolean state) { this.getHandle().setResting(!state); } + // Paper start + @Override + public org.bukkit.Location getTargetLocation() { + net.minecraft.core.BlockPos pos = this.getHandle().targetPosition; + if (pos == null) { + return null; + } + + return io.papermc.paper.util.MCUtil.toLocation(this.getHandle().level(), pos); + } + + @Override + public void setTargetLocation(org.bukkit.Location location) { + net.minecraft.core.BlockPos pos = null; + if (location != null) { + pos = io.papermc.paper.util.MCUtil.toBlockPosition(location); + } + + this.getHandle().targetPosition = pos; + } + // Paper end } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java index cfff1be6a4..3dac93b0ab 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftBee.java @@ -86,4 +86,42 @@ public class CraftBee extends CraftAnimals implements Bee { public void setCannotEnterHiveTicks(int ticks) { this.getHandle().setStayOutOfHiveCountdown(ticks); } + // Paper start + @Override + public void setRollingOverride(net.kyori.adventure.util.TriState rolling) { + this.getHandle().rollingOverride = rolling; + + this.getHandle().setRolling(this.getHandle().isRolling()); // Refresh rolling state + } + + @Override + public boolean isRolling() { + return this.getRollingOverride().toBooleanOrElse(this.getHandle().isRolling()); + } + + @Override + public net.kyori.adventure.util.TriState getRollingOverride() { + return this.getHandle().rollingOverride; + } + + @Override + public void setCropsGrownSincePollination(int crops) { + this.getHandle().numCropsGrownSincePollination = crops; + } + + @Override + public int getCropsGrownSincePollination() { + return this.getHandle().numCropsGrownSincePollination; + } + + @Override + public void setTicksSincePollination(int ticks) { + this.getHandle().ticksWithoutNectarSinceExitingHive = ticks; + } + + @Override + public int getTicksSincePollination() { + return this.getHandle().ticksWithoutNectarSinceExitingHive; + } + // Paper end } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java index 5766412496..88e876da7d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCat.java @@ -139,4 +139,26 @@ public class CraftCat extends CraftTameableAnimal implements Cat { return this.getKey().hashCode(); } } + + // Paper start - More cat api + @Override + public void setLyingDown(boolean lyingDown) { + this.getHandle().setLying(lyingDown); + } + + @Override + public boolean isLyingDown() { + return this.getHandle().isLying(); + } + + @Override + public void setHeadUp(boolean headUp) { + this.getHandle().setRelaxStateOne(headUp); + } + + @Override + public boolean isHeadUp() { + return this.getHandle().isRelaxStateOne(); + } + // Paper end - More cat api } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java index 64b75682a9..96f6e2fd9c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftChicken.java @@ -18,4 +18,26 @@ public class CraftChicken extends CraftAnimals implements Chicken { public String toString() { return "CraftChicken"; } + + // Paper start + @Override + public boolean isChickenJockey() { + return this.getHandle().isChickenJockey(); + } + + @Override + public void setIsChickenJockey(boolean isChickenJockey) { + this.getHandle().setChickenJockey(isChickenJockey); + } + + @Override + public int getEggLayTime() { + return this.getHandle().eggTime; + } + + @Override + public void setEggLayTime(int eggLayTime) { + this.getHandle().eggTime = eggLayTime; + } + // Paper end } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java index fa0bf7db88..63e6b07e3b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftCod.java @@ -3,7 +3,7 @@ package org.bukkit.craftbukkit.entity; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Cod; -public class CraftCod extends CraftFish implements Cod { +public class CraftCod extends io.papermc.paper.entity.PaperSchoolableFish implements Cod { // Paper - School Fish API public CraftCod(CraftServer server, net.minecraft.world.entity.animal.Cod entity) { super(server, entity); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java index 5bae70ad16..83867b9c54 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftDolphin.java @@ -18,4 +18,36 @@ public class CraftDolphin extends CraftAgeable implements Dolphin { public String toString() { return "CraftDolphin"; } + + // Paper start - Missing Dolphin API + @Override + public int getMoistness() { + return this.getHandle().getMoistnessLevel(); + } + + @Override + public void setMoistness(int moistness) { + this.getHandle().setMoisntessLevel(moistness); + } + + @Override + public void setHasFish(boolean hasFish) { + this.getHandle().setGotFish(hasFish); + } + + @Override + public boolean hasFish() { + return this.getHandle().gotFish(); + } + + @Override + public org.bukkit.Location getTreasureLocation() { + return io.papermc.paper.util.MCUtil.toLocation(this.getHandle().level(), this.getHandle().getTreasurePos()); + } + + @Override + public void setTreasureLocation(org.bukkit.Location location) { + this.getHandle().setTreasurePos(io.papermc.paper.util.MCUtil.toBlockPosition(location)); + } + // Paper end - Missing Dolphin API } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java index cc4194ac9d..33ae03b78b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderDragonPart.java @@ -51,6 +51,13 @@ public class CraftEnderDragonPart extends CraftComplexPart implements EnderDrago this.getParent().setHealth(health); } + // Paper start - entity heal API + @Override + public void heal(final double amount, final org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason reason) { + this.getParent().heal(amount, reason); + } + // Paper end - entity heal API + @Override public double getAbsorptionAmount() { return this.getParent().getAbsorptionAmount(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java index 21dc209e6f..983b9d6ddb 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEnderman.java @@ -40,6 +40,28 @@ public class CraftEnderman extends CraftMonster implements Enderman { this.getHandle().setCarriedBlock(blockData == null ? null : ((CraftBlockData) blockData).getState()); } + // Paper start + @Override + public boolean isScreaming() { + return this.getHandle().isCreepy(); + } + + @Override + public void setScreaming(boolean screaming) { + this.getHandle().setCreepy(screaming); + } + + @Override + public boolean hasBeenStaredAt() { + return this.getHandle().hasBeenStaredAt(); + } + + @Override + public void setHasBeenStaredAt(boolean hasBeenStaredAt) { + this.getHandle().setHasBeenStaredAt(hasBeenStaredAt); + } + // Paper end + @Override public EnderMan getHandle() { return (EnderMan) this.entity; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java index fc0f0e841d..d657fd2c50 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEndermite.java @@ -28,4 +28,15 @@ public class CraftEndermite extends CraftMonster implements Endermite { public void setPlayerSpawned(boolean playerSpawned) { // Nop } + // Paper start + @Override + public void setLifetimeTicks(int ticks) { + this.getHandle().life = ticks; + } + + @Override + public int getLifetimeTicks() { + return this.getHandle().life; + } + // Paper end } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 78afac7226..888a75423a 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -1082,4 +1082,27 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity { return set; } // Paper end - tracked players API + + // Paper start - missing entity api + @Override + public boolean isInvisible() { // Paper - moved up from LivingEntity + return this.getHandle().isInvisible(); + } + + @Override + public void setInvisible(boolean invisible) { // Paper - moved up from LivingEntity + this.getHandle().persistentInvisibility = invisible; + this.getHandle().setSharedFlag(Entity.FLAG_INVISIBLE, invisible); + } + + @Override + public void setNoPhysics(boolean noPhysics) { + this.getHandle().noPhysics = noPhysics; + } + + @Override + public boolean hasNoPhysics() { + return this.getHandle().noPhysics; + } + // Paper end - missing entity api } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java index 142f3e3257..1b084d63bd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFireball.java @@ -84,6 +84,18 @@ public class CraftFireball extends AbstractProjectile implements Fireball { return new Vector(delta.x, delta.y, delta.z); } + // Paper start - Expose power on fireball projectiles + @Override + public void setPower(final Vector power) { + this.setAcceleration(power); + } + + @Override + public Vector getPower() { + return this.getAcceleration(); + } + // Paper end - Expose power on fireball projectiles + @Override public AbstractHurtingProjectile getHandle() { return (AbstractHurtingProjectile) this.entity; diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java index dd912be293..bb2b59ce97 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftFox.java @@ -113,4 +113,41 @@ public class CraftFox extends CraftAnimals implements Fox { public boolean isFaceplanted() { return this.getHandle().isFaceplanted(); } + + // Paper start - Add more fox behavior API + @Override + public void setInterested(boolean interested) { + this.getHandle().setIsInterested(interested); + } + + @Override + public boolean isInterested() { + return this.getHandle().isInterested(); + } + + @Override + public void setLeaping(boolean leaping) { + this.getHandle().setIsPouncing(leaping); + } + + @Override + public boolean isLeaping() { + return this.getHandle().isPouncing(); + } + + @Override + public void setDefending(boolean defending) { + this.getHandle().setDefending(defending); + } + + @Override + public boolean isDefending() { + return this.getHandle().isDefending(); + } + + @Override + public void setFaceplanted(boolean faceplanted) { + this.getHandle().setFaceplanted(faceplanted); + } + // Paper end - Add more fox behavior API } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java index 2cec61a1bb..97fa4e1e70 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftGhast.java @@ -28,4 +28,17 @@ public class CraftGhast extends CraftFlying implements Ghast, CraftEnemy { public void setCharging(boolean flag) { this.getHandle().setCharging(flag); } + + // Paper start + @Override + public int getExplosionPower() { + return this.getHandle().getExplosionPower(); + } + + @Override + public void setExplosionPower(int explosionPower) { + com.google.common.base.Preconditions.checkArgument(explosionPower >= 0 && explosionPower <= 127, "The explosion power has to be between 0 and 127"); + this.getHandle().setExplosionPower(explosionPower); + } + // Paper end } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java index a4a30f52f4..6020c0c164 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLivingEntity.java @@ -128,6 +128,13 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { } } + // Paper start - entity heal API + @Override + public void heal(final double amount, final org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason reason) { + this.getHandle().heal((float) amount, reason); + } + // Paper end - entity heal API + @Override public double getAbsorptionAmount() { return this.getHandle().getAbsorptionAmount(); @@ -939,14 +946,29 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity { @Override public boolean isInvisible() { - return this.getHandle().isInvisible(); + return super.isInvisible(); // Paper - move invisibility up to Entity - diff on change } @Override public void setInvisible(boolean invisible) { - this.getHandle().persistentInvisibility = invisible; - this.getHandle().setSharedFlag(5, invisible); + super.setInvisible(invisible); // Paper - move invisibility up to Entity } + // Paper start + @Override + public float getSidewaysMovement() { + return this.getHandle().xxa; + } + + @Override + public float getForwardsMovement() { + return this.getHandle().zza; + } + + @Override + public float getUpwardsMovement() { + return this.getHandle().yya; + } + // Paper end // Paper start @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java index bf297388c7..351f42842b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftLlama.java @@ -58,4 +58,36 @@ public class CraftLlama extends CraftChestedHorse implements Llama, com.destroys public String toString() { return "CraftLlama"; } + + // Paper start + @Override + public boolean inCaravan() { + return this.getHandle().inCaravan(); + } + + @Override + public void joinCaravan(@org.jetbrains.annotations.NotNull Llama llama) { + this.getHandle().joinCaravan(((CraftLlama) llama).getHandle()); + } + + @Override + public void leaveCaravan() { + this.getHandle().leaveCaravan(); + } + + @Override + public boolean hasCaravanTail() { + return this.getHandle().hasCaravanTail(); + } + + @Override + public Llama getCaravanHead() { + return this.getHandle().getCaravanHead() == null ? null : (Llama) this.getHandle().getCaravanHead().getBukkitEntity(); + } + + @Override + public Llama getCaravanTail() { + return this.getHandle().caravanTail == null ? null : (Llama) this.getHandle().caravanTail.getBukkitEntity(); + } + // Paper end } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java index 17f5684cba..3a3563a1bd 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartHopper.java @@ -33,4 +33,20 @@ public final class CraftMinecartHopper extends CraftMinecartContainer implements public void setEnabled(boolean enabled) { ((MinecartHopper) this.getHandle()).setEnabled(enabled); } + // Paper start + @Override + public net.minecraft.world.entity.vehicle.MinecartHopper getHandle() { + return (net.minecraft.world.entity.vehicle.MinecartHopper) super.getHandle(); + } + + @Override + public int getPickupCooldown() { + throw new UnsupportedOperationException("Hopper minecarts don't have cooldowns"); + } + + @Override + public void setPickupCooldown(int cooldown) { + throw new UnsupportedOperationException("Hopper minecarts don't have cooldowns"); + } + // Paper end } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java index bd739428a7..7cf42f62d9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java @@ -146,4 +146,16 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { return getHandle().getMaxHeadXRot(); } // Paper end + + // Paper start + @Override + public boolean isAggressive() { + return this.getHandle().isAggressive(); + } + + @Override + public void setAggressive(boolean aggressive) { + this.getHandle().setAggressive(aggressive); + } + // Paper end } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java index 5467e4a74b..01d104d91d 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPanda.java @@ -41,6 +41,38 @@ public class CraftPanda extends CraftAnimals implements Panda { this.getHandle().setHiddenGene(CraftPanda.toNms(gene)); } + // Paper start - Panda API + @Override + public void setSneezeTicks(int ticks) { + this.getHandle().setSneezeCounter(ticks); + } + + @Override + public int getSneezeTicks() { + return this.getHandle().getSneezeCounter(); + } + + @Override + public void setEatingTicks(int ticks) { + this.getHandle().setEatCounter(ticks); + } + + @Override + public int getEatingTicks() { + return this.getHandle().getEatCounter(); + } + + @Override + public void setUnhappyTicks(int ticks) { + this.getHandle().setUnhappyCounter(ticks); + } + + @Override + public Gene getCombinedGene() { + return CraftPanda.fromNms(this.getHandle().getVariant()); + } + // Paper end - Panda API + @Override public boolean isRolling() { return this.getHandle().isRolling(); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java index 9304e201db..83e77c6d28 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPhantom.java @@ -44,5 +44,17 @@ public class CraftPhantom extends CraftFlying implements Phantom, CraftEnemy { public void setShouldBurnInDay(boolean shouldBurnInDay) { getHandle().setShouldBurnInDay(shouldBurnInDay); } + + @Override + public org.bukkit.Location getAnchorLocation() { + net.minecraft.core.BlockPos pos = this.getHandle().anchorPoint; + return io.papermc.paper.util.MCUtil.toLocation(this.getHandle().level(), pos); + } + + @Override + public void setAnchorLocation(org.bukkit.Location location) { + com.google.common.base.Preconditions.checkArgument(location != null, "location cannot be null"); + this.getHandle().anchorPoint = io.papermc.paper.util.MCUtil.toBlockPosition(location); + } // Paper end } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java index f5ecb8c1dc..5124a383b6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPiglin.java @@ -84,4 +84,37 @@ public class CraftPiglin extends CraftPiglinAbstract implements Piglin, com.dest public String toString() { return "CraftPiglin"; } + // Paper start + @Override + public void setChargingCrossbow(boolean chargingCrossbow) { + this.getHandle().setChargingCrossbow(chargingCrossbow); + } + + @Override + public boolean isChargingCrossbow() { + return this.getHandle().isChargingCrossbow(); + } + + @Override + public void setDancing(boolean dancing) { + if (dancing) { + this.getHandle().getBrain().setMemory(net.minecraft.world.entity.ai.memory.MemoryModuleType.DANCING, true); + this.getHandle().getBrain().setMemory(net.minecraft.world.entity.ai.memory.MemoryModuleType.CELEBRATE_LOCATION, this.getHandle().getOnPos()); + } else { + this.getHandle().getBrain().eraseMemory(net.minecraft.world.entity.ai.memory.MemoryModuleType.DANCING); + this.getHandle().getBrain().eraseMemory(net.minecraft.world.entity.ai.memory.MemoryModuleType.CELEBRATE_LOCATION); + } + } + + @Override + public void setDancing(long duration) { + this.getHandle().getBrain().setMemoryWithExpiry(net.minecraft.world.entity.ai.memory.MemoryModuleType.DANCING, true, duration); + this.getHandle().getBrain().setMemoryWithExpiry(net.minecraft.world.entity.ai.memory.MemoryModuleType.CELEBRATE_LOCATION, this.getHandle().getOnPos(), duration); + } + + @Override + public boolean isDancing() { + return this.getHandle().isDancing(); + } + // Paper end } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java index c7aec6f28e..fe075cfdf3 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPolarBear.java @@ -17,4 +17,16 @@ public class CraftPolarBear extends CraftAnimals implements PolarBear { public String toString() { return "CraftPolarBear"; } + + // Paper start + @Override + public boolean isStanding() { + return this.getHandle().isStanding(); + } + + @Override + public void setStanding(boolean standing) { + this.getHandle().setStanding(standing); + } + // Paper end } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java index 6b48b117a9..519ef701a7 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRabbit.java @@ -29,4 +29,15 @@ public class CraftRabbit extends CraftAnimals implements Rabbit { public void setRabbitType(Type type) { this.getHandle().setVariant(net.minecraft.world.entity.animal.Rabbit.Variant.values()[type.ordinal()]); } + // Paper start + @Override + public void setMoreCarrotTicks(int ticks) { + this.getHandle().moreCarrotTicks = ticks; + } + + @Override + public int getMoreCarrotTicks() { + return this.getHandle().moreCarrotTicks; + } + // Paper end } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRavager.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRavager.java index cae59f77c7..09796ce156 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRavager.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftRavager.java @@ -18,4 +18,35 @@ public class CraftRavager extends CraftRaider implements Ravager { public String toString() { return "CraftRavager"; } + // Paper start - Missing Entity Behavior + @Override + public int getAttackTicks() { + return this.getHandle().getAttackTick(); + } + + @Override + public void setAttackTicks(int ticks) { + this.getHandle().attackTick = ticks; + } + + @Override + public int getStunnedTicks() { + return this.getHandle().getStunnedTick(); + } + + @Override + public void setStunnedTicks(int ticks) { + this.getHandle().stunnedTick = ticks; + } + + @Override + public int getRoarTicks() { + return this.getHandle().getRoarTick(); + } + + @Override + public void setRoarTicks(int ticks) { + this.getHandle().roarTick = ticks; + } + // Paper end } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java index 551c30cb0f..7660cc21e9 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftSalmon.java @@ -4,7 +4,7 @@ import com.google.common.base.Preconditions; import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.Salmon; -public class CraftSalmon extends CraftFish implements Salmon { +public class CraftSalmon extends io.papermc.paper.entity.PaperSchoolableFish implements Salmon { // Paper - Schooling Fish API public CraftSalmon(CraftServer server, net.minecraft.world.entity.animal.Salmon entity) { super(server, entity); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java index 36ab282e2c..a61aec087f 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTNTPrimed.java @@ -67,4 +67,17 @@ public class CraftTNTPrimed extends CraftEntity implements TNTPrimed { this.getHandle().owner = null; } } + + // Paper start + @Override + public void setBlockData(org.bukkit.block.data.BlockData data) { + com.google.common.base.Preconditions.checkArgument(data != null, "The visual block data of this tnt cannot be null. To reset it just set to the TNT default block data"); + this.getHandle().setBlockState(((org.bukkit.craftbukkit.block.data.CraftBlockData) data).getState()); + } + + @Override + public org.bukkit.block.data.BlockData getBlockData() { + return org.bukkit.craftbukkit.block.data.CraftBlockData.fromData(this.getHandle().getBlockState()); + } + // Paper end } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTadpole.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTadpole.java index 451a9bfd9b..d7c6a0bbc5 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTadpole.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTadpole.java @@ -28,4 +28,15 @@ public class CraftTadpole extends CraftFish implements org.bukkit.entity.Tadpole public void setAge(int age) { this.getHandle().age = age; } + // Paper start + @Override + public void setAgeLock(boolean lock) { + this.getHandle().ageLocked = lock; + } + + @Override + public boolean getAgeLock() { + return this.getHandle().ageLocked; + } + // Paper end } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java index 33d6e81217..e374b9f40e 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTrident.java @@ -31,4 +31,27 @@ public class CraftTrident extends CraftAbstractArrow implements Trident { public String toString() { return "CraftTrident"; } + + // Paper start + @Override + public boolean hasGlint() { + return this.getHandle().isFoil(); + } + + @Override + public void setGlint(boolean glint) { + this.getHandle().setFoil(glint); + } + + @Override + public int getLoyaltyLevel() { + return this.getHandle().getLoyalty(); + } + + @Override + public void setLoyaltyLevel(int loyaltyLevel) { + com.google.common.base.Preconditions.checkArgument(loyaltyLevel >= 0 && loyaltyLevel <= 127, "The loyalty level has to be between 0 and 127"); + this.getHandle().setLoyalty((byte) loyaltyLevel); + } + // Paper end } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java index e3bde6d1c0..9e53c30801 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftTropicalFish.java @@ -7,7 +7,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.entity.TropicalFish; import org.bukkit.entity.TropicalFish.Pattern; -public class CraftTropicalFish extends CraftFish implements TropicalFish { +public class CraftTropicalFish extends io.papermc.paper.entity.PaperSchoolableFish implements TropicalFish { // Paper - Schooling Fish API public CraftTropicalFish(CraftServer server, net.minecraft.world.entity.animal.TropicalFish entity) { super(server, entity); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java index 1cfbe9c476..e9ec3455ea 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVex.java @@ -29,6 +29,26 @@ public class CraftVex extends CraftMonster implements Vex { public void setSummoner(org.bukkit.entity.Mob summoner) { getHandle().setOwner(summoner == null ? null : ((CraftMob) summoner).getHandle()); } + + @Override + public boolean hasLimitedLifetime() { + return this.getHandle().hasLimitedLife; + } + + @Override + public void setLimitedLifetime(boolean hasLimitedLifetime) { + this.getHandle().hasLimitedLife = hasLimitedLifetime; + } + + @Override + public int getLimitedLifetimeTicks() { + return this.getHandle().limitedLifeTicks; + } + + @Override + public void setLimitedLifetimeTicks(int ticks) { + this.getHandle().limitedLifeTicks = ticks; + } // Paper end @Override diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java index e2a0c11867..3aa23d9f22 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftVillagerZombie.java @@ -60,13 +60,20 @@ public class CraftVillagerZombie extends CraftZombie implements ZombieVillager { @Override public void setConversionTime(int time) { + // Paper start - missing entity behaviour api - converting without entity event + this.setConversionTime(time, true); + } + + @Override + public void setConversionTime(int time, boolean broadcastEntityEvent) { + // Paper end - missing entity behaviour api - converting without entity event if (time < 0) { this.getHandle().villagerConversionTime = -1; this.getHandle().getEntityData().set(net.minecraft.world.entity.monster.ZombieVillager.DATA_CONVERTING_ID, false); this.getHandle().conversionStarter = null; this.getHandle().removeEffect(MobEffects.DAMAGE_BOOST, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONVERSION); } else { - this.getHandle().startConverting(null, time); + this.getHandle().startConverting(null, time, broadcastEntityEvent); // Paper - missing entity behaviour api - converting without entity event } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java index 0e597394a3..3cceefa0d6 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWanderingTrader.java @@ -49,5 +49,25 @@ public class CraftWanderingTrader extends CraftAbstractVillager implements Wande public boolean canDrinkMilk() { return getHandle().canDrinkMilk; } + + @Override + public org.bukkit.Location getWanderingTowards() { + net.minecraft.core.BlockPos pos = this.getHandle().getWanderTarget(); + if (pos == null) { + return null; + } + + return io.papermc.paper.util.MCUtil.toLocation(this.getHandle().level(), pos); + } + + @Override + public void setWanderingTowards(org.bukkit.Location location) { + net.minecraft.core.BlockPos pos = null; + if (location != null) { + pos = io.papermc.paper.util.MCUtil.toBlockPosition(location); + } + + this.getHandle().setWanderTarget(pos); + } // Paper end } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java index 794e4fe0a3..c284eb96a1 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWarden.java @@ -37,6 +37,13 @@ public class CraftWarden extends CraftMonster implements org.bukkit.entity.Warde return this.getHandle().getAngerManagement().getActiveAnger(((CraftEntity) entity).getHandle()); } + // Paper start + @Override + public int getHighestAnger() { + return this.getHandle().getAngerManagement().getActiveAnger(null); + } + // Paper end + @Override public void increaseAnger(Entity entity, int increase) { Preconditions.checkArgument(entity != null, "Entity cannot be null"); diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java index 1113533d28..7881c6253c 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftWither.java @@ -67,4 +67,36 @@ public class CraftWither extends CraftMonster implements Wither, com.destroystok this.getHandle().setInvulnerableTicks(ticks); } + + // Paper start + @Override + public boolean isCharged() { + return getHandle().isPowered(); + } + + @Override + public int getInvulnerableTicks() { + return getHandle().getInvulnerableTicks(); + } + + @Override + public void setInvulnerableTicks(int ticks) { + getHandle().setInvulnerableTicks(ticks); + } + + @Override + public boolean canTravelThroughPortals() { + return getHandle().canUsePortal(false); + } + + @Override + public void setCanTravelThroughPortals(boolean value) { + getHandle().setCanTravelThroughPortals(value); + } + + @Override + public void enterInvulnerabilityPhase() { + this.getHandle().makeInvulnerable(); + } + // Paper end }