From 95481e1cd21f413411789d4ff7466428d54fcfbe Mon Sep 17 00:00:00 2001 From: Eloraam Date: Wed, 11 Jan 2012 19:40:04 +0000 Subject: [PATCH] Improved the ladder hook. Added a new hook for sustained-use items. --- .../net/minecraft/src/Block.java.patch | 12 ++++++++++- .../net/minecraft/src/BlockLadder.java.patch | 2 +- .../net/minecraft/src/EntityLiving.java.patch | 2 +- .../net/minecraft/src/EntityPlayer.java.patch | 20 +++++++++++++------ .../net/minecraft/src/Item.java.patch | 9 +++++++-- .../net/minecraft/src/Block.java.patch | 12 ++++++++++- .../net/minecraft/src/BlockLadder.java.patch | 2 +- .../net/minecraft/src/EntityLiving.java.patch | 2 +- .../net/minecraft/src/EntityPlayer.java.patch | 20 +++++++++++++------ .../net/minecraft/src/Item.java.patch | 9 +++++++-- 10 files changed, 68 insertions(+), 22 deletions(-) diff --git a/patches/minecraft/net/minecraft/src/Block.java.patch b/patches/minecraft/net/minecraft/src/Block.java.patch index cbfffae00e..8b3382e8d7 100644 --- a/patches/minecraft/net/minecraft/src/Block.java.patch +++ b/patches/minecraft/net/minecraft/src/Block.java.patch @@ -139,7 +139,7 @@ { ItemStack itemstack = createStackedBlock(l); if(itemstack != null) -@@ -805,6 +848,238 @@ +@@ -805,6 +848,248 @@ return iblockaccess.isBlockNormalCube(i, j, k) ? 0.2F : 1.0F; } @@ -151,11 +151,21 @@ + + /* FORGE: Implement and return true if you wish this block to behave + * like a ladder when the player is inside. ++ * ++ * This is deprecated in favor of the more flexible version below. + */ ++ @Deprecated + public boolean isLadder() { + return false; + } + ++ /* FORGE: Implement and return true if you wish this block to behave ++ * like a ladder when the player is inside. ++ */ ++ public boolean isLadder(World world, int i, int j, int k) { ++ return isLadder(); ++ } ++ + /* FORGE: Return true if the block is a normal, solid cube. This + * determines indirect power state, entity ejection from blocks, and a few + * others. diff --git a/patches/minecraft/net/minecraft/src/BlockLadder.java.patch b/patches/minecraft/net/minecraft/src/BlockLadder.java.patch index 78010cb2ad..d5da8578b2 100644 --- a/patches/minecraft/net/minecraft/src/BlockLadder.java.patch +++ b/patches/minecraft/net/minecraft/src/BlockLadder.java.patch @@ -5,7 +5,7 @@ } + /* FORGE: Implemented base method, see Block.isLadder */ -+ public boolean isLadder() { ++ public boolean isLadder(World world, int i, int j, int k) { + return true; + } + diff --git a/patches/minecraft/net/minecraft/src/EntityLiving.java.patch b/patches/minecraft/net/minecraft/src/EntityLiving.java.patch index c452466fbc..65bccb036d 100644 --- a/patches/minecraft/net/minecraft/src/EntityLiving.java.patch +++ b/patches/minecraft/net/minecraft/src/EntityLiving.java.patch @@ -7,7 +7,7 @@ - return worldObj.getBlockId(i, j, k) == Block.ladder.blockID; + Block block=Block.blocksList[worldObj.getBlockId(i,j,k)]; + if(block==null) return false; -+ return block.isLadder(); ++ return block.isLadder(worldObj,i,j,k); } public void writeEntityToNBT(NBTTagCompound nbttagcompound) diff --git a/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch b/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch index a23b43ffde..104d171a0d 100644 --- a/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch +++ b/patches/minecraft/net/minecraft/src/EntityPlayer.java.patch @@ -11,7 +11,15 @@ import java.util.*; // Referenced classes of package net.minecraft.src: -@@ -502,7 +506,16 @@ +@@ -166,6 +170,7 @@ + clearItemInUse(); + } else + { ++ itemInUse.getItem().onUsingItemTick(itemInUse,this,itemInUseCount); + if(itemInUseCount <= 25 && itemInUseCount % 4 == 0) + { + func_35201_a(itemstack, 5); +@@ -502,7 +507,16 @@ public void dropCurrentItem() { @@ -29,7 +37,7 @@ } public void dropPlayerItem(ItemStack itemstack) -@@ -548,6 +561,8 @@ +@@ -548,6 +562,8 @@ worldObj.spawnEntityInWorld(entityitem); } @@ -38,7 +46,7 @@ public float getCurrentPlayerStrVsBlock(Block block) { float f = inventory.getStrVsBlock(block); -@@ -576,6 +591,45 @@ +@@ -576,6 +592,45 @@ return f1; } @@ -84,7 +92,7 @@ public boolean canHarvestBlock(Block block) { return inventory.canHarvestBlock(block); -@@ -774,6 +828,25 @@ +@@ -774,6 +829,25 @@ protected void damageEntity(DamageSource damagesource, int i) { @@ -110,7 +118,7 @@ if(!damagesource.isUnblockable() && func_35162_ad()) { i = 1 + i >> 1; -@@ -825,7 +898,9 @@ +@@ -825,7 +899,9 @@ public void destroyCurrentEquippedItem() { @@ -120,7 +128,7 @@ } public double getYOffset() -@@ -957,6 +1032,10 @@ +@@ -957,6 +1033,10 @@ public EnumStatus sleepInBedAt(int i, int j, int k) { diff --git a/patches/minecraft/net/minecraft/src/Item.java.patch b/patches/minecraft/net/minecraft/src/Item.java.patch index 2277b4b8f6..7aa53de5f8 100644 --- a/patches/minecraft/net/minecraft/src/Item.java.patch +++ b/patches/minecraft/net/minecraft/src/Item.java.patch @@ -47,7 +47,7 @@ public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { return itemstack; -@@ -278,6 +297,29 @@ +@@ -278,6 +297,34 @@ return maxDamage > 0 && !hasSubtypes; } @@ -73,11 +73,16 @@ + EntityPlayer player) { + return false; + } ++ ++ /* FORGE: Called each tick while using an item. ++ */ ++ public void onUsingItemTick(ItemStack ist, EntityPlayer player, int count) { ++ } + public boolean hitEntity(ItemStack itemstack, EntityLiving entityliving, EntityLiving entityliving1) { return false; -@@ -473,6 +515,32 @@ +@@ -473,6 +520,32 @@ { return 0; } diff --git a/patches/minecraft_server/net/minecraft/src/Block.java.patch b/patches/minecraft_server/net/minecraft/src/Block.java.patch index 4ff735ce38..b0226e2911 100644 --- a/patches/minecraft_server/net/minecraft/src/Block.java.patch +++ b/patches/minecraft_server/net/minecraft/src/Block.java.patch @@ -124,7 +124,7 @@ { ItemStack itemstack = createStackedBlock(l); if(itemstack != null) -@@ -725,6 +767,236 @@ +@@ -725,6 +767,246 @@ return blockMaterial.getMaterialMobility(); } @@ -136,11 +136,21 @@ + + /* FORGE: Implement and return true if you wish this block to behave + * like a ladder when the player is inside. ++ * ++ * This is deprecated in favor of the more flexible version below. + */ ++ @Deprecated + public boolean isLadder() { + return false; + } + ++ /* FORGE: Implement and return true if you wish this block to behave ++ * like a ladder when the player is inside. ++ */ ++ public boolean isLadder(World world, int i, int j, int k) { ++ return isLadder(); ++ } ++ + /* FORGE: Return true if the block is a normal, solid cube. This + * determines indirect power state, entity ejection from blocks, and a few + * others. diff --git a/patches/minecraft_server/net/minecraft/src/BlockLadder.java.patch b/patches/minecraft_server/net/minecraft/src/BlockLadder.java.patch index 2956eb84fe..d5568a8f2c 100644 --- a/patches/minecraft_server/net/minecraft/src/BlockLadder.java.patch +++ b/patches/minecraft_server/net/minecraft/src/BlockLadder.java.patch @@ -5,7 +5,7 @@ } + /* FORGE: Implemented base method, see Block.isLadder */ -+ public boolean isLadder() { ++ public boolean isLadder(World world, int i, int j, int k) { + return true; + } + diff --git a/patches/minecraft_server/net/minecraft/src/EntityLiving.java.patch b/patches/minecraft_server/net/minecraft/src/EntityLiving.java.patch index fcf04d4ffe..f9ce548733 100644 --- a/patches/minecraft_server/net/minecraft/src/EntityLiving.java.patch +++ b/patches/minecraft_server/net/minecraft/src/EntityLiving.java.patch @@ -7,7 +7,7 @@ - return worldObj.getBlockId(i, j, k) == Block.ladder.blockID; + Block block=Block.blocksList[worldObj.getBlockId(i,j,k)]; + if(block==null) return false; -+ return block.isLadder(); ++ return block.isLadder(worldObj,i,j,k); } public void writeEntityToNBT(NBTTagCompound nbttagcompound) diff --git a/patches/minecraft_server/net/minecraft/src/EntityPlayer.java.patch b/patches/minecraft_server/net/minecraft/src/EntityPlayer.java.patch index 996c18ab51..e8041ba4ef 100644 --- a/patches/minecraft_server/net/minecraft/src/EntityPlayer.java.patch +++ b/patches/minecraft_server/net/minecraft/src/EntityPlayer.java.patch @@ -11,7 +11,15 @@ // Referenced classes of package net.minecraft.src: // EntityLiving, InventoryPlayer, FoodStats, PlayerCapabilities, // ContainerPlayer, World, ChunkCoordinates, DataWatcher, -@@ -447,7 +451,16 @@ +@@ -142,6 +146,7 @@ + clearItemInUse(); + } else + { ++ itemInUse.getItem().onUsingItemTick(itemInUse,this,itemInUseCount); + if(itemInUseCount <= 25 && itemInUseCount % 4 == 0) + { + func_35208_b(itemstack, 5); +@@ -447,7 +452,16 @@ public void dropCurrentItem() { @@ -29,7 +37,7 @@ } public void dropPlayerItem(ItemStack itemstack) -@@ -493,6 +506,8 @@ +@@ -493,6 +507,8 @@ worldObj.spawnEntityInWorld(entityitem); } @@ -38,7 +46,7 @@ public float getCurrentPlayerStrVsBlock(Block block) { float f = inventory.getStrVsBlock(block); -@@ -521,6 +536,45 @@ +@@ -521,6 +537,45 @@ return f1; } @@ -84,7 +92,7 @@ public boolean canHarvestBlock(Block block) { return inventory.canHarvestBlock(block); -@@ -718,7 +772,26 @@ +@@ -718,7 +773,26 @@ } protected void damageEntity(DamageSource damagesource, int i) @@ -112,7 +120,7 @@ if(!damagesource.isUnblockable() && func_35180_G()) { i = 1 + i >> 1; -@@ -770,7 +843,9 @@ +@@ -770,7 +844,9 @@ public void destroyCurrentEquippedItem() { @@ -122,7 +130,7 @@ } public double getYOffset() -@@ -896,6 +971,10 @@ +@@ -896,6 +972,10 @@ public EnumStatus sleepInBedAt(int i, int j, int k) { diff --git a/patches/minecraft_server/net/minecraft/src/Item.java.patch b/patches/minecraft_server/net/minecraft/src/Item.java.patch index 937d440b86..fa48d7f955 100644 --- a/patches/minecraft_server/net/minecraft/src/Item.java.patch +++ b/patches/minecraft_server/net/minecraft/src/Item.java.patch @@ -47,7 +47,7 @@ public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { return itemstack; -@@ -266,6 +285,29 @@ +@@ -266,6 +285,34 @@ return maxDamage > 0 && !hasSubtypes; } @@ -73,11 +73,16 @@ + EntityPlayer player) { + return false; + } ++ ++ /* FORGE: Called each tick while using an item. ++ */ ++ public void onUsingItemTick(ItemStack ist, EntityPlayer player, int count) { ++ } + public boolean hitEntity(ItemStack itemstack, EntityLiving entityliving, EntityLiving entityliving1) { return false; -@@ -414,6 +456,26 @@ +@@ -414,6 +461,26 @@ return 0; }