Move CraftBukkit per-file patches
By: Initial <noreply+automated@papermc.io>
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
--- 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,105 @@
|
||||
--- 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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
--- 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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
--- 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
--- 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;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
--- 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;
|
||||
@@ -0,0 +1,69 @@
|
||||
--- 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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
--- a/net/minecraft/world/entity/animal/EntityFox.java
|
||||
+++ b/net/minecraft/world/entity/animal/EntityFox.java
|
||||
@@ -91,6 +91,10 @@
|
||||
import net.minecraft.world.level.pathfinder.PathType;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
|
||||
+// 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();
|
||||
|
||||
- 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
|
||||
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
|
||||
this.ticksSinceEaten = 0;
|
||||
}
|
||||
|
||||
@@ -853,6 +858,16 @@
|
||||
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);
|
||||
+ if (entityBreedEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ experience = entityBreedEvent.getExperience();
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (entityplayer2 != null) {
|
||||
entityplayer2.awardStat(StatisticList.ANIMALS_BRED);
|
||||
@@ -863,12 +878,14 @@
|
||||
this.partner.setAge(6000);
|
||||
this.animal.resetLove();
|
||||
this.partner.resetLove();
|
||||
- entityfox.setAge(-24000);
|
||||
- entityfox.moveTo(this.animal.getX(), this.animal.getY(), this.animal.getZ(), 0.0F, 0.0F);
|
||||
- worldserver.addFreshEntityWithPassengers(entityfox);
|
||||
+ 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));
|
||||
+ // 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));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1264,6 +1281,11 @@
|
||||
int i = (Integer) iblockdata.getValue(BlockSweetBerryBush.AGE);
|
||||
|
||||
iblockdata.setValue(BlockSweetBerryBush.AGE, 1);
|
||||
+ // CraftBukkit start - call EntityChangeBlockEvent
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityFox.this, this.blockPos, iblockdata.setValue(BlockSweetBerryBush.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);
|
||||
|
||||
@@ -1494,7 +1516,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 EntityFox.Type byId(int i) {
|
||||
@@ -0,0 +1,11 @@
|
||||
--- 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);
|
||||
@@ -0,0 +1,59 @@
|
||||
--- 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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
--- 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
--- 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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
--- 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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
--- 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;
|
||||
@@ -0,0 +1,30 @@
|
||||
--- 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);
|
||||
@@ -0,0 +1,20 @@
|
||||
--- 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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
--- 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;
|
||||
|
||||
+// 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);
|
||||
- this.setSpeedModifier(0.0D);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -577,9 +580,19 @@
|
||||
int i = (Integer) iblockdata.getValue(BlockCarrots.AGE);
|
||||
|
||||
if (i == 0) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockposition, Blocks.AIR.defaultBlockState())) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.setBlock(blockposition, Blocks.AIR.defaultBlockState(), 2);
|
||||
world.destroyBlock(blockposition, true, this.rabbit);
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockposition, iblockdata.setValue(BlockCarrots.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.levelEvent(2001, blockposition, Block.getId(iblockdata));
|
||||
@@ -0,0 +1,50 @@
|
||||
--- 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()) {
|
||||
@@ -0,0 +1,57 @@
|
||||
--- 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;
|
||||
|
||||
+// 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 @@
|
||||
|
||||
if (world instanceof WorldServer 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);
|
||||
|
||||
if (this.level().getBlockState(blockposition).isAir() && iblockdata.canSurvive(this.level(), blockposition)) {
|
||||
- this.level().setBlockAndUpdate(blockposition, iblockdata);
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.handleBlockFormEvent(this.level(), blockposition, iblockdata, this)) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.level().gameEvent((Holder) GameEvent.BLOCK_PLACE, blockposition, GameEvent.a.of(this, iblockdata));
|
||||
}
|
||||
}
|
||||
@@ -153,6 +161,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));
|
||||
@@ -169,7 +182,9 @@
|
||||
worldserver.playSound((EntityHuman) null, (Entity) this, SoundEffects.SNOW_GOLEM_SHEAR, soundcategory, 1.0F, 1.0F);
|
||||
this.setPumpkin(false);
|
||||
this.dropFromShearingLootTable(worldserver, LootTables.SHEAR_SNOW_GOLEM, itemstack, (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/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);
|
||||
@@ -0,0 +1,105 @@
|
||||
--- 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);
|
||||
@@ -0,0 +1,93 @@
|
||||
--- a/net/minecraft/world/entity/animal/allay/Allay.java
|
||||
+++ b/net/minecraft/world/entity/animal/allay/Allay.java
|
||||
@@ -103,6 +103,7 @@
|
||||
private float dancingAnimationTicks;
|
||||
private float spinningAnimationTicks;
|
||||
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()));
|
||||
}
|
||||
|
||||
+ // 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);
|
||||
@@ -126,7 +133,7 @@
|
||||
|
||||
@Override
|
||||
public BehaviorController<Allay> getBrain() {
|
||||
- return super.getBrain();
|
||||
+ return (BehaviorController<Allay>) super.getBrain(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public static AttributeProvider.Builder createAttributes() {
|
||||
@@ -233,7 +240,7 @@
|
||||
public void aiStep() {
|
||||
super.aiStep();
|
||||
if (!this.level().isClientSide && this.isAlive() && this.tickCount % 10 == 0) {
|
||||
- this.heal(1.0F);
|
||||
+ this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
|
||||
}
|
||||
|
||||
if (this.isDancing() && this.shouldStopDancing() && this.tickCount % 20 == 0) {
|
||||
@@ -303,7 +310,12 @@
|
||||
ItemStack itemstack1 = this.getItemInHand(EnumHand.MAIN_HAND);
|
||||
|
||||
if (this.isDancing() && itemstack.is(TagsItem.DUPLICATES_ALLAYS) && this.canDuplicate()) {
|
||||
- this.duplicateAllay();
|
||||
+ // CraftBukkit start - handle cancel duplication
|
||||
+ Allay allay = this.duplicateAllay();
|
||||
+ if (allay == null) {
|
||||
+ return EnumInteractionResult.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);
|
||||
@@ -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);
|
||||
@@ -415,6 +427,7 @@
|
||||
}
|
||||
|
||||
private boolean shouldStopDancing() {
|
||||
+ if (this.forceDancing) {return false;} // CraftBukkit
|
||||
return this.jukeboxPos == null || !this.jukeboxPos.closerToCenterThan(this.position(), (double) ((GameEvent) GameEvent.JUKEBOX_PLAY.value()).notificationRadius()) || !this.level().getBlockState(this.jukeboxPos).is(Blocks.JUKEBOX);
|
||||
}
|
||||
|
||||
@@ -506,7 +519,7 @@
|
||||
|
||||
}
|
||||
|
||||
- public void duplicateAllay() {
|
||||
+ public Allay duplicateAllay() { // CraftBukkit - return allay
|
||||
Allay allay = (Allay) EntityTypes.ALLAY.create(this.level(), EntitySpawnReason.BREEDING);
|
||||
|
||||
if (allay != null) {
|
||||
@@ -514,9 +527,9 @@
|
||||
allay.setPersistenceRequired();
|
||||
allay.resetDuplicationCooldown();
|
||||
this.resetDuplicationCooldown();
|
||||
- this.level().addFreshEntity(allay);
|
||||
+ this.level().addFreshEntity(allay, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.DUPLICATION); // CraftBukkit - reason for duplicated allay
|
||||
}
|
||||
-
|
||||
+ return allay; // CraftBukkit
|
||||
}
|
||||
|
||||
public void resetDuplicationCooldown() {
|
||||
@@ -0,0 +1,76 @@
|
||||
--- 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
|
||||
@@ -0,0 +1,48 @@
|
||||
--- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
+++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java
|
||||
@@ -67,10 +67,17 @@
|
||||
|
||||
public class Axolotl extends EntityAnimal implements VariantHolder<Axolotl.Variant>, Bucketable {
|
||||
|
||||
+ // CraftBukkit start - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
|
||||
+ @Override
|
||||
+ public int getDefaultMaxAirSupply() {
|
||||
+ return AXOLOTL_TOTAL_AIR_SUPPLY;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
public static final int TOTAL_PLAYDEAD_TIME = 200;
|
||||
private static final int POSE_ANIMATION_TICKS = 10;
|
||||
protected static final ImmutableList<? extends SensorType<? extends Sensor<? super Axolotl>>> SENSOR_TYPES = ImmutableList.of(SensorType.NEAREST_LIVING_ENTITIES, SensorType.NEAREST_ADULT, SensorType.HURT_BY, SensorType.AXOLOTL_ATTACKABLES, SensorType.AXOLOTL_TEMPTATIONS);
|
||||
- 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);
|
||||
@@ -210,7 +217,7 @@
|
||||
|
||||
@Override
|
||||
public int getMaxAirSupply() {
|
||||
- return 6000;
|
||||
+ return maxAirTicks; // CraftBukkit - SPIGOT-6907: re-implement LivingEntity#setMaximumAir()
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -414,7 +421,7 @@
|
||||
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
|
||||
}
|
||||
|
||||
entityhuman.removeEffect(MobEffects.DIG_SLOWDOWN);
|
||||
@@ -464,7 +471,7 @@
|
||||
|
||||
@Override
|
||||
public BehaviorController<Axolotl> getBrain() {
|
||||
- return super.getBrain();
|
||||
+ return (BehaviorController<Axolotl>) super.getBrain(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,40 @@
|
||||
--- 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
|
||||
@@ -0,0 +1,40 @@
|
||||
--- 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;
|
||||
|
||||
+// 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 @@
|
||||
|
||||
BehaviorUtil.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
|
||||
this.calculatePathCounter = 10;
|
||||
this.state = ShootTongue.a.MOVE_TO_TARGET;
|
||||
}
|
||||
@@ -85,7 +89,7 @@
|
||||
if (entity.isAlive()) {
|
||||
frog.doHurtTarget(worldserver, 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 @@
|
||||
this.eatAnimationTimer = 0;
|
||||
this.state = ShootTongue.a.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
|
||||
this.calculatePathCounter = 10;
|
||||
} else {
|
||||
--this.calculatePathCounter;
|
||||
@@ -0,0 +1,31 @@
|
||||
--- a/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
+++ b/net/minecraft/world/entity/animal/frog/Tadpole.java
|
||||
@@ -74,7 +74,7 @@
|
||||
|
||||
@Override
|
||||
public BehaviorController<Tadpole> getBrain() {
|
||||
- return super.getBrain();
|
||||
+ return (BehaviorController<Tadpole>) super.getBrain(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -225,12 +225,17 @@
|
||||
World 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);
|
||||
frog.setPersistenceRequired();
|
||||
frog.fudgePositionAfterSizeChange(this.getDimensions(this.getPose()));
|
||||
this.playSound(SoundEffects.TADPOLE_GROW_UP, 0.15F, 1.0F);
|
||||
- });
|
||||
+ // CraftBukkit start
|
||||
+ }, org.bukkit.event.entity.EntityTransformEvent.TransformReason.METAMORPHOSIS, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.METAMORPHOSIS);
|
||||
+ if (converted == null) {
|
||||
+ this.setAge(0); // Sets the age to 0 for avoid a loop if the event is canceled
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
--- 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;
|
||||
@@ -0,0 +1,149 @@
|
||||
--- 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;
|
||||
import net.minecraft.world.ticks.ContainerSingleItem;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.Arrays;
|
||||
+import java.util.List;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.entity.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 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);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start - add fields and methods
|
||||
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
+ private int maxStack = MAX_STACK;
|
||||
+
|
||||
+ @Override
|
||||
+ public List<ItemStack> getContents() {
|
||||
+ return Arrays.asList(this.getTheItem());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onOpen(CraftHumanEntity who) {
|
||||
+ transaction.add(who);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onClose(CraftHumanEntity who) {
|
||||
+ transaction.remove(who);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<HumanEntity> getViewers() {
|
||||
+ return transaction;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxStackSize() {
|
||||
+ return maxStack;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setMaxStackSize(int size) {
|
||||
+ maxStack = size;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public InventoryHolder getOwner() {
|
||||
+ return (AbstractHorse) EntityHorseAbstract.this.getBukkitEntity();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return EntityHorseAbstract.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 @@
|
||||
public void createInventory() {
|
||||
InventorySubcontainer inventorysubcontainer = this.inventory;
|
||||
|
||||
- this.inventory = new InventorySubcontainer(this.getInventorySize());
|
||||
+ this.inventory = new InventorySubcontainer(this.getInventorySize(), (AbstractHorse) this.getBukkitEntity()); // CraftBukkit
|
||||
if (inventorysubcontainer != null) {
|
||||
inventorysubcontainer.removeListener(this);
|
||||
int i = Math.min(inventorysubcontainer.getContainerSize(), this.inventory.getContainerSize());
|
||||
@@ -470,7 +528,7 @@
|
||||
}
|
||||
|
||||
public int getMaxTemper() {
|
||||
- return 100;
|
||||
+ return this.maxDomestication; // CraftBukkit - return stored max domestication instead of 100
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -541,7 +599,7 @@
|
||||
}
|
||||
|
||||
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
|
||||
- this.heal(f);
|
||||
+ this.heal(f, EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
|
||||
flag = true;
|
||||
}
|
||||
|
||||
@@ -618,7 +676,7 @@
|
||||
if (world instanceof WorldServer worldserver) {
|
||||
if (this.isAlive()) {
|
||||
if (this.random.nextInt(900) == 0 && this.deathTime == 0) {
|
||||
- this.heal(1.0F);
|
||||
+ this.heal(1.0F, EntityRegainHealthEvent.RegainReason.REGEN); // CraftBukkit
|
||||
}
|
||||
|
||||
if (this.canEatGrass()) {
|
||||
@@ -883,6 +941,7 @@
|
||||
if (this.getOwnerUUID() != null) {
|
||||
nbttagcompound.putUUID("Owner", this.getOwnerUUID());
|
||||
}
|
||||
+ nbttagcompound.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 @@
|
||||
if (uuid != null) {
|
||||
this.setOwnerUUID(uuid);
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ if (nbttagcompound.contains("Bukkit.MaxDomestication")) {
|
||||
+ this.maxDomestication = nbttagcompound.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 @@
|
||||
|
||||
@Override
|
||||
public void handleStartJump(int i) {
|
||||
+ // CraftBukkit start
|
||||
+ float power;
|
||||
+ if (i >= 90) {
|
||||
+ power = 1.0F;
|
||||
+ } else {
|
||||
+ power = 0.4F + 0.4F * (float) i / 90.0F;
|
||||
+ }
|
||||
+ if (!CraftEventFactory.callHorseJumpEvent(this, power)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.allowStandSliding = true;
|
||||
this.standIfPossible();
|
||||
this.playJumpSound();
|
||||
@@ -0,0 +1,22 @@
|
||||
--- 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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
--- 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,31 @@
|
||||
--- 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;
|
||||
|
||||
+// 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;
|
||||
if (this.despawnDelay <= 0) {
|
||||
this.removeLeash();
|
||||
- this.discard();
|
||||
+ this.discard(EntityRemoveEvent.Cause.DESPAWN); // CraftBukkit - add Bukkit remove cause
|
||||
}
|
||||
|
||||
}
|
||||
@@ -160,7 +164,7 @@
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
- this.mob.setTarget(this.ownerLastHurtBy);
|
||||
+ this.mob.setTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit
|
||||
Entity entity = this.llama.getLeashHolder();
|
||||
|
||||
if (entity instanceof EntityVillagerTrader) {
|
||||
@@ -0,0 +1,26 @@
|
||||
--- a/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.java
|
||||
+++ b/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.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);
|
||||
|
||||
if (entityskeleton != null) {
|
||||
entityskeleton.startRiding(this.horse);
|
||||
- worldserver.addFreshEntityWithPassengers(entityskeleton);
|
||||
+ worldserver.addFreshEntityWithPassengers(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP); // CraftBukkit
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
EntityHorseAbstract entityhorseabstract = this.createHorse(difficultydamagescaler);
|
||||
@@ -59,7 +59,7 @@
|
||||
if (entityskeleton1 != null) {
|
||||
entityskeleton1.startRiding(entityhorseabstract);
|
||||
entityhorseabstract.push(this.horse.getRandom().triangle(0.0D, 1.1485D), 0.0D, this.horse.getRandom().triangle(0.0D, 1.1485D));
|
||||
- worldserver.addFreshEntityWithPassengers(entityhorseabstract);
|
||||
+ worldserver.addFreshEntityWithPassengers(entityhorseabstract, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
--- 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);
|
||||
|
||||
+ // CraftBukkit start - handle EntityDropItemEvent
|
||||
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
entityitem.setDefaultPickUpDelay();
|
||||
worldserver1.addFreshEntity(entityitem);
|
||||
});
|
||||
@@ -308,7 +315,7 @@
|
||||
List<GlobalPos> list = (List) this.getExploredPositions().limit(20L).collect(Collectors.toList());
|
||||
|
||||
list.add(0, GlobalPos.of(this.level().dimension(), blockposition));
|
||||
- this.getBrain().setMemory(MemoryModuleType.SNIFFER_EXPLORED_POSITIONS, (Object) list);
|
||||
+ this.getBrain().setMemory(MemoryModuleType.SNIFFER_EXPLORED_POSITIONS, list); // CraftBukkit - decompile error
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -444,7 +451,7 @@
|
||||
|
||||
@Override
|
||||
public BehaviorController<Sniffer> getBrain() {
|
||||
- return super.getBrain();
|
||||
+ return (BehaviorController<Sniffer>) super.getBrain(); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
@Override
|
||||
Reference in New Issue
Block a user