ConsoleHack000 Posted July 30, 2016 Share Posted July 30, 2016 Ok, I am making a "syringe" which holds the "DNA" of minecraft mobs using their UUID's, but when I try to get the entity based on its UUID, I don't get any entity with the same UUID, even if their chunks are loaded and the entities are not dead. Here's my code package me.Aregak2005.mc.lotostuff.tools.wtrap; import cpw.mods.fml.common.registry.GameRegistry; import me.Aregak2005.mc.lotostuff.Constants; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; import java.util.List; /** * Created by DeLL on 30/07/2016. */ public class Syringe extends Item { public IIcon empty,full; @Override public IIcon getIconIndex(ItemStack stack) { return stack.hasTagCompound()?full:empty; } @Override public IIcon getIcon(ItemStack stack, int pass) { return stack.hasTagCompound()?full:empty; } @Override public void registerIcons(IIconRegister reg) { empty = reg.registerIcon("ltstf:syringe_empty"); full = reg.registerIcon("ltstf:syringe_full"); } public Syringe() { setUnlocalizedName("syringe"); setCreativeTab(Constants.tabMetal); setTextureName("ltstf:syringe_empty"); setMaxStackSize(1); GameRegistry.registerItem(this,this.getUnlocalizedName().substring(5)); } @Override public void addInformation(ItemStack s, EntityPlayer p, List l, boolean b) { if(s.hasTagCompound()){ Entity e = null; for(Entity en : (List<Entity>)p.worldObj.getLoadedEntityList()){ if(en.getUniqueID().toString().equals(s.getTagCompound().getString("uniqueID"))){ e = en; } } l.add(s.getTagCompound().getString("uniqueID")); if(e==null) l.add(EnumChatFormatting.DARK_RED + StatCollector.translateToLocal("lang.entitynotfound.txt")); else{ l.add(String.format("X: %d", e.posX)); l.add(String.format("Y: %d", e.posY)); l.add(String.format("Z: %d", e.posZ)); } } } @Override public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { if(player.worldObj.isRemote) return false; if(!stack.hasTagCompound()) { if (entity.myEntitySize == Entity.EnumEntitySize.SIZE_2) { NBTTagCompound t = new NBTTagCompound(); t.setString("uniqueID",entity.getUniqueID().toString()); stack.setTagCompound(t); assert t.getString("uniqueID").equals(entity.getUniqueID().toString()); stack.setStackDisplayName(StatCollector.translateToLocal("item.syringe.full")); } } return false; } } Currently developing a mod called Lot'O'Stuff for 1.7.10 (I know very well its outdated.) Link to comment Share on other sites More sharing options...
Animefan8888 Posted July 30, 2016 Share Posted July 30, 2016 Is it adding the Error message to the itemstack? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
ConsoleHack000 Posted July 30, 2016 Author Share Posted July 30, 2016 Yeah I would like to upgrade but i can't (I hate the new renering system where you have to make a json file for every item/block. its annoying). Is there a way to get the UUID on the server? or sync them manually? Currently developing a mod called Lot'O'Stuff for 1.7.10 (I know very well its outdated.) Link to comment Share on other sites More sharing options...
Animefan8888 Posted July 30, 2016 Share Posted July 30, 2016 Well if you wanted to sync manually you could try to use packets, but eventually you are going to have to update. Are you planning on just addingInfo on hover to the ItemStack or was that just to test. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator. Link to comment Share on other sites More sharing options...
Recommended Posts