Jump to content

rafferty.smith@hotmail.com

Members
  • Posts

    49
  • Joined

  • Last visited

Everything posted by rafferty.smith@hotmail.com

  1. I don't mind which way i do it, using json loot_table or block break event (it will be useful to know how to do both) i want to override or make a function that will override the existing mc enchant lvl so i can get efficieny 10 book / pickaxe when i break the block. I have heard you can make custom LootFunctions but i cant get my head around how you make it. Any help is appriciated!
  2. I want to make a saturation potion by adding a golden apple to a regeneration potion but i cant find anywhere on how to do it. Ive tried playing around with addRecipe but it doesnt work. Any help is appricated Im on 1.16.5
  3. I tried deleting it off my workspace and adding it back in and it didnt work
  4. I cant remember what i did, i did it yesterday. My code: http://www.github.com/Lollypoplove08/1.16.4-Kitchen-Mod Log: http://www.pastebin.com/m94Lv9ty
  5. I just did something to my mod and now it doesnt work, i dont know what i did tho. I now get the Failed to complete lifecycle event LOAD_REGISTRIES error
  6. It is a tile entity block, the list will max out at 9 slots, so there will be 9 block models (a bit like a composter)
  7. I want to change the .json model of my block depending on the size of my list and I saw something called BlockStates that might be able to do that. How do i use BlockStates to change it? Help is appriciated!
  8. It is intentinal that its only 0-9. System.out is just for testing purposes. Ill watch some videos on OOP. Thanks
  9. Im not an expert in NonNullLists but im not sure why doesnt work. Any help is appriciated
  10. private ItemStackHandler getHandler() { if (handler == null) { handler = new ItemStackHandler(1) { @Override public ItemStack extractItem(int slot, int amount, boolean simulate) { if (getStackInSlot(1) == new ItemStack (Items.MILK_BUCKET)) { return ItemStack.EMPTY; } return super.extractItem(slot, amount, simulate); } }; } return handler; }
  11. Ive tried doing that but it isnt working, i could jsut be doing it wrong
  12. Ok, how do i use the extractItem to only be able to extract a certain item then
  13. So my code so far is this public class MixingBowlBlockTileEntity extends LockableLootTileEntity { private NonNullList<ItemStack> bowlContents = NonNullList.withSize(12, ItemStack.EMPTY); PlayerEntity player; public MixingBowlBlockTileEntity(TileEntityType<?> tileEntityTypeIn) { super(tileEntityTypeIn); } public MixingBowlBlockTileEntity() { this(TileEntityTypesInit.MIXING_BOWL.get()); } public CompoundNBT write(CompoundNBT compound) { super.write(compound); if (!this.checkLootAndWrite(compound)) { ItemStackHelper.saveAllItems(compound, this.bowlContents); } return compound; } public void read(BlockState state, CompoundNBT nbt) { super.read(state, nbt); this.bowlContents = NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY); if (!this.checkLootAndRead(nbt)) { ItemStackHelper.loadAllItems(nbt, this.bowlContents); } } public int getSizeInventory() { return 12; } protected NonNullList<ItemStack> getItems() { return this.bowlContents; } protected void setItems(NonNullList<ItemStack> itemsIn) { this.bowlContents = itemsIn; } protected ITextComponent getDefaultName() { return new TranslationTextComponent("container.mixing_bowl"); } @Override protected Container createMenu(int id, PlayerInventory player) { // TODO Auto-generated method stub return null; } @Override public int getInventoryStackLimit() { return 1; } public void addItemInventory(PlayerEntity playerIn, Hand handIn) { for (int i = 0; i < 9; i++) { if (!getStackInSlot(i).getItem().equals(Items.AIR)) { continue; } setInventorySlotContents(i, new ItemStack(playerIn.getHeldItemMainhand().getItem())); playerIn.getHeldItemMainhand().shrink(1); break; } } public void addLiquidInventory(PlayerEntity playerIn, Hand handIn) { for (int p = 9; p < 12; p++) { if (!getStackInSlot(p).getItem().equals(Items.AIR)) { continue; } setInventorySlotContents(p, new ItemStack(playerIn.getHeldItemMainhand().getItem())); int slot = playerIn.inventory.currentItem; playerIn.replaceItemInInventory(slot, new ItemStack(Items.BUCKET)); System.out.println(bowlContents); break; } } public void removeLatestItem(PlayerEntity playerIn, World worldIn, BlockPos posIn, Hand handIn) { for(int e = 8; e > -1; e--){ if(!getStackInSlot(e).getItem().equals(Items.AIR)) { if(playerIn.inventory.getFirstEmptyStack() != -1) { playerIn.inventory.addItemStackToInventory(getStackInSlot(e).getStack()); setInventorySlotContents(e, new ItemStack (Items.AIR)); break; } else if(playerIn.inventory.hasItemStack(getStackInSlot(e).getStack())) { playerIn.inventory.addItemStackToInventory(getStackInSlot(e).getStack()); setInventorySlotContents(e, new ItemStack (Items.AIR)); break; } else { worldIn.addEntity(new ItemEntity(worldIn, posIn.getX() + 0.5, posIn.getY() + 1.125, posIn.getZ() + 0.5, getStackInSlot(e).getStack())); setInventorySlotContents(e, new ItemStack (Items.AIR)); break; } } continue; } } } And it works fine but hoppers extract an item i dont want it to, I just want the hoopper not to extract a milk_bucket and water_bucket Any help would be appriciated
  14. I wnat to check if players inventory is full but the only thing i found is playerIn.inventory.getFirstEmptyStack() returns -1 if inventory is full but im not sure that works. What is the way you would actually do that?
  15. I cant figure out how to calll it in this case as it is inside of createHandler()
  16. Now that works for only accepting certain items but how do i add an item to that inventory in the onblockactivated method in my block class?
  17. ive done that atm but it only works with hoppers idk what in that adds the item to the inventory tho. What is the method or line of code that adds the item to an "inventory"
  18. So do i make a list for what i have right clicked in then save it using onChunkUnload? then i retrive it with the read and write methods. I it smth like that?? But ive just made my block a chest without a gui but i cant figure out how to add an item to its inventory withourt a gui i dont knwo what method u use to do addInventoryItem or smth
  19. Then how do add the item the player is holding to the string? will i have to use a list or smth
×
×
  • Create New...

Important Information

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