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

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/entity/player/EntityHuman.java
+++ b/net/minecraft/world/entity/player/EntityHuman.java
@@ -110,10 +110,24 @@
@@ -113,6 +113,19 @@
import net.minecraft.world.scores.ScoreboardTeam;
import net.minecraft.world.scores.ScoreboardTeamBase;
@@ -19,29 +19,33 @@
+
public abstract class EntityHuman extends EntityLiving {
public static final EntitySize bh = EntitySize.b(0.6F, 1.8F);
- private static final Map<EntityPose, EntitySize> b = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.bh).put(EntityPose.SLEEPING, EntityHuman.ah).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build();
public static final String UUID_PREFIX_OFFLINE_PLAYER = "OfflinePlayer:";
@@ -126,7 +139,8 @@
public static final float SWIMMING_BB_HEIGHT = 0.6F;
public static final float DEFAULT_EYE_HEIGHT = 1.62F;
public static final EntitySize STANDING_DIMENSIONS = EntitySize.b(0.6F, 1.8F);
- private static final Map<EntityPose, EntitySize> POSES = ImmutableMap.builder().put(EntityPose.STANDING, EntityHuman.STANDING_DIMENSIONS).put(EntityPose.SLEEPING, EntityHuman.SLEEPING_DIMENSIONS).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build();
+ // CraftBukkit - decompile error
+ private static final Map<EntityPose, EntitySize> b = ImmutableMap.<EntityPose, EntitySize>builder().put(EntityPose.STANDING, EntityHuman.bh).put(EntityPose.SLEEPING, EntityHuman.ah).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build();
private static final DataWatcherObject<Float> c = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.c);
private static final DataWatcherObject<Integer> d = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.b);
protected static final DataWatcherObject<Byte> bi = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.a);
@@ -122,10 +136,10 @@
protected static final DataWatcherObject<NBTTagCompound> bl = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.p);
private long e;
public final PlayerInventory inventory = new PlayerInventory(this);
- protected InventoryEnderChest enderChest = new InventoryEnderChest();
+ protected InventoryEnderChest enderChest = new InventoryEnderChest(this); // CraftBukkit - add "this" to constructor
public final ContainerPlayer defaultContainer;
public Container activeContainer;
+ private static final Map<EntityPose, EntitySize> POSES = ImmutableMap.<EntityPose, EntitySize>builder().put(EntityPose.STANDING, EntityHuman.STANDING_DIMENSIONS).put(EntityPose.SLEEPING, EntityHuman.SLEEPING_DIMENSIONS).put(EntityPose.FALL_FLYING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SWIMMING, EntitySize.b(0.6F, 0.6F)).put(EntityPose.SPIN_ATTACK, EntitySize.b(0.6F, 0.6F)).put(EntityPose.CROUCHING, EntitySize.b(0.6F, 1.5F)).put(EntityPose.DYING, EntitySize.c(0.2F, 0.2F)).build();
private static final int FLY_ACHIEVEMENT_SPEED = 25;
private static final DataWatcherObject<Float> DATA_PLAYER_ABSORPTION_ID = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.FLOAT);
private static final DataWatcherObject<Integer> DATA_SCORE_ID = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.INT);
@@ -136,10 +150,10 @@
protected static final DataWatcherObject<NBTTagCompound> DATA_SHOULDER_RIGHT = DataWatcher.a(EntityHuman.class, DataWatcherRegistry.COMPOUND_TAG);
private long timeEntitySatOnShoulder;
private final PlayerInventory inventory = new PlayerInventory(this);
- protected InventoryEnderChest enderChestInventory = new InventoryEnderChest();
+ protected InventoryEnderChest enderChestInventory = new InventoryEnderChest(this); // CraftBukkit - add "this" to constructor
public final ContainerPlayer inventoryMenu;
public Container containerMenu;
- protected FoodMetaData foodData = new FoodMetaData();
+ protected FoodMetaData foodData = new FoodMetaData(this); // CraftBukkit - add "this" to constructor
protected int br;
public float bs;
public float bt;
@@ -151,6 +165,16 @@
protected int jumpTriggerTime;
public float oBob;
public float bob;
@@ -166,6 +180,16 @@
@Nullable
public EntityFishingHook hookedFish;
public EntityFishingHook fishing;
+ // CraftBukkit start
+ public boolean fauxSleeping;
@@ -55,27 +59,36 @@
+
public EntityHuman(World world, BlockPosition blockposition, float f, GameProfile gameprofile) {
super(EntityTypes.PLAYER, world);
this.bL = ItemStack.b;
@@ -288,7 +312,7 @@
this.lastItemInMainHand = ItemStack.EMPTY;
@@ -304,7 +328,7 @@
ItemStack itemstack = this.getEquipment(EnumItemSlot.HEAD);
if (itemstack.getItem() == Items.TURTLE_HELMET && !this.a((Tag) TagsFluid.WATER)) {
if (itemstack.a(Items.TURTLE_HELMET) && !this.a((Tag) TagsFluid.WATER)) {
- this.addEffect(new MobEffect(MobEffects.WATER_BREATHING, 200, 0, false, false, true));
+ this.addEffect(new MobEffect(MobEffects.WATER_BREATHING, 200, 0, false, false, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.TURTLE_HELMET); // CraftBukkit
}
}
@@ -453,7 +477,8 @@
@@ -496,7 +520,8 @@
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.world.getGameRules().getBoolean(GameRules.NATURAL_REGENERATION)) {
if (this.getHealth() < this.getMaxHealth() && this.ticksLived % 20 == 0) {
if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL && this.level.getGameRules().getBoolean(GameRules.RULE_NATURAL_REGENERATION)) {
if (this.getHealth() < this.getMaxHealth() && this.tickCount % 20 == 0) {
- this.heal(1.0F);
+ // CraftBukkit - added regain reason of "REGEN" for filtering purposes.
+ this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN);
}
if (this.foodData.c() && this.ticksLived % 10 == 0) {
@@ -638,6 +663,30 @@
if (this.foodData.c() && this.tickCount % 10 == 0) {
@@ -545,7 +570,7 @@
}
if (!list1.isEmpty()) {
- this.c((Entity) SystemUtils.a((List) list1, this.random));
+ this.c((Entity) SystemUtils.a(list1, this.random)); // CraftBukkit - decompile error
}
}
@@ -688,6 +713,30 @@
entityitem.setMot((double) (-f3 * f2 * 0.3F) + Math.cos((double) f5) * (double) f6, (double) (-f1 * 0.3F + 0.1F + (this.random.nextFloat() - this.random.nextFloat()) * 0.1F), (double) (f4 * f2 * 0.3F) + Math.sin((double) f5) * (double) f6);
}
@@ -84,7 +97,7 @@
+ Item drop = (Item) entityitem.getBukkitEntity();
+
+ PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
+ this.world.getServer().getPluginManager().callEvent(event);
+ this.level.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand();
@@ -106,27 +119,27 @@
return entityitem;
}
}
@@ -764,16 +813,17 @@
@@ -814,16 +863,17 @@
if (this.isInvulnerable(damagesource)) {
return false;
} else if (this.abilities.isInvulnerable && !damagesource.ignoresInvulnerability()) {
} else if (this.abilities.invulnerable && !damagesource.ignoresInvulnerability()) {
+ this.forceExplosionKnockback = true; // SPIGOT-5258 - Make invulnerable players get knockback from explosions
return false;
} else {
this.ticksFarFromPlayer = 0;
if (this.dl()) {
this.noActionTime = 0;
if (this.dV()) {
return false;
} else {
- this.releaseShoulderEntities();
+ // this.releaseShoulderEntities(); // CraftBukkit - moved down
if (damagesource.s()) {
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL) {
if (damagesource.w()) {
if (this.level.getDifficulty() == EnumDifficulty.PEACEFUL) {
- f = 0.0F;
+ return false; // CraftBukkit - f = 0.0f -> return false
}
if (this.world.getDifficulty() == EnumDifficulty.EASY) {
@@ -785,7 +835,13 @@
if (this.level.getDifficulty() == EnumDifficulty.EASY) {
@@ -835,7 +885,13 @@
}
}
@@ -141,7 +154,7 @@
}
}
}
@@ -800,10 +856,29 @@
@@ -855,10 +911,29 @@
}
public boolean a(EntityHuman entityhuman) {
@@ -158,8 +171,8 @@
+ }
+ } else {
+ // This should never be called, but is implemented anyway
+ org.bukkit.OfflinePlayer thisPlayer = entityhuman.world.getServer().getOfflinePlayer(entityhuman.getName());
+ team = entityhuman.world.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer);
+ org.bukkit.OfflinePlayer thisPlayer = entityhuman.level.getServer().getOfflinePlayer(entityhuman.getName());
+ team = entityhuman.level.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer);
+ if (team == null || team.allowFriendlyFire()) {
+ return true;
+ }
@@ -169,12 +182,12 @@
+ if (this instanceof EntityPlayer) {
+ return !team.hasPlayer(((EntityPlayer) this).getBukkitEntity());
+ }
+ return !team.hasPlayer(this.world.getServer().getOfflinePlayer(this.getName()));
+ return !team.hasPlayer(this.level.getServer().getOfflinePlayer(this.getName()));
+ // CraftBukkit end
}
@Override
@@ -840,8 +915,13 @@
@@ -900,8 +975,13 @@
}
}
@@ -189,7 +202,7 @@
if (!this.isInvulnerable(damagesource)) {
f = this.applyArmorModifier(damagesource, f);
f = this.applyMagicModifier(damagesource, f);
@@ -856,7 +936,7 @@
@@ -916,7 +996,7 @@
}
if (f != 0.0F) {
@@ -198,7 +211,7 @@
float f3 = this.getHealth();
this.setHealth(this.getHealth() - f);
@@ -867,6 +947,7 @@
@@ -927,6 +1007,7 @@
}
}
@@ -206,7 +219,7 @@
}
@Override
@@ -1026,7 +1107,7 @@
@@ -1086,7 +1167,7 @@
f *= 0.2F + f2 * f2 * 0.8F;
f1 *= f2;
@@ -215,7 +228,7 @@
if (f > 0.0F || f1 > 0.0F) {
boolean flag = f2 > 0.9F;
boolean flag1 = false;
@@ -1065,8 +1146,15 @@
@@ -1125,8 +1206,15 @@
if (entity instanceof EntityLiving) {
f3 = ((EntityLiving) entity).getHealth();
if (j > 0 && !entity.isBurning()) {
@@ -233,30 +246,30 @@
}
}
@@ -1094,8 +1182,11 @@
@@ -1154,8 +1242,11 @@
EntityLiving entityliving = (EntityLiving) iterator.next();
if (entityliving != this && entityliving != entity && !this.r(entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.h((Entity) entityliving) < 9.0D) {
if (entityliving != this && entityliving != entity && !this.p(entityliving) && (!(entityliving instanceof EntityArmorStand) || !((EntityArmorStand) entityliving).isMarker()) && this.f((Entity) entityliving) < 9.0D) {
+ // CraftBukkit start - Only apply knockback if the damage hits
+ if (entityliving.damageEntity(DamageSource.playerAttack(this).sweep(), f4)) {
entityliving.a(0.4F, (double) MathHelper.sin(this.yaw * 0.017453292F), (double) (-MathHelper.cos(this.yaw * 0.017453292F)));
entityliving.p(0.4000000059604645D, (double) MathHelper.sin(this.getYRot() * 0.017453292F), (double) (-MathHelper.cos(this.getYRot() * 0.017453292F)));
- entityliving.damageEntity(DamageSource.playerAttack(this), f4);
+ }
+ // CraftBukkit end
}
}
@@ -1104,9 +1195,26 @@
@@ -1164,9 +1255,26 @@
}
if (entity instanceof EntityPlayer && entity.velocityChanged) {
if (entity instanceof EntityPlayer && entity.hurtMarked) {
+ // CraftBukkit start - Add Velocity Event
+ boolean cancelled = false;
+ Player player = (Player) entity.getBukkitEntity();
+ org.bukkit.util.Vector velocity = CraftVector.toBukkit(vec3d);
+
+ PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity.clone());
+ world.getServer().getPluginManager().callEvent(event);
+ level.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled()) {
+ cancelled = true;
@@ -265,15 +278,15 @@
+ }
+
+ if (!cancelled) {
((EntityPlayer) entity).playerConnection.sendPacket(new PacketPlayOutEntityVelocity(entity));
entity.velocityChanged = false;
((EntityPlayer) entity).connection.sendPacket(new PacketPlayOutEntityVelocity(entity));
entity.hurtMarked = false;
entity.setMot(vec3d);
+ }
+ // CraftBukkit end
}
if (flag2) {
@@ -1151,7 +1259,14 @@
@@ -1211,7 +1319,14 @@
this.a(StatisticList.DAMAGE_DEALT, Math.round(f5 * 10.0F));
if (j > 0) {
@@ -288,15 +301,15 @@
+ // CraftBukkit end
}
if (this.world instanceof WorldServer && f5 > 2.0F) {
@@ -1161,12 +1276,17 @@
if (this.level instanceof WorldServer && f5 > 2.0F) {
@@ -1221,12 +1336,17 @@
}
}
- this.applyExhaustion(0.1F);
+ this.applyExhaustion(0.1F, EntityExhaustionEvent.ExhaustionReason.ATTACK); // CraftBukkit - EntityExhaustionEvent
} else {
this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_PLAYER_ATTACK_NODAMAGE, this.getSoundCategory(), 1.0F, 1.0F);
this.level.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.PLAYER_ATTACK_NODAMAGE, this.getSoundCategory(), 1.0F, 1.0F);
if (flag4) {
entity.extinguish();
}
@@ -308,8 +321,8 @@
}
}
@@ -1227,6 +1347,12 @@
}
@@ -1299,6 +1419,12 @@
public void a(ItemStack itemstack, ItemStack itemstack1, ClickAction clickaction) {}
public Either<EntityHuman.EnumBedResult, Unit> sleep(BlockPosition blockposition) {
+ // CraftBukkit start
@@ -319,9 +332,9 @@
+ public Either<EntityHuman.EnumBedResult, Unit> sleep(BlockPosition blockposition, boolean force) {
+ // CraftBukkit end
this.entitySleep(blockposition);
this.sleepTicks = 0;
this.sleepCounter = 0;
return Either.right(Unit.INSTANCE);
@@ -1311,9 +1437,9 @@
@@ -1383,9 +1509,9 @@
super.jump();
this.a(StatisticList.JUMP);
if (this.isSprinting()) {
@@ -333,9 +346,9 @@
}
}
@@ -1347,7 +1473,11 @@
@@ -1419,7 +1545,11 @@
this.setMot(vec3d2.x, d3 * 0.6D, vec3d2.z);
this.aE = f;
this.flyingSpeed = f;
this.fallDistance = 0.0F;
- this.setFlag(7, false);
+ // CraftBukkit start
@@ -346,22 +359,22 @@
} else {
super.g(vec3d);
}
@@ -1382,19 +1512,19 @@
i = Math.round(MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
@@ -1454,19 +1584,19 @@
i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
if (i > 0) {
this.a(StatisticList.SWIM_ONE_CM, i);
- this.applyExhaustion(0.01F * (float) i * 0.01F);
+ this.applyExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.SWIM); // CraftBukkit - EntityExhaustionEvent
}
} else if (this.a((Tag) TagsFluid.WATER)) {
i = Math.round(MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
i = Math.round((float) Math.sqrt(d0 * d0 + d1 * d1 + d2 * d2) * 100.0F);
if (i > 0) {
this.a(StatisticList.WALK_UNDER_WATER_ONE_CM, i);
- this.applyExhaustion(0.01F * (float) i * 0.01F);
+ this.applyExhaustion(0.01F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.WALK_UNDERWATER); // CraftBukkit - EntityExhaustionEvent
}
} else if (this.isInWater()) {
i = Math.round(MathHelper.sqrt(d0 * d0 + d2 * d2) * 100.0F);
i = Math.round((float) Math.sqrt(d0 * d0 + d2 * d2) * 100.0F);
if (i > 0) {
this.a(StatisticList.WALK_ON_WATER_ONE_CM, i);
- this.applyExhaustion(0.01F * (float) i * 0.01F);
@@ -369,13 +382,13 @@
}
} else if (this.isClimbing()) {
if (d1 > 0.0D) {
@@ -1405,13 +1535,13 @@
@@ -1477,13 +1607,13 @@
if (i > 0) {
if (this.isSprinting()) {
this.a(StatisticList.SPRINT_ONE_CM, i);
- this.applyExhaustion(0.1F * (float) i * 0.01F);
+ this.applyExhaustion(0.1F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.SPRINT); // CraftBukkit - EntityExhaustionEvent
} else if (this.bz()) {
} else if (this.isCrouching()) {
this.a(StatisticList.CROUCH_ONE_CM, i);
- this.applyExhaustion(0.0F * (float) i * 0.01F);
+ this.applyExhaustion(0.0F * (float) i * 0.01F, EntityExhaustionEvent.ExhaustionReason.CROUCH); // CraftBukkit - EntityExhaustionEvent
@@ -386,7 +399,7 @@
}
}
} else if (this.isGliding()) {
@@ -1477,12 +1607,24 @@
@@ -1549,12 +1679,24 @@
}
public void startGliding() {
@@ -412,8 +425,8 @@
}
@Override
@@ -1572,10 +1714,21 @@
return this.expLevel >= 30 ? 112 + (this.expLevel - 30) * 9 : (this.expLevel >= 15 ? 37 + (this.expLevel - 15) * 5 : 7 + this.expLevel * 2);
@@ -1644,10 +1786,21 @@
return this.experienceLevel >= 30 ? 112 + (this.experienceLevel - 30) * 9 : (this.experienceLevel >= 15 ? 37 + (this.experienceLevel - 15) * 5 : 7 + this.experienceLevel * 2);
}
+ // CraftBukkit start
@@ -423,8 +436,8 @@
+
+ public void applyExhaustion(float f, EntityExhaustionEvent.ExhaustionReason reason) {
+ // CraftBukkit end
if (!this.abilities.isInvulnerable) {
if (!this.world.isClientSide) {
if (!this.abilities.invulnerable) {
if (!this.level.isClientSide) {
- this.foodData.a(f);
+ // CraftBukkit start
+ EntityExhaustionEvent event = CraftEventFactory.callPlayerExhaustionEvent(this, reason, f);
@@ -435,7 +448,7 @@
}
}
@@ -1649,14 +1802,21 @@
@@ -1724,15 +1877,22 @@
@Override
public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack) {
@@ -446,24 +459,25 @@
+ @Override
+ public void setSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean silent) {
+ // CraftBukkit end
this.f(itemstack);
if (enumitemslot == EnumItemSlot.MAINHAND) {
- this.playEquipSound(itemstack);
+ this.playEquipSound(itemstack, silent); // CraftBukkit
this.inventory.items.set(this.inventory.itemInHandIndex, itemstack);
this.inventory.items.set(this.inventory.selected, itemstack);
} else if (enumitemslot == EnumItemSlot.OFFHAND) {
- this.playEquipSound(itemstack);
+ this.playEquipSound(itemstack, silent); // CraftBukkit
this.inventory.extraSlots.set(0, itemstack);
this.inventory.offhand.set(0, itemstack);
} else if (enumitemslot.a() == EnumItemSlot.Function.ARMOR) {
- this.playEquipSound(itemstack);
+ this.playEquipSound(itemstack, silent); // CraftBukkit
this.inventory.armor.set(enumitemslot.b(), itemstack);
}
@@ -1697,26 +1857,31 @@
@@ -1773,26 +1933,31 @@
protected void releaseShoulderEntities() {
if (this.e + 20L < this.world.getTime()) {
if (this.timeEntitySatOnShoulder + 20L < this.level.getTime()) {
- this.spawnEntityFromShoulder(this.getShoulderEntityLeft());
- this.setShoulderEntityLeft(new NBTTagCompound());
- this.spawnEntityFromShoulder(this.getShoulderEntityRight());
@@ -482,17 +496,17 @@
- private void spawnEntityFromShoulder(NBTTagCompound nbttagcompound) {
+ private boolean spawnEntityFromShoulder(NBTTagCompound nbttagcompound) { // CraftBukkit void->boolean
if (!this.world.isClientSide && !nbttagcompound.isEmpty()) {
- EntityTypes.a(nbttagcompound, this.world).ifPresent((entity) -> {
+ return EntityTypes.a(nbttagcompound, this.world).map((entity) -> { // CraftBukkit
if (!this.level.isClientSide && !nbttagcompound.isEmpty()) {
- EntityTypes.a(nbttagcompound, this.level).ifPresent((entity) -> {
+ return EntityTypes.a(nbttagcompound, this.level).map((entity) -> { // CraftBukkit
if (entity instanceof EntityTameableAnimal) {
((EntityTameableAnimal) entity).setOwnerUUID(this.uniqueID);
((EntityTameableAnimal) entity).setOwnerUUID(this.uuid);
}
entity.setPosition(this.locX(), this.locY() + 0.699999988079071D, this.locZ());
- ((WorldServer) this.world).addEntitySerialized(entity);
- ((WorldServer) this.level).addEntitySerialized(entity);
- });
+ return ((WorldServer) this.world).addEntitySerialized(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit
+ return ((WorldServer) this.level).addEntitySerialized(entity, CreatureSpawnEvent.SpawnReason.SHOULDER_ENTITY); // CraftBukkit
+ }).orElse(true); // CraftBukkit
}

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/world/entity/player/PlayerInventory.java
+++ b/net/minecraft/world/entity/player/PlayerInventory.java
@@ -26,6 +26,13 @@
import net.minecraft.world.level.World;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.state.IBlockData;
+// CraftBukkit start
@@ -13,18 +13,18 @@
+
public class PlayerInventory implements IInventory, INamableTileEntity {
public final NonNullList<ItemStack> items;
@@ -37,6 +44,54 @@
private ItemStack carried;
private int h;
public static final int POP_TIME_DURATION = 5;
@@ -43,6 +50,54 @@
public final EntityHuman player;
private int timesChanged;
+ // CraftBukkit start - add fields and methods
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
+
+ public List<ItemStack> getContents() {
+ List<ItemStack> combined = new ArrayList<ItemStack>(items.size() + armor.size() + extraSlots.size());
+ for (List<net.minecraft.world.item.ItemStack> sub : this.f) {
+ List<ItemStack> combined = new ArrayList<ItemStack>(items.size() + armor.size() + offhand.size());
+ for (List<net.minecraft.world.item.ItemStack> sub : this.compartments) {
+ combined.addAll(sub);
+ }
+
@@ -67,10 +67,10 @@
+ // CraftBukkit end
+
public PlayerInventory(EntityHuman entityhuman) {
this.items = NonNullList.a(36, ItemStack.b);
this.armor = NonNullList.a(4, ItemStack.b);
@@ -62,6 +117,28 @@
return itemstack.getItem() == itemstack1.getItem() && ItemStack.equals(itemstack, itemstack1);
this.items = NonNullList.a(36, ItemStack.EMPTY);
this.armor = NonNullList.a(4, ItemStack.EMPTY);
@@ -63,6 +118,28 @@
return !itemstack.isEmpty() && ItemStack.e(itemstack, itemstack1) && itemstack.isStackable() && itemstack.getCount() < itemstack.getMaxStackSize() && itemstack.getCount() < this.getMaxStackSize();
}
+ // CraftBukkit start - Watch method above! :D
@@ -98,26 +98,3 @@
public int getFirstEmptySlotIndex() {
for (int i = 0; i < this.items.size(); ++i) {
if (((ItemStack) this.items.get(i)).isEmpty()) {
@@ -501,8 +578,9 @@
ItemStack itemstack = (ItemStack) this.armor.get(i);
if ((!damagesource.isFire() || !itemstack.getItem().u()) && itemstack.getItem() instanceof ItemArmor) {
+ int finalI = i; // CraftBukkit - decompile error
itemstack.damage((int) f, this.player, (entityhuman) -> {
- entityhuman.broadcastItemBreak(EnumItemSlot.a(EnumItemSlot.Function.ARMOR, i));
+ entityhuman.broadcastItemBreak(EnumItemSlot.a(EnumItemSlot.Function.ARMOR, finalI)); // CraftBukkit - decompile error
});
}
}
@@ -538,6 +616,11 @@
}
public ItemStack getCarried() {
+ // CraftBukkit start
+ if (this.carried.isEmpty()) {
+ this.setCarried(ItemStack.b);
+ }
+ // CraftBukkit end
return this.carried;
}