Posted August 19, 20169 yr I currently want to create a custom inventory for a tileEntity. My class inherits another inventory class which implements the rest of the methods But I don't get slots which are not multiples of 9. Is there a way to get that working without using the container class creating container, slots, inventory, GUI and all that overhead for only 1 slot inventory? (I want the player to put in 1 item, and I want to read the content of the slot and nothing more). /** * The custom chest of the field. */ public class InventoryField extends InventoryCitizen { private ItemStack[] stackResult = new ItemStack[1]; private String customName = ""; /** * Creates the inventory of the citizen. * * @param title Title of the inventory. * @param localeEnabled Boolean whether the inventory has a custom name. */ public InventoryField(final String title, final boolean localeEnabled) { super(title, localeEnabled); customName = title; } @Override public int getSizeInventory() { return 1; } @Override public int getInventoryStackLimit() { return 1; } @Override public int getHotbarSize() { return 0; } public ItemStack getStackInSlot(int index) { return this.stackResult[0]; } @Override public boolean hasCustomName() { return true; } /** * Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections). * @param index the slot to set the itemStack. * @param stack the itemStack to set. */ @Override public void setInventorySlotContents(int index, ItemStack stack) { this.stackResult[index] = stack; if (stack != null && stack.stackSize > this.getInventoryStackLimit()) { stack.stackSize = this.getInventoryStackLimit(); } this.markDirty(); } /** * Get the name of this object. For citizens this returns their name. * @return the name of the inventory. */ @Override public String getName() { return this.hasCustomName() ? this.customName : "field.inventory"; } }
August 19, 20169 yr Probably has something to do with your container. 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.
August 19, 20169 yr Author I don't use any container I think. InventoryCitizen inherits from IInventory.
August 19, 20169 yr How do you put Items into the inventory? 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.
August 20, 20169 yr Author I open the inventory like this. InventoryField inventoryField = ColonyManager.getColony(colony.getID()).getField(pos).getInventoryField(); playerIn.displayGUIChest(inventoryField); And I put items in by drag and drop.
August 20, 20169 yr You should have your own Container and Gui. You will also need a GuiHandler which is a class that implements IGuiHandler. There are plenty of tutorials out there for those, as they haven't really changed much. 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.
August 20, 20169 yr Author I thought there may be a way to do this without any custom gui and container. Since it is only 1 single inventory slot and I do not need anything besides from this =D But thank you for your help. I'll get into all that container and GUI stuff then =D
August 20, 20169 yr You can't. GUIChest assumes that all inventories opened with it will have 9n inventory slots. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
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.