Posted November 15, 20159 yr I am trying to make an Item that, when it is dropped on the ground it doesn't group together but remains as separate entities. I have made a custom EntityItem class and overrode onUpdate. I copied everything from the original function except the bit where it tests for combining items. The problem is no entity gets made at all now, and I'm not sure why. Any ideas? (Even when it is creating an Entity, it's not rendering and is invisible, but I suspect that's by design for custom item entities and a whole other kettle of complicated fish). package net.rpcraft.rpcraft; import java.util.Iterator; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.stats.AchievementList; import net.minecraft.util.BlockPos; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class EntityLifeshard extends EntityItem { protected int delayBeforeCanPickup; protected int age; public EntityLifeshard(World worldIn, double x, double y, double z, ItemStack stack) { super(worldIn, x, y, z, stack); } public EntityLifeshard(World worldIn, double x, double y, double z) { super(worldIn, x, y, z); } public EntityLifeshard(World worldIn) { super(worldIn); } @Override public void onUpdate() { ItemStack stack = this.getDataWatcher().getWatchableObjectItemStack(10); if (stack != null && stack.getItem() != null && stack.getItem().onEntityItemUpdate(this)) return; if (this.getEntityItem() == null) { System.out.println("no item death"); this.setDead(); } else { this.onEntityUpdate(); if (this.delayBeforeCanPickup > 0 && this.delayBeforeCanPickup != 32767) { --this.delayBeforeCanPickup; } this.prevPosX = this.posX; this.prevPosY = this.posY; this.prevPosZ = this.posZ; this.motionY -= 0.03999999910593033D; this.noClip = this.pushOutOfBlocks(this.posX, (this.getEntityBoundingBox().minY + this.getEntityBoundingBox().maxY) / 2.0D, this.posZ); this.moveEntity(this.motionX, this.motionY, this.motionZ); boolean flag = (int)this.prevPosX != (int)this.posX || (int)this.prevPosY != (int)this.posY || (int)this.prevPosZ != (int)this.posZ; if (flag || this.ticksExisted % 25 == 0) { if (this.worldObj.getBlockState(new BlockPos(this)).getBlock().getMaterial() == Material.lava) { this.motionY = 0.20000000298023224D; this.motionX = (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F); this.motionZ = (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F); this.playSound("random.fizz", 0.4F, 2.0F + this.rand.nextFloat() * 0.4F); } } float f = 0.98F; if (this.onGround) { f = this.worldObj.getBlockState(new BlockPos(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.getEntityBoundingBox().minY) - 1, MathHelper.floor_double(this.posZ))).getBlock().slipperiness * 0.98F; } this.motionX *= (double)f; this.motionY *= 0.9800000190734863D; this.motionZ *= (double)f; if (this.onGround) { this.motionY *= -0.5D; } if (this.age != -32768) { ++this.age; } this.handleWaterMovement(); ItemStack item = getDataWatcher().getWatchableObjectItemStack(10); if (!this.worldObj.isRemote && this.age >= lifespan) { int hook = net.minecraftforge.event.ForgeEventFactory.onItemExpire(this, item); if (hook < 0) this.setDead(); else this.lifespan += hook; } if (item != null && item.stackSize <= 0) { System.out.println("aged out"); this.setDead(); } } } Check out my Mod: The RPCraft Toolkit!
November 15, 20159 yr Author Okay, found the problem with it not existing, it was actually a problem where I declared the object in the Item class, now I'd just really need to know how to make it render. Is there some sort of special rendering function I need to call? Check out my Mod: The RPCraft Toolkit!
November 15, 20159 yr Author Fixed the rendering problem as well. Do not register custom Item Entities like regular entities. Apparently it is not necessary. Check out my Mod: The RPCraft Toolkit!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.