Remap CraftBukkit to Mojang+Yarn Mappings
By: Initial Source <noreply+automated@papermc.io>
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
--- a/net/minecraft/world/entity/animal/Animal.java
|
||||
+++ b/net/minecraft/world/entity/animal/Animal.java
|
||||
@@ -35,12 +35,20 @@
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.pathfinder.PathType;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityBreedEvent;
|
||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
||||
+import org.bukkit.event.entity.EntityEnterLoveModeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class Animal extends AgeableMob {
|
||||
|
||||
protected static final int PARENT_AGE_AFTER_BREEDING = 6000;
|
||||
public int inLove;
|
||||
@Nullable
|
||||
public UUID loveCause;
|
||||
+ public ItemStack breedItem; // CraftBukkit - Add breedItem variable
|
||||
|
||||
protected Animal(EntityType<? extends Animal> type, Level world) {
|
||||
super(type, world);
|
||||
@@ -82,9 +90,15 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void actuallyHurt(ServerLevel world, DamageSource source, float amount) {
|
||||
+ // CraftBukkit start - void -> boolean
|
||||
+ public boolean actuallyHurt(ServerLevel worldserver, DamageSource damagesource, float f, EntityDamageEvent event) {
|
||||
+ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event);
|
||||
+ if (!damageResult) {
|
||||
+ return false;
|
||||
+ }
|
||||
this.resetLove();
|
||||
- super.actuallyHurt(world, source, amount);
|
||||
+ return true;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -188,10 +202,17 @@
|
||||
}
|
||||
|
||||
public void setInLove(@Nullable Player player) {
|
||||
- this.inLove = 600;
|
||||
+ // CraftBukkit start
|
||||
+ EntityEnterLoveModeEvent entityEnterLoveModeEvent = CraftEventFactory.callEntityEnterLoveModeEvent(player, this, 600);
|
||||
+ if (entityEnterLoveModeEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ this.inLove = entityEnterLoveModeEvent.getTicksInLove();
|
||||
+ // CraftBukkit end
|
||||
if (player != null) {
|
||||
this.loveCause = player.getUUID();
|
||||
}
|
||||
+ this.breedItem = player.getInventory().getSelected(); // CraftBukkit
|
||||
|
||||
this.level().broadcastEntityEvent(this, (byte) 18);
|
||||
}
|
||||
@@ -233,25 +254,46 @@
|
||||
if (entityageable != null) {
|
||||
entityageable.setBaby(true);
|
||||
entityageable.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
|
||||
- this.finalizeSpawnChildFromBreeding(world, other, entityageable);
|
||||
- world.addFreshEntityWithPassengers(entityageable);
|
||||
+ // CraftBukkit start - call EntityBreedEvent
|
||||
+ ServerPlayer breeder = Optional.ofNullable(this.getLoveCause()).or(() -> {
|
||||
+ return Optional.ofNullable(other.getLoveCause());
|
||||
+ }).orElse(null);
|
||||
+ int experience = this.getRandom().nextInt(7) + 1;
|
||||
+ EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityageable, this, other, breeder, this.breedItem, experience);
|
||||
+ if (entityBreedEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ experience = entityBreedEvent.getExperience();
|
||||
+ this.finalizeSpawnChildFromBreeding(world, other, entityageable, experience);
|
||||
+ world.addFreshEntityWithPassengers(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
public void finalizeSpawnChildFromBreeding(ServerLevel world, Animal other, @Nullable AgeableMob baby) {
|
||||
+ // CraftBukkit start
|
||||
+ this.finalizeSpawnChildFromBreeding(world, other, baby, this.getRandom().nextInt(7) + 1);
|
||||
+ }
|
||||
+
|
||||
+ public void finalizeSpawnChildFromBreeding(ServerLevel worldserver, Animal entityanimal, @Nullable AgeableMob entityageable, int experience) {
|
||||
+ // CraftBukkit end
|
||||
Optional.ofNullable(this.getLoveCause()).or(() -> {
|
||||
- return Optional.ofNullable(other.getLoveCause());
|
||||
+ return Optional.ofNullable(entityanimal.getLoveCause());
|
||||
}).ifPresent((entityplayer) -> {
|
||||
entityplayer.awardStat(Stats.ANIMALS_BRED);
|
||||
- CriteriaTriggers.BRED_ANIMALS.trigger(entityplayer, this, other, baby);
|
||||
+ CriteriaTriggers.BRED_ANIMALS.trigger(entityplayer, this, entityanimal, entityageable);
|
||||
});
|
||||
this.setAge(6000);
|
||||
- other.setAge(6000);
|
||||
+ entityanimal.setAge(6000);
|
||||
this.resetLove();
|
||||
- other.resetLove();
|
||||
- world.broadcastEntityEvent(this, (byte) 18);
|
||||
- if (world.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
- world.addFreshEntity(new ExperienceOrb(world, this.getX(), this.getY(), this.getZ(), this.getRandom().nextInt(7) + 1));
|
||||
+ entityanimal.resetLove();
|
||||
+ worldserver.broadcastEntityEvent(this, (byte) 18);
|
||||
+ if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
+ // CraftBukkit start - use event experience
|
||||
+ if (experience > 0) {
|
||||
+ worldserver.addFreshEntity(new ExperienceOrb(worldserver, this.getX(), this.getY(), this.getZ(), experience));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
--- a/net/minecraft/world/entity/animal/Bee.java
|
||||
+++ b/net/minecraft/world/entity/animal/Bee.java
|
||||
@@ -92,6 +92,11 @@
|
||||
import net.minecraft.world.level.pathfinder.Path;
|
||||
import net.minecraft.world.level.pathfinder.PathType;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class Bee extends Animal implements NeutralMob, FlyingAnimal {
|
||||
|
||||
@@ -198,21 +203,28 @@
|
||||
|
||||
@Override
|
||||
public void addAdditionalSaveData(CompoundTag nbt) {
|
||||
- super.addAdditionalSaveData(nbt);
|
||||
- if (this.hasHive()) {
|
||||
- nbt.put("hive_pos", NbtUtils.writeBlockPos(this.getHivePos()));
|
||||
+ // CraftBukkit start - selectively save data
|
||||
+ this.addAdditionalSaveData(nbt, true);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void addAdditionalSaveData(CompoundTag nbttagcompound, boolean includeAll) {
|
||||
+ // CraftBukkit end
|
||||
+ super.addAdditionalSaveData(nbttagcompound);
|
||||
+ if (includeAll && this.hasHive()) { // CraftBukkit - selectively save hive
|
||||
+ nbttagcompound.put("hive_pos", NbtUtils.writeBlockPos(this.getHivePos()));
|
||||
}
|
||||
|
||||
- if (this.hasSavedFlowerPos()) {
|
||||
- nbt.put("flower_pos", NbtUtils.writeBlockPos(this.getSavedFlowerPos()));
|
||||
+ if (includeAll && this.hasSavedFlowerPos()) { // CraftBukkit - selectively save flower
|
||||
+ nbttagcompound.put("flower_pos", NbtUtils.writeBlockPos(this.getSavedFlowerPos()));
|
||||
}
|
||||
|
||||
- nbt.putBoolean("HasNectar", this.hasNectar());
|
||||
- nbt.putBoolean("HasStung", this.hasStung());
|
||||
- nbt.putInt("TicksSincePollination", this.ticksWithoutNectarSinceExitingHive);
|
||||
- nbt.putInt("CannotEnterHiveTicks", this.stayOutOfHiveCountdown);
|
||||
- nbt.putInt("CropsGrownSincePollination", this.numCropsGrownSincePollination);
|
||||
- this.addPersistentAngerSaveData(nbt);
|
||||
+ nbttagcompound.putBoolean("HasNectar", this.hasNectar());
|
||||
+ nbttagcompound.putBoolean("HasStung", this.hasStung());
|
||||
+ nbttagcompound.putInt("TicksSincePollination", this.ticksWithoutNectarSinceExitingHive);
|
||||
+ nbttagcompound.putInt("CannotEnterHiveTicks", this.stayOutOfHiveCountdown);
|
||||
+ nbttagcompound.putInt("CropsGrownSincePollination", this.numCropsGrownSincePollination);
|
||||
+ this.addPersistentAngerSaveData(nbttagcompound);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -223,8 +235,8 @@
|
||||
this.ticksWithoutNectarSinceExitingHive = nbt.getInt("TicksSincePollination");
|
||||
this.stayOutOfHiveCountdown = nbt.getInt("CannotEnterHiveTicks");
|
||||
this.numCropsGrownSincePollination = nbt.getInt("CropsGrownSincePollination");
|
||||
- this.hivePos = (BlockPos) NbtUtils.readBlockPos(nbt, "hive_pos").orElse((Object) null);
|
||||
- this.savedFlowerPos = (BlockPos) NbtUtils.readBlockPos(nbt, "flower_pos").orElse((Object) null);
|
||||
+ this.hivePos = (BlockPos) NbtUtils.readBlockPos(nbt, "hive_pos").orElse(null); // CraftBukkit - decompile error
|
||||
+ this.savedFlowerPos = (BlockPos) NbtUtils.readBlockPos(nbt, "flower_pos").orElse(null); // CraftBukkit - decompile error
|
||||
this.readPersistentAngerSaveData(this.level(), nbt);
|
||||
}
|
||||
|
||||
@@ -248,7 +260,7 @@
|
||||
}
|
||||
|
||||
if (b0 > 0) {
|
||||
- entityliving.addEffect(new MobEffectInstance(MobEffects.POISON, b0 * 20, 0), this);
|
||||
+ entityliving.addEffect(new MobEffectInstance(MobEffects.POISON, b0 * 20, 0), this, EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -506,7 +518,7 @@
|
||||
|
||||
@Nullable
|
||||
BeehiveBlockEntity getBeehiveBlockEntity() {
|
||||
- return this.hivePos == null ? null : (this.isTooFarAway(this.hivePos) ? null : (BeehiveBlockEntity) this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse((Object) null));
|
||||
+ return this.hivePos == null ? null : (this.isTooFarAway(this.hivePos) ? null : (BeehiveBlockEntity) this.level().getBlockEntity(this.hivePos, BlockEntityType.BEEHIVE).orElse(null)); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
boolean isHiveValid() {
|
||||
@@ -671,8 +683,14 @@
|
||||
if (this.isInvulnerableTo(world, source)) {
|
||||
return false;
|
||||
} else {
|
||||
+ // CraftBukkit start - Only stop pollinating if entity was damaged
|
||||
+ boolean result = super.hurtServer(world, source, amount);
|
||||
+ if (!result) {
|
||||
+ return result;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.beePollinateGoal.stopPollinating();
|
||||
- return super.hurtServer(world, source, amount);
|
||||
+ return result; // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1082,7 +1100,7 @@
|
||||
|
||||
BeeGoToHiveGoal() {
|
||||
super();
|
||||
- this.travellingTicks = Bee.this.level().random.nextInt(10);
|
||||
+ this.travellingTicks = Bee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues
|
||||
this.blacklistedTargets = Lists.newArrayList();
|
||||
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
|
||||
}
|
||||
@@ -1196,7 +1214,7 @@
|
||||
|
||||
BeeGoToKnownFlowerGoal() {
|
||||
super();
|
||||
- this.travellingTicks = Bee.this.level().random.nextInt(10);
|
||||
+ this.travellingTicks = Bee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues
|
||||
this.setFlags(EnumSet.of(Goal.Flag.MOVE));
|
||||
}
|
||||
|
||||
@@ -1301,7 +1319,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (iblockdata1 != null) {
|
||||
+ if (iblockdata1 != null && CraftEventFactory.callEntityChangeBlockEvent(Bee.this, blockposition, iblockdata1)) { // CraftBukkit
|
||||
Bee.this.level().levelEvent(2011, blockposition, 15);
|
||||
Bee.this.level().setBlockAndUpdate(blockposition, iblockdata1);
|
||||
Bee.this.incrementNumCropsGrownSincePollination();
|
||||
@@ -1378,7 +1396,7 @@
|
||||
@Override
|
||||
protected void alertOther(Mob mob, LivingEntity target) {
|
||||
if (mob instanceof Bee && this.mob.hasLineOfSight(target)) {
|
||||
- mob.setTarget(target);
|
||||
+ mob.setTarget(target, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1387,7 +1405,7 @@
|
||||
private static class BeeBecomeAngryTargetGoal extends NearestAttackableTargetGoal<Player> {
|
||||
|
||||
BeeBecomeAngryTargetGoal(Bee bee) {
|
||||
- Objects.requireNonNull(bee);
|
||||
+ // Objects.requireNonNull(entitybee); // CraftBukkit - decompile error
|
||||
super(bee, Player.class, 10, true, false, bee::isAngryAt);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
--- a/net/minecraft/world/entity/animal/Bucketable.java
|
||||
+++ b/net/minecraft/world/entity/animal/Bucketable.java
|
||||
@@ -16,6 +16,11 @@
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.item.component.CustomData;
|
||||
import net.minecraft.world.level.Level;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+import org.bukkit.event.player.PlayerBucketEntityEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
public interface Bucketable {
|
||||
|
||||
@@ -93,10 +98,22 @@
|
||||
ItemStack itemstack = player.getItemInHand(hand);
|
||||
|
||||
if (itemstack.getItem() == Items.WATER_BUCKET && entity.isAlive()) {
|
||||
- entity.playSound(((Bucketable) entity).getPickupSound(), 1.0F, 1.0F);
|
||||
+ // CraftBukkit start
|
||||
+ // t0.playSound(((Bucketable) t0).getPickupSound(), 1.0F, 1.0F); // CraftBukkit - moved down
|
||||
ItemStack itemstack1 = ((Bucketable) entity).getBucketItemStack();
|
||||
|
||||
((Bucketable) entity).saveToBucketTag(itemstack1);
|
||||
+
|
||||
+ PlayerBucketEntityEvent playerBucketFishEvent = CraftEventFactory.callPlayerFishBucketEvent(entity, player, itemstack, itemstack1, hand);
|
||||
+ itemstack1 = CraftItemStack.asNMSCopy(playerBucketFishEvent.getEntityBucket());
|
||||
+ if (playerBucketFishEvent.isCancelled()) {
|
||||
+ ((ServerPlayer) player).containerMenu.sendAllDataToRemote(); // We need to update inventory to resync client's bucket
|
||||
+ entity.getBukkitEntity().update((ServerPlayer) player); // We need to play out these packets as the client assumes the fish is gone
|
||||
+ entity.refreshEntityData((ServerPlayer) player); // Need to send data such as the display name to client
|
||||
+ return Optional.of(InteractionResult.FAIL);
|
||||
+ }
|
||||
+ entity.playSound(((Bucketable) entity).getPickupSound(), 1.0F, 1.0F);
|
||||
+ // CraftBukkit end
|
||||
ItemStack itemstack2 = ItemUtils.createFilledResult(itemstack, player, itemstack1, false);
|
||||
|
||||
player.setItemInHand(hand, itemstack2);
|
||||
@@ -106,7 +123,7 @@
|
||||
CriteriaTriggers.FILLED_BUCKET.trigger((ServerPlayer) player, itemstack1);
|
||||
}
|
||||
|
||||
- entity.discard();
|
||||
+ entity.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
return Optional.of(InteractionResult.SUCCESS);
|
||||
} else {
|
||||
return Optional.empty();
|
||||
@@ -1,50 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/Bucketable.java
|
||||
+++ b/net/minecraft/world/entity/animal/Bucketable.java
|
||||
@@ -17,6 +17,14 @@
|
||||
import net.minecraft.world.item.component.CustomData;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntity;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+import org.bukkit.event.player.PlayerBucketEntityEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public interface Bucketable {
|
||||
|
||||
boolean fromBucket();
|
||||
@@ -93,10 +101,22 @@
|
||||
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
|
||||
|
||||
if (itemstack.getItem() == Items.WATER_BUCKET && t0.isAlive()) {
|
||||
- t0.playSound(((Bucketable) t0).getPickupSound(), 1.0F, 1.0F);
|
||||
+ // CraftBukkit start
|
||||
+ // t0.playSound(((Bucketable) t0).getPickupSound(), 1.0F, 1.0F); // CraftBukkit - moved down
|
||||
ItemStack itemstack1 = ((Bucketable) t0).getBucketItemStack();
|
||||
|
||||
((Bucketable) t0).saveToBucketTag(itemstack1);
|
||||
+
|
||||
+ PlayerBucketEntityEvent playerBucketFishEvent = CraftEventFactory.callPlayerFishBucketEvent(t0, entityhuman, itemstack, itemstack1, enumhand);
|
||||
+ itemstack1 = CraftItemStack.asNMSCopy(playerBucketFishEvent.getEntityBucket());
|
||||
+ if (playerBucketFishEvent.isCancelled()) {
|
||||
+ ((EntityPlayer) entityhuman).containerMenu.sendAllDataToRemote(); // We need to update inventory to resync client's bucket
|
||||
+ t0.getBukkitEntity().update((EntityPlayer) entityhuman); // We need to play out these packets as the client assumes the fish is gone
|
||||
+ t0.refreshEntityData((EntityPlayer) entityhuman); // Need to send data such as the display name to client
|
||||
+ return Optional.of(EnumInteractionResult.FAIL);
|
||||
+ }
|
||||
+ t0.playSound(((Bucketable) t0).getPickupSound(), 1.0F, 1.0F);
|
||||
+ // CraftBukkit end
|
||||
ItemStack itemstack2 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, itemstack1, false);
|
||||
|
||||
entityhuman.setItemInHand(enumhand, itemstack2);
|
||||
@@ -106,7 +126,7 @@
|
||||
CriterionTriggers.FILLED_BUCKET.trigger((EntityPlayer) entityhuman, itemstack1);
|
||||
}
|
||||
|
||||
- t0.discard();
|
||||
+ t0.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
return Optional.of(EnumInteractionResult.SUCCESS);
|
||||
} else {
|
||||
return Optional.empty();
|
||||
@@ -0,0 +1,64 @@
|
||||
--- a/net/minecraft/world/entity/animal/Cat.java
|
||||
+++ b/net/minecraft/world/entity/animal/Cat.java
|
||||
@@ -174,10 +174,10 @@
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag nbt) {
|
||||
super.readAdditionalSaveData(nbt);
|
||||
- Optional optional = Optional.ofNullable(ResourceLocation.tryParse(nbt.getString("variant"))).map((minecraftkey) -> {
|
||||
+ Optional<ResourceKey<CatVariant>> optional = Optional.ofNullable(ResourceLocation.tryParse(nbt.getString("variant"))).map((minecraftkey) -> { // CraftBukkit - decompile error
|
||||
return ResourceKey.create(Registries.CAT_VARIANT, minecraftkey);
|
||||
});
|
||||
- Registry iregistry = BuiltInRegistries.CAT_VARIANT;
|
||||
+ Registry<CatVariant> iregistry = BuiltInRegistries.CAT_VARIANT; // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(iregistry);
|
||||
optional.flatMap(iregistry::get).ifPresent(this::setVariant);
|
||||
@@ -462,7 +462,7 @@
|
||||
}
|
||||
|
||||
private void tryToTame(Player player) {
|
||||
- if (this.random.nextInt(3) == 0) {
|
||||
+ 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);
|
||||
@@ -480,7 +480,7 @@
|
||||
private static class CatTemptGoal extends TemptGoal {
|
||||
|
||||
@Nullable
|
||||
- private Player selectedPlayer;
|
||||
+ private LivingEntity selectedPlayer; // CraftBukkit
|
||||
private final Cat cat;
|
||||
|
||||
public CatTemptGoal(Cat cat, double speed, Predicate<ItemStack> foodPredicate, boolean canBeScared) {
|
||||
@@ -614,7 +614,15 @@
|
||||
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());
|
||||
this.cat.dropFromGiftLootTable(getServerLevel((Entity) this.cat), BuiltInLootTables.CAT_MORNING_GIFT, (worldserver, itemstack) -> {
|
||||
- worldserver.addFreshEntity(new ItemEntity(worldserver, (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));
|
||||
+ // CraftBukkit start
|
||||
+ ItemEntity entityitem = new ItemEntity(worldserver, (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()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ worldserver.addFreshEntity(entityitem);
|
||||
+ // CraftBukkit end
|
||||
});
|
||||
}
|
||||
|
||||
@@ -645,10 +653,10 @@
|
||||
private final Cat cat;
|
||||
|
||||
public CatAvoidEntityGoal(Cat cat, Class<T> fleeFromType, float distance, double slowSpeed, double fastSpeed) {
|
||||
- Predicate predicate = EntitySelector.NO_CREATIVE_OR_SPECTATOR;
|
||||
+ // Predicate predicate = IEntitySelector.NO_CREATIVE_OR_SPECTATOR; // CraftBukkit - decompile error
|
||||
|
||||
- Objects.requireNonNull(predicate);
|
||||
- super(cat, fleeFromType, distance, slowSpeed, fastSpeed, predicate::test);
|
||||
+ // Objects.requireNonNull(predicate); // CraftBukkit - decompile error
|
||||
+ super(cat, fleeFromType, distance, slowSpeed, fastSpeed, EntitySelector.NO_CREATIVE_OR_SPECTATOR::test); // CraftBukkit - decompile error
|
||||
this.cat = cat;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
--- a/net/minecraft/world/entity/animal/Chicken.java
|
||||
+++ b/net/minecraft/world/entity/animal/Chicken.java
|
||||
@@ -99,10 +99,12 @@
|
||||
|
||||
if (world instanceof ServerLevel worldserver) {
|
||||
if (this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
if (this.dropFromGiftLootTable(worldserver, BuiltInLootTables.CHICKEN_LAY, this::spawnAtLocation)) {
|
||||
this.playSound(SoundEvents.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
||||
this.gameEvent(GameEvent.ENTITY_PLACE);
|
||||
}
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
|
||||
this.eggTime = this.random.nextInt(6000) + 6000;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
--- a/net/minecraft/world/entity/animal/Cow.java
|
||||
+++ b/net/minecraft/world/entity/animal/Cow.java
|
||||
@@ -30,6 +30,11 @@
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class Cow extends Animal {
|
||||
|
||||
@@ -92,8 +97,16 @@
|
||||
ItemStack itemstack = player.getItemInHand(hand);
|
||||
|
||||
if (itemstack.is(Items.BUCKET) && !this.isBaby()) {
|
||||
+ // CraftBukkit start - Got milk?
|
||||
+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((ServerLevel) player.level(), player, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, hand);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
player.playSound(SoundEvents.COW_MILK, 1.0F, 1.0F);
|
||||
- ItemStack itemstack1 = ItemUtils.createFilledResult(itemstack, player, Items.MILK_BUCKET.getDefaultInstance());
|
||||
+ ItemStack itemstack1 = ItemUtils.createFilledResult(itemstack, player, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
|
||||
|
||||
player.setItemInHand(hand, itemstack1);
|
||||
return InteractionResult.SUCCESS;
|
||||
@@ -0,0 +1,69 @@
|
||||
--- a/net/minecraft/world/entity/animal/Dolphin.java
|
||||
+++ b/net/minecraft/world/entity/animal/Dolphin.java
|
||||
@@ -61,9 +61,20 @@
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
import net.minecraft.world.level.pathfinder.PathComputationType;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class Dolphin extends AgeableWaterCreature {
|
||||
|
||||
+ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
|
||||
+ @Override
|
||||
+ public int getDefaultMaxAirSupply() {
|
||||
+ return Dolphin.TOTAL_AIR_SUPPLY;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
private static final EntityDataAccessor<BlockPos> TREASURE_POS = SynchedEntityData.defineId(Dolphin.class, EntityDataSerializers.BLOCK_POS);
|
||||
private static final EntityDataAccessor<Boolean> GOT_FISH = SynchedEntityData.defineId(Dolphin.class, EntityDataSerializers.BOOLEAN);
|
||||
private static final EntityDataAccessor<Integer> MOISTNESS_LEVEL = SynchedEntityData.defineId(Dolphin.class, EntityDataSerializers.INT);
|
||||
@@ -200,7 +211,7 @@
|
||||
|
||||
@Override
|
||||
public int getMaxAirSupply() {
|
||||
- return 4800;
|
||||
+ return this.maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -234,11 +245,17 @@
|
||||
ItemStack itemstack = itemEntity.getItem();
|
||||
|
||||
if (this.canHoldItem(itemstack)) {
|
||||
+ // CraftBukkit start - call EntityPickupItemEvent
|
||||
+ if (CraftEventFactory.callEntityPickupItemEvent(this, itemEntity, 0, false).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ itemstack = itemEntity.getItem(); // CraftBukkit- update ItemStack from event
|
||||
+ // CraftBukkit start
|
||||
this.onItemPickup(itemEntity);
|
||||
this.setItemSlot(EquipmentSlot.MAINHAND, itemstack);
|
||||
this.setGuaranteedDrop(EquipmentSlot.MAINHAND);
|
||||
this.take(itemEntity, itemstack.getCount());
|
||||
- itemEntity.discard();
|
||||
+ itemEntity.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
}
|
||||
|
||||
@@ -495,7 +512,7 @@
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
- this.player.addEffect(new MobEffectInstance(MobEffects.DOLPHINS_GRACE, 100), this.dolphin);
|
||||
+ this.player.addEffect(new MobEffectInstance(MobEffects.DOLPHINS_GRACE, 100), this.dolphin, EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -514,7 +531,7 @@
|
||||
}
|
||||
|
||||
if (this.player.isSwimming() && this.player.level().random.nextInt(6) == 0) {
|
||||
- this.player.addEffect(new MobEffectInstance(MobEffects.DOLPHINS_GRACE, 100), this.dolphin);
|
||||
+ this.player.addEffect(new MobEffectInstance(MobEffects.DOLPHINS_GRACE, 100), this.dolphin, EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityAnimal.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityAnimal.java
|
||||
@@ -35,12 +35,20 @@
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.pathfinder.PathType;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityBreedEvent;
|
||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
||||
+import org.bukkit.event.entity.EntityEnterLoveModeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class EntityAnimal extends EntityAgeable {
|
||||
|
||||
protected static final int PARENT_AGE_AFTER_BREEDING = 6000;
|
||||
public int inLove;
|
||||
@Nullable
|
||||
public UUID loveCause;
|
||||
+ public ItemStack breedItem; // CraftBukkit - Add breedItem variable
|
||||
|
||||
protected EntityAnimal(EntityTypes<? extends EntityAnimal> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -82,9 +90,15 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) {
|
||||
+ // CraftBukkit start - void -> boolean
|
||||
+ public boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) {
|
||||
+ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event);
|
||||
+ if (!damageResult) {
|
||||
+ return false;
|
||||
+ }
|
||||
this.resetLove();
|
||||
- super.actuallyHurt(worldserver, damagesource, f);
|
||||
+ return true;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -188,10 +202,17 @@
|
||||
}
|
||||
|
||||
public void setInLove(@Nullable EntityHuman entityhuman) {
|
||||
- this.inLove = 600;
|
||||
+ // CraftBukkit start
|
||||
+ EntityEnterLoveModeEvent entityEnterLoveModeEvent = CraftEventFactory.callEntityEnterLoveModeEvent(entityhuman, this, 600);
|
||||
+ if (entityEnterLoveModeEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ this.inLove = entityEnterLoveModeEvent.getTicksInLove();
|
||||
+ // CraftBukkit end
|
||||
if (entityhuman != null) {
|
||||
this.loveCause = entityhuman.getUUID();
|
||||
}
|
||||
+ this.breedItem = entityhuman.getInventory().getSelected(); // CraftBukkit
|
||||
|
||||
this.level().broadcastEntityEvent(this, (byte) 18);
|
||||
}
|
||||
@@ -233,12 +254,29 @@
|
||||
if (entityageable != null) {
|
||||
entityageable.setBaby(true);
|
||||
entityageable.moveTo(this.getX(), this.getY(), this.getZ(), 0.0F, 0.0F);
|
||||
- this.finalizeSpawnChildFromBreeding(worldserver, entityanimal, entityageable);
|
||||
- worldserver.addFreshEntityWithPassengers(entityageable);
|
||||
+ // CraftBukkit start - call EntityBreedEvent
|
||||
+ EntityPlayer breeder = Optional.ofNullable(this.getLoveCause()).or(() -> {
|
||||
+ return Optional.ofNullable(entityanimal.getLoveCause());
|
||||
+ }).orElse(null);
|
||||
+ int experience = this.getRandom().nextInt(7) + 1;
|
||||
+ EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityageable, this, entityanimal, breeder, this.breedItem, experience);
|
||||
+ if (entityBreedEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ experience = entityBreedEvent.getExperience();
|
||||
+ this.finalizeSpawnChildFromBreeding(worldserver, entityanimal, entityageable, experience);
|
||||
+ worldserver.addFreshEntityWithPassengers(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
public void finalizeSpawnChildFromBreeding(WorldServer worldserver, EntityAnimal entityanimal, @Nullable EntityAgeable entityageable) {
|
||||
+ // CraftBukkit start
|
||||
+ this.finalizeSpawnChildFromBreeding(worldserver, entityanimal, entityageable, this.getRandom().nextInt(7) + 1);
|
||||
+ }
|
||||
+
|
||||
+ public void finalizeSpawnChildFromBreeding(WorldServer worldserver, EntityAnimal entityanimal, @Nullable EntityAgeable entityageable, int experience) {
|
||||
+ // CraftBukkit end
|
||||
Optional.ofNullable(this.getLoveCause()).or(() -> {
|
||||
return Optional.ofNullable(entityanimal.getLoveCause());
|
||||
}).ifPresent((entityplayer) -> {
|
||||
@@ -251,7 +289,11 @@
|
||||
entityanimal.resetLove();
|
||||
worldserver.broadcastEntityEvent(this, (byte) 18);
|
||||
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
- worldserver.addFreshEntity(new EntityExperienceOrb(worldserver, this.getX(), this.getY(), this.getZ(), this.getRandom().nextInt(7) + 1));
|
||||
+ // CraftBukkit start - use event experience
|
||||
+ if (experience > 0) {
|
||||
+ worldserver.addFreshEntity(new EntityExperienceOrb(worldserver, this.getX(), this.getY(), this.getZ(), experience));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityBee.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityBee.java
|
||||
@@ -93,6 +93,12 @@
|
||||
import net.minecraft.world.level.pathfinder.PathType;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityBee extends EntityAnimal implements IEntityAngerable, EntityBird {
|
||||
|
||||
public static final float FLAP_DEGREES_PER_TICK = 120.32113F;
|
||||
@@ -198,12 +204,19 @@
|
||||
|
||||
@Override
|
||||
public void addAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
||||
+ // CraftBukkit start - selectively save data
|
||||
+ addAdditionalSaveData(nbttagcompound, true);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void addAdditionalSaveData(NBTTagCompound nbttagcompound, boolean includeAll) {
|
||||
+ // CraftBukkit end
|
||||
super.addAdditionalSaveData(nbttagcompound);
|
||||
- if (this.hasHive()) {
|
||||
+ if (includeAll && this.hasHive()) { // CraftBukkit - selectively save hive
|
||||
nbttagcompound.put("hive_pos", GameProfileSerializer.writeBlockPos(this.getHivePos()));
|
||||
}
|
||||
|
||||
- if (this.hasSavedFlowerPos()) {
|
||||
+ if (includeAll && this.hasSavedFlowerPos()) { // CraftBukkit - selectively save flower
|
||||
nbttagcompound.put("flower_pos", GameProfileSerializer.writeBlockPos(this.getSavedFlowerPos()));
|
||||
}
|
||||
|
||||
@@ -223,8 +236,8 @@
|
||||
this.ticksWithoutNectarSinceExitingHive = nbttagcompound.getInt("TicksSincePollination");
|
||||
this.stayOutOfHiveCountdown = nbttagcompound.getInt("CannotEnterHiveTicks");
|
||||
this.numCropsGrownSincePollination = nbttagcompound.getInt("CropsGrownSincePollination");
|
||||
- this.hivePos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "hive_pos").orElse((Object) null);
|
||||
- this.savedFlowerPos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "flower_pos").orElse((Object) null);
|
||||
+ this.hivePos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "hive_pos").orElse(null); // CraftBukkit - decompile error
|
||||
+ this.savedFlowerPos = (BlockPosition) GameProfileSerializer.readBlockPos(nbttagcompound, "flower_pos").orElse(null); // CraftBukkit - decompile error
|
||||
this.readPersistentAngerSaveData(this.level(), nbttagcompound);
|
||||
}
|
||||
|
||||
@@ -248,7 +261,7 @@
|
||||
}
|
||||
|
||||
if (b0 > 0) {
|
||||
- entityliving.addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this);
|
||||
+ entityliving.addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this, EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -506,7 +519,7 @@
|
||||
|
||||
@Nullable
|
||||
TileEntityBeehive getBeehiveBlockEntity() {
|
||||
- return this.hivePos == null ? null : (this.isTooFarAway(this.hivePos) ? null : (TileEntityBeehive) this.level().getBlockEntity(this.hivePos, TileEntityTypes.BEEHIVE).orElse((Object) null));
|
||||
+ return this.hivePos == null ? null : (this.isTooFarAway(this.hivePos) ? null : (TileEntityBeehive) this.level().getBlockEntity(this.hivePos, TileEntityTypes.BEEHIVE).orElse(null)); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
boolean isHiveValid() {
|
||||
@@ -671,8 +684,14 @@
|
||||
if (this.isInvulnerableTo(worldserver, damagesource)) {
|
||||
return false;
|
||||
} else {
|
||||
+ // CraftBukkit start - Only stop pollinating if entity was damaged
|
||||
+ boolean result = super.hurtServer(worldserver, damagesource, f);
|
||||
+ if (!result) {
|
||||
+ return result;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.beePollinateGoal.stopPollinating();
|
||||
- return super.hurtServer(worldserver, damagesource, f);
|
||||
+ return result; // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1082,7 +1101,7 @@
|
||||
|
||||
e() {
|
||||
super();
|
||||
- this.travellingTicks = EntityBee.this.level().random.nextInt(10);
|
||||
+ this.travellingTicks = EntityBee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues
|
||||
this.blacklistedTargets = Lists.newArrayList();
|
||||
this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE));
|
||||
}
|
||||
@@ -1196,7 +1215,7 @@
|
||||
|
||||
f() {
|
||||
super();
|
||||
- this.travellingTicks = EntityBee.this.level().random.nextInt(10);
|
||||
+ this.travellingTicks = EntityBee.this.random.nextInt(10); // CraftBukkit - SPIGOT-7495: Give Bees another chance and let them use their own random, avoid concurrency issues
|
||||
this.setFlags(EnumSet.of(PathfinderGoal.Type.MOVE));
|
||||
}
|
||||
|
||||
@@ -1301,7 +1320,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (iblockdata1 != null) {
|
||||
+ if (iblockdata1 != null && CraftEventFactory.callEntityChangeBlockEvent(EntityBee.this, blockposition, iblockdata1)) { // CraftBukkit
|
||||
EntityBee.this.level().levelEvent(2011, blockposition, 15);
|
||||
EntityBee.this.level().setBlockAndUpdate(blockposition, iblockdata1);
|
||||
EntityBee.this.incrementNumCropsGrownSincePollination();
|
||||
@@ -1378,7 +1397,7 @@
|
||||
@Override
|
||||
protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) {
|
||||
if (entityinsentient instanceof EntityBee && this.mob.hasLineOfSight(entityliving)) {
|
||||
- entityinsentient.setTarget(entityliving);
|
||||
+ entityinsentient.setTarget(entityliving, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1387,7 +1406,7 @@
|
||||
private static class c extends PathfinderGoalNearestAttackableTarget<EntityHuman> {
|
||||
|
||||
c(EntityBee entitybee) {
|
||||
- Objects.requireNonNull(entitybee);
|
||||
+ // Objects.requireNonNull(entitybee); // CraftBukkit - decompile error
|
||||
super(entitybee, EntityHuman.class, 10, true, false, entitybee::isAngryAt);
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityCat.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityCat.java
|
||||
@@ -174,10 +174,10 @@
|
||||
@Override
|
||||
public void readAdditionalSaveData(NBTTagCompound nbttagcompound) {
|
||||
super.readAdditionalSaveData(nbttagcompound);
|
||||
- Optional optional = Optional.ofNullable(MinecraftKey.tryParse(nbttagcompound.getString("variant"))).map((minecraftkey) -> {
|
||||
+ Optional<ResourceKey<CatVariant>> optional = Optional.ofNullable(MinecraftKey.tryParse(nbttagcompound.getString("variant"))).map((minecraftkey) -> { // CraftBukkit - decompile error
|
||||
return ResourceKey.create(Registries.CAT_VARIANT, minecraftkey);
|
||||
});
|
||||
- IRegistry iregistry = BuiltInRegistries.CAT_VARIANT;
|
||||
+ IRegistry<CatVariant> iregistry = BuiltInRegistries.CAT_VARIANT; // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(iregistry);
|
||||
optional.flatMap(iregistry::get).ifPresent(this::setVariant);
|
||||
@@ -462,7 +462,7 @@
|
||||
}
|
||||
|
||||
private void tryToTame(EntityHuman entityhuman) {
|
||||
- if (this.random.nextInt(3) == 0) {
|
||||
+ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { // CraftBukkit
|
||||
this.tame(entityhuman);
|
||||
this.setOrderedToSit(true);
|
||||
this.level().broadcastEntityEvent(this, (byte) 7);
|
||||
@@ -480,7 +480,7 @@
|
||||
private static class PathfinderGoalTemptChance extends PathfinderGoalTempt {
|
||||
|
||||
@Nullable
|
||||
- private EntityHuman selectedPlayer;
|
||||
+ private EntityLiving selectedPlayer; // CraftBukkit
|
||||
private final EntityCat cat;
|
||||
|
||||
public PathfinderGoalTemptChance(EntityCat entitycat, double d0, Predicate<ItemStack> predicate, boolean flag) {
|
||||
@@ -614,7 +614,15 @@
|
||||
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());
|
||||
this.cat.dropFromGiftLootTable(getServerLevel((Entity) this.cat), LootTables.CAT_MORNING_GIFT, (worldserver, itemstack) -> {
|
||||
- worldserver.addFreshEntity(new EntityItem(worldserver, (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.cat.yBodyRot * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.cat.yBodyRot * 0.017453292F), itemstack));
|
||||
+ // CraftBukkit start
|
||||
+ EntityItem entityitem = new EntityItem(worldserver, (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.cat.yBodyRot * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.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()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ worldserver.addFreshEntity(entityitem);
|
||||
+ // CraftBukkit end
|
||||
});
|
||||
}
|
||||
|
||||
@@ -645,10 +653,10 @@
|
||||
private final EntityCat cat;
|
||||
|
||||
public a(EntityCat entitycat, Class<T> oclass, float f, double d0, double d1) {
|
||||
- Predicate predicate = IEntitySelector.NO_CREATIVE_OR_SPECTATOR;
|
||||
+ // Predicate predicate = IEntitySelector.NO_CREATIVE_OR_SPECTATOR; // CraftBukkit - decompile error
|
||||
|
||||
- Objects.requireNonNull(predicate);
|
||||
- super(entitycat, oclass, f, d0, d1, predicate::test);
|
||||
+ // Objects.requireNonNull(predicate); // CraftBukkit - decompile error
|
||||
+ super(entitycat, oclass, f, d0, d1, IEntitySelector.NO_CREATIVE_OR_SPECTATOR::test); // CraftBukkit - decompile error
|
||||
this.cat = entitycat;
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityChicken.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityChicken.java
|
||||
@@ -99,10 +99,12 @@
|
||||
|
||||
if (world instanceof WorldServer worldserver) {
|
||||
if (this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
if (this.dropFromGiftLootTable(worldserver, LootTables.CHICKEN_LAY, this::spawnAtLocation)) {
|
||||
this.playSound(SoundEffects.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
||||
this.gameEvent(GameEvent.ENTITY_PLACE);
|
||||
}
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
|
||||
this.eggTime = this.random.nextInt(6000) + 6000;
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityCow.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityCow.java
|
||||
@@ -31,6 +31,12 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityCow extends EntityAnimal {
|
||||
|
||||
private static final EntitySize BABY_DIMENSIONS = EntityTypes.COW.getDimensions().scale(0.5F).withEyeHeight(0.665F);
|
||||
@@ -92,8 +98,16 @@
|
||||
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
|
||||
|
||||
if (itemstack.is(Items.BUCKET) && !this.isBaby()) {
|
||||
+ // CraftBukkit start - Got milk?
|
||||
+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level(), entityhuman, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, enumhand);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
entityhuman.playSound(SoundEffects.COW_MILK, 1.0F, 1.0F);
|
||||
- ItemStack itemstack1 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, Items.MILK_BUCKET.getDefaultInstance());
|
||||
+ ItemStack itemstack1 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
|
||||
|
||||
entityhuman.setItemInHand(enumhand, itemstack1);
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
@@ -1,69 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityDolphin.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityDolphin.java
|
||||
@@ -62,8 +62,20 @@
|
||||
import net.minecraft.world.level.pathfinder.PathMode;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityPotionEffectEvent;
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityDolphin extends AgeableWaterCreature {
|
||||
|
||||
+ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
|
||||
+ @Override
|
||||
+ public int getDefaultMaxAirSupply() {
|
||||
+ return TOTAL_AIR_SUPPLY;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
private static final DataWatcherObject<BlockPosition> TREASURE_POS = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BLOCK_POS);
|
||||
private static final DataWatcherObject<Boolean> GOT_FISH = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.BOOLEAN);
|
||||
private static final DataWatcherObject<Integer> MOISTNESS_LEVEL = DataWatcher.defineId(EntityDolphin.class, DataWatcherRegistry.INT);
|
||||
@@ -200,7 +212,7 @@
|
||||
|
||||
@Override
|
||||
public int getMaxAirSupply() {
|
||||
- return 4800;
|
||||
+ return maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -234,11 +246,17 @@
|
||||
ItemStack itemstack = entityitem.getItem();
|
||||
|
||||
if (this.canHoldItem(itemstack)) {
|
||||
+ // CraftBukkit start - call EntityPickupItemEvent
|
||||
+ if (CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, false).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ itemstack = entityitem.getItem(); // CraftBukkit- update ItemStack from event
|
||||
+ // CraftBukkit start
|
||||
this.onItemPickup(entityitem);
|
||||
this.setItemSlot(EnumItemSlot.MAINHAND, itemstack);
|
||||
this.setGuaranteedDrop(EnumItemSlot.MAINHAND);
|
||||
this.take(entityitem, itemstack.getCount());
|
||||
- entityitem.discard();
|
||||
+ entityitem.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
}
|
||||
|
||||
@@ -495,7 +513,7 @@
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
- this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin);
|
||||
+ this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin, EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -514,7 +532,7 @@
|
||||
}
|
||||
|
||||
if (this.player.isSwimming() && this.player.level().random.nextInt(6) == 0) {
|
||||
- this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin);
|
||||
+ this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin, EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityIronGolem.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityIronGolem.java
|
||||
@@ -98,7 +98,7 @@
|
||||
@Override
|
||||
protected void doPush(Entity entity) {
|
||||
if (entity instanceof IMonster && !(entity instanceof EntityCreeper) && this.getRandom().nextInt(20) == 0) {
|
||||
- this.setTarget((EntityLiving) entity);
|
||||
+ this.setTarget((EntityLiving) entity, org.bukkit.event.entity.EntityTargetLivingEntityEvent.TargetReason.COLLISION, true); // CraftBukkit - set reason
|
||||
}
|
||||
|
||||
super.doPush(entity);
|
||||
@@ -1,59 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityMushroomCow.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityMushroomCow.java
|
||||
@@ -43,6 +43,13 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.storage.loot.LootTables;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityDropItemEvent;
|
||||
+import org.bukkit.event.entity.EntityTransformEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityMushroomCow extends EntityCow implements IShearable, VariantHolder<EntityMushroomCow.Type> {
|
||||
|
||||
private static final DataWatcherObject<String> DATA_TYPE = DataWatcher.defineId(EntityMushroomCow.class, DataWatcherRegistry.STRING);
|
||||
@@ -120,6 +127,11 @@
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.shear(worldserver, SoundCategory.PLAYERS, itemstack);
|
||||
this.gameEvent(GameEvent.SHEAR, entityhuman);
|
||||
itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand));
|
||||
@@ -163,11 +175,19 @@
|
||||
worldserver.sendParticles(Particles.EXPLOSION, this.getX(), this.getY(0.5D), this.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
|
||||
this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_MOOSHROOM, itemstack, (worldserver1, itemstack1) -> {
|
||||
for (int i = 0; i < itemstack1.getCount(); ++i) {
|
||||
- worldserver1.addFreshEntity(new EntityItem(this.level(), this.getX(), this.getY(1.0D), this.getZ(), itemstack1.copyWithCount(1)));
|
||||
+ // CraftBukkit start
|
||||
+ EntityItem entityitem = new EntityItem(this.level(), this.getX(), this.getY(1.0D), this.getZ(), itemstack1.copyWithCount(1));
|
||||
+ EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
|
||||
+ Bukkit.getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ worldserver1.addFreshEntity(entityitem);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
});
|
||||
- });
|
||||
+ }, EntityTransformEvent.TransformReason.SHEARED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -263,7 +283,7 @@
|
||||
}
|
||||
|
||||
static EntityMushroomCow.Type byName(String s) {
|
||||
- return (EntityMushroomCow.Type) EntityMushroomCow.Type.CODEC.byName(s, (Enum) EntityMushroomCow.Type.RED);
|
||||
+ return (EntityMushroomCow.Type) EntityMushroomCow.Type.CODEC.byName(s, EntityMushroomCow.Type.RED); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityOcelot.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityOcelot.java
|
||||
@@ -167,7 +167,7 @@
|
||||
if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemstack) && entityhuman.distanceToSqr((Entity) this) < 9.0D) {
|
||||
this.usePlayerItem(entityhuman, enumhand, itemstack);
|
||||
if (!this.level().isClientSide) {
|
||||
- if (this.random.nextInt(3) == 0) {
|
||||
+ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { // CraftBukkit - added event call and isCancelled check
|
||||
this.setTrusting(true);
|
||||
this.spawnTrustingParticles(true);
|
||||
this.level().broadcastEntityEvent(this, (byte) 41);
|
||||
@@ -298,10 +298,10 @@
|
||||
private final EntityOcelot ocelot;
|
||||
|
||||
public a(EntityOcelot entityocelot, Class<T> oclass, float f, double d0, double d1) {
|
||||
- Predicate predicate = IEntitySelector.NO_CREATIVE_OR_SPECTATOR;
|
||||
+ // Predicate predicate = IEntitySelector.NO_CREATIVE_OR_SPECTATOR; // CraftBukkit - decompile error
|
||||
|
||||
- Objects.requireNonNull(predicate);
|
||||
- super(entityocelot, oclass, f, d0, d1, predicate::test);
|
||||
+ // Objects.requireNonNull(predicate); // CraftBukkit - decompile error
|
||||
+ super(entityocelot, oclass, f, d0, d1, IEntitySelector.NO_CREATIVE_OR_SPECTATOR::test); // CraftBukkit - decompile error
|
||||
this.ocelot = entityocelot;
|
||||
}
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityPanda.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityPanda.java
|
||||
@@ -69,6 +69,12 @@
|
||||
import net.minecraft.world.level.storage.loot.LootTables;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityPanda extends EntityAnimal {
|
||||
|
||||
private static final DataWatcherObject<Integer> UNHAPPY_COUNTER = DataWatcher.defineId(EntityPanda.class, DataWatcherRegistry.INT);
|
||||
@@ -541,14 +547,14 @@
|
||||
|
||||
@Override
|
||||
protected void pickUpItem(WorldServer worldserver, EntityItem entityitem) {
|
||||
- if (this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && canPickUpAndEat(entityitem)) {
|
||||
+ if (!CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !(this.getItemBySlot(EnumItemSlot.MAINHAND).isEmpty() && canPickUpAndEat(entityitem))).isCancelled()) { // CraftBukkit
|
||||
this.onItemPickup(entityitem);
|
||||
ItemStack itemstack = entityitem.getItem();
|
||||
|
||||
this.setItemSlot(EnumItemSlot.MAINHAND, itemstack);
|
||||
this.setGuaranteedDrop(EnumItemSlot.MAINHAND);
|
||||
this.take(entityitem, itemstack.getCount());
|
||||
- entityitem.discard();
|
||||
+ entityitem.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
|
||||
}
|
||||
@@ -772,7 +778,7 @@
|
||||
}
|
||||
|
||||
public static EntityPanda.Gene byName(String s) {
|
||||
- return (EntityPanda.Gene) EntityPanda.Gene.CODEC.byName(s, (Enum) EntityPanda.Gene.NORMAL);
|
||||
+ return (EntityPanda.Gene) EntityPanda.Gene.CODEC.byName(s, EntityPanda.Gene.NORMAL); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public static EntityPanda.Gene getRandom(RandomSource randomsource) {
|
||||
@@ -876,10 +882,10 @@
|
||||
private final EntityPanda panda;
|
||||
|
||||
public c(EntityPanda entitypanda, Class<T> oclass, float f, double d0, double d1) {
|
||||
- Predicate predicate = IEntitySelector.NO_SPECTATORS;
|
||||
+ // Predicate predicate = IEntitySelector.NO_SPECTATORS;
|
||||
|
||||
- Objects.requireNonNull(predicate);
|
||||
- super(entitypanda, oclass, f, d0, d1, predicate::test);
|
||||
+ // Objects.requireNonNull(predicate);
|
||||
+ super(entitypanda, oclass, f, d0, d1, IEntitySelector.NO_SPECTATORS::test);
|
||||
this.panda = entitypanda;
|
||||
}
|
||||
|
||||
@@ -1116,7 +1122,7 @@
|
||||
@Override
|
||||
protected void alertOther(EntityInsentient entityinsentient, EntityLiving entityliving) {
|
||||
if (entityinsentient instanceof EntityPanda && entityinsentient.isAggressive()) {
|
||||
- entityinsentient.setTarget(entityliving);
|
||||
+ entityinsentient.setTarget(entityliving, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityParrot.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityParrot.java
|
||||
@@ -248,7 +248,7 @@
|
||||
}
|
||||
|
||||
if (!this.level().isClientSide) {
|
||||
- if (this.random.nextInt(10) == 0) {
|
||||
+ if (this.random.nextInt(10) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) { // CraftBukkit
|
||||
this.tame(entityhuman);
|
||||
this.level().broadcastEntityEvent(this, (byte) 7);
|
||||
} else {
|
||||
@@ -269,7 +269,7 @@
|
||||
}
|
||||
} else {
|
||||
this.usePlayerItem(entityhuman, enumhand, itemstack);
|
||||
- this.addEffect(new MobEffect(MobEffects.POISON, 900));
|
||||
+ this.addEffect(new MobEffect(MobEffects.POISON, 900), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit
|
||||
if (entityhuman.isCreative() || !this.isInvulnerable()) {
|
||||
this.hurt(this.damageSources().playerAttack(entityhuman), Float.MAX_VALUE);
|
||||
}
|
||||
@@ -363,7 +363,7 @@
|
||||
|
||||
@Override
|
||||
public boolean isPushable() {
|
||||
- return true;
|
||||
+ return super.isPushable(); // CraftBukkit - collidable API
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -378,8 +378,14 @@
|
||||
if (this.isInvulnerableTo(worldserver, damagesource)) {
|
||||
return false;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ boolean result = super.hurtServer(worldserver, damagesource, f);
|
||||
+ if (!result) {
|
||||
+ return result;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.setOrderedToSit(false);
|
||||
- return super.hurtServer(worldserver, damagesource, f);
|
||||
+ return result; // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityPerchable.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityPerchable.java
|
||||
@@ -6,6 +6,10 @@
|
||||
import net.minecraft.world.entity.EntityTypes;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class EntityPerchable extends EntityTameableAnimal {
|
||||
|
||||
private static final int RIDE_COOLDOWN = 100;
|
||||
@@ -21,7 +25,7 @@
|
||||
nbttagcompound.putString("id", this.getEncodeId());
|
||||
this.saveWithoutId(nbttagcompound);
|
||||
if (entityplayer.setEntityOnShoulder(nbttagcompound)) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -1,30 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityPig.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityPig.java
|
||||
@@ -50,6 +50,11 @@
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityPig extends EntityAnimal implements ISteerable, ISaddleable {
|
||||
|
||||
private static final DataWatcherObject<Boolean> DATA_SADDLE_ID = DataWatcher.defineId(EntityPig.class, DataWatcherRegistry.BOOLEAN);
|
||||
@@ -247,7 +252,14 @@
|
||||
}
|
||||
|
||||
entitypigzombie1.setPersistenceRequired();
|
||||
- });
|
||||
+ // CraftBukkit start
|
||||
+ }, null, null);
|
||||
+ if (CraftEventFactory.callPigZapEvent(this, entitylightning, entitypigzombie).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ worldserver.addFreshEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
|
||||
+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (entitypigzombie == null) {
|
||||
super.thunderHit(worldserver, entitylightning);
|
||||
@@ -1,20 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityPufferFish.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityPufferFish.java
|
||||
@@ -155,7 +155,7 @@
|
||||
int i = this.getPuffState();
|
||||
|
||||
if (entityinsentient.hurtServer(worldserver, this.damageSources().mobAttack(this), (float) (1 + i))) {
|
||||
- entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this);
|
||||
+ entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
this.playSound(SoundEffects.PUFFER_FISH_STING, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
entityplayer.connection.send(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.PUFFER_FISH_STING, 0.0F));
|
||||
}
|
||||
|
||||
- entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this);
|
||||
+ entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntitySheep.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntitySheep.java
|
||||
@@ -50,6 +50,12 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.storage.loot.LootTables;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.world.item.Item;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.SheepRegrowWoolEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntitySheep extends EntityAnimal implements IShearable {
|
||||
|
||||
private static final int EAT_ANIMATION_TICKS = 40;
|
||||
@@ -160,6 +166,11 @@
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
if (this.readyForShearing()) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.shear(worldserver, SoundCategory.PLAYERS, itemstack);
|
||||
this.gameEvent(GameEvent.SHEAR, entityhuman);
|
||||
itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand));
|
||||
@@ -178,7 +189,9 @@
|
||||
worldserver.playSound((EntityHuman) null, (Entity) this, SoundEffects.SHEEP_SHEAR, soundcategory, 1.0F, 1.0F);
|
||||
this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_SHEEP, itemstack, (worldserver1, itemstack1) -> {
|
||||
for (int i = 0; i < itemstack1.getCount(); ++i) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
EntityItem entityitem = this.spawnAtLocation(worldserver1, itemstack1.copyWithCount(1), 1.0F);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
|
||||
if (entityitem != null) {
|
||||
entityitem.setDeltaMovement(entityitem.getDeltaMovement().add((double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (this.random.nextFloat() * 0.05F), (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F)));
|
||||
@@ -276,6 +289,12 @@
|
||||
|
||||
@Override
|
||||
public void ate() {
|
||||
+ // CraftBukkit start
|
||||
+ SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity());
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) return;
|
||||
+ // CraftBukkit end
|
||||
super.ate();
|
||||
this.setSheared(false);
|
||||
if (this.isBaby()) {
|
||||
@@ -1,36 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityTurtle.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityTurtle.java
|
||||
@@ -310,7 +310,9 @@
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.spawnAtLocation(worldserver, Items.TURTLE_SCUTE, 1);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -339,7 +341,7 @@
|
||||
|
||||
@Override
|
||||
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
|
||||
- this.hurtServer(worldserver, this.damageSources().lightningBolt(), Float.MAX_VALUE);
|
||||
+ this.hurtServer(worldserver, this.damageSources().lightningBolt().customEntityDamager(entitylightning), Float.MAX_VALUE); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -496,12 +498,14 @@
|
||||
} else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) {
|
||||
World world = this.turtle.level();
|
||||
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), (IBlockData) Blocks.TURTLE_EGG.defaultBlockState().setValue(BlockTurtleEgg.EGGS, this.turtle.random.nextInt(4) + 1))) { // CraftBukkit
|
||||
world.playSound((EntityHuman) null, blockposition, SoundEffects.TURTLE_LAY_EGG, SoundCategory.BLOCKS, 0.3F, 0.9F + world.random.nextFloat() * 0.2F);
|
||||
BlockPosition blockposition1 = this.blockPos.above();
|
||||
IBlockData iblockdata = (IBlockData) Blocks.TURTLE_EGG.defaultBlockState().setValue(BlockTurtleEgg.EGGS, this.turtle.random.nextInt(4) + 1);
|
||||
|
||||
world.setBlock(blockposition1, iblockdata, 3);
|
||||
world.gameEvent((Holder) GameEvent.BLOCK_PLACE, blockposition1, GameEvent.a.of(this.turtle, iblockdata));
|
||||
+ } // CraftBukkit
|
||||
this.turtle.setHasEgg(false);
|
||||
this.turtle.setLayingEgg(false);
|
||||
this.turtle.setInLoveTime(600);
|
||||
@@ -1,105 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityWolf.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityWolf.java
|
||||
@@ -86,6 +86,13 @@
|
||||
import net.minecraft.world.level.pathfinder.PathType;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
||||
+import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable, VariantHolder<Holder<WolfVariant>> {
|
||||
|
||||
private static final DataWatcherObject<Boolean> DATA_INTERESTED_ID = DataWatcher.defineId(EntityWolf.class, DataWatcherRegistry.BOOLEAN);
|
||||
@@ -345,8 +352,14 @@
|
||||
if (this.isInvulnerableTo(worldserver, damagesource)) {
|
||||
return false;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ boolean result = super.hurtServer(worldserver, damagesource, f);
|
||||
+ if (!result) {
|
||||
+ return result;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.setOrderedToSit(false);
|
||||
- return super.hurtServer(worldserver, damagesource, f);
|
||||
+ return result; // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,10 +369,15 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) {
|
||||
+ public boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) { // CraftBukkit - void -> boolean
|
||||
if (!this.canArmorAbsorb(damagesource)) {
|
||||
- super.actuallyHurt(worldserver, damagesource, f);
|
||||
+ return super.actuallyHurt(worldserver, damagesource, f, event); // CraftBukkit
|
||||
} else {
|
||||
+ // CraftBukkit start - SPIGOT-7815: if the damage was cancelled, no need to run the wolf armor behaviour
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ItemStack itemstack = this.getBodyArmorItem();
|
||||
int i = itemstack.getDamageValue();
|
||||
int j = itemstack.getMaxDamage();
|
||||
@@ -371,6 +389,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
+ return false; // CraftBukkit
|
||||
}
|
||||
|
||||
private boolean canArmorAbsorb(DamageSource damagesource) {
|
||||
@@ -381,7 +400,7 @@
|
||||
protected void applyTamingSideEffects() {
|
||||
if (this.isTame()) {
|
||||
this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(40.0D);
|
||||
- this.setHealth(40.0F);
|
||||
+ this.setHealth(this.getMaxHealth()); // CraftBukkit - 40.0 -> getMaxHealth()
|
||||
} else {
|
||||
this.getAttribute(GenericAttributes.MAX_HEALTH).setBaseValue(8.0D);
|
||||
}
|
||||
@@ -404,7 +423,7 @@
|
||||
FoodInfo foodinfo = (FoodInfo) itemstack.get(DataComponents.FOOD);
|
||||
float f = foodinfo != null ? (float) foodinfo.nutrition() : 1.0F;
|
||||
|
||||
- this.heal(2.0F * f);
|
||||
+ this.heal(2.0F * f, EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
} else {
|
||||
if (item instanceof ItemDye) {
|
||||
@@ -440,7 +459,9 @@
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.spawnAtLocation(worldserver, itemstack1);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
}
|
||||
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
@@ -459,7 +480,7 @@
|
||||
this.setOrderedToSit(!this.isOrderedToSit());
|
||||
this.jumping = false;
|
||||
this.navigation.stop();
|
||||
- this.setTarget((EntityLiving) null);
|
||||
+ this.setTarget((EntityLiving) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason
|
||||
return EnumInteractionResult.SUCCESS.withoutItem();
|
||||
} else {
|
||||
return enuminteractionresult;
|
||||
@@ -477,7 +498,8 @@
|
||||
}
|
||||
|
||||
private void tryToTame(EntityHuman entityhuman) {
|
||||
- if (this.random.nextInt(3) == 0) {
|
||||
+ // CraftBukkit - added event call and isCancelled check.
|
||||
+ if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) {
|
||||
this.tame(entityhuman);
|
||||
this.navigation.stop();
|
||||
this.setTarget((EntityLiving) null);
|
||||
@@ -1,53 +1,53 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityFox.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityFox.java
|
||||
@@ -91,6 +91,10 @@
|
||||
--- a/net/minecraft/world/entity/animal/Fox.java
|
||||
+++ b/net/minecraft/world/entity/animal/Fox.java
|
||||
@@ -90,6 +90,9 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.pathfinder.PathType;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityFox extends EntityAnimal implements VariantHolder<EntityFox.Type> {
|
||||
|
||||
private static final DataWatcherObject<Integer> DATA_TYPE_ID = DataWatcher.defineId(EntityFox.class, DataWatcherRegistry.INT);
|
||||
@@ -503,7 +507,8 @@
|
||||
protected void pickUpItem(WorldServer worldserver, EntityItem entityitem) {
|
||||
ItemStack itemstack = entityitem.getItem();
|
||||
public class Fox extends Animal implements VariantHolder<Fox.Variant> {
|
||||
|
||||
@@ -503,7 +506,8 @@
|
||||
protected void pickUpItem(ServerLevel world, ItemEntity itemEntity) {
|
||||
ItemStack itemstack = itemEntity.getItem();
|
||||
|
||||
- if (this.canHoldItem(itemstack)) {
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, itemstack.getCount() - 1, !this.canHoldItem(itemstack)).isCancelled()) { // CraftBukkit - call EntityPickupItemEvent
|
||||
+ itemstack = entityitem.getItem(); // CraftBukkit - update ItemStack from event
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, itemEntity, itemstack.getCount() - 1, !this.canHoldItem(itemstack)).isCancelled()) { // CraftBukkit - call EntityPickupItemEvent
|
||||
+ itemstack = itemEntity.getItem(); // CraftBukkit - update ItemStack from event
|
||||
int i = itemstack.getCount();
|
||||
|
||||
if (i > 1) {
|
||||
@@ -515,7 +520,7 @@
|
||||
this.setItemSlot(EnumItemSlot.MAINHAND, itemstack.split(1));
|
||||
this.setGuaranteedDrop(EnumItemSlot.MAINHAND);
|
||||
this.take(entityitem, itemstack.getCount());
|
||||
- entityitem.discard();
|
||||
+ entityitem.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
@@ -515,7 +519,7 @@
|
||||
this.setItemSlot(EquipmentSlot.MAINHAND, itemstack.split(1));
|
||||
this.setGuaranteedDrop(EquipmentSlot.MAINHAND);
|
||||
this.take(itemEntity, itemstack.getCount());
|
||||
- itemEntity.discard();
|
||||
+ itemEntity.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
this.ticksSinceEaten = 0;
|
||||
}
|
||||
|
||||
@@ -853,6 +858,16 @@
|
||||
@@ -852,7 +856,17 @@
|
||||
|
||||
if (entityplayer1 != null && entityplayer != entityplayer1) {
|
||||
entityfox.addTrustedUUID(entityplayer1.getUUID());
|
||||
}
|
||||
+ }
|
||||
+ // CraftBukkit start - call EntityBreedEvent
|
||||
+ entityfox.setAge(-24000);
|
||||
+ entityfox.moveTo(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(entityfox, animal, partner, entityplayer, this.animal.breedItem, experience);
|
||||
+ org.bukkit.event.entity.EntityBreedEvent entityBreedEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreedEvent(entityfox, this.animal, this.partner, entityplayer, this.animal.breedItem, experience);
|
||||
+ if (entityBreedEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
}
|
||||
+ experience = entityBreedEvent.getExperience();
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (entityplayer2 != null) {
|
||||
entityplayer2.awardStat(StatisticList.ANIMALS_BRED);
|
||||
@@ -863,12 +878,14 @@
|
||||
entityplayer2.awardStat(Stats.ANIMALS_BRED);
|
||||
@@ -863,12 +877,14 @@
|
||||
this.partner.setAge(6000);
|
||||
this.animal.resetLove();
|
||||
this.partner.resetLove();
|
||||
@@ -57,33 +57,33 @@
|
||||
+ worldserver.addFreshEntityWithPassengers(entityfox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
|
||||
this.level.broadcastEntityEvent(this.animal, (byte) 18);
|
||||
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
- this.level.addFreshEntity(new EntityExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), this.animal.getRandom().nextInt(7) + 1));
|
||||
- this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), this.animal.getRandom().nextInt(7) + 1));
|
||||
+ // CraftBukkit start - use event experience
|
||||
+ if (experience > 0) {
|
||||
+ this.level.addFreshEntity(new EntityExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), experience));
|
||||
+ this.level.addFreshEntity(new ExperienceOrb(this.level, this.animal.getX(), this.animal.getY(), this.animal.getZ(), experience));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1264,6 +1281,11 @@
|
||||
int i = (Integer) iblockdata.getValue(BlockSweetBerryBush.AGE);
|
||||
@@ -1264,6 +1280,11 @@
|
||||
int i = (Integer) state.getValue(SweetBerryBushBlock.AGE);
|
||||
|
||||
iblockdata.setValue(BlockSweetBerryBush.AGE, 1);
|
||||
state.setValue(SweetBerryBushBlock.AGE, 1);
|
||||
+ // CraftBukkit start - call EntityChangeBlockEvent
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityFox.this, this.blockPos, iblockdata.setValue(BlockSweetBerryBush.AGE, 1))) {
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(Fox.this, this.blockPos, state.setValue(SweetBerryBushBlock.AGE, 1))) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
int j = 1 + EntityFox.this.level().random.nextInt(2) + (i == 3 ? 1 : 0);
|
||||
ItemStack itemstack = EntityFox.this.getItemBySlot(EnumItemSlot.MAINHAND);
|
||||
int j = 1 + Fox.this.level().random.nextInt(2) + (i == 3 ? 1 : 0);
|
||||
ItemStack itemstack = Fox.this.getItemBySlot(EquipmentSlot.MAINHAND);
|
||||
|
||||
@@ -1494,7 +1516,7 @@
|
||||
@@ -1494,7 +1515,7 @@
|
||||
}
|
||||
|
||||
public static EntityFox.Type byName(String s) {
|
||||
- return (EntityFox.Type) EntityFox.Type.CODEC.byName(s, (Enum) EntityFox.Type.RED);
|
||||
+ return (EntityFox.Type) EntityFox.Type.CODEC.byName(s, EntityFox.Type.RED); // CraftBukkit - decompile error
|
||||
public static Fox.Variant byName(String name) {
|
||||
- return (Fox.Variant) Fox.Variant.CODEC.byName(name, (Enum) Fox.Variant.RED);
|
||||
+ return (Fox.Variant) Fox.Variant.CODEC.byName(name, Fox.Variant.RED); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public static EntityFox.Type byId(int i) {
|
||||
public static Fox.Variant byId(int id) {
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/world/entity/animal/IronGolem.java
|
||||
+++ b/net/minecraft/world/entity/animal/IronGolem.java
|
||||
@@ -98,7 +98,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
|
||||
}
|
||||
|
||||
super.doPush(entity);
|
||||
@@ -0,0 +1,58 @@
|
||||
--- a/net/minecraft/world/entity/animal/MushroomCow.java
|
||||
+++ b/net/minecraft/world/entity/animal/MushroomCow.java
|
||||
@@ -42,6 +42,12 @@
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityDropItemEvent;
|
||||
+import org.bukkit.event.entity.EntityTransformEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class MushroomCow extends Cow implements Shearable, VariantHolder<MushroomCow.Variant> {
|
||||
|
||||
@@ -120,6 +126,11 @@
|
||||
if (world instanceof ServerLevel) {
|
||||
ServerLevel worldserver = (ServerLevel) world;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemstack, hand)) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.shear(worldserver, SoundSource.PLAYERS, itemstack);
|
||||
this.gameEvent(GameEvent.SHEAR, player);
|
||||
itemstack.hurtAndBreak(1, player, getSlotForHand(hand));
|
||||
@@ -163,11 +174,19 @@
|
||||
world.sendParticles(ParticleTypes.EXPLOSION, this.getX(), this.getY(0.5D), this.getZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
|
||||
this.dropFromShearingLootTable(world, BuiltInLootTables.SHEAR_MOOSHROOM, shears, (worldserver1, itemstack1) -> {
|
||||
for (int i = 0; i < itemstack1.getCount(); ++i) {
|
||||
- worldserver1.addFreshEntity(new ItemEntity(this.level(), this.getX(), this.getY(1.0D), this.getZ(), itemstack1.copyWithCount(1)));
|
||||
+ // CraftBukkit start
|
||||
+ ItemEntity entityitem = new ItemEntity(this.level(), this.getX(), this.getY(1.0D), this.getZ(), itemstack1.copyWithCount(1));
|
||||
+ EntityDropItemEvent event = new EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
|
||||
+ Bukkit.getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ worldserver1.addFreshEntity(entityitem);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
});
|
||||
- });
|
||||
+ }, EntityTransformEvent.TransformReason.SHEARED, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -263,7 +282,7 @@
|
||||
}
|
||||
|
||||
static MushroomCow.Variant byName(String name) {
|
||||
- return (MushroomCow.Variant) MushroomCow.Variant.CODEC.byName(name, (Enum) MushroomCow.Variant.RED);
|
||||
+ return (MushroomCow.Variant) MushroomCow.Variant.CODEC.byName(name, MushroomCow.Variant.RED); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
--- a/net/minecraft/world/entity/animal/Ocelot.java
|
||||
+++ b/net/minecraft/world/entity/animal/Ocelot.java
|
||||
@@ -167,7 +167,7 @@
|
||||
if ((this.temptGoal == null || this.temptGoal.isRunning()) && !this.isTrusting() && this.isFood(itemstack) && player.distanceToSqr((Entity) this) < 9.0D) {
|
||||
this.usePlayerItem(player, hand, itemstack);
|
||||
if (!this.level().isClientSide) {
|
||||
- if (this.random.nextInt(3) == 0) {
|
||||
+ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit - added event call and isCancelled check
|
||||
this.setTrusting(true);
|
||||
this.spawnTrustingParticles(true);
|
||||
this.level().broadcastEntityEvent(this, (byte) 41);
|
||||
@@ -298,10 +298,10 @@
|
||||
private final Ocelot ocelot;
|
||||
|
||||
public OcelotAvoidEntityGoal(Ocelot ocelot, Class<T> fleeFromType, float distance, double slowSpeed, double fastSpeed) {
|
||||
- Predicate predicate = EntitySelector.NO_CREATIVE_OR_SPECTATOR;
|
||||
+ // Predicate predicate = IEntitySelector.NO_CREATIVE_OR_SPECTATOR; // CraftBukkit - decompile error
|
||||
|
||||
- Objects.requireNonNull(predicate);
|
||||
- super(ocelot, fleeFromType, distance, slowSpeed, fastSpeed, predicate::test);
|
||||
+ // Objects.requireNonNull(predicate); // CraftBukkit - decompile error
|
||||
+ super(ocelot, fleeFromType, distance, slowSpeed, fastSpeed, EntitySelector.NO_CREATIVE_OR_SPECTATOR::test); // CraftBukkit - decompile error
|
||||
this.ocelot = ocelot;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
--- a/net/minecraft/world/entity/animal/Panda.java
|
||||
+++ b/net/minecraft/world/entity/animal/Panda.java
|
||||
@@ -68,6 +68,11 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+// CraftBukkit start;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class Panda extends Animal {
|
||||
|
||||
@@ -541,14 +546,14 @@
|
||||
|
||||
@Override
|
||||
protected void pickUpItem(ServerLevel world, ItemEntity itemEntity) {
|
||||
- if (this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty() && Panda.canPickUpAndEat(itemEntity)) {
|
||||
+ if (!CraftEventFactory.callEntityPickupItemEvent(this, itemEntity, 0, !(this.getItemBySlot(EquipmentSlot.MAINHAND).isEmpty() && Panda.canPickUpAndEat(itemEntity))).isCancelled()) { // CraftBukkit
|
||||
this.onItemPickup(itemEntity);
|
||||
ItemStack itemstack = itemEntity.getItem();
|
||||
|
||||
this.setItemSlot(EquipmentSlot.MAINHAND, itemstack);
|
||||
this.setGuaranteedDrop(EquipmentSlot.MAINHAND);
|
||||
this.take(itemEntity, itemstack.getCount());
|
||||
- itemEntity.discard();
|
||||
+ itemEntity.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
|
||||
}
|
||||
@@ -772,7 +777,7 @@
|
||||
}
|
||||
|
||||
public static Panda.Gene byName(String name) {
|
||||
- return (Panda.Gene) Panda.Gene.CODEC.byName(name, (Enum) Panda.Gene.NORMAL);
|
||||
+ return (Panda.Gene) Panda.Gene.CODEC.byName(name, Panda.Gene.NORMAL); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public static Panda.Gene getRandom(RandomSource random) {
|
||||
@@ -876,10 +881,10 @@
|
||||
private final Panda panda;
|
||||
|
||||
public PandaAvoidGoal(Panda panda, Class<T> fleeFromType, float distance, double slowSpeed, double fastSpeed) {
|
||||
- Predicate predicate = EntitySelector.NO_SPECTATORS;
|
||||
+ // Predicate predicate = IEntitySelector.NO_SPECTATORS;
|
||||
|
||||
- Objects.requireNonNull(predicate);
|
||||
- super(panda, fleeFromType, distance, slowSpeed, fastSpeed, predicate::test);
|
||||
+ // Objects.requireNonNull(predicate);
|
||||
+ super(panda, fleeFromType, distance, slowSpeed, fastSpeed, EntitySelector.NO_SPECTATORS::test);
|
||||
this.panda = panda;
|
||||
}
|
||||
|
||||
@@ -1116,7 +1121,7 @@
|
||||
@Override
|
||||
protected void alertOther(Mob mob, LivingEntity target) {
|
||||
if (mob instanceof Panda && mob.isAggressive()) {
|
||||
- mob.setTarget(target);
|
||||
+ mob.setTarget(target, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
--- a/net/minecraft/world/entity/animal/Parrot.java
|
||||
+++ b/net/minecraft/world/entity/animal/Parrot.java
|
||||
@@ -248,7 +248,7 @@
|
||||
}
|
||||
|
||||
if (!this.level().isClientSide) {
|
||||
- if (this.random.nextInt(10) == 0) {
|
||||
+ if (this.random.nextInt(10) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) { // CraftBukkit
|
||||
this.tame(player);
|
||||
this.level().broadcastEntityEvent(this, (byte) 7);
|
||||
} else {
|
||||
@@ -269,7 +269,7 @@
|
||||
}
|
||||
} else {
|
||||
this.usePlayerItem(player, hand, itemstack);
|
||||
- this.addEffect(new MobEffectInstance(MobEffects.POISON, 900));
|
||||
+ this.addEffect(new MobEffectInstance(MobEffects.POISON, 900), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.FOOD); // CraftBukkit
|
||||
if (player.isCreative() || !this.isInvulnerable()) {
|
||||
this.hurt(this.damageSources().playerAttack(player), Float.MAX_VALUE);
|
||||
}
|
||||
@@ -363,7 +363,7 @@
|
||||
|
||||
@Override
|
||||
public boolean isPushable() {
|
||||
- return true;
|
||||
+ return super.isPushable(); // CraftBukkit - collidable API
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -378,8 +378,14 @@
|
||||
if (this.isInvulnerableTo(world, source)) {
|
||||
return false;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ boolean result = super.hurtServer(world, source, amount);
|
||||
+ if (!result) {
|
||||
+ return result;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.setOrderedToSit(false);
|
||||
- return super.hurtServer(world, source, amount);
|
||||
+ return result; // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
--- a/net/minecraft/world/entity/animal/Pig.java
|
||||
+++ b/net/minecraft/world/entity/animal/Pig.java
|
||||
@@ -49,6 +49,10 @@
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class Pig extends Animal implements ItemSteerable, Saddleable {
|
||||
|
||||
@@ -247,7 +251,14 @@
|
||||
}
|
||||
|
||||
entitypigzombie1.setPersistenceRequired();
|
||||
- });
|
||||
+ // CraftBukkit start
|
||||
+ }, null, null);
|
||||
+ if (CraftEventFactory.callPigZapEvent(this, lightning, entitypigzombie).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ world.addFreshEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
|
||||
+ this.discard(EntityRemoveEvent.Cause.TRANSFORMATION); // CraftBukkit - add Bukkit remove cause
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (entitypigzombie == null) {
|
||||
super.thunderHit(world, lightning);
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/world/entity/animal/Pufferfish.java
|
||||
+++ b/net/minecraft/world/entity/animal/Pufferfish.java
|
||||
@@ -155,7 +155,7 @@
|
||||
int i = this.getPuffState();
|
||||
|
||||
if (target.hurtServer(world, this.damageSources().mobAttack(this), (float) (1 + i))) {
|
||||
- target.addEffect(new MobEffectInstance(MobEffects.POISON, 60 * i, 0), this);
|
||||
+ target.addEffect(new MobEffectInstance(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
this.playSound(SoundEvents.PUFFER_FISH_STING, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@
|
||||
entityplayer.connection.send(new ClientboundGameEventPacket(ClientboundGameEventPacket.PUFFER_FISH_STING, 0.0F));
|
||||
}
|
||||
|
||||
- player.addEffect(new MobEffectInstance(MobEffects.POISON, 60 * i, 0), this);
|
||||
+ player.addEffect(new MobEffectInstance(MobEffects.POISON, 60 * i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,25 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityRabbit.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityRabbit.java
|
||||
@@ -66,6 +66,10 @@
|
||||
import net.minecraft.world.level.pathfinder.PathEntity;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
--- a/net/minecraft/world/entity/animal/Rabbit.java
|
||||
+++ b/net/minecraft/world/entity/animal/Rabbit.java
|
||||
@@ -65,6 +65,9 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.pathfinder.Path;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityRabbit extends EntityAnimal implements VariantHolder<EntityRabbit.Variant> {
|
||||
|
||||
public static final double STROLL_SPEED_MOD = 0.6D;
|
||||
@@ -90,7 +94,6 @@
|
||||
super(entitytypes, world);
|
||||
this.jumpControl = new EntityRabbit.ControllerJumpRabbit(this);
|
||||
this.moveControl = new EntityRabbit.ControllerMoveRabbit(this);
|
||||
public class Rabbit extends Animal implements VariantHolder<Rabbit.Variant> {
|
||||
|
||||
@@ -90,7 +93,6 @@
|
||||
super(type, world);
|
||||
this.jumpControl = new Rabbit.RabbitJumpControl(this);
|
||||
this.moveControl = new Rabbit.RabbitMoveControl(this);
|
||||
- this.setSpeedModifier(0.0D);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -577,9 +580,19 @@
|
||||
int i = (Integer) iblockdata.getValue(BlockCarrots.AGE);
|
||||
@@ -577,9 +579,19 @@
|
||||
int i = (Integer) iblockdata.getValue(CarrotBlock.AGE);
|
||||
|
||||
if (i == 0) {
|
||||
+ // CraftBukkit start
|
||||
@@ -32,10 +31,10 @@
|
||||
world.destroyBlock(blockposition, true, this.rabbit);
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockposition, iblockdata.setValue(BlockCarrots.AGE, i - 1))) {
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockposition, iblockdata.setValue(CarrotBlock.AGE, i - 1))) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockCarrots.AGE, i - 1), 2);
|
||||
world.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of((Entity) this.rabbit));
|
||||
world.setBlock(blockposition, (BlockState) iblockdata.setValue(CarrotBlock.AGE, i - 1), 2);
|
||||
world.gameEvent((Holder) GameEvent.BLOCK_CHANGE, blockposition, GameEvent.Context.of((Entity) this.rabbit));
|
||||
world.levelEvent(2001, blockposition, Block.getId(iblockdata));
|
||||
@@ -0,0 +1,58 @@
|
||||
--- a/net/minecraft/world/entity/animal/Sheep.java
|
||||
+++ b/net/minecraft/world/entity/animal/Sheep.java
|
||||
@@ -41,7 +41,6 @@
|
||||
import net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal;
|
||||
import net.minecraft.world.entity.item.ItemEntity;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
-import net.minecraft.world.item.DyeColor;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.Level;
|
||||
@@ -49,6 +48,12 @@
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
|
||||
+import net.minecraft.world.item.DyeColor;
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.world.item.Item;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.SheepRegrowWoolEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class Sheep extends Animal implements Shearable {
|
||||
|
||||
@@ -160,6 +165,11 @@
|
||||
ServerLevel worldserver = (ServerLevel) world;
|
||||
|
||||
if (this.readyForShearing()) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemstack, hand)) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.shear(worldserver, SoundSource.PLAYERS, itemstack);
|
||||
this.gameEvent(GameEvent.SHEAR, player);
|
||||
itemstack.hurtAndBreak(1, player, getSlotForHand(hand));
|
||||
@@ -178,7 +188,9 @@
|
||||
world.playSound((Player) null, (Entity) this, SoundEvents.SHEEP_SHEAR, shearedSoundCategory, 1.0F, 1.0F);
|
||||
this.dropFromShearingLootTable(world, BuiltInLootTables.SHEAR_SHEEP, shears, (worldserver1, itemstack1) -> {
|
||||
for (int i = 0; i < itemstack1.getCount(); ++i) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
ItemEntity entityitem = this.spawnAtLocation(worldserver1, itemstack1.copyWithCount(1), 1.0F);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
|
||||
if (entityitem != null) {
|
||||
entityitem.setDeltaMovement(entityitem.getDeltaMovement().add((double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (this.random.nextFloat() * 0.05F), (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F)));
|
||||
@@ -276,6 +288,12 @@
|
||||
|
||||
@Override
|
||||
public void ate() {
|
||||
+ // CraftBukkit start
|
||||
+ SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity());
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) return;
|
||||
+ // CraftBukkit end
|
||||
super.ate();
|
||||
this.setSheared(false);
|
||||
if (this.isBaby()) {
|
||||
@@ -0,0 +1,21 @@
|
||||
--- a/net/minecraft/world/entity/animal/ShoulderRidingEntity.java
|
||||
+++ b/net/minecraft/world/entity/animal/ShoulderRidingEntity.java
|
||||
@@ -5,6 +5,9 @@
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.TamableAnimal;
|
||||
import net.minecraft.world.level.Level;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
public abstract class ShoulderRidingEntity extends TamableAnimal {
|
||||
|
||||
@@ -21,7 +24,7 @@
|
||||
nbttagcompound.putString("id", this.getEncodeId());
|
||||
this.saveWithoutId(nbttagcompound);
|
||||
if (player.setEntityOnShoulder(nbttagcompound)) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.PICKUP); // CraftBukkit - add Bukkit remove cause
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -1,27 +1,26 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntitySnowman.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntitySnowman.java
|
||||
@@ -43,6 +43,10 @@
|
||||
import net.minecraft.world.level.storage.loot.LootTables;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
--- a/net/minecraft/world/entity/animal/SnowGolem.java
|
||||
+++ b/net/minecraft/world/entity/animal/SnowGolem.java
|
||||
@@ -42,6 +42,9 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntitySnowman extends EntityGolem implements IShearable, IRangedEntity {
|
||||
|
||||
private static final DataWatcherObject<Byte> DATA_PUMPKIN_ID = DataWatcher.defineId(EntitySnowman.class, DataWatcherRegistry.BYTE);
|
||||
@@ -100,7 +104,7 @@
|
||||
public class SnowGolem extends AbstractGolem implements Shearable, RangedAttackMob {
|
||||
|
||||
if (world instanceof WorldServer worldserver) {
|
||||
@@ -100,7 +103,7 @@
|
||||
|
||||
if (world instanceof ServerLevel worldserver) {
|
||||
if (this.level().getBiome(this.blockPosition()).is(BiomeTags.SNOW_GOLEM_MELTS)) {
|
||||
- this.hurtServer(worldserver, this.damageSources().onFire(), 1.0F);
|
||||
+ this.hurtServer(worldserver, this.damageSources().melting(), 1.0F); // CraftBukkit - DamageSources.ON_FIRE -> CraftEventFactory.MELTING
|
||||
}
|
||||
|
||||
if (!worldserver.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
|
||||
@@ -116,7 +120,11 @@
|
||||
BlockPosition blockposition = new BlockPosition(j, k, l);
|
||||
@@ -116,7 +119,11 @@
|
||||
BlockPos blockposition = new BlockPos(j, k, l);
|
||||
|
||||
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
|
||||
- this.level().setBlockAndUpdate(blockposition, iblockdata);
|
||||
@@ -30,25 +29,25 @@
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.level().gameEvent((Holder) GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(this, iblockdata));
|
||||
this.level().gameEvent((Holder) GameEvent.BLOCK_PLACE, blockposition, GameEvent.Context.of(this, iblockdata));
|
||||
}
|
||||
}
|
||||
@@ -153,6 +161,11 @@
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
@@ -153,6 +160,11 @@
|
||||
if (world instanceof ServerLevel) {
|
||||
ServerLevel worldserver = (ServerLevel) world;
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(player, this, itemstack, hand)) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.shear(worldserver, SoundCategory.PLAYERS, itemstack);
|
||||
this.gameEvent(GameEvent.SHEAR, entityhuman);
|
||||
itemstack.hurtAndBreak(1, entityhuman, getSlotForHand(enumhand));
|
||||
@@ -169,7 +182,9 @@
|
||||
worldserver.playSound((EntityHuman) null, (Entity) this, SoundEffects.SNOW_GOLEM_SHEAR, soundcategory, 1.0F, 1.0F);
|
||||
this.shear(worldserver, SoundSource.PLAYERS, itemstack);
|
||||
this.gameEvent(GameEvent.SHEAR, player);
|
||||
itemstack.hurtAndBreak(1, player, getSlotForHand(hand));
|
||||
@@ -169,7 +181,9 @@
|
||||
world.playSound((Player) null, (Entity) this, SoundEvents.SNOW_GOLEM_SHEAR, shearedSoundCategory, 1.0F, 1.0F);
|
||||
this.setPumpkin(false);
|
||||
this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_SNOW_GOLEM, itemstack, (worldserver1, itemstack1) -> {
|
||||
this.dropFromShearingLootTable(world, BuiltInLootTables.SHEAR_SNOW_GOLEM, shears, (worldserver1, itemstack1) -> {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.spawnAtLocation(worldserver1, itemstack1, this.getEyeHeight());
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
@@ -0,0 +1,36 @@
|
||||
--- a/net/minecraft/world/entity/animal/Turtle.java
|
||||
+++ b/net/minecraft/world/entity/animal/Turtle.java
|
||||
@@ -310,7 +310,9 @@
|
||||
ServerLevel worldserver = (ServerLevel) world;
|
||||
|
||||
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.spawnAtLocation(worldserver, Items.TURTLE_SCUTE, 1);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -339,7 +341,7 @@
|
||||
|
||||
@Override
|
||||
public void thunderHit(ServerLevel world, LightningBolt lightning) {
|
||||
- this.hurtServer(world, this.damageSources().lightningBolt(), Float.MAX_VALUE);
|
||||
+ this.hurtServer(world, this.damageSources().lightningBolt().customEntityDamager(lightning), Float.MAX_VALUE); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -496,12 +498,14 @@
|
||||
} else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) {
|
||||
Level world = this.turtle.level();
|
||||
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.above(), (BlockState) Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, this.turtle.random.nextInt(4) + 1))) { // CraftBukkit
|
||||
world.playSound((Player) null, blockposition, SoundEvents.TURTLE_LAY_EGG, SoundSource.BLOCKS, 0.3F, 0.9F + world.random.nextFloat() * 0.2F);
|
||||
BlockPos blockposition1 = this.blockPos.above();
|
||||
BlockState iblockdata = (BlockState) Blocks.TURTLE_EGG.defaultBlockState().setValue(TurtleEggBlock.EGGS, this.turtle.random.nextInt(4) + 1);
|
||||
|
||||
world.setBlock(blockposition1, iblockdata, 3);
|
||||
world.gameEvent((Holder) GameEvent.BLOCK_PLACE, blockposition1, GameEvent.Context.of(this.turtle, iblockdata));
|
||||
+ } // CraftBukkit
|
||||
this.turtle.setHasEgg(false);
|
||||
this.turtle.setLayingEgg(false);
|
||||
this.turtle.setInLoveTime(600);
|
||||
@@ -0,0 +1,111 @@
|
||||
--- a/net/minecraft/world/entity/animal/Wolf.java
|
||||
+++ b/net/minecraft/world/entity/animal/Wolf.java
|
||||
@@ -85,6 +85,12 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.pathfinder.PathType;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
||||
+import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
+import org.bukkit.event.entity.EntityTargetEvent;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class Wolf extends TamableAnimal implements NeutralMob, VariantHolder<Holder<WolfVariant>> {
|
||||
|
||||
@@ -345,8 +351,14 @@
|
||||
if (this.isInvulnerableTo(world, source)) {
|
||||
return false;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ boolean result = super.hurtServer(world, source, amount);
|
||||
+ if (!result) {
|
||||
+ return result;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.setOrderedToSit(false);
|
||||
- return super.hurtServer(world, source, amount);
|
||||
+ return result; // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,21 +368,27 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void actuallyHurt(ServerLevel world, DamageSource source, float amount) {
|
||||
- if (!this.canArmorAbsorb(source)) {
|
||||
- super.actuallyHurt(world, source, amount);
|
||||
+ public boolean actuallyHurt(ServerLevel worldserver, DamageSource damagesource, float f, EntityDamageEvent event) { // CraftBukkit - void -> boolean
|
||||
+ if (!this.canArmorAbsorb(damagesource)) {
|
||||
+ return super.actuallyHurt(worldserver, damagesource, f, event); // CraftBukkit
|
||||
} else {
|
||||
+ // CraftBukkit start - SPIGOT-7815: if the damage was cancelled, no need to run the wolf armor behaviour
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ItemStack itemstack = this.getBodyArmorItem();
|
||||
int i = itemstack.getDamageValue();
|
||||
int j = itemstack.getMaxDamage();
|
||||
|
||||
- itemstack.hurtAndBreak(Mth.ceil(amount), this, EquipmentSlot.BODY);
|
||||
+ itemstack.hurtAndBreak(Mth.ceil(f), this, EquipmentSlot.BODY);
|
||||
if (Crackiness.WOLF_ARMOR.byDamage(i, j) != Crackiness.WOLF_ARMOR.byDamage(this.getBodyArmorItem())) {
|
||||
this.playSound(SoundEvents.WOLF_ARMOR_CRACK);
|
||||
- world.sendParticles(new ItemParticleOption(ParticleTypes.ITEM, Items.ARMADILLO_SCUTE.getDefaultInstance()), this.getX(), this.getY() + 1.0D, this.getZ(), 20, 0.2D, 0.1D, 0.2D, 0.1D);
|
||||
+ worldserver.sendParticles(new ItemParticleOption(ParticleTypes.ITEM, Items.ARMADILLO_SCUTE.getDefaultInstance()), this.getX(), this.getY() + 1.0D, this.getZ(), 20, 0.2D, 0.1D, 0.2D, 0.1D);
|
||||
}
|
||||
|
||||
}
|
||||
+ return false; // CraftBukkit
|
||||
}
|
||||
|
||||
private boolean canArmorAbsorb(DamageSource source) {
|
||||
@@ -381,7 +399,7 @@
|
||||
protected void applyTamingSideEffects() {
|
||||
if (this.isTame()) {
|
||||
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(40.0D);
|
||||
- this.setHealth(40.0F);
|
||||
+ this.setHealth(this.getMaxHealth()); // CraftBukkit - 40.0 -> getMaxHealth()
|
||||
} else {
|
||||
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(8.0D);
|
||||
}
|
||||
@@ -404,7 +422,7 @@
|
||||
FoodProperties foodinfo = (FoodProperties) itemstack.get(DataComponents.FOOD);
|
||||
float f = foodinfo != null ? (float) foodinfo.nutrition() : 1.0F;
|
||||
|
||||
- this.heal(2.0F * f);
|
||||
+ this.heal(2.0F * f, EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
|
||||
return InteractionResult.SUCCESS;
|
||||
} else {
|
||||
if (item instanceof DyeItem) {
|
||||
@@ -440,7 +458,9 @@
|
||||
if (world instanceof ServerLevel) {
|
||||
ServerLevel worldserver = (ServerLevel) world;
|
||||
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.spawnAtLocation(worldserver, itemstack1);
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
}
|
||||
|
||||
return InteractionResult.SUCCESS;
|
||||
@@ -459,7 +479,7 @@
|
||||
this.setOrderedToSit(!this.isOrderedToSit());
|
||||
this.jumping = false;
|
||||
this.navigation.stop();
|
||||
- this.setTarget((LivingEntity) null);
|
||||
+ this.setTarget((LivingEntity) null, EntityTargetEvent.TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason
|
||||
return InteractionResult.SUCCESS.withoutItem();
|
||||
} else {
|
||||
return enuminteractionresult;
|
||||
@@ -477,7 +497,8 @@
|
||||
}
|
||||
|
||||
private void tryToTame(Player player) {
|
||||
- if (this.random.nextInt(3) == 0) {
|
||||
+ // CraftBukkit - added event call and isCancelled check.
|
||||
+ if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, player).isCancelled()) {
|
||||
this.tame(player);
|
||||
this.navigation.stop();
|
||||
this.setTarget((LivingEntity) null);
|
||||
@@ -6,30 +6,30 @@
|
||||
private float spinningAnimationTicks0;
|
||||
+ public boolean forceDancing = false; // CraftBukkit
|
||||
|
||||
public Allay(EntityTypes<? extends Allay> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -114,6 +115,12 @@
|
||||
this.dynamicJukeboxListener = new DynamicGameEventListener<>(new Allay.a(this.vibrationUser.getPositionSource(), ((GameEvent) GameEvent.JUKEBOX_PLAY.value()).notificationRadius()));
|
||||
public Allay(EntityType<? extends Allay> type, Level world) {
|
||||
super(type, world);
|
||||
@@ -113,6 +114,12 @@
|
||||
this.dynamicVibrationListener = new DynamicGameEventListener<>(new VibrationSystem.Listener(this));
|
||||
this.dynamicJukeboxListener = new DynamicGameEventListener<>(new Allay.JukeboxListener(this.vibrationUser.getPositionSource(), ((GameEvent) GameEvent.JUKEBOX_PLAY.value()).notificationRadius()));
|
||||
}
|
||||
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public void setCanDuplicate(boolean canDuplicate) {
|
||||
+ this.entityData.set(Allay.DATA_CAN_DUPLICATE, canDuplicate);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
@Override
|
||||
protected BehaviorController.b<Allay> brainProvider() {
|
||||
return BehaviorController.provider(Allay.MEMORY_TYPES, Allay.SENSOR_TYPES);
|
||||
protected Brain.Provider<Allay> brainProvider() {
|
||||
@@ -126,7 +133,7 @@
|
||||
|
||||
@Override
|
||||
public BehaviorController<Allay> getBrain() {
|
||||
public Brain<Allay> getBrain() {
|
||||
- return super.getBrain();
|
||||
+ return (BehaviorController<Allay>) super.getBrain(); // CraftBukkit - decompile error
|
||||
+ return (Brain<Allay>) super.getBrain(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public static AttributeProvider.Builder createAttributes() {
|
||||
public static AttributeSupplier.Builder createAttributes() {
|
||||
@@ -233,7 +240,7 @@
|
||||
public void aiStep() {
|
||||
super.aiStep();
|
||||
@@ -40,28 +40,28 @@
|
||||
|
||||
if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) {
|
||||
@@ -303,7 +310,12 @@
|
||||
ItemStack itemstack1 = this.getItemInHand(EnumHand.MAIN_HAND);
|
||||
ItemStack itemstack1 = this.getItemInHand(InteractionHand.MAIN_HAND);
|
||||
|
||||
if (this.isDancing() && itemstack.is(TagsItem.DUPLICATES_ALLAYS) && this.canDuplicate()) {
|
||||
if (this.isDancing() && itemstack.is(ItemTags.DUPLICATES_ALLAYS) && this.canDuplicate()) {
|
||||
- this.duplicateAllay();
|
||||
+ // CraftBukkit start - handle cancel duplication
|
||||
+ Allay allay = this.duplicateAllay();
|
||||
+ if (allay == null) {
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ return InteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.level().broadcastEntityEvent(this, (byte) 18);
|
||||
this.level().playSound(entityhuman, (Entity) this, SoundEffects.AMETHYST_BLOCK_CHIME, SoundCategory.NEUTRAL, 2.0F, 1.0F);
|
||||
this.removeInteractionItem(entityhuman, itemstack);
|
||||
this.level().playSound(player, (Entity) this, SoundEvents.AMETHYST_BLOCK_CHIME, SoundSource.NEUTRAL, 2.0F, 1.0F);
|
||||
this.removeInteractionItem(player, itemstack);
|
||||
@@ -314,7 +326,7 @@
|
||||
this.setItemInHand(EnumHand.MAIN_HAND, itemstack2);
|
||||
this.removeInteractionItem(entityhuman, itemstack);
|
||||
this.level().playSound(entityhuman, (Entity) this, SoundEffects.ALLAY_ITEM_GIVEN, SoundCategory.NEUTRAL, 2.0F, 1.0F);
|
||||
- this.getBrain().setMemory(MemoryModuleType.LIKED_PLAYER, (Object) entityhuman.getUUID());
|
||||
+ this.getBrain().setMemory(MemoryModuleType.LIKED_PLAYER, entityhuman.getUUID()); // CraftBukkit - decompile error
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
} else if (!itemstack1.isEmpty() && enumhand == EnumHand.MAIN_HAND && itemstack.isEmpty()) {
|
||||
this.setItemSlot(EnumItemSlot.MAINHAND, ItemStack.EMPTY);
|
||||
this.setItemInHand(InteractionHand.MAIN_HAND, itemstack2);
|
||||
this.removeInteractionItem(player, itemstack);
|
||||
this.level().playSound(player, (Entity) this, SoundEvents.ALLAY_ITEM_GIVEN, SoundSource.NEUTRAL, 2.0F, 1.0F);
|
||||
- this.getBrain().setMemory(MemoryModuleType.LIKED_PLAYER, (Object) player.getUUID());
|
||||
+ this.getBrain().setMemory(MemoryModuleType.LIKED_PLAYER, player.getUUID()); // CraftBukkit - decompile error
|
||||
return InteractionResult.SUCCESS;
|
||||
} else if (!itemstack1.isEmpty() && hand == InteractionHand.MAIN_HAND && itemstack.isEmpty()) {
|
||||
this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY);
|
||||
@@ -415,6 +427,7 @@
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
|
||||
- public void duplicateAllay() {
|
||||
+ public Allay duplicateAllay() { // CraftBukkit - return allay
|
||||
Allay allay = (Allay) EntityTypes.ALLAY.create(this.level(), EntitySpawnReason.BREEDING);
|
||||
Allay allay = (Allay) EntityType.ALLAY.create(this.level(), EntitySpawnReason.BREEDING);
|
||||
|
||||
if (allay != null) {
|
||||
@@ -514,9 +527,9 @@
|
||||
@@ -0,0 +1,81 @@
|
||||
--- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
||||
+++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
||||
@@ -47,6 +47,9 @@
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.storage.loot.BuiltInLootTables;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class Armadillo extends Animal {
|
||||
|
||||
@@ -135,16 +138,18 @@
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("armadilloBrain");
|
||||
- this.brain.tick(world, this);
|
||||
+ ((Brain<Armadillo>) this.brain).tick(world, this); // CraftBukkit - decompile error
|
||||
gameprofilerfiller.pop();
|
||||
gameprofilerfiller.push("armadilloActivityUpdate");
|
||||
ArmadilloAi.updateActivity(this);
|
||||
gameprofilerfiller.pop();
|
||||
if (this.isAlive() && !this.isBaby() && --this.scuteTime <= 0) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
if (this.dropFromGiftLootTable(world, BuiltInLootTables.ARMADILLO_SHED, this::spawnAtLocation)) {
|
||||
this.playSound(SoundEvents.ARMADILLO_SCUTE_DROP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
||||
this.gameEvent(GameEvent.ENTITY_PLACE);
|
||||
}
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
|
||||
this.scuteTime = this.pickNextScuteDropTime();
|
||||
}
|
||||
@@ -291,19 +296,25 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void actuallyHurt(ServerLevel world, DamageSource source, float amount) {
|
||||
- super.actuallyHurt(world, source, amount);
|
||||
+ // CraftBukkit start - void -> boolean
|
||||
+ public boolean actuallyHurt(ServerLevel worldserver, DamageSource damagesource, float f, EntityDamageEvent event) {
|
||||
+ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event);
|
||||
+ if (!damageResult) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (!this.isNoAi() && !this.isDeadOrDying()) {
|
||||
- if (source.getEntity() instanceof LivingEntity) {
|
||||
+ if (damagesource.getEntity() instanceof LivingEntity) {
|
||||
this.getBrain().setMemoryWithExpiry(MemoryModuleType.DANGER_DETECTED_RECENTLY, true, 80L);
|
||||
if (this.canStayRolledUp()) {
|
||||
this.rollUp();
|
||||
}
|
||||
- } else if (source.is(DamageTypeTags.PANIC_ENVIRONMENTAL_CAUSES)) {
|
||||
+ } else if (damagesource.is(DamageTypeTags.PANIC_ENVIRONMENTAL_CAUSES)) {
|
||||
this.rollOut();
|
||||
}
|
||||
|
||||
}
|
||||
+ return true; // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -327,7 +338,9 @@
|
||||
if (world instanceof ServerLevel) {
|
||||
ServerLevel worldserver = (ServerLevel) world;
|
||||
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.spawnAtLocation(worldserver, new ItemStack(Items.ARMADILLO_SCUTE));
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
this.gameEvent(GameEvent.ENTITY_INTERACT);
|
||||
this.playSound(SoundEvents.ARMADILLO_BRUSH);
|
||||
}
|
||||
@@ -431,7 +444,7 @@
|
||||
}
|
||||
|
||||
public static Armadillo.ArmadilloState fromName(String name) {
|
||||
- return (Armadillo.ArmadilloState) Armadillo.ArmadilloState.CODEC.byName(name, (Enum) Armadillo.ArmadilloState.IDLE);
|
||||
+ return (Armadillo.ArmadilloState) Armadillo.ArmadilloState.CODEC.byName(name, Armadillo.ArmadilloState.IDLE); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,76 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
||||
+++ b/net/minecraft/world/entity/animal/armadillo/Armadillo.java
|
||||
@@ -48,6 +48,10 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.level.storage.loot.LootTables;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class Armadillo extends EntityAnimal {
|
||||
|
||||
public static final float BABY_SCALE = 0.6F;
|
||||
@@ -135,16 +139,18 @@
|
||||
GameProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("armadilloBrain");
|
||||
- this.brain.tick(worldserver, this);
|
||||
+ ((BehaviorController<Armadillo>) this.brain).tick(worldserver, this); // CraftBukkit - decompile error
|
||||
gameprofilerfiller.pop();
|
||||
gameprofilerfiller.push("armadilloActivityUpdate");
|
||||
ArmadilloAi.updateActivity(this);
|
||||
gameprofilerfiller.pop();
|
||||
if (this.isAlive() && !this.isBaby() && --this.scuteTime <= 0) {
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
if (this.dropFromGiftLootTable(worldserver, LootTables.ARMADILLO_SHED, this::spawnAtLocation)) {
|
||||
this.playSound(SoundEffects.ARMADILLO_SCUTE_DROP, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
|
||||
this.gameEvent(GameEvent.ENTITY_PLACE);
|
||||
}
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
|
||||
this.scuteTime = this.pickNextScuteDropTime();
|
||||
}
|
||||
@@ -291,8 +297,13 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) {
|
||||
- super.actuallyHurt(worldserver, damagesource, f);
|
||||
+ // CraftBukkit start - void -> boolean
|
||||
+ public boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) {
|
||||
+ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event);
|
||||
+ if (!damageResult) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (!this.isNoAi() && !this.isDeadOrDying()) {
|
||||
if (damagesource.getEntity() instanceof EntityLiving) {
|
||||
this.getBrain().setMemoryWithExpiry(MemoryModuleType.DANGER_DETECTED_RECENTLY, true, 80L);
|
||||
@@ -304,6 +315,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
+ return true; // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -327,7 +339,9 @@
|
||||
if (world instanceof WorldServer) {
|
||||
WorldServer worldserver = (WorldServer) world;
|
||||
|
||||
+ this.forceDrops = true; // CraftBukkit
|
||||
this.spawnAtLocation(worldserver, new ItemStack(Items.ARMADILLO_SCUTE));
|
||||
+ this.forceDrops = false; // CraftBukkit
|
||||
this.gameEvent(GameEvent.ENTITY_INTERACT);
|
||||
this.playSound(SoundEffects.ARMADILLO_BRUSH);
|
||||
}
|
||||
@@ -431,7 +445,7 @@
|
||||
}
|
||||
|
||||
public static Armadillo.a fromName(String s) {
|
||||
- return (Armadillo.a) Armadillo.a.CODEC.byName(s, (Enum) Armadillo.a.IDLE);
|
||||
+ return (Armadillo.a) Armadillo.a.CODEC.byName(s, Armadillo.a.IDLE); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2,12 +2,12 @@
|
||||
+++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
@@ -67,10 +67,17 @@
|
||||
|
||||
public class Axolotl extends EntityAnimal implements VariantHolder<Axolotl.Variant>, Bucketable {
|
||||
public class Axolotl extends Animal implements VariantHolder<Axolotl.Variant>, Bucketable {
|
||||
|
||||
+ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
|
||||
+ @Override
|
||||
+ public int getDefaultMaxAirSupply() {
|
||||
+ return AXOLOTL_TOTAL_AIR_SUPPLY;
|
||||
+ return Axolotl.AXOLOTL_TOTAL_AIR_SUPPLY;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
public static final int TOTAL_PLAYDEAD_TIME = 200;
|
||||
@@ -16,15 +16,15 @@
|
||||
- protected static final ImmutableList<? extends MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.of(MemoryModuleType.BREED_TARGET, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT, new MemoryModuleType[]{MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.PLAY_DEAD_TICKS, MemoryModuleType.NEAREST_ATTACKABLE, MemoryModuleType.TEMPTING_PLAYER, MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, MemoryModuleType.IS_TEMPTED, MemoryModuleType.HAS_HUNTING_COOLDOWN, MemoryModuleType.IS_PANICKING});
|
||||
+ // CraftBukkit - decompile error
|
||||
+ protected static final ImmutableList<? extends MemoryModuleType<?>> MEMORY_TYPES = ImmutableList.<MemoryModuleType<?>>of(MemoryModuleType.BREED_TARGET, MemoryModuleType.NEAREST_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_LIVING_ENTITIES, MemoryModuleType.NEAREST_VISIBLE_PLAYER, MemoryModuleType.NEAREST_VISIBLE_ATTACKABLE_PLAYER, MemoryModuleType.LOOK_TARGET, MemoryModuleType.WALK_TARGET, MemoryModuleType.CANT_REACH_WALK_TARGET_SINCE, MemoryModuleType.PATH, MemoryModuleType.ATTACK_TARGET, MemoryModuleType.ATTACK_COOLING_DOWN, MemoryModuleType.NEAREST_VISIBLE_ADULT, new MemoryModuleType[]{MemoryModuleType.HURT_BY_ENTITY, MemoryModuleType.PLAY_DEAD_TICKS, MemoryModuleType.NEAREST_ATTACKABLE, MemoryModuleType.TEMPTING_PLAYER, MemoryModuleType.TEMPTATION_COOLDOWN_TICKS, MemoryModuleType.IS_TEMPTED, MemoryModuleType.HAS_HUNTING_COOLDOWN, MemoryModuleType.IS_PANICKING});
|
||||
private static final DataWatcherObject<Integer> DATA_VARIANT = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.INT);
|
||||
private static final DataWatcherObject<Boolean> DATA_PLAYING_DEAD = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN);
|
||||
private static final DataWatcherObject<Boolean> FROM_BUCKET = DataWatcher.defineId(Axolotl.class, DataWatcherRegistry.BOOLEAN);
|
||||
private static final EntityDataAccessor<Integer> DATA_VARIANT = SynchedEntityData.defineId(Axolotl.class, EntityDataSerializers.INT);
|
||||
private static final EntityDataAccessor<Boolean> DATA_PLAYING_DEAD = SynchedEntityData.defineId(Axolotl.class, EntityDataSerializers.BOOLEAN);
|
||||
private static final EntityDataAccessor<Boolean> FROM_BUCKET = SynchedEntityData.defineId(Axolotl.class, EntityDataSerializers.BOOLEAN);
|
||||
@@ -210,7 +217,7 @@
|
||||
|
||||
@Override
|
||||
public int getMaxAirSupply() {
|
||||
- return 6000;
|
||||
+ return maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
|
||||
+ return this.maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,17 +32,17 @@
|
||||
int i = mobeffect != null ? mobeffect.getDuration() : 0;
|
||||
int j = Math.min(2400, 100 + i);
|
||||
|
||||
- entityhuman.addEffect(new MobEffect(MobEffects.REGENERATION, j, 0), this);
|
||||
+ entityhuman.addEffect(new MobEffect(MobEffects.REGENERATION, j, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AXOLOTL); // CraftBukkit
|
||||
- player.addEffect(new MobEffectInstance(MobEffects.REGENERATION, j, 0), this);
|
||||
+ player.addEffect(new MobEffectInstance(MobEffects.REGENERATION, j, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AXOLOTL); // CraftBukkit
|
||||
}
|
||||
|
||||
entityhuman.removeEffect(MobEffects.DIG_SLOWDOWN);
|
||||
player.removeEffect(MobEffects.DIG_SLOWDOWN);
|
||||
@@ -464,7 +471,7 @@
|
||||
|
||||
@Override
|
||||
public BehaviorController<Axolotl> getBrain() {
|
||||
public Brain<Axolotl> getBrain() {
|
||||
- return super.getBrain();
|
||||
+ return (BehaviorController<Axolotl>) super.getBrain(); // CraftBukkit - decompile error
|
||||
+ return (Brain<Axolotl>) super.getBrain(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,39 @@
|
||||
--- a/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
+++ b/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
@@ -49,6 +49,9 @@
|
||||
import net.minecraft.world.level.gameevent.GameEvent;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class Camel extends AbstractHorse {
|
||||
|
||||
@@ -143,7 +146,7 @@
|
||||
ProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("camelBrain");
|
||||
- Brain<?> behaviorcontroller = this.getBrain();
|
||||
+ Brain<Camel> behaviorcontroller = (Brain<Camel>) this.getBrain(); // CraftBukkit - decompile error
|
||||
|
||||
behaviorcontroller.tick(world, this);
|
||||
gameprofilerfiller.pop();
|
||||
@@ -454,9 +457,15 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void actuallyHurt(ServerLevel world, DamageSource source, float amount) {
|
||||
+ // CraftBukkit start - void -> boolean
|
||||
+ public boolean actuallyHurt(ServerLevel worldserver, DamageSource damagesource, float f, EntityDamageEvent event) {
|
||||
+ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event);
|
||||
+ if (!damageResult) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.standUpInstantly();
|
||||
- super.actuallyHurt(world, source, amount);
|
||||
+ return true; // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,40 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
+++ b/net/minecraft/world/entity/animal/camel/Camel.java
|
||||
@@ -50,6 +50,10 @@
|
||||
import net.minecraft.world.phys.Vec2F;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityDamageEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class Camel extends EntityHorseAbstract {
|
||||
|
||||
public static final float BABY_SCALE = 0.45F;
|
||||
@@ -143,7 +147,7 @@
|
||||
GameProfilerFiller gameprofilerfiller = Profiler.get();
|
||||
|
||||
gameprofilerfiller.push("camelBrain");
|
||||
- BehaviorController<?> behaviorcontroller = this.getBrain();
|
||||
+ BehaviorController<Camel> behaviorcontroller = (BehaviorController<Camel>) this.getBrain(); // CraftBukkit - decompile error
|
||||
|
||||
behaviorcontroller.tick(worldserver, this);
|
||||
gameprofilerfiller.pop();
|
||||
@@ -454,9 +458,15 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- protected void actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f) {
|
||||
+ // CraftBukkit start - void -> boolean
|
||||
+ public boolean actuallyHurt(WorldServer worldserver, DamageSource damagesource, float f, EntityDamageEvent event) {
|
||||
+ boolean damageResult = super.actuallyHurt(worldserver, damagesource, f, event);
|
||||
+ if (!damageResult) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.standUpInstantly();
|
||||
- super.actuallyHurt(worldserver, damagesource, f);
|
||||
+ return true; // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1,40 +1,39 @@
|
||||
--- a/net/minecraft/world/entity/animal/frog/ShootTongue.java
|
||||
+++ b/net/minecraft/world/entity/animal/frog/ShootTongue.java
|
||||
@@ -20,6 +20,10 @@
|
||||
import net.minecraft.world.level.pathfinder.PathEntity;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.pathfinder.Path;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
|
||||
public class ShootTongue extends Behavior<Frog> {
|
||||
|
||||
public static final int TIME_OUT_DURATION = 100;
|
||||
@@ -64,7 +68,7 @@
|
||||
@@ -64,7 +67,7 @@
|
||||
|
||||
BehaviorUtil.lookAtEntity(frog, entityliving);
|
||||
BehaviorUtils.lookAtEntity(frog, entityliving);
|
||||
frog.setTongueTarget(entityliving);
|
||||
- frog.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(entityliving.position(), 2.0F, 0)));
|
||||
+ frog.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(entityliving.position(), 2.0F, 0))); // CraftBukkit - decompile error
|
||||
- frog.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new WalkTarget(entityliving.position(), 2.0F, 0)));
|
||||
+ frog.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (new WalkTarget(entityliving.position(), 2.0F, 0))); // CraftBukkit - decompile error
|
||||
this.calculatePathCounter = 10;
|
||||
this.state = ShootTongue.a.MOVE_TO_TARGET;
|
||||
this.state = ShootTongue.State.MOVE_TO_TARGET;
|
||||
}
|
||||
@@ -85,7 +89,7 @@
|
||||
@@ -85,7 +88,7 @@
|
||||
if (entity.isAlive()) {
|
||||
frog.doHurtTarget(worldserver, entity);
|
||||
frog.doHurtTarget(world, entity);
|
||||
if (!entity.isAlive()) {
|
||||
- entity.remove(Entity.RemovalReason.KILLED);
|
||||
+ entity.remove(Entity.RemovalReason.KILLED, EntityRemoveEvent.Cause.DEATH); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,7 +110,7 @@
|
||||
@@ -106,7 +109,7 @@
|
||||
this.eatAnimationTimer = 0;
|
||||
this.state = ShootTongue.a.CATCH_ANIMATION;
|
||||
this.state = ShootTongue.State.CATCH_ANIMATION;
|
||||
} else if (this.calculatePathCounter <= 0) {
|
||||
- frog.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new MemoryTarget(entityliving.position(), 2.0F, 0)));
|
||||
+ frog.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (new MemoryTarget(entityliving.position(), 2.0F, 0))); // CraftBukkit - decompile error
|
||||
- frog.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (Object) (new WalkTarget(entityliving.position(), 2.0F, 0)));
|
||||
+ frog.getBrain().setMemory(MemoryModuleType.WALK_TARGET, (new WalkTarget(entityliving.position(), 2.0F, 0))); // CraftBukkit - decompile error
|
||||
this.calculatePathCounter = 10;
|
||||
} else {
|
||||
--this.calculatePathCounter;
|
||||
@@ -3,22 +3,22 @@
|
||||
@@ -74,7 +74,7 @@
|
||||
|
||||
@Override
|
||||
public BehaviorController<Tadpole> getBrain() {
|
||||
public Brain<Tadpole> getBrain() {
|
||||
- return super.getBrain();
|
||||
+ return (BehaviorController<Tadpole>) super.getBrain(); // CraftBukkit - decompile error
|
||||
+ return (Brain<Tadpole>) super.getBrain(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -225,12 +225,17 @@
|
||||
World world = this.level();
|
||||
Level world = this.level();
|
||||
|
||||
if (world instanceof WorldServer worldserver) {
|
||||
- this.convertTo(EntityTypes.FROG, ConversionParams.single(this, false, false), (frog) -> {
|
||||
+ Frog converted = this.convertTo(EntityTypes.FROG, ConversionParams.single(this, false, false), (frog) -> { // CraftBukkit
|
||||
frog.finalizeSpawn(worldserver, this.level().getCurrentDifficultyAt(frog.blockPosition()), EntitySpawnReason.CONVERSION, (GroupDataEntity) null);
|
||||
if (world instanceof ServerLevel worldserver) {
|
||||
- this.convertTo(EntityType.FROG, ConversionParams.single(this, false, false), (frog) -> {
|
||||
+ Frog converted = this.convertTo(EntityType.FROG, ConversionParams.single(this, false, false), (frog) -> { // CraftBukkit
|
||||
frog.finalizeSpawn(worldserver, this.level().getCurrentDifficultyAt(frog.blockPosition()), EntitySpawnReason.CONVERSION, (SpawnGroupData) null);
|
||||
frog.setPersistenceRequired();
|
||||
frog.fudgePositionAfterSizeChange(this.getDimensions(this.getPose()));
|
||||
this.playSound(SoundEffects.TADPOLE_GROW_UP, 0.15F, 1.0F);
|
||||
this.playSound(SoundEvents.TADPOLE_GROW_UP, 0.15F, 1.0F);
|
||||
- });
|
||||
+ // CraftBukkit start
|
||||
+ }, org.bukkit.event.entity.EntityTransformEvent.TransformReason.METAMORPHOSIS, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.METAMORPHOSIS);
|
||||
@@ -0,0 +1,40 @@
|
||||
--- a/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
+++ b/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
@@ -53,6 +53,11 @@
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.pathfinder.PathType;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class Goat extends Animal {
|
||||
|
||||
@@ -184,7 +189,7 @@
|
||||
|
||||
@Override
|
||||
public Brain<Goat> getBrain() {
|
||||
- return super.getBrain();
|
||||
+ return (Brain<Goat>) super.getBrain(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -229,8 +234,15 @@
|
||||
ItemStack itemstack = player.getItemInHand(hand);
|
||||
|
||||
if (itemstack.is(Items.BUCKET) && !this.isBaby()) {
|
||||
+ // CraftBukkit start - Got milk?
|
||||
+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((ServerLevel) player.level(), player, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, hand);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return InteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
player.playSound(this.getMilkingSound(), 1.0F, 1.0F);
|
||||
- ItemStack itemstack1 = ItemUtils.createFilledResult(itemstack, player, Items.MILK_BUCKET.getDefaultInstance());
|
||||
+ ItemStack itemstack1 = ItemUtils.createFilledResult(itemstack, player, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
|
||||
|
||||
player.setItemInHand(hand, itemstack1);
|
||||
return InteractionResult.SUCCESS;
|
||||
@@ -1,41 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
+++ b/net/minecraft/world/entity/animal/goat/Goat.java
|
||||
@@ -54,6 +54,12 @@
|
||||
import net.minecraft.world.level.pathfinder.PathType;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.player.PlayerBucketFillEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class Goat extends EntityAnimal {
|
||||
|
||||
public static final EntitySize LONG_JUMPING_DIMENSIONS = EntitySize.scalable(0.9F, 1.3F).scale(0.7F);
|
||||
@@ -184,7 +190,7 @@
|
||||
|
||||
@Override
|
||||
public BehaviorController<Goat> getBrain() {
|
||||
- return super.getBrain();
|
||||
+ return (BehaviorController<Goat>) super.getBrain(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -229,8 +235,15 @@
|
||||
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
|
||||
|
||||
if (itemstack.is(Items.BUCKET) && !this.isBaby()) {
|
||||
+ // CraftBukkit start - Got milk?
|
||||
+ PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level(), entityhuman, this.blockPosition(), this.blockPosition(), null, itemstack, Items.MILK_BUCKET, enumhand);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return EnumInteractionResult.PASS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
entityhuman.playSound(this.getMilkingSound(), 1.0F, 1.0F);
|
||||
- ItemStack itemstack1 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, Items.MILK_BUCKET.getDefaultInstance());
|
||||
+ ItemStack itemstack1 = ItemLiquidUtil.createFilledResult(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
|
||||
|
||||
entityhuman.setItemInHand(enumhand, itemstack1);
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java
|
||||
@@ -79,6 +79,18 @@
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
--- a/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/AbstractHorse.java
|
||||
@@ -79,6 +79,17 @@
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import net.minecraft.world.ticks.ContainerSingleItem;
|
||||
|
||||
+// CraftBukkit start
|
||||
@@ -10,19 +10,19 @@
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.entity.AbstractHorse;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
+import org.bukkit.inventory.InventoryHolder;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, HasCustomInventoryScreen, OwnableEntity, IJumpable, ISaddleable {
|
||||
public abstract class AbstractHorse extends Animal implements ContainerListener, HasCustomInventoryScreen, OwnableEntity, PlayerRideableJumping, Saddleable {
|
||||
|
||||
public static final int EQUIPMENT_SLOT_OFFSET = 400;
|
||||
@@ -167,7 +179,53 @@
|
||||
public boolean stillValid(EntityHuman entityhuman) {
|
||||
return entityhuman.getVehicle() == EntityHorseAbstract.this || entityhuman.canInteractWithEntity((Entity) EntityHorseAbstract.this, 4.0D);
|
||||
}
|
||||
@@ -166,8 +177,54 @@
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
return player.getVehicle() == AbstractHorse.this || player.canInteractWithEntity((Entity) AbstractHorse.this, 4.0D);
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start - add fields and methods
|
||||
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
@@ -35,54 +35,54 @@
|
||||
+
|
||||
+ @Override
|
||||
+ public void onOpen(CraftHumanEntity who) {
|
||||
+ transaction.add(who);
|
||||
+ this.transaction.add(who);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onClose(CraftHumanEntity who) {
|
||||
+ transaction.remove(who);
|
||||
+ this.transaction.remove(who);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<HumanEntity> getViewers() {
|
||||
+ return transaction;
|
||||
+ return this.transaction;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxStackSize() {
|
||||
+ return maxStack;
|
||||
+ return this.maxStack;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setMaxStackSize(int size) {
|
||||
+ maxStack = size;
|
||||
+ this.maxStack = size;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public InventoryHolder getOwner() {
|
||||
+ return (AbstractHorse) EntityHorseAbstract.this.getBukkitEntity();
|
||||
+ return (org.bukkit.entity.AbstractHorse) AbstractHorse.this.getBukkitEntity();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return EntityHorseAbstract.this.getBukkitEntity().getLocation();
|
||||
+ }
|
||||
+ return AbstractHorse.this.getBukkitEntity().getLocation();
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
};
|
||||
+ public int maxDomestication = 100; // CraftBukkit - store max domestication value
|
||||
|
||||
protected EntityHorseAbstract(EntityTypes<? extends EntityHorseAbstract> entitytypes, World world) {
|
||||
super(entitytypes, world);
|
||||
@@ -366,7 +424,7 @@
|
||||
protected AbstractHorse(EntityType<? extends AbstractHorse> type, Level world) {
|
||||
super(type, world);
|
||||
@@ -366,7 +423,7 @@
|
||||
public void createInventory() {
|
||||
InventorySubcontainer inventorysubcontainer = this.inventory;
|
||||
SimpleContainer inventorysubcontainer = this.inventory;
|
||||
|
||||
- this.inventory = new InventorySubcontainer(this.getInventorySize());
|
||||
+ this.inventory = new InventorySubcontainer(this.getInventorySize(), (AbstractHorse) this.getBukkitEntity()); // CraftBukkit
|
||||
- this.inventory = new SimpleContainer(this.getInventorySize());
|
||||
+ this.inventory = new SimpleContainer(this.getInventorySize(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit
|
||||
if (inventorysubcontainer != null) {
|
||||
inventorysubcontainer.removeListener(this);
|
||||
int i = Math.min(inventorysubcontainer.getContainerSize(), this.inventory.getContainerSize());
|
||||
@@ -470,7 +528,7 @@
|
||||
@@ -470,7 +527,7 @@
|
||||
}
|
||||
|
||||
public int getMaxTemper() {
|
||||
@@ -91,7 +91,7 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -541,7 +599,7 @@
|
||||
@@ -541,7 +598,7 @@
|
||||
}
|
||||
|
||||
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
|
||||
@@ -100,8 +100,8 @@
|
||||
flag = true;
|
||||
}
|
||||
|
||||
@@ -618,7 +676,7 @@
|
||||
if (world instanceof WorldServer worldserver) {
|
||||
@@ -618,7 +675,7 @@
|
||||
if (world instanceof ServerLevel worldserver) {
|
||||
if (this.isAlive()) {
|
||||
if (this.random.nextInt(900) == 0 && this.deathTime == 0) {
|
||||
- this.heal(1.0F);
|
||||
@@ -109,36 +109,36 @@
|
||||
}
|
||||
|
||||
if (this.canEatGrass()) {
|
||||
@@ -883,6 +941,7 @@
|
||||
@@ -883,6 +940,7 @@
|
||||
if (this.getOwnerUUID() != null) {
|
||||
nbttagcompound.putUUID("Owner", this.getOwnerUUID());
|
||||
nbt.putUUID("Owner", this.getOwnerUUID());
|
||||
}
|
||||
+ nbttagcompound.putInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit
|
||||
+ nbt.putInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit
|
||||
|
||||
if (!this.inventory.getItem(0).isEmpty()) {
|
||||
nbttagcompound.put("SaddleItem", this.inventory.getItem(0).save(this.registryAccess()));
|
||||
@@ -910,6 +969,11 @@
|
||||
nbt.put("SaddleItem", this.inventory.getItem(0).save(this.registryAccess()));
|
||||
@@ -910,6 +968,11 @@
|
||||
if (uuid != null) {
|
||||
this.setOwnerUUID(uuid);
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ if (nbttagcompound.contains("Bukkit.MaxDomestication")) {
|
||||
+ this.maxDomestication = nbttagcompound.getInt("Bukkit.MaxDomestication");
|
||||
+ if (nbt.contains("Bukkit.MaxDomestication")) {
|
||||
+ this.maxDomestication = nbt.getInt("Bukkit.MaxDomestication");
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (nbttagcompound.contains("SaddleItem", 10)) {
|
||||
ItemStack itemstack = (ItemStack) ItemStack.parse(this.registryAccess(), nbttagcompound.getCompound("SaddleItem")).orElse(ItemStack.EMPTY);
|
||||
@@ -1012,6 +1076,17 @@
|
||||
if (nbt.contains("SaddleItem", 10)) {
|
||||
ItemStack itemstack = (ItemStack) ItemStack.parse(this.registryAccess(), nbt.getCompound("SaddleItem")).orElse(ItemStack.EMPTY);
|
||||
@@ -1012,6 +1075,17 @@
|
||||
|
||||
@Override
|
||||
public void handleStartJump(int i) {
|
||||
public void handleStartJump(int height) {
|
||||
+ // CraftBukkit start
|
||||
+ float power;
|
||||
+ if (i >= 90) {
|
||||
+ if (height >= 90) {
|
||||
+ power = 1.0F;
|
||||
+ } else {
|
||||
+ power = 0.4F + 0.4F * (float) i / 90.0F;
|
||||
+ power = 0.4F + 0.4F * (float) height / 90.0F;
|
||||
+ }
|
||||
+ if (!CraftEventFactory.callHorseJumpEvent(this, power)) {
|
||||
+ return;
|
||||
@@ -1,22 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/horse/EntityHorseSkeleton.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/EntityHorseSkeleton.java
|
||||
@@ -27,6 +27,10 @@
|
||||
import net.minecraft.world.level.GeneratorAccess;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityHorseSkeleton extends EntityHorseAbstract {
|
||||
|
||||
private final PathfinderGoalHorseTrap skeletonTrapGoal = new PathfinderGoalHorseTrap(this);
|
||||
@@ -122,7 +126,7 @@
|
||||
public void aiStep() {
|
||||
super.aiStep();
|
||||
if (this.isTrap() && this.trapTime++ >= 18000) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
--- a/net/minecraft/world/entity/animal/horse/EntityLlama.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/EntityLlama.java
|
||||
@@ -82,6 +82,11 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void setStrengthPublic(int i) {
|
||||
+ this.setStrength(i);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
private void setStrength(int i) {
|
||||
this.entityData.set(EntityLlama.DATA_STRENGTH_ID, Math.max(1, Math.min(5, i)));
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/world/entity/animal/horse/Llama.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/Llama.java
|
||||
@@ -82,6 +82,11 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void setStrengthPublic(int i) {
|
||||
+ this.setStrength(i);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
private void setStrength(int strength) {
|
||||
this.entityData.set(Llama.DATA_STRENGTH_ID, Math.max(1, Math.min(5, strength)));
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
--- a/net/minecraft/world/entity/animal/horse/SkeletonHorse.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/SkeletonHorse.java
|
||||
@@ -26,6 +26,9 @@
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+// CraftBukkit end
|
||||
|
||||
public class SkeletonHorse extends AbstractHorse {
|
||||
|
||||
@@ -122,7 +125,7 @@
|
||||
public void aiStep() {
|
||||
super.aiStep();
|
||||
if (this.isTrap() && this.trapTime++ >= 18000) {
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
--- a/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.java
|
||||
--- a/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/SkeletonTrapGoal.java
|
||||
@@ -43,12 +43,12 @@
|
||||
if (entitylightning != null) {
|
||||
entitylightning.moveTo(this.horse.getX(), this.horse.getY(), this.horse.getZ());
|
||||
entitylightning.setVisualOnly(true);
|
||||
- worldserver.addFreshEntity(entitylightning);
|
||||
+ worldserver.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRAP); // CraftBukkit
|
||||
EntitySkeleton entityskeleton = this.createSkeleton(difficultydamagescaler, this.horse);
|
||||
Skeleton entityskeleton = this.createSkeleton(difficultydamagescaler, this.horse);
|
||||
|
||||
if (entityskeleton != null) {
|
||||
entityskeleton.startRiding(this.horse);
|
||||
@@ -14,7 +14,7 @@
|
||||
+ worldserver.addFreshEntityWithPassengers(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP); // CraftBukkit
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
EntityHorseAbstract entityhorseabstract = this.createHorse(difficultydamagescaler);
|
||||
AbstractHorse entityhorseabstract = this.createHorse(difficultydamagescaler);
|
||||
@@ -59,7 +59,7 @@
|
||||
if (entityskeleton1 != null) {
|
||||
entityskeleton1.startRiding(entityhorseabstract);
|
||||
@@ -1,18 +1,17 @@
|
||||
--- a/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.java
|
||||
@@ -22,6 +22,10 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.WorldAccess;
|
||||
|
||||
--- a/net/minecraft/world/entity/animal/horse/TraderLlama.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/TraderLlama.java
|
||||
@@ -21,6 +21,9 @@
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.ServerLevelAccessor;
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityRemoveEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityLlamaTrader extends EntityLlama {
|
||||
|
||||
private int despawnDelay = 47999;
|
||||
@@ -94,7 +98,7 @@
|
||||
this.despawnDelay = this.isLeashedToWanderingTrader() ? ((EntityVillagerTrader) this.getLeashHolder()).getDespawnDelay() - 1 : this.despawnDelay - 1;
|
||||
public class TraderLlama extends Llama {
|
||||
|
||||
@@ -94,7 +97,7 @@
|
||||
this.despawnDelay = this.isLeashedToWanderingTrader() ? ((WanderingTrader) this.getLeashHolder()).getDespawnDelay() - 1 : this.despawnDelay - 1;
|
||||
if (this.despawnDelay <= 0) {
|
||||
this.removeLeash();
|
||||
- this.discard();
|
||||
@@ -20,7 +19,7 @@
|
||||
}
|
||||
|
||||
}
|
||||
@@ -160,7 +164,7 @@
|
||||
@@ -160,7 +163,7 @@
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
@@ -28,4 +27,4 @@
|
||||
+ this.mob.setTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit
|
||||
Entity entity = this.llama.getLeashHolder();
|
||||
|
||||
if (entity instanceof EntityVillagerTrader) {
|
||||
if (entity instanceof WanderingTrader) {
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||
+++ b/net/minecraft/world/entity/animal/sniffer/Sniffer.java
|
||||
@@ -267,6 +267,13 @@
|
||||
this.dropFromGiftLootTable(worldserver, LootTables.SNIFFER_DIGGING, (worldserver1, itemstack) -> {
|
||||
EntityItem entityitem = new EntityItem(this.level(), (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack);
|
||||
this.dropFromGiftLootTable(worldserver, BuiltInLootTables.SNIFFER_DIGGING, (worldserver1, itemstack) -> {
|
||||
ItemEntity entityitem = new ItemEntity(this.level(), (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack);
|
||||
|
||||
+ // CraftBukkit start - handle EntityDropItemEvent
|
||||
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
|
||||
@@ -17,7 +17,7 @@
|
||||
@@ -308,7 +315,7 @@
|
||||
List<GlobalPos> list = (List) this.getExploredPositions().limit(20L).collect(Collectors.toList());
|
||||
|
||||
list.add(0, GlobalPos.of(this.level().dimension(), blockposition));
|
||||
list.add(0, GlobalPos.of(this.level().dimension(), pos));
|
||||
- this.getBrain().setMemory(MemoryModuleType.SNIFFER_EXPLORED_POSITIONS, (Object) list);
|
||||
+ this.getBrain().setMemory(MemoryModuleType.SNIFFER_EXPLORED_POSITIONS, list); // CraftBukkit - decompile error
|
||||
return this;
|
||||
@@ -26,9 +26,9 @@
|
||||
@@ -444,7 +451,7 @@
|
||||
|
||||
@Override
|
||||
public BehaviorController<Sniffer> getBrain() {
|
||||
public Brain<Sniffer> getBrain() {
|
||||
- return super.getBrain();
|
||||
+ return (BehaviorController<Sniffer>) super.getBrain(); // CraftBukkit - decompile error
|
||||
+ return (Brain<Sniffer>) super.getBrain(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
Reference in New Issue
Block a user