Initial commit (Forge 1291).
This commit is contained in:
484
patches/net/minecraft/entity/player/EntityPlayer.java.patch
Normal file
484
patches/net/minecraft/entity/player/EntityPlayer.java.patch
Normal file
@ -0,0 +1,484 @@
|
||||
--- ../src-base/minecraft/net/minecraft/entity/player/EntityPlayer.java
|
||||
+++ ../src-work/minecraft/net/minecraft/entity/player/EntityPlayer.java
|
||||
@@ -92,6 +92,22 @@
|
||||
import net.minecraftforge.event.entity.player.PlayerFlyableFallEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.network.play.server.S2FPacketSetSlot;
|
||||
+
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.craftbukkit.entity.CraftItem;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
+import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
+import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||
+import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||
+import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
+import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class EntityPlayer extends EntityLivingBase implements ICommandSender
|
||||
{
|
||||
public static final String PERSISTED_NBT_TAG = "PlayerPersisted";
|
||||
@@ -102,7 +118,7 @@
|
||||
private InventoryEnderChest theInventoryEnderChest = new InventoryEnderChest();
|
||||
public Container inventoryContainer;
|
||||
public Container openContainer;
|
||||
- protected FoodStats foodStats = new FoodStats();
|
||||
+ protected FoodStats foodStats = new FoodStats(this); // CraftBukkit - add this argument
|
||||
protected int flyToggleTimer;
|
||||
public float prevCameraYaw;
|
||||
public float cameraYaw;
|
||||
@@ -113,9 +129,19 @@
|
||||
public double field_71094_bP;
|
||||
public double field_71095_bQ;
|
||||
public double field_71085_bR;
|
||||
- protected boolean sleeping;
|
||||
+ // CraftBukkit start
|
||||
+ public boolean sleeping; // protected -> public
|
||||
+ public boolean fauxSleeping;
|
||||
+ public String spawnWorld = "";
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftHumanEntity getBukkitEntity()
|
||||
+ {
|
||||
+ return (CraftHumanEntity) super.getBukkitEntity();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
public ChunkCoordinates playerLocation;
|
||||
- private int sleepTimer;
|
||||
+ public int sleepTimer; // CraftBukkit - private -> public
|
||||
public float field_71079_bU;
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float field_71082_cx;
|
||||
@@ -124,6 +150,7 @@
|
||||
private boolean spawnForced;
|
||||
private ChunkCoordinates startMinecartRidingCoordinate;
|
||||
public PlayerCapabilities capabilities = new PlayerCapabilities();
|
||||
+ public int oldLevel = -1; // CraftBukkit
|
||||
public int experienceLevel;
|
||||
public int experienceTotal;
|
||||
public float experience;
|
||||
@@ -416,6 +443,42 @@
|
||||
{
|
||||
this.updateItemUse(this.itemInUse, 16);
|
||||
int i = this.itemInUse.stackSize;
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.itemInUse);
|
||||
+ PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
|
||||
+ worldObj.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled())
|
||||
+ {
|
||||
+ // Update client
|
||||
+ if (this instanceof EntityPlayerMP)
|
||||
+ {
|
||||
+ ((EntityPlayerMP) this).playerNetServerHandler.sendPacket(new S2FPacketSetSlot((byte) 0, openContainer.getSlotFromInventory(
|
||||
+ (IInventory) this.inventory, this.inventory.currentItem).slotIndex, this.itemInUse));
|
||||
+ // Spigot Start
|
||||
+ ((EntityPlayerMP) this).getBukkitEntity().updateInventory();
|
||||
+ ((EntityPlayerMP) this).getBukkitEntity().updateScaledHealth();
|
||||
+ // Spigot End
|
||||
+ }
|
||||
+
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // Plugin modified the item, process it but don't remove it
|
||||
+ if (!craftItem.equals(event.getItem()))
|
||||
+ {
|
||||
+ CraftItemStack.asNMSCopy(event.getItem()).onFoodEaten(this.worldObj, this);
|
||||
+
|
||||
+ // Update client
|
||||
+ if (this instanceof EntityPlayerMP)
|
||||
+ {
|
||||
+ ((EntityPlayerMP) this).playerNetServerHandler.sendPacket(new S2FPacketSetSlot((byte) 0, openContainer.getSlotFromInventory(
|
||||
+ (IInventory) this.inventory, this.inventory.currentItem).slotIndex, this.itemInUse));
|
||||
+ }
|
||||
+
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ItemStack itemstack = this.itemInUse.onFoodEaten(this.worldObj, this);
|
||||
|
||||
itemstack = ForgeEventFactory.onItemUseFinish(this, itemInUse, itemInUseCount, itemstack);
|
||||
@@ -452,6 +515,7 @@
|
||||
return this.getHealth() <= 0.0F || this.isPlayerSleeping();
|
||||
}
|
||||
|
||||
+ // CraftBukkit - protected -> public
|
||||
public void closeScreen()
|
||||
{
|
||||
this.openContainer = this.inventoryContainer;
|
||||
@@ -459,23 +523,40 @@
|
||||
|
||||
public void mountEntity(Entity p_70078_1_)
|
||||
{
|
||||
+ // CraftBukkit start - mirror Entity mount changes
|
||||
+ this.setPassengerOf(p_70078_1_);
|
||||
+ }
|
||||
+
|
||||
+ public void setPassengerOf(Entity p_70078_1_)
|
||||
+ {
|
||||
+ // CraftBukkit end
|
||||
if (this.ridingEntity != null && p_70078_1_ == null)
|
||||
{
|
||||
- if (!this.worldObj.isRemote)
|
||||
- {
|
||||
- this.dismountEntity(this.ridingEntity);
|
||||
- }
|
||||
+ worldObj.getServer().getPluginManager()
|
||||
+ .callEvent(new org.spigotmc.event.entity.EntityDismountEvent(this.getBukkitEntity(), this.ridingEntity.getBukkitEntity())); // Spigot
|
||||
+ // CraftBukkit start - use parent method instead to correctly fire
|
||||
+ // VehicleExitEvent
|
||||
+ Entity originalVehicle = this.ridingEntity;
|
||||
+ // First statement moved down, second statement handled in parent
|
||||
+ // method.
|
||||
+ /*
|
||||
+ * if (!this.world.isStatic) { this.l(this.vehicle); }
|
||||
+ *
|
||||
+ * if (this.vehicle != null) { this.vehicle.passenger = null; }
|
||||
+ *
|
||||
+ * this.vehicle = null;
|
||||
+ */
|
||||
+ super.setPassengerOf(p_70078_1_);
|
||||
|
||||
- if (this.ridingEntity != null)
|
||||
+ if (!this.worldObj.isRemote && this.ridingEntity == null)
|
||||
{
|
||||
- this.ridingEntity.riddenByEntity = null;
|
||||
+ this.dismountEntity(originalVehicle);
|
||||
}
|
||||
-
|
||||
- this.ridingEntity = null;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
else
|
||||
{
|
||||
- super.mountEntity(p_70078_1_);
|
||||
+ super.setPassengerOf(p_70078_1_); // CraftBukkit - call new parent
|
||||
}
|
||||
}
|
||||
|
||||
@@ -532,7 +613,8 @@
|
||||
|
||||
if (this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL && this.getHealth() < this.getMaxHealth() && this.worldObj.getGameRules().getGameRuleBooleanValue("naturalRegeneration") && this.ticksExisted % 20 * 12 == 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);
|
||||
}
|
||||
|
||||
this.inventory.decrementAnimations();
|
||||
@@ -554,7 +636,8 @@
|
||||
|
||||
this.setAIMoveSpeed((float)iattributeinstance.getAttributeValue());
|
||||
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
|
||||
- float f1 = (float)Math.atan(-this.motionY * 0.20000000298023224D) * 15.0F;
|
||||
+ // CraftBukkit - Math -> TrigMath
|
||||
+ float f1 = (float) org.bukkit.craftbukkit.TrigMath.atan(-this.motionY * 0.20000000298023224D) * 15.0F;
|
||||
|
||||
if (f > 0.1F)
|
||||
{
|
||||
@@ -589,7 +672,7 @@
|
||||
|
||||
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, axisalignedbb);
|
||||
|
||||
- if (list != null)
|
||||
+ if (list != null && this.canBeCollidedWith()) // Spigot: this.canBeCollidedWith() condition
|
||||
{
|
||||
for (int i = 0; i < list.size(); ++i)
|
||||
{
|
||||
@@ -687,12 +770,14 @@
|
||||
public void addToPlayerScore(Entity p_70084_1_, int p_70084_2_)
|
||||
{
|
||||
this.addScore(p_70084_2_);
|
||||
- Collection collection = this.getWorldScoreboard().func_96520_a(IScoreObjectiveCriteria.totalKillCount);
|
||||
+ // CraftBukkit - Get our scores instead
|
||||
+ Collection<Score> collection = this.worldObj.getServer().getScoreboardManager().getScoreboardScores(IScoreObjectiveCriteria.totalKillCount, this.getCommandSenderName(), new java.util.ArrayList<Score>());
|
||||
|
||||
if (p_70084_1_ instanceof EntityPlayer)
|
||||
{
|
||||
this.addStat(StatList.playerKillsStat, 1);
|
||||
- collection.addAll(this.getWorldScoreboard().func_96520_a(IScoreObjectiveCriteria.playerKillCount));
|
||||
+ // CraftBukkit - Get our scores instead
|
||||
+ this.worldObj.getServer().getScoreboardManager().getScoreboardScores(IScoreObjectiveCriteria.playerKillCount, this.getCommandSenderName(), collection);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -703,8 +788,7 @@
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
- ScoreObjective scoreobjective = (ScoreObjective)iterator.next();
|
||||
- Score score = this.getWorldScoreboard().func_96529_a(this.getCommandSenderName(), scoreobjective);
|
||||
+ Score score = (Score) iterator.next(); // CraftBukkit - Use our scores instead
|
||||
score.func_96648_a();
|
||||
}
|
||||
}
|
||||
@@ -777,6 +861,19 @@
|
||||
entityitem.motionZ += Math.sin((double)f1) * (double)f;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ Player player = (Player) this.getBukkitEntity();
|
||||
+ CraftItem drop = new CraftItem(this.worldObj.getServer(), entityitem);
|
||||
+ PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
|
||||
+ this.worldObj.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled())
|
||||
+ {
|
||||
+ player.getInventory().addItem(drop.getItemStack());
|
||||
+ return null;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.joinEntityItemWithWorld(entityitem);
|
||||
this.addStat(StatList.dropStat, 1);
|
||||
return entityitem;
|
||||
@@ -881,6 +978,15 @@
|
||||
this.wakeUpPlayer(true, true, false);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ this.spawnWorld = p_70037_1_.getString("SpawnWorld");
|
||||
+
|
||||
+ if ("".equals(spawnWorld))
|
||||
+ {
|
||||
+ this.spawnWorld = this.worldObj.getServer().getWorlds().get(0).getName();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (p_70037_1_.hasKey("SpawnX", 99) && p_70037_1_.hasKey("SpawnY", 99) && p_70037_1_.hasKey("SpawnZ", 99))
|
||||
{
|
||||
this.spawnChunk = new ChunkCoordinates(p_70037_1_.getInteger("SpawnX"), p_70037_1_.getInteger("SpawnY"), p_70037_1_.getInteger("SpawnZ"));
|
||||
@@ -925,6 +1031,7 @@
|
||||
p_70014_1_.setInteger("SpawnY", this.spawnChunk.posY);
|
||||
p_70014_1_.setInteger("SpawnZ", this.spawnChunk.posZ);
|
||||
p_70014_1_.setBoolean("SpawnForced", this.spawnForced);
|
||||
+ p_70014_1_.setString("SpawnWorld", spawnWorld); // CraftBukkit - fixes bed spawns for multiworld worlds
|
||||
}
|
||||
|
||||
NBTTagList spawnlist = new NBTTagList();
|
||||
@@ -1003,7 +1110,7 @@
|
||||
{
|
||||
if (this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL)
|
||||
{
|
||||
- p_70097_2_ = 0.0F;
|
||||
+ return false; // CraftBukkit - p_70097_2_ = 0.0F; -> return false
|
||||
}
|
||||
|
||||
if (this.worldObj.difficultySetting == EnumDifficulty.EASY)
|
||||
@@ -1017,7 +1124,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (p_70097_2_ == 0.0F)
|
||||
+ if (false && p_70097_2_ == 0.0F) // CraftBukkit - Don't filter out 0 damage
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -1039,9 +1146,40 @@
|
||||
|
||||
public boolean canAttackPlayer(EntityPlayer p_96122_1_)
|
||||
{
|
||||
- Team team = this.getTeam();
|
||||
- Team team1 = p_96122_1_.getTeam();
|
||||
- return team == null ? true : (!team.isSameTeam(team1) ? true : team.getAllowFriendlyFire());
|
||||
+ // CraftBukkit start - Change to check OTHER player's scoreboard team
|
||||
+ // according to API
|
||||
+ // To summarize this method's logic, it's "Can parameter hurt this"
|
||||
+ org.bukkit.scoreboard.Team team;
|
||||
+
|
||||
+ if (p_96122_1_ instanceof EntityPlayerMP)
|
||||
+ {
|
||||
+ EntityPlayerMP thatPlayer = (EntityPlayerMP) p_96122_1_;
|
||||
+ team = thatPlayer.getBukkitEntity().getScoreboard().getPlayerTeam(thatPlayer.getBukkitEntity());
|
||||
+
|
||||
+ if (team == null || team.allowFriendlyFire())
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ // This should never be called, but is implemented anyway
|
||||
+ org.bukkit.OfflinePlayer thisPlayer = p_96122_1_.worldObj.getServer().getOfflinePlayer(p_96122_1_.getCommandSenderName());
|
||||
+ team = p_96122_1_.worldObj.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer);
|
||||
+
|
||||
+ if (team == null || team.allowFriendlyFire())
|
||||
+ {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (this instanceof EntityPlayerMP)
|
||||
+ {
|
||||
+ return !team.hasPlayer(((EntityPlayerMP) this).getBukkitEntity());
|
||||
+ }
|
||||
+
|
||||
+ return !team.hasPlayer(this.worldObj.getServer().getOfflinePlayer(this.getCommandSenderName()));
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
protected void damageArmor(float p_70675_1_)
|
||||
@@ -1073,19 +1211,34 @@
|
||||
return (float)i / (float)this.inventory.armorInventory.length;
|
||||
}
|
||||
|
||||
+ // Cauldron start - vanilla compatibility
|
||||
protected void damageEntity(DamageSource p_70665_1_, float p_70665_2_)
|
||||
{
|
||||
+ this.damageEntity_CB(p_70665_1_, p_70665_2_);
|
||||
+ }
|
||||
+ // Cauldron end
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ protected boolean damageEntity_CB(DamageSource p_70665_1_, float p_70665_2_) // void
|
||||
+ // ->
|
||||
+ // boolean
|
||||
+ {
|
||||
+ if (true)
|
||||
+ {
|
||||
+ return super.damageEntity_CB(p_70665_1_, p_70665_2_);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (!this.isEntityInvulnerable())
|
||||
{
|
||||
p_70665_2_ = ForgeHooks.onLivingHurt(this, p_70665_1_, p_70665_2_);
|
||||
- if (p_70665_2_ <= 0) return;
|
||||
+ if (p_70665_2_ <= 0) return false;
|
||||
if (!p_70665_1_.isUnblockable() && this.isBlocking() && p_70665_2_ > 0.0F)
|
||||
{
|
||||
p_70665_2_ = (1.0F + p_70665_2_) * 0.5F;
|
||||
}
|
||||
|
||||
p_70665_2_ = ArmorProperties.ApplyArmor(this, inventory.armorInventory, p_70665_1_, p_70665_2_);
|
||||
- if (p_70665_2_ <= 0) return;
|
||||
+ if (p_70665_2_ <= 0) return false;
|
||||
p_70665_2_ = this.applyPotionDamageCalculations(p_70665_1_, p_70665_2_);
|
||||
float f1 = p_70665_2_;
|
||||
p_70665_2_ = Math.max(p_70665_2_ - this.getAbsorptionAmount(), 0.0F);
|
||||
@@ -1099,6 +1252,7 @@
|
||||
this.func_110142_aN().func_94547_a(p_70665_1_, f2, p_70665_2_);
|
||||
}
|
||||
}
|
||||
+ return false;
|
||||
}
|
||||
|
||||
public void func_146101_a(TileEntityFurnace p_146101_1_) {}
|
||||
@@ -1134,7 +1288,8 @@
|
||||
|
||||
if (itemstack.interactWithEntity(this, (EntityLivingBase)p_70998_1_))
|
||||
{
|
||||
- if (itemstack.stackSize <= 0 && !this.capabilities.isCreativeMode)
|
||||
+ // CraftBukkit - bypass infinite items; <= 0 -> == 0
|
||||
+ if (itemstack.stackSize == 0 && !this.capabilities.isCreativeMode)
|
||||
{
|
||||
this.destroyCurrentEquippedItem();
|
||||
}
|
||||
@@ -1281,7 +1436,8 @@
|
||||
{
|
||||
itemstack.hitEntity((EntityLivingBase)object, this);
|
||||
|
||||
- if (itemstack.stackSize <= 0)
|
||||
+ // CraftBukkit - bypass infinite items; <= 0 -> == 0
|
||||
+ if (itemstack.stackSize == 0)
|
||||
{
|
||||
this.destroyCurrentEquippedItem();
|
||||
}
|
||||
@@ -1293,7 +1449,17 @@
|
||||
|
||||
if (j > 0)
|
||||
{
|
||||
- p_71059_1_.setFire(j * 4);
|
||||
+ // CraftBukkit start - Call a combust event when
|
||||
+ // somebody hits with a fire enchanted item
|
||||
+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), p_71059_1_.getBukkitEntity(),
|
||||
+ j * 4);
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
|
||||
+
|
||||
+ if (!combustEvent.isCancelled())
|
||||
+ {
|
||||
+ p_71059_1_.setFire(combustEvent.getDuration());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1322,6 +1488,10 @@
|
||||
|
||||
if (this.openContainer != null)
|
||||
{
|
||||
+ // CraftBukkit start
|
||||
+ InventoryCloseEvent event = new InventoryCloseEvent(this.openContainer.getBukkitView());
|
||||
+ if (this.openContainer.getBukkitView() != null) Bukkit.getServer().getPluginManager().callEvent(event); // Cauldron - allow vanilla mods to bypass
|
||||
+ // CraftBukkit end
|
||||
this.openContainer.onContainerClosed(this);
|
||||
}
|
||||
}
|
||||
@@ -1381,6 +1551,20 @@
|
||||
this.mountEntity((Entity)null);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (this.getBukkitEntity() instanceof Player)
|
||||
+ {
|
||||
+ Player player = (Player) this.getBukkitEntity();
|
||||
+ org.bukkit.block.Block bed = this.worldObj.getWorld().getBlockAt(p_71018_1_, p_71018_2_, p_71018_3_);
|
||||
+ PlayerBedEnterEvent cbEvent = new PlayerBedEnterEvent(player, bed);
|
||||
+ this.worldObj.getServer().getPluginManager().callEvent(cbEvent);
|
||||
+
|
||||
+ if (cbEvent.isCancelled())
|
||||
+ {
|
||||
+ return EntityPlayer.EnumStatus.OTHER_PROBLEM;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.setSize(0.2F, 0.2F);
|
||||
this.yOffset = 0.2F;
|
||||
|
||||
@@ -1476,6 +1660,26 @@
|
||||
this.worldObj.updateAllPlayersSleepingFlag();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (this.getBukkitEntity() instanceof Player)
|
||||
+ {
|
||||
+ Player player = (Player) this.getBukkitEntity();
|
||||
+ org.bukkit.block.Block bed;
|
||||
+
|
||||
+ if (chunkcoordinates != null)
|
||||
+ {
|
||||
+ bed = this.worldObj.getWorld().getBlockAt(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ bed = this.worldObj.getWorld().getBlockAt(player.getLocation());
|
||||
+ }
|
||||
+
|
||||
+ PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed);
|
||||
+ this.worldObj.getServer().getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (p_70999_1_)
|
||||
{
|
||||
this.sleepTimer = 0;
|
||||
@@ -1606,11 +1810,13 @@
|
||||
{
|
||||
this.spawnChunk = new ChunkCoordinates(p_71063_1_);
|
||||
this.spawnForced = p_71063_2_;
|
||||
+ this.spawnWorld = this.worldObj.worldInfo.getWorldName(); // CraftBukkit
|
||||
}
|
||||
else
|
||||
{
|
||||
this.spawnChunk = null;
|
||||
this.spawnForced = false;
|
||||
+ this.spawnWorld = ""; // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
822
patches/net/minecraft/entity/player/EntityPlayerMP.java.patch
Normal file
822
patches/net/minecraft/entity/player/EntityPlayerMP.java.patch
Normal file
@ -0,0 +1,822 @@
|
||||
--- ../src-base/minecraft/net/minecraft/entity/player/EntityPlayerMP.java
|
||||
+++ ../src-work/minecraft/net/minecraft/entity/player/EntityPlayerMP.java
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
+
|
||||
import io.netty.buffer.Unpooled;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -83,6 +84,7 @@
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.tileentity.TileEntityHopper;
|
||||
import net.minecraft.tileentity.TileEntitySign;
|
||||
+import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraft.util.ChunkCoordinates;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.EntityDamageSource;
|
||||
@@ -106,24 +108,38 @@
|
||||
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
|
||||
import net.minecraftforge.event.world.ChunkWatchEvent;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.util.CombatTracker;
|
||||
+import net.minecraft.util.FoodStats;
|
||||
+import net.minecraft.world.World;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.WeatherType;
|
||||
+import org.bukkit.craftbukkit.CraftWorld;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.inventory.InventoryType;
|
||||
+import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityPlayerMP extends EntityPlayer implements ICrafting
|
||||
{
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
- private String translator = "en_US";
|
||||
+ public String translator = "en_US"; // CraftBukkit - private -> public
|
||||
public NetHandlerPlayServer playerNetServerHandler;
|
||||
public final MinecraftServer mcServer;
|
||||
public final ItemInWorldManager theItemInWorldManager;
|
||||
public double managedPosX;
|
||||
public double managedPosZ;
|
||||
public final List loadedChunks = new LinkedList();
|
||||
- private final List destroyedItemsNetCache = new LinkedList();
|
||||
+ public final List destroyedItemsNetCache = new LinkedList();
|
||||
private final StatisticsFile field_147103_bO;
|
||||
private float field_130068_bO = Float.MIN_VALUE;
|
||||
private float lastHealth = -1.0E8F;
|
||||
private int lastFoodLevel = -99999999;
|
||||
private boolean wasHungry = true;
|
||||
- private int lastExperience = -99999999;
|
||||
- private int field_147101_bU = 60;
|
||||
+ public int lastExperience = -99999999; // CraftBukkit - private -> public
|
||||
+ public int field_147101_bU = 60; // CraftBukkit - private -> public
|
||||
private EntityPlayer.EnumChatVisibility chatVisibility;
|
||||
private boolean chatColours = true;
|
||||
private long field_143005_bX = System.currentTimeMillis();
|
||||
@@ -131,6 +147,39 @@
|
||||
public boolean isChangingQuantityOnly;
|
||||
public int ping;
|
||||
public boolean playerConqueredTheEnd;
|
||||
+ // CraftBukkit start
|
||||
+ public String displayName;
|
||||
+ public String listName;
|
||||
+ public org.bukkit.Location compassTarget;
|
||||
+ public int newExp = 0;
|
||||
+ public int newLevel = 0;
|
||||
+ public int newTotalExp = 0;
|
||||
+ public boolean keepLevel = false;
|
||||
+ public double maxHealthCache;
|
||||
+ // CraftBukkit end
|
||||
+ // Spigot start
|
||||
+ public boolean collidesWithEntities = true;
|
||||
+
|
||||
+ @Override
|
||||
+
|
||||
+ /**
|
||||
+ * Returns true if other Entities should be prevented from moving through this Entity.
|
||||
+ */
|
||||
+ public boolean canBeCollidedWith()
|
||||
+ {
|
||||
+ return this.collidesWithEntities && super.canBeCollidedWith();
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+
|
||||
+ /**
|
||||
+ * Returns true if this entity should push and be pushed by other entities when colliding.
|
||||
+ */
|
||||
+ public boolean canBePushed()
|
||||
+ {
|
||||
+ return this.collidesWithEntities && super.canBePushed();
|
||||
+ }
|
||||
+ // Spigot end
|
||||
private static final String __OBFID = "CL_00001440";
|
||||
|
||||
public EntityPlayerMP(MinecraftServer p_i45285_1_, WorldServer p_i45285_2_, GameProfile p_i45285_3_, ItemInWorldManager p_i45285_4_)
|
||||
@@ -153,6 +202,13 @@
|
||||
{
|
||||
this.setPosition(this.posX, this.posY + 1.0D, this.posZ);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ this.displayName = this.getCommandSenderName();
|
||||
+ this.listName = this.getCommandSenderName();
|
||||
+ // this.canPickUpLoot = true; TODO
|
||||
+ this.maxHealthCache = this.getMaxHealth();
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void readEntityFromNBT(NBTTagCompound p_70037_1_)
|
||||
@@ -170,14 +226,57 @@
|
||||
this.theItemInWorldManager.setGameType(WorldSettings.GameType.getByID(p_70037_1_.getInteger("playerGameType")));
|
||||
}
|
||||
}
|
||||
+
|
||||
+ this.getBukkitEntity().readExtraData(p_70037_1_); // CraftBukkit
|
||||
}
|
||||
|
||||
public void writeEntityToNBT(NBTTagCompound p_70014_1_)
|
||||
{
|
||||
super.writeEntityToNBT(p_70014_1_);
|
||||
p_70014_1_.setInteger("playerGameType", this.theItemInWorldManager.getGameType().getID());
|
||||
+ this.getBukkitEntity().setExtraData(p_70014_1_); // CraftBukkit
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - World fallback code, either respawn location or global spawn
|
||||
+
|
||||
+ /**
|
||||
+ * Sets the reference to the World object.
|
||||
+ */
|
||||
+ public void setWorld(World world)
|
||||
+ {
|
||||
+ super.setWorld(world);
|
||||
+
|
||||
+ if (world == null)
|
||||
+ {
|
||||
+ this.isDead = false;
|
||||
+ ChunkCoordinates position = null;
|
||||
+
|
||||
+ if (this.spawnWorld != null && !this.spawnWorld.equals(""))
|
||||
+ {
|
||||
+ CraftWorld cworld = (CraftWorld) Bukkit.getServer().getWorld(this.spawnWorld);
|
||||
+
|
||||
+ if (cworld != null && this.getBedLocation() != null)
|
||||
+ {
|
||||
+ world = cworld.getHandle();
|
||||
+ position = EntityPlayer.verifyRespawnCoordinates(cworld.getHandle(), this.getBedLocation(), false);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (world == null || position == null)
|
||||
+ {
|
||||
+ world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle();
|
||||
+ position = world.getSpawnPoint();
|
||||
+ }
|
||||
+
|
||||
+ this.worldObj = world;
|
||||
+ this.setPosition(position.posX + 0.5, position.posY, position.posZ + 0.5);
|
||||
+ }
|
||||
+
|
||||
+ this.dimension = ((WorldServer) this.worldObj).provider.dimensionId;
|
||||
+ this.theItemInWorldManager.setWorld((WorldServer) world);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void addExperienceLevel(int p_82242_1_)
|
||||
{
|
||||
super.addExperienceLevel(p_82242_1_);
|
||||
@@ -240,7 +339,7 @@
|
||||
ArrayList arraylist1 = new ArrayList();
|
||||
Chunk chunk;
|
||||
|
||||
- while (iterator1.hasNext() && arraylist.size() < S26PacketMapChunkBulk.func_149258_c())
|
||||
+ while (iterator1.hasNext() && arraylist.size() < this.worldObj.getSpigotConfig().maxBulkChunk) // Spigot // Cauldron
|
||||
{
|
||||
ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair)iterator1.next();
|
||||
|
||||
@@ -253,8 +352,7 @@
|
||||
if (chunk.func_150802_k())
|
||||
{
|
||||
arraylist.add(chunk);
|
||||
- arraylist1.addAll(((WorldServer)this.worldObj).func_147486_a(chunkcoordintpair.chunkXPos * 16, 0, chunkcoordintpair.chunkZPos * 16, chunkcoordintpair.chunkXPos * 16 + 15, 256, chunkcoordintpair.chunkZPos * 16 + 15));
|
||||
- //BugFix: 16 makes it load an extra chunk, which isn't associated with a player, which makes it not unload unless a player walks near it.
|
||||
+ arraylist1.addAll(chunk.chunkTileEntityMap.values()); // CraftBukkit - Get tile entities directly from the chunk instead of the world
|
||||
iterator1.remove();
|
||||
}
|
||||
}
|
||||
@@ -309,9 +407,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit - Optionally scale health
|
||||
if (this.getHealth() != this.lastHealth || this.lastFoodLevel != this.foodStats.getFoodLevel() || this.foodStats.getSaturationLevel() == 0.0F != this.wasHungry)
|
||||
{
|
||||
- this.playerNetServerHandler.sendPacket(new S06PacketUpdateHealth(this.getHealth(), this.foodStats.getFoodLevel(), this.foodStats.getSaturationLevel()));
|
||||
+ this.playerNetServerHandler.sendPacket(new S06PacketUpdateHealth(this.getBukkitEntity().getScaledHealth(), this.foodStats.getFoodLevel(), this.foodStats.getSaturationLevel()));
|
||||
this.lastHealth = this.getHealth();
|
||||
this.lastFoodLevel = this.foodStats.getFoodLevel();
|
||||
this.wasHungry = this.foodStats.getSaturationLevel() == 0.0F;
|
||||
@@ -320,16 +419,18 @@
|
||||
if (this.getHealth() + this.getAbsorptionAmount() != this.field_130068_bO)
|
||||
{
|
||||
this.field_130068_bO = this.getHealth() + this.getAbsorptionAmount();
|
||||
- Collection collection = this.getWorldScoreboard().func_96520_a(IScoreObjectiveCriteria.health);
|
||||
- Iterator iterator = collection.iterator();
|
||||
+ // CraftBukkit - Update ALL the scores!
|
||||
+ this.worldObj.getServer().getScoreboardManager().updateAllScoresForList(IScoreObjectiveCriteria.health, this.getCommandSenderName(), com.google.common.collect.ImmutableList.of(this));
|
||||
+ }
|
||||
|
||||
- while (iterator.hasNext())
|
||||
- {
|
||||
- ScoreObjective scoreobjective = (ScoreObjective)iterator.next();
|
||||
- this.getWorldScoreboard().func_96529_a(this.getCommandSenderName(), scoreobjective).func_96651_a(Arrays.asList(new EntityPlayer[] {this}));
|
||||
- }
|
||||
+ // CraftBukkit start - Force max health updates
|
||||
+ if (this.maxHealthCache != this.getMaxHealth())
|
||||
+ {
|
||||
+ this.getBukkitEntity().updateScaledHealth();
|
||||
}
|
||||
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (this.experienceTotal != this.lastExperience)
|
||||
{
|
||||
this.lastExperience = this.experienceTotal;
|
||||
@@ -340,6 +441,20 @@
|
||||
{
|
||||
this.func_147098_j();
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ if (this.oldLevel == -1)
|
||||
+ {
|
||||
+ this.oldLevel = this.experienceLevel;
|
||||
+ }
|
||||
+
|
||||
+ if (this.oldLevel != this.experienceLevel)
|
||||
+ {
|
||||
+ CraftEventFactory.callPlayerLevelChangeEvent(this.worldObj.getServer().getPlayer((EntityPlayerMP) this), this.oldLevel, this.experienceLevel);
|
||||
+ this.oldLevel = this.experienceLevel;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
catch (Throwable throwable)
|
||||
{
|
||||
@@ -402,34 +517,74 @@
|
||||
|
||||
public void onDeath(DamageSource p_70645_1_)
|
||||
{
|
||||
- if (ForgeHooks.onLivingDeath(this, p_70645_1_)) return;
|
||||
- this.mcServer.getConfigurationManager().sendChatMsg(this.func_110142_aN().func_151521_b());
|
||||
+ // CraftBukkit start
|
||||
+ if (this.isDead || ForgeHooks.onLivingDeath(this, p_70645_1_)) // Cauldron - call Forge hook
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
|
||||
- if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory"))
|
||||
+ java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
|
||||
+ boolean keepInventory = this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory");
|
||||
+
|
||||
+ if (!keepInventory)
|
||||
{
|
||||
+ // Cauldron start - rework CraftBukkit logic to support Forge better
|
||||
captureDrops = true;
|
||||
capturedDrops.clear();
|
||||
-
|
||||
this.inventory.dropAllItems();
|
||||
+ for (int i = 0; i < capturedDrops.size(); ++i)
|
||||
+ {
|
||||
+ if (capturedDrops.get(i) != null)
|
||||
+ {
|
||||
+ loot.add(CraftItemStack.asCraftMirror(capturedDrops.get(i).getEntityItem()));
|
||||
+ }
|
||||
+ }
|
||||
+ // Cauldron end
|
||||
+ }
|
||||
|
||||
+ IChatComponent chatmessage = this.func_110142_aN().func_151521_b();
|
||||
+ String deathmessage = chatmessage.getUnformattedText();
|
||||
+ org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage);
|
||||
+ String deathMessage = event.getDeathMessage();
|
||||
+
|
||||
+ if (deathMessage != null && deathMessage.length() > 0)
|
||||
+ {
|
||||
+ if (deathMessage.equals(deathmessage))
|
||||
+ {
|
||||
+ this.mcServer.getConfigurationManager().sendChatMsg(chatmessage);
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ this.mcServer.getConfigurationManager().sendMessage(org.bukkit.craftbukkit.util.CraftChatMessage.fromString(deathMessage));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!keepInventory)
|
||||
+ {
|
||||
+ // Cauldron start - rework CraftBukkit logic to support Forge better
|
||||
+ this.inventory.clearInventory(null, -1); // CraftBukkit - we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory.
|
||||
captureDrops = false;
|
||||
- PlayerDropsEvent event = new PlayerDropsEvent(this, p_70645_1_, capturedDrops, recentlyHit > 0);
|
||||
- if (!MinecraftForge.EVENT_BUS.post(event))
|
||||
+ PlayerDropsEvent forgeEvent = new PlayerDropsEvent(this, p_70645_1_, capturedDrops, recentlyHit > 0);
|
||||
+
|
||||
+ if (!MinecraftForge.EVENT_BUS.post(forgeEvent))
|
||||
{
|
||||
for (EntityItem item : capturedDrops)
|
||||
{
|
||||
joinEntityItemWithWorld(item);
|
||||
}
|
||||
}
|
||||
+ // Cauldron end
|
||||
}
|
||||
|
||||
- Collection collection = this.worldObj.getScoreboard().func_96520_a(IScoreObjectiveCriteria.deathCount);
|
||||
+ this.closeScreen();
|
||||
+ // CraftBukkit end
|
||||
+ // CraftBukkit - Get our scores instead
|
||||
+ Collection<Score> collection = this.worldObj.getServer().getScoreboardManager().getScoreboardScores(IScoreObjectiveCriteria.deathCount, this.getCommandSenderName(), new java.util.ArrayList<Score>());
|
||||
Iterator iterator = collection.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
- ScoreObjective scoreobjective = (ScoreObjective)iterator.next();
|
||||
- Score score = this.getWorldScoreboard().func_96529_a(this.getCommandSenderName(), scoreobjective);
|
||||
+ Score score = (Score) iterator.next(); // CraftBukkit - Use our scores instead
|
||||
score.func_96648_a();
|
||||
}
|
||||
|
||||
@@ -495,7 +650,8 @@
|
||||
|
||||
public boolean canAttackPlayer(EntityPlayer p_96122_1_)
|
||||
{
|
||||
- return !this.mcServer.isPVPEnabled() ? false : super.canAttackPlayer(p_96122_1_);
|
||||
+ // CraftBukkit - this.mcServer.isPVPEnabled() -> this.world.pvpMode
|
||||
+ return !this.worldObj.pvpMode ? false : super.canAttackPlayer(p_96122_1_);
|
||||
}
|
||||
|
||||
public void travelToDimension(int p_71027_1_)
|
||||
@@ -526,7 +682,10 @@
|
||||
this.triggerAchievement(AchievementList.portal);
|
||||
}
|
||||
|
||||
- this.mcServer.getConfigurationManager().transferPlayerToDimension(this, p_71027_1_);
|
||||
+ // CraftBukkit start
|
||||
+ TeleportCause cause = (this.dimension == 1 || p_71027_1_ == 1) ? TeleportCause.END_PORTAL : TeleportCause.NETHER_PORTAL;
|
||||
+ this.mcServer.getConfigurationManager().transferPlayerToDimension(this, p_71027_1_, cause); // Cauldron
|
||||
+ // CraftBukkit end
|
||||
this.lastExperience = -1;
|
||||
this.lastHealth = -1.0F;
|
||||
this.lastFoodLevel = -1;
|
||||
@@ -569,6 +728,11 @@
|
||||
|
||||
public void wakeUpPlayer(boolean p_70999_1_, boolean p_70999_2_, boolean p_70999_3_)
|
||||
{
|
||||
+ if (this.fauxSleeping && !this.sleeping)
|
||||
+ {
|
||||
+ return; // CraftBukkit - Can't leave bed if not in one!
|
||||
+ }
|
||||
+
|
||||
if (this.isPlayerSleeping())
|
||||
{
|
||||
this.getServerForPlayer().getEntityTracker().func_151248_b(this, new S0BPacketAnimation(this, 2));
|
||||
@@ -584,11 +748,27 @@
|
||||
|
||||
public void mountEntity(Entity p_70078_1_)
|
||||
{
|
||||
- super.mountEntity(p_70078_1_);
|
||||
- this.playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(0, this, this.ridingEntity));
|
||||
- this.playerNetServerHandler.setPlayerLocation(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
|
||||
+ // CraftBukkit start
|
||||
+ this.setPassengerOf(p_70078_1_);
|
||||
}
|
||||
|
||||
+ public void setPassengerOf(Entity entity)
|
||||
+ {
|
||||
+ // mount(null) doesn't really fly for overloaded methods,
|
||||
+ // so this method is needed
|
||||
+ Entity currentVehicle = this.ridingEntity;
|
||||
+ super.setPassengerOf(entity);
|
||||
+
|
||||
+ // Check if the vehicle actually changed.
|
||||
+ if (currentVehicle != this.ridingEntity)
|
||||
+ {
|
||||
+ this.playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(0, this, this.ridingEntity));
|
||||
+ this.playerNetServerHandler.setPlayerLocation(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+
|
||||
protected void updateFallState(double p_70064_1_, boolean p_70064_3_) {}
|
||||
|
||||
public void handleFalling(double p_71122_1_, boolean p_71122_3_)
|
||||
@@ -610,29 +790,64 @@
|
||||
this.currentWindowId = this.currentWindowId % 100 + 1;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - change signature from void to int
|
||||
+ public int nextContainerCounter()
|
||||
+ {
|
||||
+ this.currentWindowId = this.currentWindowId % 100 + 1;
|
||||
+ return this.currentWindowId;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void displayGUIWorkbench(int p_71058_1_, int p_71058_2_, int p_71058_3_)
|
||||
{
|
||||
+ // CraftBukkit start - Inventory open hook
|
||||
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerWorkbench(this.inventory, this.worldObj, p_71058_1_, p_71058_2_, p_71058_3_));
|
||||
+
|
||||
+ if (container == null)
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
this.getNextWindowId();
|
||||
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 1, "Crafting", 9, true));
|
||||
- this.openContainer = new ContainerWorkbench(this.inventory, this.worldObj, p_71058_1_, p_71058_2_, p_71058_3_);
|
||||
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
|
||||
this.openContainer.windowId = this.currentWindowId;
|
||||
this.openContainer.addCraftingToCrafters(this);
|
||||
}
|
||||
|
||||
public void displayGUIEnchantment(int p_71002_1_, int p_71002_2_, int p_71002_3_, String p_71002_4_)
|
||||
{
|
||||
+ // CraftBukkit start - Inventory open hook
|
||||
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerEnchantment(this.inventory, this.worldObj, p_71002_1_, p_71002_2_, p_71002_3_));
|
||||
+
|
||||
+ if (container == null)
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
this.getNextWindowId();
|
||||
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 4, p_71002_4_ == null ? "" : p_71002_4_, 9, p_71002_4_ != null));
|
||||
- this.openContainer = new ContainerEnchantment(this.inventory, this.worldObj, p_71002_1_, p_71002_2_, p_71002_3_);
|
||||
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
|
||||
this.openContainer.windowId = this.currentWindowId;
|
||||
this.openContainer.addCraftingToCrafters(this);
|
||||
}
|
||||
|
||||
public void displayGUIAnvil(int p_82244_1_, int p_82244_2_, int p_82244_3_)
|
||||
{
|
||||
+ // CraftBukkit start - Inventory open hook
|
||||
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerRepair(this.inventory, this.worldObj, p_82244_1_, p_82244_2_, p_82244_3_, this));
|
||||
+
|
||||
+ if (container == null)
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
this.getNextWindowId();
|
||||
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 8, "Repairing", 9, true));
|
||||
- this.openContainer = new ContainerRepair(this.inventory, this.worldObj, p_82244_1_, p_82244_2_, p_82244_3_, this);
|
||||
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
|
||||
this.openContainer.windowId = this.currentWindowId;
|
||||
this.openContainer.addCraftingToCrafters(this);
|
||||
}
|
||||
@@ -644,71 +859,150 @@
|
||||
this.closeScreen();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Inventory open hook
|
||||
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerChest(this.inventory, p_71007_1_));
|
||||
+
|
||||
+ if (container == null)
|
||||
+ {
|
||||
+ p_71007_1_.closeInventory(); // Cauldron - prevent chest from being stuck in open state on clients
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
this.getNextWindowId();
|
||||
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 0, p_71007_1_.getInventoryName(), p_71007_1_.getSizeInventory(), p_71007_1_.hasCustomInventoryName()));
|
||||
- this.openContainer = new ContainerChest(this.inventory, p_71007_1_);
|
||||
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
|
||||
this.openContainer.windowId = this.currentWindowId;
|
||||
this.openContainer.addCraftingToCrafters(this);
|
||||
}
|
||||
|
||||
public void func_146093_a(TileEntityHopper p_146093_1_)
|
||||
{
|
||||
+ // CraftBukkit start - Inventory open hook
|
||||
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHopper(this.inventory, p_146093_1_));
|
||||
+
|
||||
+ if (container == null)
|
||||
+ {
|
||||
+ p_146093_1_.closeInventory(); // Cauldron - prevent chest from being stuck in open state on clients
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
this.getNextWindowId();
|
||||
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 9, p_146093_1_.getInventoryName(), p_146093_1_.getSizeInventory(), p_146093_1_.hasCustomInventoryName()));
|
||||
- this.openContainer = new ContainerHopper(this.inventory, p_146093_1_);
|
||||
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
|
||||
this.openContainer.windowId = this.currentWindowId;
|
||||
this.openContainer.addCraftingToCrafters(this);
|
||||
}
|
||||
|
||||
public void displayGUIHopperMinecart(EntityMinecartHopper p_96125_1_)
|
||||
{
|
||||
+ // CraftBukkit start - Inventory open hook
|
||||
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHopper(this.inventory, p_96125_1_));
|
||||
+
|
||||
+ if (container == null)
|
||||
+ {
|
||||
+ p_96125_1_.closeInventory(); // Cauldron - prevent chest from being stuck in open state on clients
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
this.getNextWindowId();
|
||||
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 9, p_96125_1_.getInventoryName(), p_96125_1_.getSizeInventory(), p_96125_1_.hasCustomInventoryName()));
|
||||
- this.openContainer = new ContainerHopper(this.inventory, p_96125_1_);
|
||||
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
|
||||
this.openContainer.windowId = this.currentWindowId;
|
||||
this.openContainer.addCraftingToCrafters(this);
|
||||
}
|
||||
|
||||
public void func_146101_a(TileEntityFurnace p_146101_1_)
|
||||
{
|
||||
+ // CraftBukkit start - Inventory open hook
|
||||
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerFurnace(this.inventory, p_146101_1_));
|
||||
+
|
||||
+ if (container == null)
|
||||
+ {
|
||||
+ p_146101_1_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
this.getNextWindowId();
|
||||
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 2, p_146101_1_.getInventoryName(), p_146101_1_.getSizeInventory(), p_146101_1_.hasCustomInventoryName()));
|
||||
- this.openContainer = new ContainerFurnace(this.inventory, p_146101_1_);
|
||||
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
|
||||
this.openContainer.windowId = this.currentWindowId;
|
||||
this.openContainer.addCraftingToCrafters(this);
|
||||
}
|
||||
|
||||
public void func_146102_a(TileEntityDispenser p_146102_1_)
|
||||
{
|
||||
+ // CraftBukkit start - Inventory open hook
|
||||
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerDispenser(this.inventory, p_146102_1_));
|
||||
+
|
||||
+ if (container == null)
|
||||
+ {
|
||||
+ p_146102_1_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
this.getNextWindowId();
|
||||
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, p_146102_1_ instanceof TileEntityDropper ? 10 : 3, p_146102_1_.getInventoryName(), p_146102_1_.getSizeInventory(), p_146102_1_.hasCustomInventoryName()));
|
||||
- this.openContainer = new ContainerDispenser(this.inventory, p_146102_1_);
|
||||
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
|
||||
this.openContainer.windowId = this.currentWindowId;
|
||||
this.openContainer.addCraftingToCrafters(this);
|
||||
}
|
||||
|
||||
public void func_146098_a(TileEntityBrewingStand p_146098_1_)
|
||||
{
|
||||
+ // CraftBukkit start - Inventory open hook
|
||||
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerBrewingStand(this.inventory, p_146098_1_));
|
||||
+
|
||||
+ if (container == null)
|
||||
+ {
|
||||
+ p_146098_1_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
this.getNextWindowId();
|
||||
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 5, p_146098_1_.getInventoryName(), p_146098_1_.getSizeInventory(), p_146098_1_.hasCustomInventoryName()));
|
||||
- this.openContainer = new ContainerBrewingStand(this.inventory, p_146098_1_);
|
||||
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
|
||||
this.openContainer.windowId = this.currentWindowId;
|
||||
this.openContainer.addCraftingToCrafters(this);
|
||||
}
|
||||
|
||||
public void func_146104_a(TileEntityBeacon p_146104_1_)
|
||||
{
|
||||
+ // CraftBukkit start - Inventory open hook
|
||||
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerBeacon(this.inventory, p_146104_1_));
|
||||
+
|
||||
+ if (container == null)
|
||||
+ {
|
||||
+ p_146104_1_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
this.getNextWindowId();
|
||||
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 7, p_146104_1_.getInventoryName(), p_146104_1_.getSizeInventory(), p_146104_1_.hasCustomInventoryName()));
|
||||
- this.openContainer = new ContainerBeacon(this.inventory, p_146104_1_);
|
||||
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
|
||||
this.openContainer.windowId = this.currentWindowId;
|
||||
this.openContainer.addCraftingToCrafters(this);
|
||||
}
|
||||
|
||||
public void displayGUIMerchant(IMerchant p_71030_1_, String p_71030_2_)
|
||||
{
|
||||
+ // CraftBukkit start - Inventory open hook
|
||||
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerMerchant(this.inventory, p_71030_1_, this.worldObj));
|
||||
+
|
||||
+ if (container == null)
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
this.getNextWindowId();
|
||||
- this.openContainer = new ContainerMerchant(this.inventory, p_71030_1_, this.worldObj);
|
||||
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
|
||||
this.openContainer.windowId = this.currentWindowId;
|
||||
this.openContainer.addCraftingToCrafters(this);
|
||||
InventoryMerchant inventorymerchant = ((ContainerMerchant)this.openContainer).getMerchantInventory();
|
||||
@@ -725,7 +1019,7 @@
|
||||
merchantrecipelist.func_151391_a(packetbuffer);
|
||||
this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|TrList", packetbuffer));
|
||||
}
|
||||
- catch (IOException ioexception)
|
||||
+ catch (Exception ioexception) // CraftBukkit - IOException -> Exception
|
||||
{
|
||||
logger.error("Couldn\'t send trade list", ioexception);
|
||||
}
|
||||
@@ -738,6 +1032,17 @@
|
||||
|
||||
public void displayGUIHorse(EntityHorse p_110298_1_, IInventory p_110298_2_)
|
||||
{
|
||||
+ // CraftBukkit start - Inventory open hook
|
||||
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHorseInventory(this.inventory, p_110298_2_, p_110298_1_));
|
||||
+
|
||||
+ if (container == null)
|
||||
+ {
|
||||
+ p_110298_2_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (this.openContainer != this.inventoryContainer)
|
||||
{
|
||||
this.closeScreen();
|
||||
@@ -745,7 +1050,7 @@
|
||||
|
||||
this.getNextWindowId();
|
||||
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 11, p_110298_2_.getInventoryName(), p_110298_2_.getSizeInventory(), p_110298_2_.hasCustomInventoryName(), p_110298_1_.getEntityId()));
|
||||
- this.openContainer = new ContainerHorseInventory(this.inventory, p_110298_2_, p_110298_1_);
|
||||
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
|
||||
this.openContainer.windowId = this.currentWindowId;
|
||||
this.openContainer.addCraftingToCrafters(this);
|
||||
}
|
||||
@@ -770,6 +1075,15 @@
|
||||
{
|
||||
this.playerNetServerHandler.sendPacket(new S30PacketWindowItems(p_71110_1_.windowId, p_71110_2_));
|
||||
this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(-1, -1, this.inventory.getItemStack()));
|
||||
+
|
||||
+ if (p_71110_1_.getBukkitView() == null) return; // Cauldron - allow vanilla mods to bypass
|
||||
+ // CraftBukkit start - Send a Set Slot to update the crafting result slot
|
||||
+ if (java.util.EnumSet.of(InventoryType.CRAFTING, InventoryType.WORKBENCH).contains(p_71110_1_.getBukkitView().getType()))
|
||||
+ {
|
||||
+ this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(p_71110_1_.windowId, 0, p_71110_1_.getSlot(0).getStack()));
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public void sendProgressBarUpdate(Container p_71112_1_, int p_71112_2_, int p_71112_3_)
|
||||
@@ -779,6 +1093,7 @@
|
||||
|
||||
public void closeScreen()
|
||||
{
|
||||
+ CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit
|
||||
this.playerNetServerHandler.sendPacket(new S2EPacketCloseWindow(this.openContainer.windowId));
|
||||
this.closeContainer();
|
||||
}
|
||||
@@ -853,8 +1168,19 @@
|
||||
public void setPlayerHealthUpdated()
|
||||
{
|
||||
this.lastHealth = -1.0E8F;
|
||||
+ this.lastExperience = -1; // CraftBukkit - Added to reset
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Support multi-line messages
|
||||
+ public void sendMessage(IChatComponent[] ichatcomponent)
|
||||
+ {
|
||||
+ for (IChatComponent component : ichatcomponent)
|
||||
+ {
|
||||
+ this.addChatComponentMessage(component);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void addChatComponentMessage(IChatComponent p_146105_1_)
|
||||
{
|
||||
this.playerNetServerHandler.sendPacket(new S02PacketChat(p_146105_1_));
|
||||
@@ -1037,6 +1363,114 @@
|
||||
return this.field_143005_bX;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public long timeOffset = 0;
|
||||
+ public boolean relativeTime = true;
|
||||
+
|
||||
+ public long getPlayerTime()
|
||||
+ {
|
||||
+ if (this.relativeTime)
|
||||
+ {
|
||||
+ // Adds timeOffset to the current server time.
|
||||
+ return this.worldObj.getWorldTime() + this.timeOffset;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ // Adds timeOffset to the beginning of this day.
|
||||
+ return this.worldObj.getWorldTime() - (this.worldObj.getWorldTime() % 24000) + this.timeOffset;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public WeatherType weather = null;
|
||||
+
|
||||
+ public WeatherType getPlayerWeather()
|
||||
+ {
|
||||
+ return this.weather;
|
||||
+ }
|
||||
+
|
||||
+ public void setPlayerWeather(WeatherType type, boolean plugin)
|
||||
+ {
|
||||
+ if (!plugin && this.weather != null)
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (plugin)
|
||||
+ {
|
||||
+ this.weather = type;
|
||||
+ }
|
||||
+
|
||||
+ if (type == WeatherType.DOWNFALL)
|
||||
+ {
|
||||
+ this.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(2, 0));
|
||||
+ // this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, this.world.j(1.0F)));
|
||||
+ // this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, this.world.h(1.0F)));
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ this.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(1, 0));
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public void resetPlayerWeather()
|
||||
+ {
|
||||
+ this.weather = null;
|
||||
+ this.setPlayerWeather(this.worldObj.getWorldInfo().isRaining() ? WeatherType.DOWNFALL : WeatherType.CLEAR, false);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public String toString()
|
||||
+ {
|
||||
+ return super.toString() + "(" + this.getCommandSenderName() + " at " + this.posX + "," + this.posY + "," + this.posZ + ")";
|
||||
+ }
|
||||
+
|
||||
+ public void reset()
|
||||
+ {
|
||||
+ float exp = 0;
|
||||
+ boolean keepInventory = this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory");
|
||||
+
|
||||
+ if (this.keepLevel || keepInventory)
|
||||
+ {
|
||||
+ exp = this.experience;
|
||||
+ this.newTotalExp = this.experienceTotal;
|
||||
+ this.newLevel = this.experienceLevel;
|
||||
+ }
|
||||
+
|
||||
+ this.setHealth(this.getMaxHealth());
|
||||
+ this.fire = 0;
|
||||
+ this.fallDistance = 0;
|
||||
+ this.foodStats = new FoodStats(this);
|
||||
+ this.experienceLevel = this.newLevel;
|
||||
+ this.experienceTotal = this.newTotalExp;
|
||||
+ this.experience = 0;
|
||||
+ this.deathTime = 0;
|
||||
+ this.clearActivePotions(); // Should be remapped: removeAllEffects should be remapped to this.
|
||||
+ super.potionsNeedUpdate = true; // Cauldron - change to super to temporarily workaround remapping bug with SpecialSource
|
||||
+ this.openContainer = this.inventoryContainer;
|
||||
+ this.attackingPlayer = null;
|
||||
+ this.entityLivingToAttack = null;
|
||||
+ this._combatTracker = new CombatTracker(this);
|
||||
+ this.lastExperience = -1;
|
||||
+
|
||||
+ if (this.keepLevel || keepInventory)
|
||||
+ {
|
||||
+ this.experience = exp;
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ this.addExperience(this.newExp);
|
||||
+ }
|
||||
+
|
||||
+ this.keepLevel = false;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public CraftPlayer getBukkitEntity()
|
||||
+ {
|
||||
+ return (CraftPlayer) super.getBukkitEntity();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
/* ===================================== FORGE START =====================================*/
|
||||
/**
|
||||
* Returns the default eye height of the player
|
140
patches/net/minecraft/entity/player/InventoryPlayer.java.patch
Normal file
140
patches/net/minecraft/entity/player/InventoryPlayer.java.patch
Normal file
@ -0,0 +1,140 @@
|
||||
--- ../src-base/minecraft/net/minecraft/entity/player/InventoryPlayer.java
|
||||
+++ ../src-work/minecraft/net/minecraft/entity/player/InventoryPlayer.java
|
||||
@@ -2,7 +2,9 @@
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
+
|
||||
import java.util.concurrent.Callable;
|
||||
+
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.crash.CrashReport;
|
||||
import net.minecraft.crash.CrashReportCategory;
|
||||
@@ -13,7 +15,13 @@
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.util.ReportedException;
|
||||
+// CraftBukkit start
|
||||
+import java.util.List;
|
||||
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class InventoryPlayer implements IInventory
|
||||
{
|
||||
public ItemStack[] mainInventory = new ItemStack[36];
|
||||
@@ -25,7 +33,46 @@
|
||||
private ItemStack itemStack;
|
||||
public boolean inventoryChanged;
|
||||
private static final String __OBFID = "CL_00001709";
|
||||
+ // CraftBukkit start
|
||||
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
+ private int maxStack = MAX_STACK;
|
||||
|
||||
+ public ItemStack[] getContents()
|
||||
+ {
|
||||
+ return this.mainInventory;
|
||||
+ }
|
||||
+
|
||||
+ public ItemStack[] getArmorContents()
|
||||
+ {
|
||||
+ return this.armorInventory;
|
||||
+ }
|
||||
+
|
||||
+ public void onOpen(CraftHumanEntity who)
|
||||
+ {
|
||||
+ transaction.add(who);
|
||||
+ }
|
||||
+
|
||||
+ public void onClose(CraftHumanEntity who)
|
||||
+ {
|
||||
+ transaction.remove(who);
|
||||
+ }
|
||||
+
|
||||
+ public List<HumanEntity> getViewers()
|
||||
+ {
|
||||
+ return transaction;
|
||||
+ }
|
||||
+
|
||||
+ public org.bukkit.inventory.InventoryHolder getOwner()
|
||||
+ {
|
||||
+ return this.player.getBukkitEntity();
|
||||
+ }
|
||||
+
|
||||
+ public void setMaxStackSize(int size)
|
||||
+ {
|
||||
+ maxStack = size;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public InventoryPlayer(EntityPlayer p_i1750_1_)
|
||||
{
|
||||
this.player = p_i1750_1_;
|
||||
@@ -81,6 +128,34 @@
|
||||
return -1;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Watch method above! :D
|
||||
+ public int canHold(ItemStack itemstack)
|
||||
+ {
|
||||
+ int remains = itemstack.stackSize;
|
||||
+
|
||||
+ for (int i = 0; i < this.mainInventory.length; ++i)
|
||||
+ {
|
||||
+ if (this.mainInventory[i] == null)
|
||||
+ {
|
||||
+ return itemstack.stackSize;
|
||||
+ }
|
||||
+
|
||||
+ // Taken from firstPartial(ItemStack)
|
||||
+ if (this.mainInventory[i] != null && this.mainInventory[i].getItem() == itemstack.getItem() && this.mainInventory[i].isStackable() && this.mainInventory[i].stackSize < this.mainInventory[i].getMaxStackSize() && this.mainInventory[i].stackSize < this.getInventoryStackLimit() && (!this.mainInventory[i].getHasSubtypes() || this.mainInventory[i].getItemDamage() == itemstack.getItemDamage()) && ItemStack.areItemStackTagsEqual(this.mainInventory[i], itemstack))
|
||||
+ {
|
||||
+ remains -= (this.mainInventory[i].getMaxStackSize() < this.getInventoryStackLimit() ? this.mainInventory[i].getMaxStackSize() : this.getInventoryStackLimit()) - this.mainInventory[i].stackSize;
|
||||
+ }
|
||||
+
|
||||
+ if (remains <= 0)
|
||||
+ {
|
||||
+ return itemstack.stackSize;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return itemstack.stackSize - remains;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public int getFirstEmptyStack()
|
||||
{
|
||||
for (int i = 0; i < this.mainInventory.length; ++i)
|
||||
@@ -658,7 +733,7 @@
|
||||
if (this.mainInventory[i] != null)
|
||||
{
|
||||
this.player.func_146097_a(this.mainInventory[i], true, false);
|
||||
- this.mainInventory[i] = null;
|
||||
+ //this.mainInventory[i] = null; // Cauldron - we clear this in EntityPlayerMP.onDeath after PlayerDeathEvent
|
||||
}
|
||||
}
|
||||
|
||||
@@ -667,7 +742,7 @@
|
||||
if (this.armorInventory[i] != null)
|
||||
{
|
||||
this.player.func_146097_a(this.armorInventory[i], true, false);
|
||||
- this.armorInventory[i] = null;
|
||||
+ //this.armorInventory[i] = null; // Cauldron - we clear this in EntityPlayerMP.onDeath after PlayerDeathEvent
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -684,6 +759,13 @@
|
||||
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
+ // CraftBukkit start
|
||||
+ if (this.itemStack != null && this.itemStack.stackSize == 0)
|
||||
+ {
|
||||
+ this.setItemStack(null);
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
return this.itemStack;
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
--- ../src-base/minecraft/net/minecraft/entity/player/PlayerCapabilities.java
|
||||
+++ ../src-work/minecraft/net/minecraft/entity/player/PlayerCapabilities.java
|
||||
@@ -11,8 +11,8 @@
|
||||
public boolean allowFlying;
|
||||
public boolean isCreativeMode;
|
||||
public boolean allowEdit = true;
|
||||
- private float flySpeed = 0.05F;
|
||||
- private float walkSpeed = 0.1F;
|
||||
+ public float flySpeed = 0.05F; // CraftBukkit private -> public
|
||||
+ public float walkSpeed = 0.1F; // CraftBukkit private -> public
|
||||
private static final String __OBFID = "CL_00001708";
|
||||
|
||||
public void writeCapabilitiesToNBT(NBTTagCompound p_75091_1_)
|
Reference in New Issue
Block a user