Jump to content

the

Members
  • Posts

    4
  • Joined

  • Last visited

the's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I understand you are talking about what is being shared over the network, not what is being saved to the disk, though Minecraft modding is new to me - should I create a separate pair of read/write NBT functions that only do the redstone state, and then use those in the packet functions in place of readFromNBT/writeToNBT? Also, is "new NBTTagCompound()" not an empty NBTTagCompound? I was under the impression that it was.
  2. Changing the body of getUpdateTag to return new NBTTagCompound(); still produces "0 0 0 tile:bedrock". As for writing both items and previousRedstoneState to the NBT, I'm following both the capability system outlined in this tutorial and the method used by TileEntityNote of remembering if a block is currently being powered so that it does not trigger again upon world reload. I'm still finding my way around modding and I'd very much appreciate if you have a more elegant way to handle NBT, though I will optimize after I have the block working as intended. The rest of my code for the tile entity class is linked here (and is pretty much a combination of that tutorial and vanilla's previousRedstoneState as well).
  3. The "pos" is the field of the tile entity class that is inherited from TileEntity (and returned by this.getPos(), which using instead does not change the problem, and which I would have originally used more formally if 1 was not debug code). The issue is happening with the fields of the block's tile entity class.
  4. So I have a tile entity of a container block, and on the client side at least, it seems to think everything is 0, false, etc. 1.) For instance, I have the debug code IBlockState state = world.getBlockState(pos); if (state.getBlock() == ModBlocks.MY_BLOCK) { // you'd think this would always be true return state.getValue(MyBlock.ACTIVATED); } MyMod.LOGGER.info(pos.getX() + " " + pos.getY() + " " + pos.getZ() + " " + state.getBlock().getUnlocalizedName()); // debug return false; which not only always prints something to the logger, but the thing that it prints is actually 0 0 0 tile:bedrock (or sometimes tile:air, depending on what is at 0,0,0) The value of pos is not being changed/overwritten anywhere in my code. 2.) As well, the tile entity resets to default whenever the world is reloaded, forgetting all of the items inside it. While I am setting NBT as follows: @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); if (compound.hasKey("ITEMS")) { itemStackHandler.deserializeNBT((NBTTagCompound) compound.getTag("ITEMS")); } if (compound.hasKey("previousRedstoneState")) { previousRedstoneState = compound.getBoolean("previousRedstoneState"); } } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setTag("ITEMS", itemStackHandler.serializeNBT()); compound.setBoolean("previousRedstoneState", previousRedstoneState); return compound; } my GUI for the block does not display the correct previousRedstoneState. It does get the items right, but only until world exit. 3.) I have tried sending packets using the MinecraftByExample method, in case the GUI was a server/client issue: @Nullable @Override public SPacketUpdateTileEntity getUpdatePacket() { return new SPacketUpdateTileEntity(getPos(), getBlockMetadata(), getUpdateTag()); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { handleUpdateTag(pkt.getNbtCompound()); } @Override public NBTTagCompound getUpdateTag() { NBTTagCompound nbtTagCompound = new NBTTagCompound(); writeToNBT(new NBTTagCompound()); return nbtTagCompound; } @Override public void handleUpdateTag(NBTTagCompound tag) { this.readFromNBT(tag); } This updates the GUI text that corresponds to the NBT, but not to the blockstate. As well, if I store a byte array in the NBT that is being created from analyzing the inventory of a neighbouring block, that part of the NBT does not update correctly. I can supply additional context as necessary. How can I medicate my poor block?
×
×
  • Create New...

Important Information

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