Update to Minecraft 1.17

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-06-11 15:00:00 +10:00
parent 75faba7fde
commit b3a8254758
619 changed files with 10708 additions and 8451 deletions

View File

@@ -0,0 +1,41 @@
--- a/net/minecraft/world/entity/animal/Bucketable.java
+++ b/net/minecraft/world/entity/animal/Bucketable.java
@@ -15,6 +15,14 @@
import net.minecraft.world.item.Items;
import net.minecraft.world.level.World;
+// CraftBukkit start
+import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.player.PlayerBucketEntityEvent;
+// CraftBukkit end
+
public interface Bucketable {
boolean isFromBucket();
@@ -90,10 +98,22 @@
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.WATER_BUCKET && t0.isAlive()) {
- t0.playSound(((Bucketable) t0).t(), 1.0F, 1.0F);
+ // CraftBukkit start
+ // t0.playSound(((Bucketable) t0).t(), 1.0F, 1.0F); // CraftBukkit - moved down
ItemStack itemstack1 = ((Bucketable) t0).getBucketItem();
((Bucketable) t0).setBucketName(itemstack1);
+
+ PlayerBucketEntityEvent playerBucketFishEvent = CraftEventFactory.callPlayerFishBucketEvent(t0, entityhuman, itemstack, itemstack1);
+ itemstack1 = CraftItemStack.asNMSCopy(playerBucketFishEvent.getEntityBucket());
+ if (playerBucketFishEvent.isCancelled()) {
+ ((EntityPlayer) entityhuman).containerMenu.updateInventory(); // We need to update inventory to resync client's bucket
+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutSpawnEntityLiving(t0)); // We need to play out these packets as the client assumes the fish is gone
+ ((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutEntityMetadata(t0.getId(), t0.getDataWatcher(), true)); // Need to send data such as the display name to client
+ return Optional.of(EnumInteractionResult.FAIL);
+ }
+ t0.playSound(((Bucketable) t0).t(), 1.0F, 1.0F);
+ // CraftBukkit end
ItemStack itemstack2 = ItemLiquidUtil.a(itemstack, entityhuman, itemstack1, false);
entityhuman.a(enumhand, itemstack2);

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/animal/EntityAnimal.java
+++ b/net/minecraft/world/entity/animal/EntityAnimal.java
@@ -27,10 +27,17 @@
import net.minecraft.world.level.block.Blocks;
@@ -28,11 +28,18 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.pathfinder.PathType;
+// CraftBukkit start
@@ -12,13 +12,14 @@
+
public abstract class EntityAnimal extends EntityAgeable {
public int loveTicks;
public UUID breedCause;
static final int PARENT_AGE_AFTER_BREEDING = 6000;
public int inLove;
public UUID loveCause;
+ public ItemStack breedItem; // CraftBukkit - Add breedItem variable
protected EntityAnimal(EntityTypes<? extends EntityAnimal> entitytypes, World world) {
super(entitytypes, world);
@@ -67,6 +74,9 @@
@@ -69,6 +76,9 @@
}
@@ -28,7 +29,7 @@
@Override
public boolean damageEntity(DamageSource damagesource, float f) {
if (this.isInvulnerable(damagesource)) {
@@ -76,6 +86,7 @@
@@ -78,6 +88,7 @@
return super.damageEntity(damagesource, f);
}
}
@@ -36,32 +37,32 @@
@Override
public float a(BlockPosition blockposition, IWorldReader iworldreader) {
@@ -166,10 +177,17 @@
@@ -170,10 +181,17 @@
}
public void g(@Nullable EntityHuman entityhuman) {
- this.loveTicks = 600;
- this.inLove = 600;
+ // CraftBukkit start
+ EntityEnterLoveModeEvent entityEnterLoveModeEvent = CraftEventFactory.callEntityEnterLoveModeEvent(entityhuman, this, 600);
+ if (entityEnterLoveModeEvent.isCancelled()) {
+ return;
+ }
+ this.loveTicks = entityEnterLoveModeEvent.getTicksInLove();
+ this.inLove = entityEnterLoveModeEvent.getTicksInLove();
+ // CraftBukkit end
if (entityhuman != null) {
this.breedCause = entityhuman.getUniqueID();
this.loveCause = entityhuman.getUniqueID();
}
+ this.breedItem = entityhuman.inventory.getItemInHand(); // CraftBukkit
+ this.breedItem = entityhuman.getInventory().getItemInHand(); // CraftBukkit
this.world.broadcastEntityEffect(this, (byte) 18);
this.level.broadcastEntityEffect(this, (byte) 18);
}
@@ -209,11 +227,26 @@
@@ -213,11 +231,26 @@
EntityAgeable entityageable = this.createChild(worldserver, entityanimal);
if (entityageable != null) {
+ // CraftBukkit start - set persistence for tame animals
+ if (entityageable instanceof EntityTameableAnimal && ((EntityTameableAnimal) entityageable).isTamed()) {
+ entityageable.persistent = true;
+ entityageable.persistenceRequired = true;
+ }
+ // CraftBukkit end
EntityPlayer entityplayer = this.getBreedCause();
@@ -82,7 +83,7 @@
if (entityplayer != null) {
entityplayer.a(StatisticList.ANIMALS_BRED);
@@ -224,12 +257,14 @@
@@ -228,12 +261,14 @@
entityanimal.setAgeRaw(6000);
this.resetLove();
entityanimal.resetLove();
@@ -91,7 +92,7 @@
- worldserver.addAllEntities(entityageable);
+ worldserver.addAllEntities(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
worldserver.broadcastEntityEffect(this, (byte) 18);
if (worldserver.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
if (worldserver.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
- worldserver.addEntity(new EntityExperienceOrb(worldserver, this.locX(), this.locY(), this.locZ(), this.getRandom().nextInt(7) + 1));
+ // CraftBukkit start - use event experience
+ if (experience > 0) {

View File

@@ -1,24 +1,24 @@
--- a/net/minecraft/world/entity/animal/EntityBee.java
+++ b/net/minecraft/world/entity/animal/EntityBee.java
@@ -211,7 +211,7 @@
@@ -243,7 +243,7 @@
}
if (b0 > 0) {
- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0));
+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
- ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this);
+ ((EntityLiving) entity).addEffect(new MobEffect(MobEffects.POISON, b0 * 20, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
}
}
@@ -586,11 +586,15 @@
@@ -642,11 +642,15 @@
if (this.isInvulnerable(damagesource)) {
return false;
} else {
Entity entity = damagesource.getEntity();
- if (!this.world.isClientSide) {
- if (!this.level.isClientSide) {
+ // CraftBukkit start
+ boolean result = super.damageEntity(damagesource, f);
+
+ if (result && !this.world.isClientSide) {
this.bC.l();
+ if (result && !this.level.isClientSide) {
this.beePollinateGoal.l();
}
- return super.damageEntity(damagesource, f);
@@ -27,75 +27,30 @@
}
}
@@ -611,7 +615,7 @@
class d extends EntityBee.a {
private d() {
- super(null);
+ super(); // CraftBukkit - decompile error
}
@Override
@@ -671,7 +675,7 @@
class g extends EntityBee.a {
private g() {
- super(null);
+ super(); // CraftBukkit - decompile error
}
@Override
@@ -720,7 +724,7 @@
@@ -1216,7 +1220,7 @@
}
}
- if (flag) {
+ if (flag && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityBee.this, blockposition, iblockdata.set(blockstateinteger, (Integer) iblockdata.get(blockstateinteger) + 1)).isCancelled()) { // Spigot
EntityBee.this.world.triggerEffect(2005, blockposition, 0);
EntityBee.this.world.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(blockstateinteger, (Integer) iblockdata.get(blockstateinteger) + 1));
EntityBee.this.fi();
@@ -735,7 +739,7 @@
class i extends EntityBee.a {
private i() {
- super(null);
+ super(); // CraftBukkit - decompile error
}
@Override
@@ -799,7 +803,7 @@
private int h = 0;
k() {
- super(null);
+ super(); // CraftBukkit - decompile error
this.a(EnumSet.of(PathfinderGoal.Type.MOVE));
}
@@ -983,7 +987,7 @@
private int c;
f() {
- super(null);
+ super(); // CraftBukkit - decompile error
this.c = EntityBee.this.world.random.nextInt(10);
this.a(EnumSet.of(PathfinderGoal.Type.MOVE));
}
@@ -1041,7 +1045,7 @@
private int f;
e() {
- super(null);
+ super(); // CraftBukkit - decompile error
this.c = EntityBee.this.world.random.nextInt(10);
this.d = Lists.newArrayList();
this.e = null;
@@ -1261,7 +1265,7 @@
EntityBee.this.level.triggerEffect(2005, blockposition, 0);
EntityBee.this.level.setTypeUpdate(blockposition, (IBlockData) iblockdata.set(blockstateinteger, (Integer) iblockdata.get(blockstateinteger) + 1));
EntityBee.this.fR();
@@ -1289,7 +1293,7 @@
@Override
protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) {
if (entityinsentient instanceof EntityBee && this.e.hasLineOfSight(entityliving)) {
if (entityinsentient instanceof EntityBee && this.mob.hasLineOfSight(entityliving)) {
- entityinsentient.setGoalTarget(entityliving);
+ entityinsentient.setGoalTarget(entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true); // CraftBukkit - reason
}
}
@@ -1298,7 +1302,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::a_);
}

View File

@@ -1,58 +1,60 @@
--- a/net/minecraft/world/entity/animal/EntityCat.java
+++ b/net/minecraft/world/entity/animal/EntityCat.java
@@ -78,7 +78,7 @@
private static final DataWatcherObject<Boolean> bt = DataWatcher.a(EntityCat.class, DataWatcherRegistry.i);
private static final DataWatcherObject<Boolean> bu = DataWatcher.a(EntityCat.class, DataWatcherRegistry.i);
private static final DataWatcherObject<Integer> bv = DataWatcher.a(EntityCat.class, DataWatcherRegistry.b);
- public static final Map<Integer, MinecraftKey> bq = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> {
+ public static final Map<Integer, MinecraftKey> bq = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error
@@ -95,7 +95,7 @@
public static final int TYPE_ALL_BLACK = 10;
private static final int NUMBER_OF_CAT_TYPES = 11;
private static final int NUMBER_OF_CAT_TYPES_EXCEPT_ALL_BLACK = 10;
- public static final Map<Integer, MinecraftKey> TEXTURE_BY_TYPE = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> {
+ public static final Map<Integer, MinecraftKey> TEXTURE_BY_TYPE = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error
hashmap.put(0, new MinecraftKey("textures/entity/cat/tabby.png"));
hashmap.put(1, new MinecraftKey("textures/entity/cat/black.png"));
hashmap.put(2, new MinecraftKey("textures/entity/cat/red.png"));
@@ -404,7 +404,7 @@
@@ -433,7 +433,7 @@
}
} else if (this.k(itemstack)) {
this.a(entityhuman, itemstack);
} else if (this.n(itemstack)) {
this.a(entityhuman, enumhand, itemstack);
- 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.setWillSit(true);
this.world.broadcastEntityEffect(this, (byte) 7);
@@ -562,7 +562,15 @@
this.level.broadcastEntityEffect(this, (byte) 7);
@@ -490,7 +490,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, RecipeItemStack recipeitemstack, boolean flag) {
@@ -629,7 +629,15 @@
while (iterator.hasNext()) {
ItemStack itemstack = (ItemStack) iterator.next();
- this.a.world.addEntity(new EntityItem(this.a.world, (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.a.aA * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.a.aA * 0.017453292F), itemstack));
- this.cat.level.addEntity(new EntityItem(this.cat.level, (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(this.a.world, (double) blockposition_mutableblockposition.getX() - (double) MathHelper.sin(this.a.aA * 0.017453292F), (double) blockposition_mutableblockposition.getY(), (double) blockposition_mutableblockposition.getZ() + (double) MathHelper.cos(this.a.aA * 0.017453292F), itemstack);
+ org.bukkit.event.entity.EntityDropItemEvent event = new org.bukkit.event.entity.EntityDropItemEvent(this.a.getBukkitEntity(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
+ entityitem.world.getServer().getPluginManager().callEvent(event);
+ EntityItem entityitem = new EntityItem(this.cat.level, (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.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ continue;
+ }
+ this.a.world.addEntity(entityitem);
+ this.cat.level.addEntity(entityitem);
+ // CraftBukkit end
}
}
@@ -592,7 +600,7 @@
static class PathfinderGoalTemptChance extends PathfinderGoalTempt {
@Nullable
- private EntityHuman chosenTarget;
+ private EntityLiving chosenTarget; // CraftBukkit
private final EntityCat d;
public PathfinderGoalTemptChance(EntityCat entitycat, double d0, RecipeItemStack recipeitemstack, boolean flag) {
@@ -627,9 +635,9 @@
private final EntityCat i;
@@ -661,10 +669,10 @@
private final EntityCat cat;
public a(EntityCat entitycat, Class<T> oclass, float f, double d0, double d1) {
- Predicate predicate = IEntitySelector.e;
- Predicate predicate = IEntitySelector.NO_CREATIVE_OR_SPECTATOR;
+ // Predicate predicate = IEntitySelector.e; // CraftBukkit - decompile error
- Objects.requireNonNull(predicate);
- super(entitycat, oclass, f, d0, d1, predicate::test);
+ super(entitycat, oclass, f, d0, d1, IEntitySelector.e::test); // CraftBukkit - decompile error
this.i = entitycat;
+ // Objects.requireNonNull(predicate); // CraftBukkit - decompile error
+ super(entitycat, oclass, f, d0, d1, IEntitySelector.NO_CREATIVE_OR_SPECTATOR::test); // CraftBukkit - decompile error
this.cat = entitycat;
}

View File

@@ -1,24 +1,24 @@
--- a/net/minecraft/world/entity/animal/EntityChicken.java
+++ b/net/minecraft/world/entity/animal/EntityChicken.java
@@ -74,6 +74,11 @@
@@ -75,6 +75,11 @@
@Override
public void movementTick() {
+ // CraftBukkit start
+ if (this.isChickenJockey()) {
+ this.persistent = !this.isTypeNotPersistent(0);
+ this.persistenceRequired = !this.isTypeNotPersistent(0);
+ }
+ // CraftBukkit end
super.movementTick();
this.br = this.bo;
this.bq = this.bp;
@@ -93,7 +98,9 @@
this.bo += this.bs * 2.0F;
if (!this.world.isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggLayTime <= 0) {
this.playSound(SoundEffects.ENTITY_CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
this.oFlap = this.flap;
this.oFlapSpeed = this.flapSpeed;
@@ -94,7 +99,9 @@
this.flap += this.flapping * 2.0F;
if (!this.level.isClientSide && this.isAlive() && !this.isBaby() && !this.isChickenJockey() && --this.eggTime <= 0) {
this.playSound(SoundEffects.CHICKEN_EGG, 1.0F, (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F);
+ this.forceDrops = true; // CraftBukkit
this.a((IMaterial) Items.EGG);
+ this.forceDrops = false; // CraftBukkit
this.eggLayTime = this.random.nextInt(6000) + 6000;
this.eggTime = this.random.nextInt(6000) + 6000;
}

View File

@@ -15,18 +15,18 @@
@@ -82,8 +87,16 @@
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.BUCKET && !this.isBaby()) {
if (itemstack.a(Items.BUCKET) && !this.isBaby()) {
+ // CraftBukkit start - Got milk?
+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.world, entityhuman, this.getChunkCoordinates(), this.getChunkCoordinates(), null, itemstack, Items.MILK_BUCKET);
+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level, entityhuman, this.getChunkCoordinates(), this.getChunkCoordinates(), null, itemstack, Items.MILK_BUCKET);
+
+ if (event.isCancelled()) {
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
+
entityhuman.playSound(SoundEffects.ENTITY_COW_MILK, 1.0F, 1.0F);
entityhuman.playSound(SoundEffects.COW_MILK, 1.0F, 1.0F);
- ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, Items.MILK_BUCKET.createItemStack());
+ ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
entityhuman.a(enumhand, itemstack1);
return EnumInteractionResult.a(this.world.isClientSide);
return EnumInteractionResult.a(this.level.isClientSide);

View File

@@ -1,15 +1,15 @@
--- a/net/minecraft/world/entity/animal/EntityDolphin.java
+++ b/net/minecraft/world/entity/animal/EntityDolphin.java
@@ -173,7 +173,7 @@
this.goalSelector.a(8, new EntityDolphin.d());
@@ -176,7 +176,7 @@
this.goalSelector.a(8, new EntityDolphin.c());
this.goalSelector.a(8, new PathfinderGoalFollowBoat(this));
this.goalSelector.a(9, new PathfinderGoalAvoidTarget<>(this, EntityGuardian.class, 8.0F, 1.0D, 1.0D));
- this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityGuardian.class})).a());
+ this.targetSelector.a(1, (new PathfinderGoalHurtByTarget(this, new Class[]{EntityGuardian.class})).a(new Class[0])); // CraftBukkit - decompile error
}
public static AttributeProvider.Builder eM() {
@@ -240,6 +240,12 @@
public static AttributeProvider.Builder fv() {
@@ -243,6 +243,12 @@
ItemStack itemstack = entityitem.getItemStack();
if (this.canPickup(itemstack)) {
@@ -21,31 +21,31 @@
+ // CraftBukkit end
this.a(entityitem);
this.setSlot(EnumItemSlot.MAINHAND, itemstack);
this.dropChanceHand[EnumItemSlot.MAINHAND.b()] = 2.0F;
@@ -387,7 +393,7 @@
this.handDropChances[EnumItemSlot.MAINHAND.b()] = 2.0F;
@@ -411,7 +417,7 @@
@Override
public boolean a() {
- return this.a.gotFish() && this.a.getAirTicks() >= 100;
+ return this.a.gotFish() && this.a.getAirTicks() >= 100 && this.a.world.getWorld().canGenerateStructures(); // MC-151364, SPIGOT-5494: hangs if generate-structures=false
- return this.dolphin.gotFish() && this.dolphin.getAirTicks() >= 100;
+ return this.dolphin.gotFish() && this.dolphin.getAirTicks() >= 100 && this.dolphin.level.getWorld().canGenerateStructures(); // MC-151364, SPIGOT-5494: hangs if generate-structures=false
}
@Override
@@ -496,7 +502,7 @@
@@ -520,7 +526,7 @@
@Override
public void c() {
- this.c.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100));
+ this.c.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
- this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin);
+ this.player.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), this.dolphin, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
}
@Override
@@ -515,7 +521,7 @@
@@ -539,7 +545,7 @@
}
if (this.c.isSwimming() && this.c.world.random.nextInt(6) == 0) {
- this.c.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100));
+ this.c.addEffect(new MobEffect(MobEffects.DOLPHINS_GRACE, 100), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
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, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.DOLPHIN); // CraftBukkit
}
}

View File

@@ -1,21 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityFish.java
+++ b/net/minecraft/world/entity/animal/EntityFish.java
@@ -41,6 +41,14 @@
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import net.minecraft.network.protocol.game.PacketPlayOutEntityMetadata;
+import net.minecraft.network.protocol.game.PacketPlayOutSpawnEntityLiving;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.player.PlayerBucketFishEvent;
+// CraftBukkit end
+
public abstract class EntityFish extends EntityWaterAnimal {
private static final DataWatcherObject<Boolean> FROM_BUCKET = DataWatcher.a(EntityFish.class, DataWatcherRegistry.i);
@@ -70,7 +78,7 @@
@@ -68,7 +68,7 @@
@Override
public boolean isTypeNotPersistent(double d0) {
@@ -24,38 +9,11 @@
}
@Override
@@ -90,6 +98,7 @@
@@ -90,6 +90,7 @@
@Override
public void setFromBucket(boolean flag) {
this.datawatcher.set(EntityFish.FROM_BUCKET, flag);
+ this.persistent = this.isPersistent(); // CraftBukkit - SPIGOT-4106 update persistence
this.entityData.set(EntityFish.FROM_BUCKET, flag);
+ this.persistenceRequired = this.isPersistent(); // CraftBukkit - SPIGOT-4106 update persistence
}
@Override
@@ -153,11 +162,24 @@
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.WATER_BUCKET && this.isAlive()) {
+ // CraftBukkit start
+ ItemStack itemstack1 = this.eK();
+ this.k(itemstack1);
+
+ PlayerBucketFishEvent playerBucketFishEvent = CraftEventFactory.callPlayerFishBucketEvent(this, entityhuman, itemstack, itemstack1);
+ itemstack1 = CraftItemStack.asNMSCopy(playerBucketFishEvent.getFishBucket());
+ if (playerBucketFishEvent.isCancelled()) {
+ ((EntityPlayer) entityhuman).updateInventory(((EntityPlayer) entityhuman).activeContainer); // We need to update inventory to resync client's bucket
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutSpawnEntityLiving(this)); // We need to play out these packets as the client assumes the fish is gone
+ ((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutEntityMetadata(this.getId(), datawatcher, true)); // Need to send data such as the display name to client
+ return EnumInteractionResult.FAIL;
+ }
+ // CraftBukkit end
this.playSound(SoundEffects.ITEM_BUCKET_FILL_FISH, 1.0F, 1.0F);
itemstack.subtract(1);
- ItemStack itemstack1 = this.eK();
+ // ItemStack itemstack1 = this.eK(); // CraftBukkit - moved up
- this.k(itemstack1);
+ // this.k(itemstack1); // CraftBukkit - moved up
if (!this.world.isClientSide) {
CriterionTriggers.j.a((EntityPlayer) entityhuman, itemstack1);
}

View File

@@ -1,17 +1,6 @@
--- a/net/minecraft/world/entity/animal/EntityFox.java
+++ b/net/minecraft/world/entity/animal/EntityFox.java
@@ -334,8 +334,8 @@
private List<UUID> fa() {
List<UUID> list = Lists.newArrayList();
- list.add(((Optional) this.datawatcher.get(EntityFox.FIRST_TRUSTED_PLAYER)).orElse((Object) null));
- list.add(((Optional) this.datawatcher.get(EntityFox.SECOND_TRUSTED_PLAYER)).orElse((Object) null));
+ list.add((this.datawatcher.get(EntityFox.FIRST_TRUSTED_PLAYER)).orElse(null)); // CraftBukkit - decompile error
+ list.add((this.datawatcher.get(EntityFox.SECOND_TRUSTED_PLAYER)).orElse(null)); // CraftBukkit - decompile error
return list;
}
@@ -471,7 +471,8 @@
@@ -502,7 +502,8 @@
protected void b(EntityItem entityitem) {
ItemStack itemstack = entityitem.getItemStack();
@@ -21,46 +10,7 @@
int i = itemstack.getCount();
if (i > 1) {
@@ -993,6 +994,11 @@
int i = (Integer) iblockdata.get(BlockSweetBerryBush.a);
iblockdata.set(BlockSweetBerryBush.a, 1);
+ // CraftBukkit start - call EntityChangeBlockEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityFox.this, this.e, iblockdata.set(BlockSweetBerryBush.a, 1)).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
int j = 1 + EntityFox.this.world.random.nextInt(2) + (i == 3 ? 1 : 0);
ItemStack itemstack = EntityFox.this.getEquipment(EnumItemSlot.MAINHAND);
@@ -1032,7 +1038,7 @@
private int f;
public r() {
- super(null);
+ super(); // CraftBukkit - decompile error
this.a(EnumSet.of(PathfinderGoal.Type.MOVE, PathfinderGoal.Type.LOOK));
}
@@ -1084,7 +1090,7 @@
private int c;
public t() {
- super(null);
+ super(); // CraftBukkit - decompile error
this.c = EntityFox.this.random.nextInt(140);
this.a(EnumSet.of(PathfinderGoal.Type.MOVE, PathfinderGoal.Type.LOOK, PathfinderGoal.Type.JUMP));
}
@@ -1195,7 +1201,7 @@
private EntityLiving k;
private int l;
- public a(Class oclass, boolean flag, boolean flag1, Predicate predicate) {
+ public a(Class oclass, boolean flag, boolean flag1, Predicate<EntityLiving> predicate) { // CraftBukkit - decompile error
super(EntityFox.this, oclass, 10, flag, flag1, predicate);
}
@@ -1275,6 +1281,16 @@
@@ -857,6 +858,16 @@
if (entityplayer1 != null && entityplayer != entityplayer1) {
entityfox.b(entityplayer1.getUniqueID());
}
@@ -77,7 +27,7 @@
if (entityplayer2 != null) {
entityplayer2.a(StatisticList.ANIMALS_BRED);
@@ -1285,12 +1301,14 @@
@@ -867,12 +878,14 @@
this.partner.setAgeRaw(6000);
this.animal.resetLove();
this.partner.resetLove();
@@ -85,14 +35,43 @@
- entityfox.setPositionRotation(this.animal.locX(), this.animal.locY(), this.animal.locZ(), 0.0F, 0.0F);
- worldserver.addAllEntities(entityfox);
+ worldserver.addAllEntities(entityfox, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
this.b.broadcastEntityEffect(this.animal, (byte) 18);
if (this.b.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
- this.b.addEntity(new EntityExperienceOrb(this.b, this.animal.locX(), this.animal.locY(), this.animal.locZ(), this.animal.getRandom().nextInt(7) + 1));
this.level.broadcastEntityEffect(this.animal, (byte) 18);
if (this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
- this.level.addEntity(new EntityExperienceOrb(this.level, this.animal.locX(), this.animal.locY(), this.animal.locZ(), this.animal.getRandom().nextInt(7) + 1));
+ // CraftBukkit start - use event experience
+ if (experience > 0) {
+ this.b.addEntity(new EntityExperienceOrb(this.b, this.animal.locX(), this.animal.locY(), this.animal.locZ(), experience));
+ this.level.addEntity(new EntityExperienceOrb(this.level, this.animal.locX(), this.animal.locY(), this.animal.locZ(), experience));
+ }
+ // CraftBukkit end
}
}
@@ -1258,13 +1271,18 @@
}
private void a(IBlockData iblockdata) {
- CaveVines.harvest(iblockdata, EntityFox.this.level, this.blockPos);
+ CaveVines.harvest(iblockdata, EntityFox.this.level, this.blockPos, EntityFox.this); // CraftBukkit
}
private void b(IBlockData iblockdata) {
int i = (Integer) iblockdata.get(BlockSweetBerryBush.AGE);
iblockdata.set(BlockSweetBerryBush.AGE, 1);
+ // CraftBukkit start - call EntityChangeBlockEvent
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(EntityFox.this, this.blockPos, iblockdata.set(BlockSweetBerryBush.AGE, 1)).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
int j = 1 + EntityFox.this.level.random.nextInt(2) + (i == 3 ? 1 : 0);
ItemStack itemstack = EntityFox.this.getEquipment(EnumItemSlot.MAINHAND);
@@ -1420,7 +1438,7 @@
private EntityLiving trustedLastHurt;
private int timestamp;
- public a(Class oclass, boolean flag, boolean flag1, @Nullable Predicate predicate) {
+ public a(Class oclass, boolean flag, boolean flag1, @Nullable Predicate<EntityLiving> predicate) { // CraftBukkit - decompile error
super(EntityFox.this, oclass, 10, flag, flag1, predicate);
}

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/entity/animal/EntityIronGolem.java
+++ b/net/minecraft/world/entity/animal/EntityIronGolem.java
@@ -104,7 +104,7 @@
@@ -106,7 +106,7 @@
@Override
protected void C(Entity entity) {
protected void A(Entity entity) {
if (entity instanceof IMonster && !(entity instanceof EntityCreeper) && this.getRandom().nextInt(20) == 0) {
- this.setGoalTarget((EntityLiving) entity);
+ this.setGoalTarget((EntityLiving) entity, org.bukkit.event.entity.EntityTargetLivingEntityEvent.TargetReason.COLLISION, true); // CraftBukkit - set reason
}
super.C(entity);
super.A(entity);

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/animal/EntityMushroomCow.java
+++ b/net/minecraft/world/entity/animal/EntityMushroomCow.java
@@ -41,6 +41,11 @@
import net.minecraft.world.level.block.state.IBlockData;
@@ -42,6 +42,11 @@
import net.minecraft.world.level.gameevent.GameEvent;
import org.apache.commons.lang3.tuple.Pair;
+// CraftBukkit start
@@ -11,41 +11,41 @@
+
public class EntityMushroomCow extends EntityCow implements IShearable {
private static final DataWatcherObject<String> bo = DataWatcher.a(EntityMushroomCow.class, DataWatcherRegistry.d);
@@ -111,6 +116,11 @@
private static final DataWatcherObject<String> DATA_TYPE = DataWatcher.a(EntityMushroomCow.class, DataWatcherRegistry.STRING);
@@ -113,6 +118,11 @@
this.playSound(soundeffect, 1.0F, 1.0F);
return EnumInteractionResult.a(this.world.isClientSide);
} else if (itemstack.getItem() == Items.SHEARS && this.canShear()) {
return EnumInteractionResult.a(this.level.isClientSide);
} else if (itemstack.a(Items.SHEARS) && this.canShear()) {
+ // CraftBukkit start
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
this.shear(SoundCategory.PLAYERS);
if (!this.world.isClientSide) {
itemstack.damage(1, entityhuman, (entityhuman1) -> {
@@ -157,7 +167,7 @@
this.world.playSound((EntityHuman) null, (Entity) this, SoundEffects.ENTITY_MOOSHROOM_SHEAR, soundcategory, 1.0F, 1.0F);
if (!this.world.s_()) {
((WorldServer) this.world).a(Particles.EXPLOSION, this.locX(), this.e(0.5D), this.locZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
this.a(GameEvent.SHEAR, (Entity) entityhuman);
if (!this.level.isClientSide) {
@@ -160,7 +170,7 @@
this.level.playSound((EntityHuman) null, (Entity) this, SoundEffects.MOOSHROOM_SHEAR, soundcategory, 1.0F, 1.0F);
if (!this.level.isClientSide()) {
((WorldServer) this.level).a(Particles.EXPLOSION, this.locX(), this.e(0.5D), this.locZ(), 1, 0.0D, 0.0D, 0.0D, 0.0D);
- this.die();
+ // this.die(); // CraftBukkit - moved down
EntityCow entitycow = (EntityCow) EntityTypes.COW.a(this.world);
EntityCow entitycow = (EntityCow) EntityTypes.COW.a(this.level);
entitycow.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.yaw, this.pitch);
@@ -173,7 +183,14 @@
entitycow.setPositionRotation(this.locX(), this.locY(), this.locZ(), this.getYRot(), this.getXRot());
@@ -176,7 +186,14 @@
}
entitycow.setInvulnerable(this.isInvulnerable());
- this.world.addEntity(entitycow);
- this.level.addEntity(entitycow);
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityTransformEvent(this, entitycow, EntityTransformEvent.TransformReason.SHEARED).isCancelled()) {
+ return;
+ }
+ this.world.addEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED);
+ this.level.addEntity(entitycow, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SHEARED);
+
+ this.die(); // CraftBukkit - from above
+ // CraftBukkit end
for (int i = 0; i < 5; ++i) {
this.world.addEntity(new EntityItem(this.world, this.locX(), this.e(1.0D), this.locZ(), new ItemStack(this.getVariant().d.getBlock())));
this.level.addEntity(new EntityItem(this.level, this.locX(), this.e(1.0D), this.locZ(), new ItemStack(this.getVariant().blockState.getBlock())));

View File

@@ -1,33 +1,35 @@
--- a/net/minecraft/world/entity/animal/EntityOcelot.java
+++ b/net/minecraft/world/entity/animal/EntityOcelot.java
@@ -128,7 +128,7 @@
@@ -133,7 +133,7 @@
@Override
public boolean isTypeNotPersistent(double d0) {
- return !this.isTrusting() && this.ticksLived > 2400;
- return !this.isTrusting() && this.tickCount > 2400;
+ return !this.isTrusting() /*&& this.ticksLived > 2400*/; // CraftBukkit
}
public static AttributeProvider.Builder eK() {
public static AttributeProvider.Builder p() {
@@ -182,7 +182,8 @@
if ((this.br == null || this.br.h()) && !this.isTrusting() && this.k(itemstack) && entityhuman.h((Entity) this) < 9.0D) {
this.a(entityhuman, itemstack);
if (!this.world.isClientSide) {
if ((this.temptGoal == null || this.temptGoal.h()) && !this.isTrusting() && this.n(itemstack) && entityhuman.f((Entity) this) < 9.0D) {
this.a(entityhuman, enumhand, itemstack);
if (!this.level.isClientSide) {
- if (this.random.nextInt(3) == 0) {
+ // CraftBukkit - added event call and isCancelled check
+ if (this.random.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) {
this.setTrusting(true);
this.u(true);
this.world.broadcastEntityEffect(this, (byte) 41);
@@ -290,9 +291,9 @@
private final EntityOcelot i;
this.w(true);
this.level.broadcastEntityEffect(this, (byte) 41);
@@ -312,10 +313,10 @@
private final EntityOcelot ocelot;
public a(EntityOcelot entityocelot, Class<T> oclass, float f, double d0, double d1) {
- Predicate predicate = IEntitySelector.e;
+ // Predicate predicate = IEntitySelector.e; // CraftBukkit - decompile error
- 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);
+ super(entityocelot, oclass, f, d0, d1, IEntitySelector.e::test); // CraftBukkit - decompile error
this.i = entityocelot;
+ // Objects.requireNonNull(predicate); // CraftBukkit - decompile error
+ super(entityocelot, oclass, f, d0, d1, IEntitySelector.NO_CREATIVE_OR_SPECTATOR::test); // CraftBukkit - decompile error
this.ocelot = entityocelot;
}

View File

@@ -1,24 +1,38 @@
--- a/net/minecraft/world/entity/animal/EntityPanda.java
+++ b/net/minecraft/world/entity/animal/EntityPanda.java
@@ -64,6 +64,8 @@
import net.minecraft.world.level.block.state.IBlockData;
@@ -65,6 +65,8 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.Vec3D;
+import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit
+
public class EntityPanda extends EntityAnimal {
private static final DataWatcherObject<Integer> bp = DataWatcher.a(EntityPanda.class, DataWatcherRegistry.b);
@@ -500,7 +502,7 @@
private static final DataWatcherObject<Integer> UNHAPPY_COUNTER = DataWatcher.a(EntityPanda.class, DataWatcherRegistry.INT);
@@ -525,7 +527,7 @@
@Override
protected void b(EntityItem entityitem) {
- if (this.getEquipment(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PICKUP_PREDICATE.test(entityitem)) {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !(this.getEquipment(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PICKUP_PREDICATE.test(entityitem))).isCancelled()) { // CraftBukkit
- if (this.getEquipment(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PANDA_ITEMS.test(entityitem)) {
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, entityitem, 0, !(this.getEquipment(EnumItemSlot.MAINHAND).isEmpty() && EntityPanda.PANDA_ITEMS.test(entityitem))).isCancelled()) { // CraftBukkit
this.a(entityitem);
ItemStack itemstack = entityitem.getItemStack();
@@ -721,7 +723,7 @@
@@ -881,10 +883,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;
}
@@ -1131,7 +1133,7 @@
@Override
protected void a(EntityInsentient entityinsentient, EntityLiving entityliving) {
if (entityinsentient instanceof EntityPanda && ((EntityPanda) entityinsentient).isAggressive()) {
@@ -27,15 +41,3 @@
}
}
@@ -825,9 +827,9 @@
private final EntityPanda i;
public c(EntityPanda entitypanda, Class<T> oclass, float f, double d0, double d1) {
- Predicate predicate = IEntitySelector.g;
+ // Predicate predicate = IEntitySelector.g; // CraftBukkit - decompile error
- super(entitypanda, oclass, f, d0, d1, predicate::test);
+ super(entitypanda, oclass, f, d0, d1, IEntitySelector.g::test); // CraftBukkit - decompile error
this.i = entitypanda;
}

View File

@@ -1,24 +1,24 @@
--- a/net/minecraft/world/entity/animal/EntityParrot.java
+++ b/net/minecraft/world/entity/animal/EntityParrot.java
@@ -74,7 +74,7 @@
};
private static final Item bw = Items.COOKIE;
private static final Set<Item> bx = Sets.newHashSet(new Item[]{Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS});
- private static final Map<EntityTypes<?>, SoundEffect> by = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> {
+ private static final Map<EntityTypes<?>, SoundEffect> by = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error
hashmap.put(EntityTypes.BLAZE, SoundEffects.ENTITY_PARROT_IMITATE_BLAZE);
hashmap.put(EntityTypes.CAVE_SPIDER, SoundEffects.ENTITY_PARROT_IMITATE_SPIDER);
hashmap.put(EntityTypes.CREEPER, SoundEffects.ENTITY_PARROT_IMITATE_CREEPER);
@@ -241,7 +241,7 @@
@@ -75,7 +75,7 @@
private static final Item POISONOUS_FOOD = Items.COOKIE;
private static final Set<Item> TAME_FOOD = Sets.newHashSet(new Item[]{Items.WHEAT_SEEDS, Items.MELON_SEEDS, Items.PUMPKIN_SEEDS, Items.BEETROOT_SEEDS});
private static final int VARIANTS = 5;
- static final Map<EntityTypes<?>, SoundEffect> MOB_SOUND_MAP = (Map) SystemUtils.a((Object) Maps.newHashMap(), (hashmap) -> {
+ static final Map<EntityTypes<?>, SoundEffect> MOB_SOUND_MAP = (Map) SystemUtils.a(Maps.newHashMap(), (hashmap) -> { // CraftBukkit - decompile error
hashmap.put(EntityTypes.BLAZE, SoundEffects.PARROT_IMITATE_BLAZE);
hashmap.put(EntityTypes.CAVE_SPIDER, SoundEffects.PARROT_IMITATE_SPIDER);
hashmap.put(EntityTypes.CREEPER, SoundEffects.PARROT_IMITATE_CREEPER);
@@ -253,7 +253,7 @@
}
if (!this.world.isClientSide) {
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.world.broadcastEntityEffect(this, (byte) 7);
this.level.broadcastEntityEffect(this, (byte) 7);
} else {
@@ -255,7 +255,7 @@
@@ -267,7 +267,7 @@
itemstack.subtract(1);
}
@@ -27,7 +27,7 @@
if (entityhuman.isCreative() || !this.isInvulnerable()) {
this.damageEntity(DamageSource.playerAttack(entityhuman), Float.MAX_VALUE);
}
@@ -369,7 +369,7 @@
@@ -381,7 +381,7 @@
@Override
public boolean isCollidable() {
@@ -36,7 +36,7 @@
}
@Override
@@ -384,7 +384,7 @@
@@ -396,7 +396,7 @@
if (this.isInvulnerable(damagesource)) {
return false;
} else {

View File

@@ -10,7 +10,7 @@
+
public class EntityPig extends EntityAnimal implements ISteerable, ISaddleable {
private static final DataWatcherObject<Boolean> bo = DataWatcher.a(EntityPig.class, DataWatcherRegistry.i);
private static final DataWatcherObject<Boolean> DATA_SADDLE_ID = DataWatcher.a(EntityPig.class, DataWatcherRegistry.BOOLEAN);
@@ -251,7 +255,13 @@
}

View File

@@ -1,20 +1,20 @@
--- a/net/minecraft/world/entity/animal/EntityPufferFish.java
+++ b/net/minecraft/world/entity/animal/EntityPufferFish.java
@@ -136,7 +136,7 @@
@@ -144,7 +144,7 @@
int i = this.getPuffState();
if (entityinsentient.damageEntity(DamageSource.mobAttack(this), (float) (1 + i))) {
- entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0));
+ entityinsentient.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
this.playSound(SoundEffects.ENTITY_PUFFER_FISH_STING, 1.0F, 1.0F);
- 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);
}
@@ -151,7 +151,7 @@
((EntityPlayer) entityhuman).playerConnection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.j, 0.0F));
@@ -159,7 +159,7 @@
((EntityPlayer) entityhuman).connection.sendPacket(new PacketPlayOutGameStateChange(PacketPlayOutGameStateChange.PUFFER_FISH_STING, 0.0F));
}
- entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0));
+ entityhuman.addEffect(new MobEffect(MobEffects.POISON, 60 * i, 0), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.ATTACK); // CraftBukkit
- 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
}
}

View File

@@ -1,9 +1,9 @@
--- a/net/minecraft/world/entity/animal/EntityRabbit.java
+++ b/net/minecraft/world/entity/animal/EntityRabbit.java
@@ -72,8 +72,14 @@
@@ -86,8 +86,14 @@
super(entitytypes, world);
this.bi = new EntityRabbit.ControllerJumpRabbit(this);
this.moveController = new EntityRabbit.ControllerMoveRabbit(this);
this.jumpControl = new EntityRabbit.ControllerJumpRabbit(this);
this.moveControl = new EntityRabbit.ControllerMoveRabbit(this);
+ this.initializePathFinderGoals(); // CraftBukkit - moved code
+ }
+
@@ -15,7 +15,7 @@
@Override
public void initPathfinder() {
@@ -340,7 +346,7 @@
@@ -353,7 +359,7 @@
if (i == 99) {
this.getAttributeInstance(GenericAttributes.ARMOR).setValue(8.0D);
this.goalSelector.a(4, new EntityRabbit.PathfinderGoalKillerRabbitMeleeAttack(this));
@@ -24,27 +24,27 @@
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, true));
this.targetSelector.a(2, new PathfinderGoalNearestAttackableTarget<>(this, EntityWolf.class, true));
if (!this.hasCustomName()) {
@@ -456,9 +462,23 @@
Integer integer = (Integer) iblockdata.get(BlockCarrots.AGE);
@@ -556,9 +562,23 @@
int i = (Integer) iblockdata.get(BlockCarrots.AGE);
if (integer == 0) {
if (i == 0) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.entity, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.rabbit, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 2);
world.a(blockposition, true, this.entity);
world.a(blockposition, true, this.rabbit);
} else {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(
+ this.entity,
+ this.rabbit,
+ blockposition,
+ iblockdata.set(BlockCarrots.AGE, integer - 1)
+ iblockdata.set(BlockCarrots.AGE, i - 1)
+ ).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCarrots.AGE, integer - 1), 2);
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCarrots.AGE, i - 1), 2);
world.triggerEffect(2001, blockposition, Block.getCombinedId(iblockdata));
}

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/animal/EntitySheep.java
+++ b/net/minecraft/world/entity/animal/EntitySheep.java
@@ -60,10 +60,18 @@
import net.minecraft.world.level.block.state.IBlockData;
@@ -64,11 +64,19 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.level.storage.loot.LootTables;
+// CraftBukkit start
@@ -14,57 +14,60 @@
+
public class EntitySheep extends EntityAnimal implements IShearable {
private static final DataWatcherObject<Byte> bo = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.a);
- private static final Map<EnumColor, IMaterial> bp = (Map) SystemUtils.a((Object) Maps.newEnumMap(EnumColor.class), (enummap) -> {
+ private static final Map<EnumColor, IMaterial> bp = (Map) SystemUtils.a(Maps.newEnumMap(EnumColor.class), (enummap) -> { // CraftBukkit - decompile error
private static final int EAT_ANIMATION_TICKS = 40;
private static final DataWatcherObject<Byte> DATA_WOOL_ID = DataWatcher.a(EntitySheep.class, DataWatcherRegistry.BYTE);
- private static final Map<EnumColor, IMaterial> ITEM_BY_DYE = (Map) SystemUtils.a((Object) Maps.newEnumMap(EnumColor.class), (enummap) -> {
+ private static final Map<EnumColor, IMaterial> ITEM_BY_DYE = (Map) SystemUtils.a(Maps.newEnumMap(EnumColor.class), (enummap) -> { // CraftBukkit - decompile error
enummap.put(EnumColor.WHITE, Blocks.WHITE_WOOL);
enummap.put(EnumColor.ORANGE, Blocks.ORANGE_WOOL);
enummap.put(EnumColor.MAGENTA, Blocks.MAGENTA_WOOL);
@@ -190,6 +198,11 @@
@@ -223,6 +231,11 @@
if (itemstack.getItem() == Items.SHEARS) {
if (!this.world.isClientSide && this.canShear()) {
if (itemstack.a(Items.SHEARS)) {
if (!this.level.isClientSide && this.canShear()) {
+ // CraftBukkit start
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
this.shear(SoundCategory.PLAYERS);
this.a(GameEvent.SHEAR, (Entity) entityhuman);
itemstack.damage(1, entityhuman, (entityhuman1) -> {
entityhuman1.broadcastItemBreak(enumhand);
@@ -210,7 +223,9 @@
@@ -244,7 +257,9 @@
int i = 1 + this.random.nextInt(3);
for (int j = 0; j < i; ++j) {
+ this.forceDrops = true; // CraftBukkit
EntityItem entityitem = this.a((IMaterial) EntitySheep.bp.get(this.getColor()), 1);
EntityItem entityitem = this.a((IMaterial) EntitySheep.ITEM_BY_DYE.get(this.getColor()), 1);
+ this.forceDrops = false; // CraftBukkit
if (entityitem != null) {
entityitem.setMot(entityitem.getMot().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)));
@@ -300,6 +315,12 @@
@@ -334,6 +349,12 @@
@Override
public void blockEaten() {
+ // CraftBukkit start
+ SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity());
+ this.world.getServer().getPluginManager().callEvent(event);
+ this.level.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) return;
+ // CraftBukkit end
this.setSheared(false);
if (this.isBaby()) {
this.setAge(60);
@@ -318,7 +339,7 @@
@@ -352,8 +373,8 @@
EnumColor enumcolor = ((EntitySheep) entityanimal).getColor();
EnumColor enumcolor1 = ((EntitySheep) entityanimal1).getColor();
InventoryCrafting inventorycrafting = a(enumcolor, enumcolor1);
- Optional optional = this.world.getCraftingManager().craft(Recipes.CRAFTING, inventorycrafting, this.world).map((recipecrafting) -> {
+ Optional<Item> optional = this.world.getCraftingManager().craft(Recipes.CRAFTING, inventorycrafting, this.world).map((recipecrafting) -> { // Eclipse fail
return recipecrafting.a(inventorycrafting);
- Optional optional = this.level.getCraftingManager().craft(Recipes.CRAFTING, inventorycrafting, this.level).map((recipecrafting) -> {
- return recipecrafting.a((IInventory) inventorycrafting);
+ Optional<Item> optional = this.level.getCraftingManager().craft(Recipes.CRAFTING, inventorycrafting, this.level).map((recipecrafting) -> { // Eclipse fail
+ return recipecrafting.a(inventorycrafting); // CraftBukkit - decompile error
}).map(ItemStack::getItem);
@@ -336,10 +357,18 @@
Objects.requireNonNull(ItemDye.class);
@@ -370,10 +391,18 @@
public boolean canUse(EntityHuman entityhuman) {
return false;
}

View File

@@ -1,8 +1,8 @@
--- a/net/minecraft/world/entity/animal/EntitySnowman.java
+++ b/net/minecraft/world/entity/animal/EntitySnowman.java
@@ -38,6 +38,10 @@
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.IBlockData;
@@ -40,6 +40,10 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
@@ -10,34 +10,34 @@
+
public class EntitySnowman extends EntityGolem implements IShearable, IRangedEntity {
private static final DataWatcherObject<Byte> b = DataWatcher.a(EntitySnowman.class, DataWatcherRegistry.a);
@@ -96,7 +100,7 @@
private static final DataWatcherObject<Byte> DATA_PUMPKIN_ID = DataWatcher.a(EntitySnowman.class, DataWatcherRegistry.BYTE);
@@ -100,7 +104,7 @@
int k = MathHelper.floor(this.locZ());
if (this.world.getBiome(new BlockPosition(i, 0, k)).getAdjustedTemperature(new BlockPosition(i, j, k)) > 1.0F) {
- this.damageEntity(DamageSource.BURN, 1.0F);
if (this.level.getBiome(new BlockPosition(i, 0, k)).getAdjustedTemperature(new BlockPosition(i, j, k)) > 1.0F) {
- this.damageEntity(DamageSource.ON_FIRE, 1.0F);
+ this.damageEntity(CraftEventFactory.MELTING, 1.0F); // CraftBukkit - DamageSource.BURN -> CraftEventFactory.MELTING
}
if (!this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) {
@@ -112,7 +116,7 @@
if (!this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
@@ -116,7 +120,7 @@
BlockPosition blockposition = new BlockPosition(i, j, k);
if (this.world.getType(blockposition).isAir() && this.world.getBiome(blockposition).getAdjustedTemperature(blockposition) < 0.8F && iblockdata.canPlace(this.world, blockposition)) {
- this.world.setTypeUpdate(blockposition, iblockdata);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.world, blockposition, iblockdata, this); // CraftBukkit
if (this.level.getType(blockposition).isAir() && this.level.getBiome(blockposition).getAdjustedTemperature(blockposition) < 0.8F && iblockdata.canPlace(this.level, blockposition)) {
- this.level.setTypeUpdate(blockposition, iblockdata);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(this.level, blockposition, iblockdata, this); // CraftBukkit
}
}
}
@@ -143,6 +147,11 @@
@@ -147,6 +151,11 @@
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.getItem() == Items.SHEARS && this.canShear()) {
if (itemstack.a(Items.SHEARS) && this.canShear()) {
+ // CraftBukkit start
+ if (!CraftEventFactory.handlePlayerShearEntityEvent(entityhuman, this, itemstack, enumhand)) {
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
this.shear(SoundCategory.PLAYERS);
if (!this.world.isClientSide) {
itemstack.damage(1, entityhuman, (entityhuman1) -> {
this.a(GameEvent.SHEAR, (Entity) entityhuman);
if (!this.level.isClientSide) {

View File

@@ -1,9 +1,9 @@
--- a/net/minecraft/world/entity/animal/EntityTurtle.java
+++ b/net/minecraft/world/entity/animal/EntityTurtle.java
@@ -314,7 +314,9 @@
protected void m() {
super.m();
if (!this.isBaby() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
protected void n() {
super.n();
if (!this.isBaby() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
+ this.forceDrops = true; // CraftBukkit
this.a((IMaterial) Items.SCUTE, 1);
+ this.forceDrops = false; // CraftBukkit
@@ -15,30 +15,21 @@
@Override
public void onLightningStrike(WorldServer worldserver, EntityLightning entitylightning) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = entitylightning; // CraftBukkit
this.damageEntity(DamageSource.LIGHTNING, Float.MAX_VALUE);
this.damageEntity(DamageSource.LIGHTNING_BOLT, Float.MAX_VALUE);
+ org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = null; // CraftBukkit
}
static class g extends NavigationGuardian {
@@ -500,8 +504,12 @@
} else if (this.g.bv > 200) {
World world = this.g.world;
private static class e extends ControllerMove {
@@ -487,8 +491,12 @@
} else if (this.turtle.layEggCounter > 200) {
World world = this.turtle.level;
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.g, this.e.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, this.g.random.nextInt(4) + 1)).isCancelled()) {
world.playSound((EntityHuman) null, blockposition, SoundEffects.ENTITY_TURTLE_LAY_EGG, SoundCategory.BLOCKS, 0.3F, 0.9F + world.random.nextFloat() * 0.2F);
world.setTypeAndData(this.e.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.b, this.g.random.nextInt(4) + 1), 3);
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(this.turtle, this.blockPos.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.EGGS, this.turtle.random.nextInt(4) + 1)).isCancelled()) {
world.playSound((EntityHuman) null, blockposition, SoundEffects.TURTLE_LAY_EGG, SoundCategory.BLOCKS, 0.3F, 0.9F + world.random.nextFloat() * 0.2F);
world.setTypeAndData(this.blockPos.up(), (IBlockData) Blocks.TURTLE_EGG.getBlockData().set(BlockTurtleEgg.EGGS, this.turtle.random.nextInt(4) + 1), 3);
+ }
+ // CraftBukkit end
this.g.setHasEgg(false);
this.g.u(false);
this.g.setLoveTicks(600);
@@ -581,7 +589,7 @@
--this.e;
return false;
} else {
- this.d = this.b.world.a(EntityTurtle.i.a, (EntityLiving) this.b);
+ this.d = this.b.world.a(this.a, (EntityLiving) this.b); // CraftBukkit - decompile error
return this.d == null ? false : this.a(this.d.getItemInMainHand()) || this.a(this.d.getItemInOffHand());
}
}
this.turtle.setHasEgg(false);
this.turtle.w(false);
this.turtle.setLoveTicks(600);

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/animal/EntityWolf.java
+++ b/net/minecraft/world/entity/animal/EntityWolf.java
@@ -62,6 +62,11 @@
import net.minecraft.world.level.block.state.IBlockData;
@@ -63,6 +63,11 @@
import net.minecraft.world.level.gameevent.GameEvent;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
@@ -11,18 +11,18 @@
+
public class EntityWolf extends EntityTameableAnimal implements IEntityAngerable {
private static final DataWatcherObject<Boolean> br = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.i);
@@ -101,7 +106,7 @@
private static final DataWatcherObject<Boolean> DATA_INTERESTED_ID = DataWatcher.a(EntityWolf.class, DataWatcherRegistry.BOOLEAN);
@@ -104,7 +109,7 @@
this.goalSelector.a(10, new PathfinderGoalRandomLookaround(this));
this.targetSelector.a(1, new PathfinderGoalOwnerHurtByTarget(this));
this.targetSelector.a(2, new PathfinderGoalOwnerHurtTarget(this));
- this.targetSelector.a(3, (new PathfinderGoalHurtByTarget(this, new Class[0])).a());
+ this.targetSelector.a(3, (new PathfinderGoalHurtByTarget(this, new Class[0])).a(new Class[0])); // CraftBukkit - decompile error
this.targetSelector.a(4, new PathfinderGoalNearestAttackableTarget<>(this, EntityHuman.class, 10, true, false, this::a_));
this.targetSelector.a(5, new PathfinderGoalRandomTargetNonTamed<>(this, EntityAnimal.class, false, EntityWolf.bq));
this.targetSelector.a(6, new PathfinderGoalRandomTargetNonTamed<>(this, EntityTurtle.class, false, EntityTurtle.bo));
@@ -113,6 +118,24 @@
return EntityInsentient.p().a(GenericAttributes.MOVEMENT_SPEED, 0.30000001192092896D).a(GenericAttributes.MAX_HEALTH, 8.0D).a(GenericAttributes.ATTACK_DAMAGE, 2.0D);
this.targetSelector.a(5, new PathfinderGoalRandomTargetNonTamed<>(this, EntityAnimal.class, false, EntityWolf.PREY_SELECTOR));
this.targetSelector.a(6, new PathfinderGoalRandomTargetNonTamed<>(this, EntityTurtle.class, false, EntityTurtle.BABY_ON_LAND_SELECTOR));
@@ -116,6 +121,24 @@
return EntityInsentient.w().a(GenericAttributes.MOVEMENT_SPEED, 0.30000001192092896D).a(GenericAttributes.MAX_HEALTH, 8.0D).a(GenericAttributes.ATTACK_DAMAGE, 2.0D);
}
+ // CraftBukkit - add overriden version
@@ -46,7 +46,7 @@
@Override
protected void initDatawatcher() {
super.initDatawatcher();
@@ -259,7 +282,7 @@
@@ -287,7 +310,7 @@
} else {
Entity entity = damagesource.getEntity();
@@ -55,7 +55,7 @@
if (entity != null && !(entity instanceof EntityHuman) && !(entity instanceof EntityArrow)) {
f = (f + 1.0F) / 2.0F;
}
@@ -284,7 +307,7 @@
@@ -312,7 +335,7 @@
super.setTamed(flag);
if (flag) {
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(20.0D);
@@ -64,16 +64,16 @@
} else {
this.getAttributeInstance(GenericAttributes.MAX_HEALTH).setValue(8.0D);
}
@@ -308,7 +331,7 @@
@@ -336,7 +359,7 @@
itemstack.subtract(1);
}
- this.heal((float) item.getFoodInfo().getNutrition());
+ this.heal((float) item.getFoodInfo().getNutrition(), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
this.a(GameEvent.MOB_INTERACT, this.cT());
return EnumInteractionResult.SUCCESS;
}
@@ -319,7 +342,7 @@
@@ -348,7 +371,7 @@
this.setWillSit(!this.isWillSit());
this.jumping = false;
this.navigation.o();
@@ -82,7 +82,7 @@
return EnumInteractionResult.SUCCESS;
}
@@ -341,7 +364,8 @@
@@ -370,7 +393,8 @@
itemstack.subtract(1);
}

View File

@@ -0,0 +1,56 @@
--- a/net/minecraft/world/entity/animal/axolotl/Axolotl.java
+++ b/net/minecraft/world/entity/animal/axolotl/Axolotl.java
@@ -68,7 +68,8 @@
public static final int TOTAL_PLAYDEAD_TIME = 200;
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});
+ // 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});
private static final DataWatcherObject<Integer> DATA_VARIANT = DataWatcher.a(Axolotl.class, DataWatcherRegistry.INT);
private static final DataWatcherObject<Boolean> DATA_PLAYING_DEAD = DataWatcher.a(Axolotl.class, DataWatcherRegistry.BOOLEAN);
private static final DataWatcherObject<Boolean> FROM_BUCKET = DataWatcher.a(Axolotl.class, DataWatcherRegistry.BOOLEAN);
@@ -239,6 +240,7 @@
@Override
public void setFromBucket(boolean flag) {
this.entityData.set(Axolotl.FROM_BUCKET, flag);
+ this.persistenceRequired = this.isPersistent(); // CraftBukkit - SPIGOT-4106 update persistence
}
@Nullable
@@ -280,7 +282,7 @@
@Override
protected void mobTick() {
this.level.getMethodProfiler().enter("axolotlBrain");
- this.getBehaviorController().a((WorldServer) this.level, (EntityLiving) this);
+ this.getBehaviorController().a((WorldServer) this.level, this); // CraftBukkit - decompile error
this.level.getMethodProfiler().exit();
this.level.getMethodProfiler().enter("axolotlActivityUpdate");
AxolotlAi.a(this);
@@ -422,7 +424,7 @@
if (i < 2400) {
i = Math.min(2400, 100 + i);
- entityhuman.addEffect(new MobEffect(MobEffects.REGENERATION, i, 0), this);
+ entityhuman.addEffect(new MobEffect(MobEffects.REGENERATION, i, 0), this, org.bukkit.event.entity.EntityPotionEffectEvent.Cause.AXOLOTL); // CraftBukkit
}
entityhuman.removeEffect(MobEffects.DIG_SLOWDOWN);
@@ -472,7 +474,7 @@
@Override
public BehaviorController<Axolotl> getBehaviorController() {
- return super.getBehaviorController();
+ return (BehaviorController<Axolotl>) super.getBehaviorController(); // CraftBukkit - decompile error
}
@Override
@@ -505,7 +507,7 @@
@Override
public boolean isTypeNotPersistent(double d0) {
- return !this.isFromBucket() && !this.hasCustomName();
+ return true; // CraftBukkit
}
private static class c extends SmoothSwimmingMoveControl {

View File

@@ -0,0 +1,47 @@
--- a/net/minecraft/world/entity/animal/goat/Goat.java
+++ b/net/minecraft/world/entity/animal/goat/Goat.java
@@ -50,6 +50,11 @@
import net.minecraft.world.level.pathfinder.Pathfinder;
import net.minecraft.world.level.pathfinder.PathfinderNormal;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+// CraftBukkit end
+
public class Goat extends EntityAnimal {
public static final EntitySize LONG_JUMPING_DIMENSIONS = EntitySize.b(0.9F, 1.3F).a(0.7F);
@@ -123,13 +128,13 @@
@Override
public BehaviorController<Goat> getBehaviorController() {
- return super.getBehaviorController();
+ return (BehaviorController<Goat>) super.getBehaviorController(); // CraftBukkit - decompile error
}
@Override
protected void mobTick() {
this.level.getMethodProfiler().enter("goatBrain");
- this.getBehaviorController().a((WorldServer) this.level, (EntityLiving) this);
+ this.getBehaviorController().a((WorldServer) this.level, this); // CraftBukkit - decompile error
this.level.getMethodProfiler().exit();
this.level.getMethodProfiler().enter("goatActivityUpdate");
GoatAi.b(this);
@@ -161,8 +166,15 @@
ItemStack itemstack = entityhuman.b(enumhand);
if (itemstack.a(Items.BUCKET) && !this.isBaby()) {
+ // CraftBukkit start - Got milk?
+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent((WorldServer) entityhuman.level, entityhuman, this.getChunkCoordinates(), this.getChunkCoordinates(), null, itemstack, Items.MILK_BUCKET);
+
+ if (event.isCancelled()) {
+ return EnumInteractionResult.PASS;
+ }
+ // CraftBukkit end
entityhuman.playSound(this.t(), 1.0F, 1.0F);
- ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, Items.MILK_BUCKET.createItemStack());
+ ItemStack itemstack1 = ItemLiquidUtil.a(itemstack, entityhuman, CraftItemStack.asNMSCopy(event.getItemStack())); // CraftBukkit
entityhuman.a(enumhand, itemstack1);
return EnumInteractionResult.a(this.level.isClientSide);

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java
+++ b/net/minecraft/world/entity/animal/horse/EntityHorseAbstract.java
@@ -68,6 +68,8 @@
@@ -70,6 +70,8 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
@@ -8,25 +8,25 @@
+
public abstract class EntityHorseAbstract extends EntityAnimal implements IInventoryListener, IJumpable, ISaddleable {
private static final Predicate<EntityLiving> bw = (entityliving) -> {
@@ -95,6 +97,7 @@
private float bK;
protected boolean bu = true;
protected int bv;
public static final int EQUIPMENT_SLOT_OFFSET = 400;
@@ -109,6 +111,7 @@
private float mouthAnimO;
protected boolean canGallop = true;
protected int gallopSoundCounter;
+ public int maxDomestication = 100; // CraftBukkit - store max domestication value
protected EntityHorseAbstract(EntityTypes<? extends EntityHorseAbstract> entitytypes, World world) {
super(entitytypes, world);
@@ -279,7 +282,7 @@
@@ -293,7 +296,7 @@
public void loadChest() {
InventorySubcontainer inventorysubcontainer = this.inventoryChest;
InventorySubcontainer inventorysubcontainer = this.inventory;
- this.inventoryChest = new InventorySubcontainer(this.getChestSlots());
+ this.inventoryChest = new InventorySubcontainer(this.getChestSlots(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit
- this.inventory = new InventorySubcontainer(this.getChestSlots());
+ this.inventory = new InventorySubcontainer(this.getChestSlots(), (org.bukkit.entity.AbstractHorse) this.getBukkitEntity()); // CraftBukkit
if (inventorysubcontainer != null) {
inventorysubcontainer.b((IInventoryListener) this);
int i = Math.min(inventorysubcontainer.getSize(), this.inventoryChest.getSize());
@@ -395,7 +398,7 @@
int i = Math.min(inventorysubcontainer.getSize(), this.inventory.getSize());
@@ -409,7 +412,7 @@
}
public int getMaxDomestication() {
@@ -35,7 +35,7 @@
}
@Override
@@ -466,7 +469,7 @@
@@ -479,7 +482,7 @@
}
if (this.getHealth() < this.getMaxHealth() && f > 0.0F) {
@@ -44,24 +44,24 @@
flag = true;
}
@@ -542,7 +545,7 @@
@@ -556,7 +559,7 @@
super.movementTick();
if (!this.world.isClientSide && this.isAlive()) {
if (this.random.nextInt(900) == 0 && this.deathTicks == 0) {
if (!this.level.isClientSide && this.isAlive()) {
if (this.random.nextInt(900) == 0 && this.deathTime == 0) {
- this.heal(1.0F);
+ this.heal(1.0F, RegainReason.REGEN); // CraftBukkit
}
if (this.fl()) {
@@ -779,6 +782,7 @@
if (this.fU()) {
@@ -794,6 +797,7 @@
if (this.getOwnerUUID() != null) {
nbttagcompound.a("Owner", this.getOwnerUUID());
}
+ nbttagcompound.setInt("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit
if (!this.inventoryChest.getItem(0).isEmpty()) {
nbttagcompound.set("SaddleItem", this.inventoryChest.getItem(0).save(new NBTTagCompound()));
@@ -806,6 +810,11 @@
if (!this.inventory.getItem(0).isEmpty()) {
nbttagcompound.set("SaddleItem", this.inventory.getItem(0).save(new NBTTagCompound()));
@@ -821,6 +825,11 @@
if (uuid != null) {
this.setOwnerUUID(uuid);
}
@@ -73,7 +73,7 @@
if (nbttagcompound.hasKeyOfType("SaddleItem", 10)) {
ItemStack itemstack = ItemStack.a(nbttagcompound.getCompound("SaddleItem"));
@@ -857,6 +866,18 @@
@@ -903,6 +912,18 @@
@Override
public void b(int i) {
@@ -89,6 +89,6 @@
+ return;
+ }
+ // CraftBukkit end
this.canSlide = true;
this.eU();
this.fn();
this.allowStandSliding = true;
this.fD();
this.fW();

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.java
+++ b/net/minecraft/world/entity/animal/horse/EntityLlamaTrader.java
@@ -143,7 +143,7 @@
@@ -152,7 +152,7 @@
@Override
public void c() {
- this.e.setGoalTarget(this.c);
+ this.e.setGoalTarget(this.c, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit
Entity entity = this.b.getLeashHolder();
- this.mob.setGoalTarget(this.ownerLastHurtBy);
+ this.mob.setGoalTarget(this.ownerLastHurtBy, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER, true); // CraftBukkit
Entity entity = this.llama.getLeashHolder();
if (entity instanceof EntityVillagerTrader) {

View File

@@ -2,15 +2,15 @@
+++ b/net/minecraft/world/entity/animal/horse/PathfinderGoalHorseTrap.java
@@ -40,19 +40,20 @@
entitylightning.teleportAndSync(this.a.locX(), this.a.locY(), this.a.locZ());
entitylightning.teleportAndSync(this.horse.locX(), this.horse.locY(), this.horse.locZ());
entitylightning.setEffect(true);
- worldserver.addEntity(entitylightning);
+ worldserver.strikeLightning(entitylightning, org.bukkit.event.weather.LightningStrikeEvent.Cause.TRAP); // CraftBukkit
EntitySkeleton entityskeleton = this.a(difficultydamagescaler, this.a);
EntitySkeleton entityskeleton = this.a(difficultydamagescaler, this.horse);
- entityskeleton.startRiding(this.a);
- entityskeleton.startRiding(this.horse);
- worldserver.addAllEntities(entityskeleton);
+ if (entityskeleton != null) entityskeleton.startRiding(this.a); // CraftBukkit
+ if (entityskeleton != null) entityskeleton.startRiding(this.horse); // CraftBukkit
+ worldserver.addAllEntities(entityskeleton, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.TRAP); // CraftBukkit
for (int i = 0; i < 3; ++i) {
@@ -20,7 +20,7 @@
- entityskeleton1.startRiding(entityhorseabstract);
+ if (entityskeleton1 != null) entityskeleton1.startRiding(entityhorseabstract); // CraftBukkit
entityhorseabstract.i(this.a.getRandom().nextGaussian() * 0.5D, 0.0D, this.a.getRandom().nextGaussian() * 0.5D);
entityhorseabstract.i(this.horse.getRandom().nextGaussian() * 0.5D, 0.0D, this.horse.getRandom().nextGaussian() * 0.5D);
- worldserver.addAllEntities(entityhorseabstract);
+ worldserver.addAllEntities(entityhorseabstract, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.JOCKEY); // CraftBukkit
}