Everything posted by Gess1t
-
[1.12.1] Making a mod that notify player when inventory is full
so basicly if(!Minecraft.getMinecraft().player.inventory.getStackInSlot(i).isEmpty()) is causing the crash if the script is set to i < 37 and it doesn't if the script is set to i > 37 because it does nothing. so : nope it doesn't help, and yep, it crash before being able to do a single one the one that crash : public Main() { for(int i=0; i < 37; i++) { if(!Minecraft.getMinecraft().player.inventory.getStackInSlot(i).isEmpty()) { Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Your inventory is full")); return; } } return; } Main.java package Gess.mod; import Gess.mod.proxy.iProxy; import net.minecraft.client.Minecraft; import net.minecraft.util.text.TextComponentString; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import util.Reference; @Mod(modid=Reference.MODID, name=Reference.MODNAME, version=Reference.VERSION) public class Main { public static Main instance; public static final String CLIENT = "gess.mod.proxy.ClientProxy"; public static final String SERVER = "gess.mod.proxy.CommonProxy"; @SidedProxy(clientSide = Reference.CLIENT, serverSide = Reference.COMMON) public static iProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event){} @EventHandler public void init(FMLInitializationEvent event){} @EventHandler public void postInit(FMLPostInitializationEvent event){} public Main() { for(int i=0; i < 37; i++) { if(!Minecraft.getMinecraft().player.inventory.getStackInSlot(i).isEmpty()) { Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Your inventory is full")); return; } } return; } @SubscribeEvent public static void chkInv(TickEvent.ClientTickEvent event) { if(Minecraft.getMinecraft().player != null) { Minecraft.getMinecraft().player.sendMessage(new TextComponentString("you're ingame")); Main main = new Main(); } } } Reference.java package util; public class Reference { public static final String MODID = "f"; public static final String MODNAME = "Full Inventory Checker"; public static final String VERSION = "1.0"; public static final String CLIENT = "Gess.mod.proxy.ClientProxy"; public static final String COMMON = "Gess.mod.proxy.CommonProxy"; } ClientProxy package Gess.mod.proxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; public class ClientProxy implements iProxy { public void preInit(FMLPreInitializationEvent event) { } public void init(FMLInitializationEvent event) { } public void postInit(FMLPostInitializationEvent event) { } } CommonProxy.java package Gess.mod.proxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; public class CommonProxy implements iProxy { public void preInit(FMLPreInitializationEvent event) { } public void init(FMLInitializationEvent event) { } public void postInit(FMLPostInitializationEvent event) { } } iProxy package Gess.mod.proxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; public interface iProxy { public void preInit(FMLPreInitializationEvent event); public void init(FMLInitializationEvent event); public void postInit(FMLPostInitializationEvent event); } These are the only class i have rn
-
[1.12.1] Making a mod that notify player when inventory is full
- [1.12.1] Making a mod that notify player when inventory is full
how to use ItemStack::isEmpty has still, to be explained most forums and wikis say nothing about that it's just like "use ItemStacks::isEmpty instead or equals(ItemStack.EMPTY)" over and over again without anyone talking about it the same thread, i can't fin tutorials and java knowledge won't help me anyway there because i need Forge API knowledge because as far as we know, forge didn't created java, but the reverse is true. EDIT: now what? i can't reverse the > because it crash public Main() { for(int i=0; i > 37; i++) { if(!Minecraft.getMinecraft().player.inventory.getStackInSlot(i).isEmpty()) { Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Your inventory is full")); return; } } return; so apparently the issue would be with my clientTickEvent : @SubscribeEvent public static void chkInv(TickEvent.ClientTickEvent event) { if(Minecraft.getMinecraft().player != null) { Minecraft.getMinecraft().player.sendMessage(new TextComponentString("you're ingame")); Main main = new Main(); } when ingame, it doesn't spam a client-side message in the chat- [1.12.1] Making a mod that notify player when inventory is full
EDITED : yeah i know, just probably gonna start fresh at this points. with no knowledge or proper documentation (totally not overkill and impossible tbh) having code but not knowing how to apply it because an API lack of documentation or any kind of other tutorials that talk about it is like having the answer before knowing what the question is about- [1.12.1] Making a mod that notify player when inventory is full
removed it at a moment re-added it now, cause i'm not looking for an empty inventory not a full one look above, edited the post.- [1.12.1] Making a mod that notify player when inventory is full
reversed it with !- [1.12.1] Making a mod that notify player when inventory is full
you know copy-paste right? "Itemstack cannot be resolved" brain wash time! going to try to find where the problem is. Looking for the exact thread where i've found about the same code (cause i edited it)- [1.12.1] Making a mod that notify player when inventory is full
@loordgek that part isn't my code tbh look what i said above : "i know the basics i'm learning through other open-source mods now, right now, the difficulties are : why is the forge documentation so empty?" if i knew how forge worked then i wouldn't have done a mistake, this isn't a problem about learning java, this is a problem about learning forge with a coffee spoon quantity of documentation. one peeps on another forum pointed out that itemstack.isEmpty thing, maybe should have replaced what was wrong first before posting- [1.12.1] Making a mod that notify player when inventory is full
tried that, still not working, reverted the change well it still doesn't work : public Main() { checkFreeSlot : { for(int i=0; i > 36; i++) { if(!Minecraft.getMinecraft().player.inventory.getStackInSlot(i).equals(ItemStack.EMPTY)) { Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Your inventory is full")); break checkFreeSlot; } } } } @SubscribeEvent public static void chkInv(TickEvent.ClientTickEvent event) { if(Minecraft.getMinecraft().player != null) { Main main = new Main(); } }- [1.12.1] Making a mod that notify player when inventory is full
Forge is an API, and the documentation they give is far from complete. i can afford to loose processing power just to make the mod work, then optimize it. right now, i'm looking for a way to make the game actually send the message, cause it doesn't. even with @SubscribeEvent- [1.12.1] Making a mod that notify player when inventory is full
like i've said on another forum, there is java outside of forge, and java in forge, i know the basics i'm learning through other open-source mods now, right now, the difficulties are : why is the forge documentation so empty? and yeah, i can pay 20% of my CPU just to run 4 lines of script every ticks that's why i'm doing it this way.- [1.12.1] Making a mod that notify player when inventory is full
another forge forum advised me to either use TickEvent.PlayerTickEvent or TickEvent.ClientTickEvent, i used the second one cause i assumed i had less work to do with it cause i didn't had to check for a specific player inventory, which is complicated on a server, i assume, again. well now i need to find how to make the first one work i guess?- [1.12.1] Making a mod that notify player when inventory is full
@DavidM Well the mod show ingame, so i assume it compile- [1.12.1] Making a mod that notify player when inventory is full
mod still not working with @SubscribeEvent (no output) i won't update to 1.12.2 because most of the 1.12.1 mods i have are compatible in 1.12.2 @DavidM code updated on github- [1.12.1] Making a mod that notify player when inventory is full
Right now, i'm stuck with an error : [f]: The mod f appears to have an invalid event annotation EventHandler. This annotation can only apply to methods with recognized event arguments - it will not be called here is the github for the mod : https://github.com/Mrcubix/Full-Inventory-Checker My Main class (Edited with @SubscribeEvent instead) : package Gess.mod; import Gess.mod.proxy.iProxy; import Gess.mod.scripts.invChk; import net.minecraft.client.Minecraft; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; import util.Reference; @Mod(modid=Reference.MODID, name=Reference.MODNAME, version=Reference.VERSION) public class Main { public static Main instance; public static final String CLIENT = "gess.mod.proxy.ClientProxy"; public static final String SERVER = "gess.mod.proxy.CommonProxy"; @SidedProxy(clientSide = Reference.CLIENT, serverSide = Reference.COMMON) public static iProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event){} @EventHandler public void init(FMLInitializationEvent event){} @EventHandler public void postInit(FMLPostInitializationEvent event){} @SubscribeEvent public void chkInv(TickEvent.ClientTickEvent event) { if(Minecraft.getMinecraft().player != null) { invChk invchk = new invChk(); } } } my invChK class : package Gess.mod.scripts; import net.minecraft.client.Minecraft; import net.minecraft.item.ItemStack; import net.minecraft.util.text.TextComponentString; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class invChk { @SubscribeEvent public void invChecker() { checkFreeSlot : { for(int i=0; i > 36; i++) { if(Minecraft.getMinecraft().player.inventory.getStackInSlot(i).equals(ItemStack.EMPTY)) { Minecraft.getMinecraft().player.sendMessage(new TextComponentString("Your inventory is full")); break checkFreeSlot; } } } } } The mod is supposed to output a message when the inventory is full (i'm also going to add a sound later on) but it doesn't, for some reasons, i suspect the error below to be the issue The mod is supposed to be client side only. I'm working with the recommended 1.12.1 version available in forge mod builder (14.22.1.2478) i'm working in eclipse. The game start, the mod is displayed in the list. - [1.12.1] Making a mod that notify player when inventory is full
IPS spam blocked by CleanTalk.
Important Information
By using this site, you agree to our Terms of Use.