247 lines
9.0 KiB
Diff
247 lines
9.0 KiB
Diff
--- ../src_base/minecraft/net/minecraft/src/EntityPlayer.java 0000-00-00 00:00:00.000000000 -0000
|
|
+++ ../src_work/minecraft/net/minecraft/src/EntityPlayer.java 0000-00-00 00:00:00.000000000 -0000
|
|
@@ -7,6 +7,8 @@
|
|
import cpw.mods.fml.common.FMLCommonHandler;
|
|
import cpw.mods.fml.common.TickType;
|
|
|
|
+import net.minecraft.src.forge.*;
|
|
+
|
|
public abstract class EntityPlayer extends EntityLiving
|
|
{
|
|
/** Inventory of the player */
|
|
@@ -215,6 +217,7 @@
|
|
}
|
|
else
|
|
{
|
|
+ itemInUse.getItem().onUsingItemTick(itemInUse, this, itemInUseCount);
|
|
if (this.itemInUseCount <= 25 && this.itemInUseCount % 4 == 0)
|
|
{
|
|
this.updateItemUse(var1, 5);
|
|
@@ -624,7 +627,16 @@
|
|
*/
|
|
public EntityItem dropOneItem()
|
|
{
|
|
- return this.dropPlayerItemWithRandomChoice(this.inventory.decrStackSize(this.inventory.currentItem, 1), false);
|
|
+ ItemStack stack = inventory.getCurrentItem();
|
|
+ if (stack == null)
|
|
+ {
|
|
+ return null;
|
|
+ }
|
|
+ if (stack.getItem().onDroppedByPlayer(stack, this))
|
|
+ {
|
|
+ return dropPlayerItemWithRandomChoice(inventory.decrStackSize(inventory.currentItem, 1), false);
|
|
+ }
|
|
+ return null;
|
|
}
|
|
|
|
/**
|
|
@@ -690,14 +702,22 @@
|
|
|
|
/**
|
|
* Returns how strong the player is against the specified block at this moment
|
|
+ * Deprecated in favor of the metadata-sensitive version
|
|
*/
|
|
+ @Deprecated
|
|
public float getCurrentPlayerStrVsBlock(Block par1Block)
|
|
{
|
|
- float var2 = this.inventory.getStrVsBlock(par1Block);
|
|
+ return getCurrentPlayerStrVsBlock(par1Block, 0);
|
|
+ }
|
|
+
|
|
+ public float getCurrentPlayerStrVsBlock(Block par1Block, int meta)
|
|
+ {
|
|
+ ItemStack stack = inventory.getCurrentItem();
|
|
+ float var2 = (stack == null ? 1.0F : stack.getItem().getStrVsBlock(stack, par1Block, meta));
|
|
float var3 = var2;
|
|
int var4 = EnchantmentHelper.getEfficiencyModifier(this.inventory);
|
|
|
|
- if (var4 > 0 && this.inventory.canHarvestBlock(par1Block))
|
|
+ if (var4 > 0 && ForgeHooks.canHarvestBlock(par1Block, this, meta))
|
|
{
|
|
var3 = var2 + (float)(var4 * var4 + 1);
|
|
}
|
|
@@ -984,12 +1004,22 @@
|
|
*/
|
|
protected void damageEntity(DamageSource par1DamageSource, int par2)
|
|
{
|
|
+ par2 = ForgeHooks.onEntityLivingHurt(this, par1DamageSource, par2);
|
|
+ if (par2 == 0)
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
+
|
|
if (!par1DamageSource.isUnblockable() && this.isBlocking())
|
|
{
|
|
par2 = 1 + par2 >> 1;
|
|
}
|
|
|
|
- par2 = this.applyArmorCalculations(par1DamageSource, par2);
|
|
+ par2 = ArmorProperties.ApplyArmor(this, inventory.armorInventory, par1DamageSource, par2);
|
|
+ if (par2 <= 0)
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
par2 = this.applyPotionDamageCalculations(par1DamageSource, par2);
|
|
this.addExhaustion(par1DamageSource.getHungerDamage());
|
|
this.health -= par2;
|
|
@@ -1020,6 +1050,10 @@
|
|
*/
|
|
public void useCurrentItemOnEntity(Entity par1Entity)
|
|
{
|
|
+ if (!ForgeHooks.onEntityInteract(this, par1Entity, false))
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
if (!par1Entity.interact(this))
|
|
{
|
|
ItemStack var2 = this.getCurrentEquippedItem();
|
|
@@ -1050,7 +1084,9 @@
|
|
*/
|
|
public void destroyCurrentEquippedItem()
|
|
{
|
|
+ ItemStack orig = inventory.getCurrentItem();
|
|
this.inventory.setInventorySlotContents(this.inventory.currentItem, (ItemStack)null);
|
|
+ ForgeHooks.onDestroyCurrentItem(this, orig);
|
|
}
|
|
|
|
/**
|
|
@@ -1079,6 +1115,15 @@
|
|
*/
|
|
public void attackTargetEntityWithCurrentItem(Entity par1Entity)
|
|
{
|
|
+ if (!ForgeHooks.onEntityInteract(this, par1Entity, true))
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
+ ItemStack stack = getCurrentEquippedItem();
|
|
+ if (stack != null && stack.getItem().onLeftClickEntity(stack, this, par1Entity))
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
if (par1Entity.canAttackWithItem())
|
|
{
|
|
int var2 = this.inventory.getDamageVsEntity(par1Entity);
|
|
@@ -1221,6 +1266,12 @@
|
|
*/
|
|
public EnumStatus sleepInBedAt(int par1, int par2, int par3)
|
|
{
|
|
+ EnumStatus customSleep = ForgeHooks.sleepInBedAt(this, par1, par2, par3);
|
|
+ if (customSleep != null)
|
|
+ {
|
|
+ return customSleep;
|
|
+ }
|
|
+
|
|
if (!this.worldObj.isRemote)
|
|
{
|
|
if (this.isPlayerSleeping() || !this.isEntityAlive())
|
|
@@ -1260,6 +1311,11 @@
|
|
{
|
|
int var9 = this.worldObj.getBlockMetadata(par1, par2, par3);
|
|
int var5 = BlockBed.getDirection(var9);
|
|
+ Block block = Block.blocksList[worldObj.getBlockId(par1, par2, par3)];
|
|
+ if (block != null)
|
|
+ {
|
|
+ var5 = block.getBedDirection(worldObj, par1, par2, par3);
|
|
+ }
|
|
float var10 = 0.5F;
|
|
float var7 = 0.5F;
|
|
|
|
@@ -1329,11 +1385,12 @@
|
|
this.resetHeight();
|
|
ChunkCoordinates var4 = this.playerLocation;
|
|
ChunkCoordinates var5 = this.playerLocation;
|
|
+ Block block = (var4 == null ? null : Block.blocksList[worldObj.getBlockId(var4.posX, var4.posY, var4.posZ)]);
|
|
|
|
- if (var4 != null && this.worldObj.getBlockId(var4.posX, var4.posY, var4.posZ) == Block.bed.blockID)
|
|
+ if (var4 != null && block != null && block.isBed(worldObj, var4.posX, var4.posY, var4.posZ, this))
|
|
{
|
|
- BlockBed.setBedOccupied(this.worldObj, var4.posX, var4.posY, var4.posZ, false);
|
|
- var5 = BlockBed.getNearestEmptyChunkCoordinates(this.worldObj, var4.posX, var4.posY, var4.posZ, 0);
|
|
+ block.setBedOccupied(this.worldObj, var4.posX, var4.posY, var4.posZ, this, false);
|
|
+ var5 = block.getBedSpawnPosition(worldObj, var4.posX, var4.posY, var4.posZ, this);
|
|
|
|
if (var5 == null)
|
|
{
|
|
@@ -1370,7 +1427,9 @@
|
|
*/
|
|
private boolean isInBed()
|
|
{
|
|
- return this.worldObj.getBlockId(this.playerLocation.posX, this.playerLocation.posY, this.playerLocation.posZ) == Block.bed.blockID;
|
|
+ ChunkCoordinates c = playerLocation;
|
|
+ int blockID = worldObj.getBlockId(c.posX, c.posY, c.posZ);
|
|
+ return Block.blocksList[blockID] != null && Block.blocksList[blockID].isBed(worldObj, c.posX, c.posY, c.posZ, this);
|
|
}
|
|
|
|
/**
|
|
@@ -1385,13 +1444,15 @@
|
|
var2.loadChunk(par1ChunkCoordinates.posX - 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4);
|
|
var2.loadChunk(par1ChunkCoordinates.posX + 3 >> 4, par1ChunkCoordinates.posZ + 3 >> 4);
|
|
|
|
- if (par0World.getBlockId(par1ChunkCoordinates.posX, par1ChunkCoordinates.posY, par1ChunkCoordinates.posZ) != Block.bed.blockID)
|
|
+ ChunkCoordinates c = par1ChunkCoordinates;
|
|
+ Block block = Block.blocksList[par0World.getBlockId(c.posX, c.posY, c.posZ)];
|
|
+ if (block == null || !block.isBed(par0World, c.posX, c.posY, c.posZ, null))
|
|
{
|
|
return null;
|
|
}
|
|
else
|
|
{
|
|
- ChunkCoordinates var3 = BlockBed.getNearestEmptyChunkCoordinates(par0World, par1ChunkCoordinates.posX, par1ChunkCoordinates.posY, par1ChunkCoordinates.posZ, 0);
|
|
+ ChunkCoordinates var3 = block.getBedSpawnPosition(par0World, c.posX, c.posY, c.posZ, null);
|
|
return var3;
|
|
}
|
|
}
|
|
@@ -1403,8 +1464,11 @@
|
|
{
|
|
if (this.playerLocation != null)
|
|
{
|
|
- int var1 = this.worldObj.getBlockMetadata(this.playerLocation.posX, this.playerLocation.posY, this.playerLocation.posZ);
|
|
- int var2 = BlockBed.getDirection(var1);
|
|
+ int x = playerLocation.posX;
|
|
+ int y = playerLocation.posY;
|
|
+ int z = playerLocation.posZ;
|
|
+ Block block = Block.blocksList[worldObj.getBlockId(x, y, z)];
|
|
+ int var2 = (block == null ? 0 : block.getBedDirection(worldObj, x, y, z));
|
|
|
|
switch (var2)
|
|
{
|
|
@@ -1694,6 +1758,7 @@
|
|
return 101;
|
|
}
|
|
}
|
|
+ var3 = par1ItemStack.getItem().getIconIndex(par1ItemStack, par2, this, itemInUse, itemInUseCount);
|
|
}
|
|
|
|
return var3;
|
|
@@ -1866,4 +1931,30 @@
|
|
}
|
|
|
|
public void func_50009_aI() {}
|
|
+
|
|
+ /**
|
|
+ * Opens a Gui for the player.
|
|
+ *
|
|
+ * @param mod The mod associated with the gui
|
|
+ * @param ID The ID number for the Gui
|
|
+ * @param world The World
|
|
+ * @param x X Position
|
|
+ * @param y Y Position
|
|
+ * @param z Z Position
|
|
+ */
|
|
+ public void openGui(BaseMod mod, int ID, World world, int x, int y, int z)
|
|
+ {
|
|
+ if (this instanceof EntityPlayerSP)
|
|
+ {
|
|
+ IGuiHandler handler = MinecraftForge.getGuiHandler(mod);
|
|
+ if (handler != null)
|
|
+ {
|
|
+ GuiScreen screen = (GuiScreen)handler.getGuiElement(ID, this, world, x, y, z);
|
|
+ if (screen != null)
|
|
+ {
|
|
+ ModLoader.getMinecraftInstance().displayGuiScreen(screen);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ }
|
|
}
|