-
[1.14.4] How can I make multiple slots?
Oh thanks, I was getting bullied by that until now
-
[1.14.4] How can I make multiple slots?
Oh, yeah, I forgot this little one, thanks!
-
[1.14.4] How can I make multiple slots?
Better share github page instead of printing entire code, and I'm using a bit of your code as base for mine (if you don't mind it of course), since I don't fully understand Java. https://github.com/SrAranha/ChicksCanGrown1.14.4
-
[1.14.4] How can I make multiple slots?
package com.aranha.chickscangrown.blocks; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IWorldPosCallable; 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; import net.minecraftforge.items.wrapper.InvWrapper; import javax.annotation.Nonnull; import javax.annotation.Nullable; import static com.aranha.chickscangrown.blocks.ModBlocks.INCUBATOR_CONTAINER; /* Problems: Shift + right click crash minecraft */ public class IncubatorContainer extends Container { private TileEntity tileEntity; private PlayerEntity playerEntity; private IItemHandler playerInventory; public IncubatorContainer(int windowId, World world, BlockPos pos, PlayerInventory playerInventory, PlayerEntity player){ super(INCUBATOR_CONTAINER, windowId); tileEntity = world.getTileEntity(pos); this.playerEntity = player; this.playerInventory = new InvWrapper(playerInventory); //Slot for egg tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(h -> { addSlot(new SlotItemHandler(h, 0, 81, 31)); }); //Slot for first light bulb tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(h -> { addSlot(new SlotItemHandler(h, 0, 27, 13)); }); //Slot for second light bulb tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).ifPresent(h -> { addSlot(new SlotItemHandler(h, 0, 135, 13)); }); layoutPlayerInventorySlots(9, 69); } @Override public boolean canInteractWith(PlayerEntity playerIn) { return isWithinUsableDistance(IWorldPosCallable.of(tileEntity.getWorld(), tileEntity.getPos()), playerEntity, ModBlocks.INCUBATOR); } private int addSlotRange(IItemHandler handler, int index, int x, int y, int amount, int dx) { for (int i = 0 ; i < amount ; i++) { addSlot(new SlotItemHandler(handler, index, x, y)); x += dx; index++; } return index; } private int addSlotBox(IItemHandler handler, int index, int x, int y, int horAmount, int dx, int verAmount, int dy) { for (int j = 0 ; j < verAmount ; j++) { index = addSlotRange(handler, index, x, y, horAmount, dx); y += dy; } return index; } private void layoutPlayerInventorySlots(int leftCol, int topRow) { // Player inventory addSlotBox(playerInventory, 9, leftCol, topRow, 9, 18, 3, 18); // Hotbar topRow += 58; addSlotRange(playerInventory, 0, leftCol, topRow, 9, 18); } } Anything more?
-
SrAranha joined the community
-
[1.14.4] How can I make multiple slots?
I'm trying to make multiple slots on my container, but each one with unique properties, like accepting one kind of item for each slot. But I'm only doing multiple visual slots, they all share the same items/properties.
IPS spam blocked by CleanTalk.