Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/11/19 in all areas

  1. try stepping through your code with the debugger
    1 point
  2. The fek is this: https://github.com/Colton-Slayden/Solis/blob/master/src/main/java/com/royalreject/solis/proxy/ClientProxy.java#L27 ForgeRegistries.BLOCKS.getKey(b)? You mean b.getRegistryName()? https://github.com/Colton-Slayden/Solis/blob/master/src/main/java/com/royalreject/solis/gameObjs/ObjHandler.java#L23 Why the function? Is event.getRegistry().register(new ItemBlock(scorchedEarth).setRegistryName(scorchedEarth.getRegistryName)) insufficient somehow? https://github.com/Colton-Slayden/Solis/blob/master/src/main/java/com/royalreject/solis/gameObjs/ObjHandler.java#L18 Don't use static initializes.
    1 point
  3. Yeah, just remember ItemStacks should never be null. Instead, if you want an ItemStack to be empty, use ItemStack.EMPTY. What are you trying to achieve with this block? What it seems like you want to add the player's hand stack to its inventory. Instead of implementing your own inventory system, try exposing the IItemHandler capability. This will give your TE an inventory, and will most likely solve many of your problems. Not to mention, the capability will provide a lot better compat with other mods that access inventories. You shouldn't be creating an inventory from an ItemStack field. Here is an example of what I'm saying. (You should also reference the official forge documentation) First, create the handler itself (This will be a field will be in your TE): public final ItemStackHandler inv = new ItemStackHandler(1); The constructor to ItemStackHandler is how many slots the inventory should have. Now, you need to expose the capability for forge to access. @Override public boolean hasCapability(Capability<?> capability, @Nullable EnumFacing facing) { if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY){ return true; //this is also where you'd check the facing, incase you only want to insert on certain sides. } return super.hasCapability(capability, facing); } @Nullable @Override public <T> T getCapability(Capability<T> capability, @Nullable EnumFacing facing) { if(capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY){ //this will check to see if the capability being 'get' is, in fact, the ItemHandler return (T) this.inv; //this will be the inventory field that you have attached to your TE. } return super.getCapability(capability, facing); } To save the data of the inventory, use ItemStackHandler#serializeNBT and ItemStackHandler#deserializeNBT. From the block class, you need to get the capability (using TileEntity#getCapability) and use ItemStackHandler#insertItem to put the item into the TE's inventory.
    1 point
×
×
  • Create New...

Important Information

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