Item callback for EntityItem update tick. Closes #426
This commit is contained in:
parent
02a0824716
commit
395c537f2c
2 changed files with 39 additions and 10 deletions
|
@ -32,7 +32,23 @@
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -135,7 +146,29 @@
|
||||
@@ -80,6 +91,15 @@
|
||||
*/
|
||||
public void onUpdate()
|
||||
{
|
||||
+ ItemStack stack = this.getDataWatcher().getWatchableObjectItemStack(10);
|
||||
+ if (stack != null && stack.getItem() != null)
|
||||
+ {
|
||||
+ if (stack.getItem().onEntityItemUpdate(this))
|
||||
+ {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
super.onUpdate();
|
||||
|
||||
if (this.delayBeforeCanPickup > 0)
|
||||
@@ -135,7 +155,29 @@
|
||||
|
||||
++this.age;
|
||||
|
||||
|
@ -63,7 +79,7 @@
|
|||
{
|
||||
this.setDead();
|
||||
}
|
||||
@@ -270,6 +303,7 @@
|
||||
@@ -270,6 +312,7 @@
|
||||
{
|
||||
par1NBTTagCompound.setShort("Health", (short)((byte)this.health));
|
||||
par1NBTTagCompound.setShort("Age", (short)this.age);
|
||||
|
@ -71,7 +87,7 @@
|
|||
|
||||
if (this.getEntityItem() != null)
|
||||
{
|
||||
@@ -287,10 +321,17 @@
|
||||
@@ -287,10 +330,17 @@
|
||||
NBTTagCompound nbttagcompound1 = par1NBTTagCompound.getCompoundTag("Item");
|
||||
this.setEntityItemStack(ItemStack.loadItemStackFromNBT(nbttagcompound1));
|
||||
|
||||
|
@ -90,7 +106,7 @@
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -300,10 +341,22 @@
|
||||
@@ -300,10 +350,22 @@
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- ../src_base/minecraft/net/minecraft/item/Item.java
|
||||
+++ ../src_work/minecraft/net/minecraft/item/Item.java
|
||||
@@ -7,6 +7,8 @@
|
||||
@@ -7,13 +7,17 @@
|
||||
import java.util.Random;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -9,7 +9,8 @@
|
|||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
@@ -14,6 +16,7 @@
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
+import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.item.EntityItemFrame;
|
||||
import net.minecraft.entity.item.EntityPainting;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -17,7 +18,7 @@
|
|||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionHelper;
|
||||
import net.minecraft.stats.StatList;
|
||||
@@ -23,7 +26,10 @@
|
||||
@@ -23,7 +27,10 @@
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.util.StringTranslate;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
@ -28,7 +29,7 @@
|
|||
|
||||
public class Item
|
||||
{
|
||||
@@ -238,13 +244,16 @@
|
||||
@@ -238,13 +245,16 @@
|
||||
/** Icon index in the icons table. */
|
||||
protected Icon itemIcon;
|
||||
|
||||
|
@ -46,7 +47,7 @@
|
|||
}
|
||||
|
||||
itemsList[256 + par1] = this;
|
||||
@@ -640,6 +649,10 @@
|
||||
@@ -640,6 +650,10 @@
|
||||
float f7 = f4 * f5;
|
||||
float f8 = f3 * f5;
|
||||
double d3 = 5.0D;
|
||||
|
@ -57,7 +58,7 @@
|
|||
Vec3 vec31 = vec3.addVector((double)f7 * d3, (double)f6 * d3, (double)f8 * d3);
|
||||
return par1World.rayTraceBlocks_do_do(vec3, vec31, par3, !par3);
|
||||
}
|
||||
@@ -720,4 +733,395 @@
|
||||
@@ -720,4 +734,407 @@
|
||||
{
|
||||
StatList.initStats();
|
||||
}
|
||||
|
@ -252,6 +253,18 @@
|
|||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Called by the default implemetation of EntityItem's onUpdate method, allowing for cleaner
|
||||
+ * control over the update of the item without having to write a subclass.
|
||||
+ *
|
||||
+ * @param entityItem The entity Item
|
||||
+ * @return Return true to skip any further update code.
|
||||
+ */
|
||||
+ public boolean onEntityItemUpdate(EntityItem entityItem)
|
||||
+ {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ /**
|
||||
+ * Gets a list of tabs that items belonging to this class can display on,
|
||||
+ * combined properly with getSubItems allows for a single item to span
|
||||
+ * many sub-items across many tabs.
|
||||
|
|
Loading…
Reference in a new issue