Deprecated IUseItemFirst, and made onUseItemFirst work in Creative.
This commit is contained in:
parent
b91eb1ceac
commit
6e1442e8e6
6 changed files with 74 additions and 43 deletions
|
@ -14,6 +14,9 @@ import net.minecraft.src.World;
|
|||
* This interface is to be implemented by item classes. It will allow an item
|
||||
* to perform a use before the block is activated.
|
||||
*
|
||||
* @deprecated This interface is no longer used, the function has been moved to
|
||||
* Item. The functionality remains, it simply does not require this interface
|
||||
* any further.
|
||||
* @see Item
|
||||
*/
|
||||
public interface IUseItemFirst {
|
||||
|
|
|
@ -18,7 +18,22 @@
|
|||
protected Item(int i)
|
||||
{
|
||||
maxStackSize = 64;
|
||||
@@ -231,6 +235,13 @@
|
||||
@@ -221,6 +225,14 @@
|
||||
return getIconFromDamage(itemstack.getItemDamage());
|
||||
}
|
||||
|
||||
+ /* FORGE: This is called when the item is used, before the block is
|
||||
+ * activated. Return true to prevent any further processing.
|
||||
+ */
|
||||
+ public boolean onItemUseFirst(ItemStack ist, EntityPlayer player,
|
||||
+ World world, int i, int j, int k, int l) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l)
|
||||
{
|
||||
return false;
|
||||
@@ -231,6 +243,13 @@
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
|
@ -32,7 +47,7 @@
|
|||
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
|
||||
{
|
||||
return itemstack;
|
||||
@@ -278,6 +289,29 @@
|
||||
@@ -278,6 +297,29 @@
|
||||
return maxDamage > 0 && !hasSubtypes;
|
||||
}
|
||||
|
||||
|
@ -62,7 +77,7 @@
|
|||
public boolean hitEntity(ItemStack itemstack, EntityLiving entityliving, EntityLiving entityliving1)
|
||||
{
|
||||
return false;
|
||||
@@ -473,6 +507,18 @@
|
||||
@@ -473,6 +515,18 @@
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
--- ../src_base/minecraft/net/minecraft/src/PlayerControllerMP.java 0000-00-00 00:00:00.000000000 -0000
|
||||
+++ ../src_work/minecraft/net/minecraft/src/PlayerControllerMP.java 0000-00-00 00:00:00.000000000 -0000
|
||||
@@ -4,6 +4,9 @@
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
package net.minecraft.src;
|
||||
|
||||
+import net.minecraft.src.forge.IUseItemFirst;
|
||||
+import net.minecraft.src.forge.ForgeHooks;
|
||||
+
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
// Referenced classes of package net.minecraft.src:
|
||||
@@ -68,13 +71,19 @@
|
||||
@@ -68,13 +70,19 @@
|
||||
|
||||
public boolean onPlayerDestroyBlock(int i, int j, int k, int l)
|
||||
{
|
||||
|
@ -31,7 +30,7 @@
|
|||
if(itemstack != null)
|
||||
{
|
||||
itemstack.onDestroyBlock(i1, i, j, k, mc.thePlayer);
|
||||
@@ -103,7 +112,7 @@
|
||||
@@ -103,7 +111,7 @@
|
||||
{
|
||||
Block.blocksList[i1].onBlockClicked(mc.theWorld, i, j, k, mc.thePlayer);
|
||||
}
|
||||
|
@ -40,7 +39,7 @@
|
|||
{
|
||||
onPlayerDestroyBlock(i, j, k, l);
|
||||
} else
|
||||
@@ -149,7 +158,7 @@
|
||||
@@ -149,7 +157,7 @@
|
||||
return;
|
||||
}
|
||||
Block block = Block.blocksList[i1];
|
||||
|
@ -49,21 +48,21 @@
|
|||
if(stepSoundTickCounter % 4F == 0.0F && block != null)
|
||||
{
|
||||
mc.sndManager.playSound(block.stepSound.stepSoundDir2(), (float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F, (block.stepSound.getVolume() + 1.0F) / 8F, block.stepSound.getPitch() * 0.5F);
|
||||
@@ -216,6 +225,13 @@
|
||||
@@ -216,6 +224,13 @@
|
||||
{
|
||||
syncCurrentPlayItem();
|
||||
netClientHandler.addToSendQueue(new Packet15Place(i, j, k, l, entityplayer.inventory.getCurrentItem()));
|
||||
+
|
||||
+ if (itemstack != null && itemstack.getItem() instanceof IUseItemFirst) {
|
||||
+ IUseItemFirst iuif = (IUseItemFirst) itemstack.getItem();
|
||||
+ if (iuif.onItemUseFirst(itemstack, entityplayer, world, i, j, k, l)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ if (itemstack != null) {
|
||||
+ Item it=itemstack.getItem();
|
||||
+ if (it.onItemUseFirst(itemstack, entityplayer, world, i, j, k, l)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
int i1 = world.getBlockId(i, j, k);
|
||||
if(i1 > 0 && Block.blocksList[i1].blockActivated(world, i, j, k, entityplayer))
|
||||
{
|
||||
@@ -235,7 +251,11 @@
|
||||
@@ -235,7 +250,11 @@
|
||||
return flag;
|
||||
} else
|
||||
{
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
--- ../src_base/minecraft/net/minecraft/src/PlayerControllerSP.java 0000-00-00 00:00:00.000000000 -0000
|
||||
+++ ../src_work/minecraft/net/minecraft/src/PlayerControllerSP.java 0000-00-00 00:00:00.000000000 -0000
|
||||
@@ -3,6 +3,8 @@
|
||||
@@ -3,6 +3,7 @@
|
||||
// Decompiler options: packimports(3) braces deadcode fieldsfirst
|
||||
|
||||
package net.minecraft.src;
|
||||
+import net.minecraft.src.forge.IUseItemFirst;
|
||||
+import net.minecraft.src.forge.ForgeHooks;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@@ -46,11 +48,17 @@
|
||||
@@ -46,11 +47,17 @@
|
||||
|
||||
public boolean onPlayerDestroyBlock(int i, int j, int k, int l)
|
||||
{
|
||||
|
@ -29,7 +28,7 @@
|
|||
if(itemstack != null)
|
||||
{
|
||||
itemstack.onDestroyBlock(i1, i, j, k, mc.thePlayer);
|
||||
@@ -79,7 +87,7 @@
|
||||
@@ -79,7 +86,7 @@
|
||||
{
|
||||
Block.blocksList[i1].onBlockClicked(mc.theWorld, i, j, k, mc.thePlayer);
|
||||
}
|
||||
|
@ -38,7 +37,7 @@
|
|||
{
|
||||
onPlayerDestroyBlock(i, j, k, l);
|
||||
}
|
||||
@@ -110,7 +118,7 @@
|
||||
@@ -110,7 +117,7 @@
|
||||
return;
|
||||
}
|
||||
Block block = Block.blocksList[i1];
|
||||
|
@ -47,20 +46,20 @@
|
|||
if(blockDestroySoundCounter % 4F == 0.0F && block != null)
|
||||
{
|
||||
mc.sndManager.playSound(block.stepSound.stepSoundDir2(), (float)i + 0.5F, (float)j + 0.5F, (float)k + 0.5F, (block.stepSound.getVolume() + 1.0F) / 8F, block.stepSound.getPitch() * 0.5F);
|
||||
@@ -173,6 +181,12 @@
|
||||
@@ -173,6 +180,12 @@
|
||||
|
||||
public boolean onPlayerRightClick(EntityPlayer entityplayer, World world, ItemStack itemstack, int i, int j, int k, int l)
|
||||
{
|
||||
+ if (itemstack != null && itemstack.getItem() instanceof IUseItemFirst) {
|
||||
+ IUseItemFirst iuif = (IUseItemFirst) itemstack.getItem();
|
||||
+ if (iuif.onItemUseFirst(itemstack, entityplayer, world, i, j, k, l)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ if (itemstack != null) {
|
||||
+ Item it=itemstack.getItem();
|
||||
+ if (it.onItemUseFirst(itemstack, entityplayer, world, i, j, k, l)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
int i1 = world.getBlockId(i, j, k);
|
||||
if(i1 > 0 && Block.blocksList[i1].blockActivated(world, i, j, k, entityplayer))
|
||||
{
|
||||
@@ -183,7 +197,11 @@
|
||||
@@ -183,7 +196,11 @@
|
||||
return false;
|
||||
} else
|
||||
{
|
||||
|
|
|
@ -18,7 +18,22 @@
|
|||
protected Item(int i)
|
||||
{
|
||||
maxStackSize = 64;
|
||||
@@ -219,6 +223,13 @@
|
||||
@@ -209,6 +213,14 @@
|
||||
return this;
|
||||
}
|
||||
|
||||
+ /* FORGE: This is called when the item is used, before the block is
|
||||
+ * activated. Return true to prevent any further processing.
|
||||
+ */
|
||||
+ public boolean onItemUseFirst(ItemStack ist, EntityPlayer player,
|
||||
+ World world, int i, int j, int k, int l) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l)
|
||||
{
|
||||
return false;
|
||||
@@ -219,6 +231,13 @@
|
||||
return 1.0F;
|
||||
}
|
||||
|
||||
|
@ -32,7 +47,7 @@
|
|||
public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer)
|
||||
{
|
||||
return itemstack;
|
||||
@@ -266,6 +277,29 @@
|
||||
@@ -266,6 +285,29 @@
|
||||
return maxDamage > 0 && !hasSubtypes;
|
||||
}
|
||||
|
||||
|
@ -62,7 +77,7 @@
|
|||
public boolean hitEntity(ItemStack itemstack, EntityLiving entityliving, EntityLiving entityliving1)
|
||||
{
|
||||
return false;
|
||||
@@ -414,6 +448,12 @@
|
||||
@@ -414,6 +456,12 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
--- ../src_base/minecraft_server/net/minecraft/src/ItemInWorldManager.java 0000-00-00 00:00:00.000000000 -0000
|
||||
+++ ../src_work/minecraft_server/net/minecraft/src/ItemInWorldManager.java 0000-00-00 00:00:00.000000000 -0000
|
||||
@@ -3,7 +3,8 @@
|
||||
@@ -3,7 +3,7 @@
|
||||
// Decompiler options: packimports(3) braces deadcode fieldsfirst
|
||||
|
||||
package net.minecraft.src;
|
||||
-
|
||||
+import net.minecraft.src.forge.ForgeHooks;
|
||||
+import net.minecraft.src.forge.IUseItemFirst;
|
||||
|
||||
// Referenced classes of package net.minecraft.src:
|
||||
// EntityPlayer, PlayerCapabilities, World, Block,
|
||||
@@ -81,7 +82,8 @@
|
||||
@@ -81,7 +81,8 @@
|
||||
if(j != 0)
|
||||
{
|
||||
Block block = Block.blocksList[j];
|
||||
|
@ -20,7 +19,7 @@
|
|||
if(f >= 1.0F)
|
||||
{
|
||||
field_22050_k = false;
|
||||
@@ -108,7 +110,7 @@
|
||||
@@ -108,7 +109,7 @@
|
||||
{
|
||||
Block.blocksList[i1].onBlockClicked(thisWorld, i, j, k, thisPlayer);
|
||||
}
|
||||
|
@ -29,7 +28,7 @@
|
|||
{
|
||||
blockHarvessted(i, j, k);
|
||||
} else
|
||||
@@ -128,7 +130,7 @@
|
||||
@@ -128,7 +129,7 @@
|
||||
if(i1 != 0)
|
||||
{
|
||||
Block block = Block.blocksList[i1];
|
||||
|
@ -38,7 +37,7 @@
|
|||
if(f >= 0.7F)
|
||||
{
|
||||
blockHarvessted(i, j, k);
|
||||
@@ -150,16 +152,19 @@
|
||||
@@ -150,16 +151,19 @@
|
||||
{
|
||||
Block block = Block.blocksList[thisWorld.getBlockId(i, j, k)];
|
||||
int l = thisWorld.getBlockMetadata(i, j, k);
|
||||
|
@ -63,7 +62,7 @@
|
|||
int l = thisWorld.getBlockId(i, j, k);
|
||||
int i1 = thisWorld.getBlockMetadata(i, j, k);
|
||||
thisWorld.playAuxSFXAtEntity(thisPlayer, 2001, i, j, k, l + thisWorld.getBlockMetadata(i, j, k) * 256);
|
||||
@@ -169,8 +174,7 @@
|
||||
@@ -169,8 +173,7 @@
|
||||
((EntityPlayerMP)thisPlayer).playerNetServerHandler.sendPacket(new Packet53BlockChange(i, j, k, thisWorld));
|
||||
} else
|
||||
{
|
||||
|
@ -73,7 +72,7 @@
|
|||
if(itemstack != null)
|
||||
{
|
||||
itemstack.onDestroyBlock(l, i, j, k, thisPlayer);
|
||||
@@ -204,6 +208,7 @@
|
||||
@@ -204,6 +207,7 @@
|
||||
if(itemstack1.stackSize == 0)
|
||||
{
|
||||
entityplayer.inventory.mainInventory[entityplayer.inventory.currentItem] = null;
|
||||
|
@ -81,15 +80,16 @@
|
|||
}
|
||||
return true;
|
||||
} else
|
||||
@@ -214,6 +219,11 @@
|
||||
@@ -214,6 +218,12 @@
|
||||
|
||||
public boolean activeBlockOrUseItem(EntityPlayer entityplayer, World world, ItemStack itemstack, int i, int j, int k, int l)
|
||||
{
|
||||
+ if(itemstack!=null && itemstack.getItem() instanceof IUseItemFirst) {
|
||||
+ IUseItemFirst iuif=(IUseItemFirst)itemstack.getItem();
|
||||
+ if(iuif.onItemUseFirst(itemstack,entityplayer,world,i,j,k,l))
|
||||
+ if (itemstack != null) {
|
||||
+ Item it=itemstack.getItem();
|
||||
+ if (it.onItemUseFirst(itemstack, entityplayer, world, i, j, k, l)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
int i1 = world.getBlockId(i, j, k);
|
||||
if(i1 > 0 && Block.blocksList[i1].blockActivated(world, i, j, k, entityplayer))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue