Jump to content

Destructor

Members
  • Posts

    6
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Destructor's Achievements

Tree Puncher

Tree Puncher (2/8)

-1

Reputation

  1. OOps! I was so stupid. How I did missed this... Problem was because entity was rewriting it's id in nbt.
  2. Hi! I faced with strange problem, I have simple entity and I registered it this way: public void registerEntities() { registerEntity(MyEntity.class, "entity"); } private void registerEntity(Class entityClass, String name) { int entityID = getNextEntityId(); long seed = name.hashCode(); Random rand = new Random(seed); int primaryColor = rand.nextInt() * 16777215; int secondaryColor = rand.nextInt() * 16777215; EntityRegistry.registerGlobalEntityID(entityClass, name, entityID); EntityRegistry.registerModEntity(entityClass, name, entityID, LiveVillages.instance, 128, 3, true); EntityList.entityEggs.put(Integer.valueOf(entityID), new EntityList.EntityEggInfo(entityID, primaryColor, secondaryColor)); } private int getNextEntityId() { return nextEntityId++; } While I was using eggs to spawn entity, all things was going right, entity was succesfully loaded and saved. But when I started spawn entity with: world.spawnEntityInWorld(entity); Forge started skipping all entities which was spawned with this method. I even spawned entity from egg near entity spawned by world and after load entity which was spawned by world was skipped. I don't know what is wrong here... Please help! Thanks in advance.
  3. Thanks alot finally I solved it
  4. Thanks for that, but maybe I can get a small example, how to do what If I not disturbing you.
  5. Hi all! I have creature entity. When player interacts with it then it gets and holds player entity. @Override public boolean interact(EntityPlayer playerEnt) { this.playerEnt = playerEnt; } When entity writes nbt it saves player UUID to nbt. @Override public void writeEntityToNBT(NBTTagCompound var1) { super.writeEntityToNBT(var1); var1.setString("playerId", playerEnt.getGameProfile().getId().toString()); } And when it reading nbt, it also reads a player UUID and tries to get player entity from UUID @Override public void readEntityFromNBT(NBTTagCompound var1) { super.readEntityFromNBT(var1); playerEnt = this.worldObj.func_152378_a(UUID.fromString(var1.getString("playerId"))); } My problem is that after save and load 'playerEnt' always is null Where I made a mistake?
  6. So, my tile entity can't get nearest chest inventory, my tile entity founds chest and reports that he found chest to chat, but he can't get this chest inventory. I want to my tile entity check chest inventory and if inside the chest is wooden axe it returns true. But it not working Please help me. And here is my code: I don't know what here is wrong... public void updateEntity(){ super.updateEntity(); if (shouldCut){ if (hasTool()){ chat.printChatMessage(new ChatComponentText("Tool found!")); }else{ chat.printChatMessage(new ChatComponentText("Tool not found")); } shouldCut = false; } } public boolean hasTool(){ for (int i = 1; i > -2; i--){ for (int j = -1; j < 2; j++){ if (this.worldObj.getBlock(this.xCoord + j, this.yCoord, this.zCoord + i) instanceof BlockChest){ TileEntityChest te = (TileEntityChest) this.worldObj.getTileEntity(xCoord + j, yCoord, zCoord + i); IInventory teInv = null; teInv = (IInventory) te; int invSize = teInv.getSizeInventory(); if (te != null){ chat.printChatMessage(new ChatComponentText("Chest found!")); } for (int slot = 0; slot < invSize; slot++){ if (te.getStackInSlot(slot) != null){ Item slotItem = te.getStackInSlot(slot).getItem(); if (slotItem == Items.wooden_axe){ return true; } } } } } } return false; } It should work, but when I place wooden axe in nearest chest, it report that "Tool not found". What's wrong with it? It seems that "getStackInSlot()" always returns a null
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.