Jump to content

Defacto

Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by Defacto

  1. Hello, I'am currently creating a mods that need another of my mods to work. But I get stuck because of dependencies. I have already added jei dependecies for exemple and it works fine. But when I try to add an external jar, I can't use it because it is compiled, so I can't run the client. Does anyone can help me ? P.S I hope I have been clear enough
  2. Ok, I will find an other way. Thanks
  3. Hi ! I have no idea how to achive it in 1.16. In the older version, we could just add a condition before the registration, but now with the "new" DeferredRegistry system, I don't know how to do it... Please help me, and thank you !
  4. Hi ! I have created a custom container, and I need to have a slot which keep the item, without any type of extraction (like the blaze powder in the brewing stand). I already tried custom slot, and check the code of the brewing stand. Can you please help me ? Here are my tile entity and container class (the slot I need has the index 0 in the block inventory) public class CollectorTE extends LockableLootTileEntity implements ITickableTileEntity, ISidedInventory, IItemHandler { private NonNullList<ItemStack> inventory = NonNullList.withSize(19, ItemStack.EMPTY); private static final int[] SLOTS_UP = new int[]{0}; private static final int[] SLOTS_DOWN = new int[]{2, 1}; public CollectorTE() { super(TileEntityInit.COLLECTOR_TE.get()); } @Override public void tick() { int area = 5; int range = (area - 1)/2; if(!world.isRemote && world.getBlockState(pos).getBlock() instanceof BlockCollector) { Direction direction = world.getBlockState(pos).get(BlockCollector.FACING); BlockPos start = pos.offset(direction).offset(direction.rotateY(), range); BlockPos end = pos.offset(direction, area).offset(direction.rotateY(), -range); BlockPos.getAllInBox(start, end).forEach(position -> { if(world.getBlockState(position).getBlock() instanceof CropsBlock) { BlockState state = world.getBlockState(position); CropsBlock block = (CropsBlock)state.getBlock(); if(block.isMaxAge(state)) { for(ItemStack stack : Block.getDrops(state, world.getServer().getWorld(world.getDimensionKey()), position, world.getTileEntity(position))) { addItemStackInInventory(stack); } if(world.getBlockState(position).getBlock() instanceof BeetrootBlock) { world.setBlockState(position, block.getDefaultState().with(BeetrootBlock.BEETROOT_AGE, 1)); } else { world.setBlockState(position, block.getDefaultState().with(CropsBlock.AGE, 4)); } } } }); } } public void read(BlockState state, CompoundNBT nbt) { super.read(state, nbt); this.inventory = NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY); if (!this.checkLootAndRead(nbt)) { ItemStackHelper.loadAllItems(nbt, this.inventory); } } public CompoundNBT write(CompoundNBT compound) { super.write(compound); if (!this.checkLootAndWrite(compound)) { ItemStackHelper.saveAllItems(compound, this.inventory); } return compound; } public void addItemStackInInventory(ItemStack itemstack) { int i = this.getSizeInventory(); ItemStack stack = itemstack; for(int j = 1; j < i && !stack.isEmpty(); ++j) { if(this.getStackInSlot(j).getCount() < 64 && this.getStackInSlot(j).getItem() == stack.getItem() || this.getStackInSlot(j).isEmpty()) { this.setInventorySlotContents(j, new ItemStack(stack.getItem(), stack.getCount() + this.getStackInSlot(j).getCount())); stack = new ItemStack(stack.getItem(), stack.getCount() - this.getStackInSlot(j).getCount()); } } } @Override public int getSizeInventory() { return this.inventory.size(); } @Override protected NonNullList<ItemStack> getItems() { return this.inventory; } @Override protected void setItems(NonNullList<ItemStack> itemsIn) { this.inventory = itemsIn; } @Override protected ITextComponent getDefaultName() { return new TranslationTextComponent("container.collector"); } @Override protected Container createMenu(int id, PlayerInventory player) { return new CollectorContainer(id, player, this); } public boolean isItemValidForSlot(int index, ItemStack stack) { if (index == 0) { return true; } else { return false; } } @Override public int[] getSlotsForFace(Direction side) { if (side == Direction.DOWN) { return SLOTS_DOWN; } else{ return SLOTS_UP; } } @Override public boolean canInsertItem(int index, ItemStack itemStackIn, Direction direction) { return this.isItemValidForSlot(index, itemStackIn); } @Override public boolean canExtractItem(int index, ItemStack stack, Direction direction) { return !this.isItemValidForSlot(index, stack); } @Override public int getSlots() { return this.getSizeInventory(); } @Override public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) { if(this.isItemValidForSlot(slot, stack) && this.isItemValid(slot, stack)) { return stack; } else { return ItemStack.EMPTY; } } @Override public ItemStack extractItem(int slot, int amount, boolean simulate) { if(slot != 0) { return this.getStackInSlot(slot); } else { return ItemStack.EMPTY; } } @Override public int getSlotLimit(int slot) { if(slot == 0) { return 1; } return 64; } @Override public boolean isItemValid(int slot, ItemStack stack) { if(slot == 0) { return stack == new ItemStack(ItemInit.ELEMENTAL_TIME.get()); } return true; } } public class CollectorContainer extends Container{ public final IInventory collectorInventory; public CollectorContainer(final int windowId, final PlayerInventory playerInv) { this(windowId, playerInv, new Inventory(19)); } public CollectorContainer(final int windowId, final PlayerInventory playerInv, IInventory inventory) { super(ContainerInit.COLLECTOR_CONTAINER.get(), windowId); assertInventorySize(inventory, 19); collectorInventory = inventory; inventory.openInventory(playerInv.player); //Player Hotbar, slot 0 -> 8 for(int col = 0; col < 9; col++) { this.addSlot(new Slot(playerInv, col, 8 + col * 18, 142)); } //Main Player Inventory, slot 9 -> for(int row = 0; row < 3; row++) { for(int col = 0; col < 9; col++) { this.addSlot(new Slot(playerInv, col + row * 9 + 9, 8 + col * 18, 166 - (4 - row) * 18 - 10)); } } //Elemental Time this.addSlot(new TimeSlot(inventory, 0, 8, 35)); //Collector Inventory for(int row = 0; row < 3; row++) { for(int col = 0; col < 6; col++) { this.addSlot(new Slot(inventory, col + 1 + row * 6, 35 + col*18, 17 + row * 18)); } } } @Override public boolean canInteractWith(PlayerEntity playerIn) { return this.collectorInventory.isUsableByPlayer(playerIn); } public ItemStack transferStackInSlot(PlayerEntity playerIn, int index) { ItemStack itemstack = ItemStack.EMPTY; Slot slot = this.inventorySlots.get(index); if (slot != null && slot.getHasStack()) { ItemStack itemstack1 = slot.getStack(); itemstack = itemstack1.copy(); if (index < 3 * 6 + 1) { if (!this.mergeItemStack(itemstack1, 3 * 6 + 1, this.inventorySlots.size(), true)) { return ItemStack.EMPTY; } } else if (!this.mergeItemStack(itemstack1, 0, 3 * 6 + 1, false)) { return ItemStack.EMPTY; } if (itemstack1.isEmpty()) { slot.putStack(ItemStack.EMPTY); } else { slot.onSlotChanged(); } } return itemstack; } @Override public void onContainerClosed(PlayerEntity playerIn) { super.onContainerClosed(playerIn); this.collectorInventory.closeInventory(playerIn); } }
  5. I wan't to update my mod but I don't understand how the new generation system work. Can someone help me ?
  6. Thank yo it solves my problem, for your problem you can maybe find the answer with the source code of Iron Chest : https://github.com/progwml6/ironchest
  7. I want to update my code from 1.12.2 and I do not understand how do they work and how to add a TileEntityType ? Please help me.
  8. Yes it's a solution but it will make my mod heavier. Thank's for your help
  9. Hello, I want to update my code from 1.12.2 to 1.13.2 but EnumHelper.addArmorMaterial([lot of things here]); doesn't exist with forge 1.13.2. How can I fix it ? P.S I'm french, sorry for mistakes
×
×
  • Create New...

Important Information

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