Added section of the EntityData NBT that will be persisted for players across respawning.

This commit is contained in:
LexManos 2012-11-27 16:52:08 -08:00
parent 4a748beb69
commit e5231f306b
1 changed files with 44 additions and 25 deletions

View File

@ -1,10 +1,9 @@
--- ../src_base/common/net/minecraft/src/EntityPlayer.java
+++ ../src_work/common/net/minecraft/src/EntityPlayer.java
@@ -7,6 +7,17 @@
@@ -8,8 +8,21 @@
import java.util.Iterator;
import java.util.List;
+
+import net.minecraftforge.common.ForgeHooks;
+import net.minecraftforge.common.ISpecialArmor.ArmorProperties;
+import net.minecraftforge.common.MinecraftForge;
@ -15,10 +14,15 @@
+import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
+import net.minecraftforge.event.entity.player.PlayerDropsEvent;
+import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
+
public abstract class EntityPlayer extends EntityLiving implements ICommandSender
{
@@ -212,6 +223,7 @@
+ public static final String PERSISTED_NBT_TAG = "PlayerPersisted";
+
/** Inventory of the player */
public InventoryPlayer inventory = new InventoryPlayer(this);
private InventoryEnderChest theInventoryEnderChest = new InventoryEnderChest();
@@ -212,6 +225,7 @@
if (var1 == this.itemInUse)
{
@ -26,7 +30,7 @@
if (this.itemInUseCount <= 25 && this.itemInUseCount % 4 == 0)
{
this.updateItemUse(var1, 5);
@@ -450,11 +462,11 @@
@@ -450,11 +464,11 @@
this.cameraYaw = 0.0F;
this.addMountedMovementStat(this.posX - var1, this.posY - var3, this.posZ - var5);
@ -40,7 +44,7 @@
}
}
@@ -577,6 +589,9 @@
@@ -577,6 +591,9 @@
this.setPosition(this.posX, this.posY, this.posZ);
this.motionY = 0.10000000149011612D;
@ -50,7 +54,7 @@
if (this.username.equals("Notch"))
{
this.dropPlayerItemWithRandomChoice(new ItemStack(Item.appleRed, 1), true);
@@ -585,6 +600,20 @@
@@ -585,6 +602,20 @@
if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory"))
{
this.inventory.dropAllItems();
@ -71,7 +75,7 @@
}
if (par1DamageSource != null)
@@ -624,7 +653,16 @@
@@ -624,7 +655,16 @@
*/
public EntityItem dropOneItem()
{
@ -89,7 +93,7 @@
}
/**
@@ -633,7 +671,7 @@
@@ -633,7 +673,7 @@
*/
public EntityItem dropPlayerItem(ItemStack par1ItemStack)
{
@ -98,7 +102,7 @@
}
/**
@@ -685,18 +723,33 @@
@@ -685,18 +725,33 @@
*/
public void joinEntityItemWithWorld(EntityItem par1EntityItem)
{
@ -136,7 +140,7 @@
{
var2 += (float)(var3 * var3 + 1);
}
@@ -721,7 +774,8 @@
@@ -721,7 +776,8 @@
var2 /= 5.0F;
}
@ -146,7 +150,7 @@
}
/**
@@ -729,7 +783,7 @@
@@ -729,7 +785,7 @@
*/
public boolean canHarvestBlock(Block par1Block)
{
@ -155,7 +159,7 @@
}
/**
@@ -1014,12 +1068,22 @@
@@ -1014,12 +1070,22 @@
{
if (!this.func_85032_ar())
{
@ -179,7 +183,7 @@
par2 = this.applyPotionDamageCalculations(par1DamageSource, par2);
this.addExhaustion(par1DamageSource.getHungerDamage());
this.health -= par2;
@@ -1060,6 +1124,10 @@
@@ -1060,6 +1126,10 @@
public boolean interactWith(Entity par1Entity)
{
@ -190,7 +194,7 @@
if (par1Entity.interact(this))
{
return true;
@@ -1103,7 +1171,9 @@
@@ -1103,7 +1173,9 @@
*/
public void destroyCurrentEquippedItem()
{
@ -200,7 +204,7 @@
}
/**
@@ -1120,6 +1190,15 @@
@@ -1120,6 +1192,15 @@
*/
public void attackTargetEntityWithCurrentItem(Entity par1Entity)
{
@ -216,7 +220,7 @@
if (par1Entity.canAttackWithItem())
{
if (!par1Entity.func_85031_j(this))
@@ -1278,6 +1357,12 @@
@@ -1278,6 +1359,12 @@
*/
public EnumStatus sleepInBedAt(int par1, int par2, int par3)
{
@ -229,7 +233,7 @@
if (!this.worldObj.isRemote)
{
if (this.isPlayerSleeping() || !this.isEntityAlive())
@@ -1317,6 +1402,11 @@
@@ -1317,6 +1404,11 @@
{
int var9 = this.worldObj.getBlockMetadata(par1, par2, par3);
int var5 = BlockBed.getDirection(var9);
@ -241,7 +245,7 @@
float var10 = 0.5F;
float var7 = 0.5F;
@@ -1387,10 +1477,12 @@
@@ -1387,10 +1479,12 @@
ChunkCoordinates var4 = this.playerLocation;
ChunkCoordinates var5 = this.playerLocation;
@ -258,7 +262,7 @@
if (var5 == null)
{
@@ -1427,7 +1519,9 @@
@@ -1427,7 +1521,9 @@
*/
private boolean isInBed()
{
@ -269,7 +273,7 @@
}
/**
@@ -1442,9 +1536,12 @@
@@ -1442,9 +1538,12 @@
var3.loadChunk(par1ChunkCoordinates.posX - 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4);
var3.loadChunk(par1ChunkCoordinates.posX + 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4);
@ -285,7 +289,7 @@
return var8;
}
else
@@ -1466,8 +1563,11 @@
@@ -1466,8 +1565,11 @@
{
if (this.playerLocation != null)
{
@ -299,7 +303,7 @@
switch (var2)
{
@@ -1776,7 +1876,7 @@
@@ -1776,7 +1878,7 @@
{
if (par1ItemStack.getItem().requiresMultipleRenderPasses())
{
@ -308,7 +312,7 @@
}
if (this.itemInUse != null && par1ItemStack.itemID == Item.bow.shiftedIndex)
@@ -1798,6 +1898,7 @@
@@ -1798,6 +1900,7 @@
return 101;
}
}
@ -316,3 +320,18 @@
}
return var3;
@@ -2016,6 +2119,14 @@
}
this.theInventoryEnderChest = par1EntityPlayer.theInventoryEnderChest;
+
+ //Copy over a section of the Entity Data from the old player.
+ //Allows mods to specify data that persists after players respawn.
+ NBTTagCompound old = par1EntityPlayer.getEntityData();
+ if (old.hasKey(PERSISTED_NBT_TAG))
+ {
+ getEntityData().setCompoundTag(PERSISTED_NBT_TAG, old.getCompoundTag(PERSISTED_NBT_TAG));
+ }
}
/**