Advertisement
Guest User

Untitled

a guest
Jan 1st, 2024
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. package fr.irisya.irisyamod.container;
  2.  
  3. import net.minecraft.entity.player.PlayerEntity;
  4. import net.minecraft.entity.player.PlayerInventory;
  5. import net.minecraft.inventory.container.Container;
  6. import net.minecraft.inventory.container.Slot;
  7. import net.minecraft.tileentity.TileEntity;
  8. import net.minecraft.util.IIntArray;
  9. import net.minecraft.util.IntArray;
  10. import net.minecraftforge.items.CapabilityItemHandler;
  11. import net.minecraftforge.items.IItemHandler;
  12. import net.minecraftforge.items.SlotItemHandler;
  13.  
  14. public class FoundryContainer extends Container {
  15. private final IIntArray data;
  16.  
  17. public FoundryContainer(int windowId, PlayerInventory playerInventory, TileEntity tileEntity) {
  18. super(ModContainers.FOUNDRY_CONTAINER.get(), windowId);
  19. this.data = new IntArray(4);
  20.  
  21. IItemHandler itemHandler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElseThrow(NullPointerException::new);
  22.  
  23. this.addSlot(new SlotItemHandler(itemHandler, 0, 56, 17));
  24. this.addSlot(new SlotItemHandler(itemHandler, 1, 56, 53));
  25. this.addSlot(new SlotItemHandler(itemHandler, 2, 116, 35));
  26. this.addSlot(new SlotItemHandler(itemHandler, 3, 76, 35));
  27.  
  28. // Emplacements pour l'inventaire
  29. for (int row = 0; row < 3; ++row) {
  30. for (int col = 0; col < 9; ++col) {
  31. this.addSlot(new Slot(playerInventory, col + row * 9 + 9, 8 + col * 18, 84 + row * 18));
  32. }
  33. }
  34.  
  35. for (int col = 0; col < 9; ++col) {
  36. this.addSlot(new Slot(playerInventory, col, 8 + col * 18, 142));
  37. }
  38.  
  39. this.addDataSlots(this.data);
  40. }
  41.  
  42. @Override
  43. public boolean stillValid(PlayerEntity player) {
  44. return true;
  45. }
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement