-
[1.11] Moving Position of Slots in Container
Sorry, I was being stupid. Needed to change the positions in the container class and the GUI class (e.g. Client and Server so exactly what you said), thanks for your help
-
[1.11] Moving Position of Slots in Container
This is my container class. As far as I understand detectAndSendChanges() runs every tick, so that means as soon as the GUI is opened, slot 4 should be moved to position (0,0), and slot 3 should be moved to position (10,10). But this doesn't happen. package kemm.common.container; import kemm.Util; import kemm.common.block.SingleSlotBlock; import kemm.common.item.modules.Module; import kemm.common.item.modules.Module.EnumPosition; import kemm.common.tileentity.SingleSlot; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.SlotItemHandler; public class ContainerBlock extends Container { private SingleSlot te; private World blockWorld; private BlockPos position; private IInventory plInv; public ContainerBlock(IInventory playerInv, SingleSlot tile_entity, World worldIn, BlockPos pos) { this.te = tile_entity; this.blockWorld = worldIn; this.position = pos; this.plInv = playerInv; addBlockSlots(); addPlayerSlots(playerInv); System.out.println("Drawing container"); } private void addPlayerSlots(IInventory playerInv) { //Inventory for (int row = 0; row < 3; row++) { for (int col = 0; col < 9; col++) { int x = 48 + col * 18; int y = 171 + row * 18; this.addSlotToContainer(new Slot(playerInv, col + row * 9 + 9, x, y)); } } //Hotbar for (int col = 0; col < 9; col++) { int x = 48 + col * 18; int y = 229; this.addSlotToContainer(new Slot(playerInv, col, x, y)); } } private void addBlockSlots() { IItemHandler handler = this.te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); //Draw module-input slots for (int col = 0; col < 2; col++ ) { for(int row = 0; row < 3; row++) { int slotNo = row + col*3; int x = col * 90 + 75; int y = row * 18 + 62; if (slotNo < SingleSlotBlock.size) { addSlotToContainer(new SlotModule(handler, this, slotNo, x, y)); } } } } @Override public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) { return null; } @Override public boolean canInteractWith(EntityPlayer playerIn) { return te.canInteractWith(playerIn); } @Override public void detectAndSendChanges() { setSlotPosition(this.getSlot(4), 0, 0); setSlotPosition(this.getSlot(3), 10, 10); super.detectAndSendChanges(); } public void setSlotPosition(Slot slot, int xPos, int yPos) { slot.xDisplayPosition = xPos; slot.yDisplayPosition = yPos; } }
-
[1.11] Moving Position of Slots in Container
Sorry if I'm missing something really obvious here, but after the container has been opened, using addSlotToContainer() or slot.xDisplayPosition doesn't move the slots in my container.
-
[1.11] Moving Position of Slots in Container
Ahh, makes sense. How can I do that?
-
[1.11] Moving Position of Slots in Container
Using Forge version 1.11-13.19.1.2195. I've set up a block, tile entity, container and GUI, and I want the container's slots to appear/disappear when a certain item is placed in one of the slots. I have tried setting each slot's xPosition, however the container's slots are only redrawn when the container is closed and re-opened. Is there a way to change the positions of the slots whilst the GUI for the block is still open?
IPS spam blocked by CleanTalk.