diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Cat.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Cat.java.patch | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Cat.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Cat.java.patch new file mode 100644 index 0000000000..65713dfd29 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/entity/animal/Cat.java.patch @@ -0,0 +1,66 @@ +--- a/net/minecraft/world/entity/animal/Cat.java ++++ b/net/minecraft/world/entity/animal/Cat.java +@@ -402,9 +411,9 @@ + return InteractionResult.CONSUME; + } + } +- } else if (this.isFood(itemInHand)) { +- this.usePlayerItem(player, hand, itemInHand); +- if (this.random.nextInt(3) == 0) { ++ } else if (this.isFood(itemstack)) { ++ this.usePlayerItem(player, hand, itemstack); ++ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit + this.tame(player); + this.setOrderedToSit(true); + this.level().broadcastEntityEvent(this, (byte)7); +@@ -462,7 +472,10 @@ + return new Vector3f(0.0F, entityDimensions.height - 0.1875F * f, 0.0F); + } + +- static class CatAvoidEntityGoal<T extends LivingEntity> extends AvoidEntityGoal<T> { ++ private static class CatTemptGoal extends TemptGoal { ++ ++ @Nullable ++ private LivingEntity selectedPlayer; // CraftBukkit + private final Cat cat; + + public CatAvoidEntityGoal(Cat cat, Class<T> entityClassToAvoid, float maxDist, double walkSpeedModifier, double sprintSpeedModifier) { +@@ -587,18 +605,26 @@ + .withParameter(LootContextParams.THIS_ENTITY, this.cat) + .create(LootContextParamSets.GIFT); + +- for (ItemStack itemStack : lootTable.getRandomItems(lootParams)) { +- this.cat +- .level() +- .addFreshEntity( +- new ItemEntity( +- this.cat.level(), +- (double)mutableBlockPos.getX() - (double)Mth.sin(this.cat.yBodyRot * (float) (Math.PI / 180.0)), +- (double)mutableBlockPos.getY(), +- (double)mutableBlockPos.getZ() + (double)Mth.cos(this.cat.yBodyRot * (float) (Math.PI / 180.0)), +- itemStack +- ) +- ); ++ blockposition_mutableblockposition.set(this.cat.isLeashed() ? this.cat.getLeashHolder().blockPosition() : this.cat.blockPosition()); ++ this.cat.randomTeleport((double) (blockposition_mutableblockposition.getX() + randomsource.nextInt(11) - 5), (double) (blockposition_mutableblockposition.getY() + randomsource.nextInt(5) - 2), (double) (blockposition_mutableblockposition.getZ() + randomsource.nextInt(11) - 5), false); ++ blockposition_mutableblockposition.set(this.cat.blockPosition()); ++ LootTable loottable = this.cat.level().getServer().getLootData().getLootTable(BuiltInLootTables.CAT_MORNING_GIFT); ++ LootParams lootparams = (new LootParams.Builder((ServerLevel) this.cat.level())).withParameter(LootContextParams.ORIGIN, this.cat.position()).withParameter(LootContextParams.THIS_ENTITY, this.cat).create(LootContextParamSets.GIFT); ++ List<ItemStack> list = loottable.getRandomItems(lootparams); ++ Iterator iterator = list.iterator(); ++ ++ while (iterator.hasNext()) { ++ ItemStack itemstack = (ItemStack) iterator.next(); ++ ++ // CraftBukkit start ++ ItemEntity entityitem = new ItemEntity(this.cat.level(), (double) blockposition_mutableblockposition.getX() - (double) Mth.sin(this.cat.yBodyRot * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) Mth.cos(this.cat.yBodyRot * 0.017453292F), itemstack); ++ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.cat.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity()); ++ entityitem.level().getCraftServer().getPluginManager().callEvent(event); ++ if (event.isCancelled()) { ++ continue; ++ } ++ this.cat.level().addFreshEntity(entityitem); ++ // CraftBukkit end + } + } + |