Jump to content

JetCobblestone

Members
  • Posts

    11
  • Joined

  • Last visited

JetCobblestone's Achievements

Tree Puncher

Tree Puncher (2/8)

1

Reputation

  1. @LexManos I think I've made a lot more concise!!!! package jetcobblestone.firstmod; import jetcobblestone.firstmod.lists.itemList; import net.minecraft.item.Foods; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public class ItemsLoader { @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll ( itemList.hair_fibre = new Item(new Item.Properties().food(Foods.COOKIE).group(ItemGroup.FOOD).maxStackSize(1)).setRegistryName(location("hair_fibre")) ); } private static ResourceLocation location(String name) { return new ResourceLocation(FirstMod.modid, name); } } I didn't realise you could have the @Mod.EventBus... outside of a class, but I understand now that it's meant to go outside a class, thanks to your reply Also I think you have a few haters Don't know why though... you've been really helpful Also, do you have any suggested improvements? Like for efficiency or smmin. For example I don't know if there is a better way to do that helper method at the end, or if it's even advised. I'm really happy I got this to work without copying code straight from a tutorial! I'm now really excited for this, as it will be really easy to navigate in the future. Again, is it advised to separate everything into different classes for efficiency? It certainly makes code easier to navigate. Edit: I only just realised ur the guy who makes forge lmao Really nice to see somebody so high up in the community help on small posts like this one!
  2. I have good python knowledge and watched about 20 episodes of a good java tutorial, however I don't know I watched enough to get onto important things like class structure etc. I was hoping that it would mainly be different syntax, and a lot of it is. However, what I have found is that java is quite different. It's been very frustrating, but I feel like I'm learning a lot about java but also how minecraft and mc mods work by trying to make a modpack - something I've always wanted to do. I agree that there are quite a lot of confusions, but I'm knocking them out one by one and the response I've had on these forums has been really encouraging and helpful.
  3. Ok so first question, itemList.hair fibre it registering the new item, but is also telling it to look in the file itemList to look for what the item is. And so what you're saying, the @ symbol is telling forge to read this file? Thanks for the tips
  4. Ok, first we're defining the package, so basically telling the programme where this is. Next we import resources from minecraft and forge, so the programme knows what I'm referencing when talking about about items etc. I also import the item list I have, so it knows the data for the items which I'm trying to load. I then start the actual code by opening a public class, so that it can be accessed by the main. I then set the variable modid, so that I can easily change the name of my mod if needed. I did this in the main, but I couldn't seem to access it from there in this class, despite it being public. I then open a public static void method so I can call upon the code in my main programme. I set it as static, as nothing in it changes, and as a void as it returns nothing, just registers the items. Next we are telling forge that this is a registration event, so it knows I'm trying to register items. The next class is where I get lost. Tbh I don't know why it's there but that's what tutorials told me to do, they didn't explain it ? I think the name is important? We're then telling forge, ok this is the part we're registering. We then open a method to contain all the items being registered. Then we say: register all of these Then we say what we want to register and where extra information on these items can be found. Then we are creating another method which returns a section of code which would be the same for each item, meaning I don't have to add that on each time so it saves space.
  5. I want to have it out of my main programme, so it's easier to find when I want to add a new items. If I move it out of the main programme, then forge won't look at it by default, so I have to call it from my main to load the items, right?
  6. There are so many to keep track of I getting confusedd ARGGGG package jetcobblestone.firstmod; import jetcobblestone.firstmod.lists.itemList; import net.minecraft.item.Foods; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; public class ItemsLoader { public static final String modid = "first_mod"; @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll ( itemList.hair_fibre = new Item(new Item.Properties().food(Foods.COOKIE).group(ItemGroup.FOOD).maxStackSize(1)).setRegistryName(location("hair_fibre")) ); } } private static ResourceLocation location(String name) { return new ResourceLocation(modid, name); } } This works fine? I don't know where I need to put the method to be able to call the item registration into my main.
  7. Hey everyone, I'm trying to move my item assignment into a new class. I've stuck in into the same package as my main and called it ItemsLoader. package jetcobblestone.firstmod; import jetcobblestone.firstmod.lists.itemList; import net.minecraft.item.Foods; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.util.ResourceLocation; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; public class ItemsLoader { public static final String modid = "first_mod"; public static void Items() { @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll ( itemList.hair_fibre = new Item(new Item.Properties().food(Foods.COOKIE).group(ItemGroup.FOOD).maxStackSize(1)).setRegistryName(location("hair_fibre")) ); } } private static ResourceLocation location(String name) { return new ResourceLocation(modid, name); } } } This is the new class, however I'm running into an issue with the new Items function. It's giving me an error saying that it's expecting a volatile at the void token. Why is it trying to force me to do this? I don't want to send this to main memory? If I do replace void with volatile, it tells me there's a syntax error on the 'void' token, despite the fact there is no void. Any help would be much appreciated, thank you!
  8. I try to read the comments, but 95% are just people going on about how great and fantastic his tutorials are, which are of course the only ones he replies and likes. He doesn't bother helping people who can't it to work.
  9. Right. I'mt not good enough at java yet to be able to just look at the source and figure out what I can do yet, and I don't know all the commands I can use, but I'm sure I'll learn. The tutorials you sent me look really good!
  10. Right. Can you please explain to me the things he does wrong in an easy to understand manner? If I shouldn't use Harry Talks, who should I use then? He's seems to have one of the only 1.14 tutorials. Thanks!
  11. Hello everyone! I started to make a mod a few days ago. Upon watching some java tutorials and some episodes of Harry talks 1.14 mod tutorial, I've managed to create a food item. However, after brief looks at other tutorials, I've seen some big differences in the layout of the mods. Everything seems to be a lot more broken down into sections, and I've been finding it a bit overwhelming as I haven't really found a good tutorial which explains in detail everything whic his going on, only, copy this. What I'm really asking is, could somebody explain to me how to correctly layout a modpack and how do I network it? package jetcobblestone.firstmod; import jetcobblestone.firstmod.lists.itemList; import net.minecraft.item.Foods; import net.minecraft.item.Item; import net.minecraft.item.ItemGroup; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; 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; @Mod("first_mod") public class FirstMod { public static FirstMod instance; public static final String modid = "first_mod"; public FirstMod() { instance = this; FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::clientRegistries); MinecraftForge.EVENT_BUS.register(this); } private void setup(final FMLCommonSetupEvent event) { } private void clientRegistries(final FMLClientSetupEvent event) { } @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent public static void registerItems(final RegistryEvent.Register<Item> event) { event.getRegistry().registerAll ( itemList.hair_fibre = new Item(new Item.Properties().food(Foods.COOKIE).group(ItemGroup.FOOD).maxStackSize(1)).setRegistryName(location("hair_fibre")) ); } } private static ResourceLocation location(String name) { return new ResourceLocation(modid, name); } } This is what I have so far, please do not question why I have added in an edible hair. This is pretty much the only code stuff, though obviously I have an item list extra. Also, the tutorial I watching atm gives very specific ways of doing things, e.g. names and places. Do I have to have the item list in a folder called lists for example? How much freedom do I have with the position of files as long as I call on them correctly. I know this is quite a big question, but any guidance would be fantastic! Thank you!
×
×
  • Create New...

Important Information

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