-
Posts
444 -
Joined
-
Last visited
-
Days Won
5
Posts posted by kiou.23
-
-
Just now, Turnrp said:
I need it to go onto the head of the player
when? when the player places it in the head armor slot in their inventory?
-
Just now, Turnrp said:
Block. A mod block i made.
what do you mean by rendering a block on the player?
-
37 minutes ago, Turnrp said:
I already know haw to make items and blocks its just idk how to render it ON the player
you want to render a block or item on the player?
-
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); } }
-
1 minute ago, Turnrp said:
@Override? and then i what i override is the IForgeItem?
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)
-
4 minutes ago, Turnrp said:
Kinda but i hae done a lot of coding in the past and i really like this so im learning while im doing
That's great, have fun learning!
- 1
-
3 minutes ago, Turnrp said:
So i would put IForgeItem.onItemRightClick?
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)
-
9 minutes ago, Jaden0922 said:
I deleted the mod want to do it again . u have some tutorial for 1.16?
I started with this video: https://www.youtube.com/watch?v=3Uqnb8TqjTY&t=234s&ab_channel=SilentChaos512
-
3 minutes ago, Turnrp said:
What do you mean IDE?
IDE stands for Integrated Development Environment
Do you know Java or are you jumping into modding without prior knowledge of programming?
-
9 minutes ago, Turnrp said:
I found something called IForgeContainerType? Will that help with a container im a little new to this
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 minutes ago, Turnrp said:
Lol you right and is this in Intellij or another program cause ikm using Intellij
in any IDE really, you can hover any class or interface, right click it, hover on "Go To" and then Go to Definition
-
6 minutes ago, Jaden0922 said:
still dosnet work after changed
what doesn't work?
-
1 minute ago, Jaden0922 said:
I don't know what u mean so what do I type?
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)
-
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
-
5 minutes ago, Jaden0922 said:
main mod:
package com.jadenwong.doggie_land; import com.jadenwong.doggie_land.util.RegistryHandler; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent; import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent; import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @Mod("DoggieLandMod") public class DoggieLandMod { private static final Logger LOGGER = LogManager.getLogger(); public static final String MOD_ID = "DoggieLandMod"; public DoggieLandMod() { FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); RegistryHandler.init(); MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event) { } private void doClientStuff(final FMLClientSetupEvent event) { } }
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
-
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)
-
okay, actually you didn't update your build.gradle at all
you need to replace "examplemod" with your own mod id
-
yeah, you probably just forgot to update your mod id in the mods.toml file
you can find it in resources/META-INF
-
share your main mod class, your build.gradle and the mods.toml
-
Just now, diesieben07 said:
Looks right, although getDisplayName and createMenu should not return null.
Yeah, I haven't implemented those methods yet
Just wanted to solve the crafting Inventory problem
Thanks
-
Just now, diesieben07 said:
I don't know what you mean by this.
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
-
2 hours ago, diesieben07 said:
You can make a subclass of CraftingInventory that overrides all methods to delegate to your IItemHandler instead.
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; } }
-
you forgot to annotate the class with @Mod.EventBusSubscriber
Edit: and I suppose you're calling registerOre() in a common setup event listener
-
5 hours ago, Turnrp said:
I looked and nothing shows up when i do that i type it in and it shows up but when a place a dot nothing shows up after that
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
- 1
Is there a way to Render a JSON onto a player?
in Modder Support
Posted
not on setup
you'd probably want to handle that on the PlayerLoggedInEvent