Jump to content


  • Posts

  • Joined

  • Last visited

  • Days Won


Everything posted by kiou.23

  1. not on setup you'd probably want to handle that on the PlayerLoggedInEvent
  2. when? when the player places it in the head armor slot in their inventory?
  3. what do you mean by rendering a block on the player?
  4. you want to render a block or item on the player?
  5. I've implemented a workbench that works just like the vanilla one, however when I get the recipe result to output, it always returns a stack with 64 items. I have no idea why this is happening public class ModWorkbenchTileEntity extends TileEntity implements INamedContainerProvider { public static final int CRAFT_MATRIX_SLOT_START = 0; public static final int CRAFT_MATRIX_SLOT_END = 8; public static final int OUTPUT_SLOT = 9; public final ItemStackHandler inventory = new ItemStackHandler(10) { @Override protected void onContentsChanged(int slot) { super.onContentsChanged(slot); switch (slot) { case OUTPUT_SLOT: // this doesn't handle the cases were the ingredient has a container item, eg. Milk Bucket if (getStackInSlot(slot).isEmpty()) for (int i = CRAFT_MATRIX_SLOT_START; i <= CRAFT_MATRIX_SLOT_END; i++) setStackInSlot(i, ItemStack.EMPTY); default: ItemStack res = getResult().orElse(ItemStack.EMPTY); if (res.isEmpty()) return; // the Crafting Result is outputed into the output slot, and the crafting matrix is cleared // but the Item Stack in the output slot has 64 items instead of the correct count based on the recipe insertItem(OUTPUT_SLOT, res, false); } } }; public ModWorkbenchTileEntity() { super(ModTileEntityTypes.MOD_WORKBENCH.get()); } // ModWorkbenchInventory is a subclass of CraftingInventory // which delegates the getStackInSlot method to the ItemStackHandler passed in // it's purpose is so I can call RecipeManager#getRecipe() private ModWorkbenchInventory getCraftingInventory() { IItemHandler craftMatrix = new ItemStackHandler(9); for (int slot = CRAFT_MATRIX_SLOT_START; slot <= CRAFT_MATRIX_SLOT_END; slot++) craftMatrix.insertItem(slot, inventory.getStackInSlot(slot), false); return new ModWorkbenchInventory(craftMatrix); } private Optional<ICraftingRecipe> getRecipe() { return world.getRecipeManager().getRecipe( IRecipeType.CRAFTING, getCraftingInventory(), world ); } private Optional<ItemStack> getResult() { return getRecipe().map(recipe -> recipe.getCraftingResult(getCraftingInventory())); } @Override public ITextComponent getDisplayName() { return new TranslationTextComponent(ModBlocks.MOD_WORKBENCH.get().getTranslationKey()); } @Override public Container createMenu(int windowId, PlayerInventory playerInv, PlayerEntity player) { return new ModWorkbenchContainer(windowId, playerInv, this); } }
  6. the IForgeItem method that you wish to override it seems you're not so keen on how interfaces work, so you can search up OOP in Java to get a better idea of what's going on (understading OOP is really necessary for minecraft modding)
  7. no, you override it your Backpack is an implementation of that interface (check out encapsulation and interfaces in Object Oriented Programming for more guidance) so in your Backpack class, you can override it (if you don't know what this means search for overriding methods in Java)
  8. I started with this video: https://www.youtube.com/watch?v=3Uqnb8TqjTY&t=234s&ab_channel=SilentChaos512
  9. IDE stands for Integrated Development Environment Do you know Java or are you jumping into modding without prior knowledge of programming?
  10. That's something different So, okay you have your BackpackBase class right? it extends the net.minecraft.Item class, which in turn extends the IForgeItem interface the interface provides a few methods you can override, in the case of doing something upon right-click you have: onItemUse, and onItemRightClick onItemRightClick detects any right click onItemUse detects right clicks on blocks
  11. in any IDE really, you can hover any class or interface, right click it, hover on "Go To" and then Go to Definition
  12. 4- And when replying please quote the comment you're replying, so we don't have to guess I guess you're talking about the MOD_ID, just pass it like your main class has a static final String which stands for your mod Id, whenever you need the Mod Id, just use YourModClass.MOD_ID eg: instead of @Mod("DoggieLandMod") use @Mod(DoggieLandMod.MOD_ID)
  13. Also: 1- try keeping everything you have to say in just one comment so the forums don't get spammed 2- whenever you have to post a very very long text (like the debug log) post it in pastebin, and share the link to it 3- the forum has a "insert code" button for sharing your code
  14. and in here, you have MOD_ID as a static final var, so whenever you need your mod id in a .java file, you should reference DoggieLandMod.MOD_ID, instead of stringly typing it for example: in the @Mod() annotation this way is less error prone and easier to update and make changes
  15. also, your mod id should be in snake_case, not in PascalCase you can correct it to: doggie_land_mod (though there is no need to have "mod" in your mod id)
  16. okay, actually you didn't update your build.gradle at all you need to replace "examplemod" with your own mod id
  17. yeah, you probably just forgot to update your mod id in the mods.toml file you can find it in resources/META-INF
  18. share your main mod class, your build.gradle and the mods.toml
  19. Yeah, I haven't implemented those methods yet Just wanted to solve the crafting Inventory problem Thanks
  20. I think he's talking about how you can install optifine and have it as a version instead of needing to have the optifine jar in the mods folder and run a forge version
  21. like so? public class ModWorkbenchInventory extends CraftingInventory { private final ModWorkbenchItemStackHandler itemStackHandler; public ModWorkbenchInventory(ModWorkbenchItemStackHandler itemStackHandler) { super(null, 3, 3); this.itemStackHandler = itemStackHandler; } @Override public int getHeight() { return 3; } @Override public int getWidth() { return 3; } @Override public ItemStack getStackInSlot(int index) { return itemStackHandler.getStackInSlot(index); } // @Override public int getSizeInventory() { return itemStackHandler.getSlots(); } @Override public boolean isEmpty() { for(int slot = 0; slot < itemStackHandler.getSlots(); slot++) { if (!itemStackHandler.getStackInSlot(slot).isEmpty()) { return false; } } return true; } @Override public ItemStack removeStackFromSlot(int index) { return ItemStack.EMPTY; } @Override public ItemStack decrStackSize(int index, int count) { return ItemStack.EMPTY; } @Override public void setInventorySlotContents(int index, ItemStack stack) {} @Override public void markDirty() {} @Override public void clear() {} @Override public void fillStackedContents(RecipeItemHelper helper) {} } public class ModWorkbenchItemStackHandler extends ItemStackHandler { public ModWorkbenchItemStackHandler() { super(9); } @Override public boolean isItemValid(int slot, ItemStack stack) { if (slot < 0 || slot >= 9) throw new IllegalArgumentException("Invalid slot number: " + slot); if (stack.isEmpty()) return false; return !(stack.getItem() instanceof BackpackItem); } } public class ModWorkbenchTileEntity extends TileEntity implements INamedContainerProvider { final ModWorkbenchItemStackHandler craftMatrix = new ModWorkbenchItemStackHandler(); public ModWorkbenchTileEntity() { super(ModTileEntityTypes.MOD_WORKBENCH.get()); } private Optional<ICraftingRecipe> getRecipe() { ItemStack[] stacks = new ItemStack[9]; for (int i = 0; i < craftMatrix.getSlots(); i++) stacks[i] = (craftMatrix.getStackInSlot(i)); return world.getRecipeManager().getRecipe(IRecipeType.CRAFTING, new ModWorkbenchInventory(craftMatrix), world); } @Override public ITextComponent getDisplayName() { return null; } @Override public Container createMenu(int windowId, PlayerInventory playerInv, PlayerEntity player) { return null; } }
  22. you forgot to annotate the class with @Mod.EventBusSubscriber Edit: and I suppose you're calling registerOre() in a common setup event listener
  23. your Item extends the Item class, right? the Item class implements the IForgeItem interface and that interface provides some methods, go to the interface implementation (you can do that in your IDE) and look at the methods the interface provides Also, don't try coding when you're really tired, go get some rest
  • Create New...

Important Information

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