GenElectrovise
Members-
Posts
132 -
Joined
-
Last visited
Everything posted by GenElectrovise
-
No problem ? I’ve never had to use this before, so I don’t pretend to be an expert, but I hope this helps anyway...
-
Hi! Does this help?
-
Hi all! Thanks for the responses! I now see the point of BlockItems! Ok so here's what I have now with this info: (Trying to register AMETHYST_BLOCK and its BlockItem) However, I've played around a bit with it and every time I get this error: Now looking at this I can see that the error occurs in the last "section" because (according to my logging code) the FMLJavaModLoadingContext is null. Here's my Main class. Perhaps it's got something to do with a faulty annotation to "declare" my mod? I gotta try getting this onto GitHub before it gets too big
-
Hi all, I've just begun updating my 1.12.2 mod to 1.15.2 (big task!) and I have a couple of questions to ask so I can start off the right way and don't run into issues regarding the basic setup of the mod later on: 1) What is the "Forge Approved" method for registering Items and Blocks? Similarly to 1.12.2, Items and Blocks etc are registered using @Mod.EventBusSubscriber(modid = Main.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) ...and then subscribing a method to events and passing in the correct Registry Event as a parameter. @SubscribeEvent public static void registerBlocks(RegistryEvent.Register<Block> event) { Main.LOGGER.info("Doing registration of Blocks for MODID : " + Main.MODID); event.getRegistry().registerAll(AMETHYST_BLOCK); } public static final Block AMETHYST_BLOCK = new Block(Properties.create(Material.GLASS).harvestTool(ToolType.PICKAXE) .sound(SoundType.GLASS).lightValue(8).hardnessAndResistance(3F, 3F).slipperiness(0.1F)) .setRegistryName(Main.MODID, "amethyst_block"); This is slightly different in syntax to 1.12.2 but a very similar idea. ===== 2) Where does @ObjectHolder come into all of this? What is its purpose? ===== 3) How do BlockItems work? I assume there's a reason for their existence, but what is it? Here's what I'm currently using but I don't know if any of this is correct / the done-thing? @SubscribeEvent public static void registerBlockItems(RegistryEvent.Register<Item> event) { event.getRegistry().registerAll( new BlockItem(EvileBlocks.AMETHYST_BLOCK, new Item.Properties().maxStackSize(64).group(ItemGroup.BUILDING_BLOCKS)) .setRegistryName(EvileBlocks.AMETHYST_BLOCK.getRegistryName()) ); } ===== 4) Any good tutorials? So far I've been using a mix of mcforge.readthedocs.io and the MC source code. Unfortunately, readthedocs doesn't give some of the basic practical information needed (eg What resources does a Block need? I believe it needs a model, blockstate and a loot table?) ; and MC source, while great for examples, doesn't explain anything (although with time and effort you can often work out what's happening). In 1.12.2 I used HarryTalks until @Draco18s kindly explained why I shouldn't in this post (Don't worry I'm cured now ) ===== Anyway that's certainly enough questions for one post -- someone let me know if each one of these should be in its own topic, but I figured that these are perhaps small enough to be grouped! Thanks!
-
Forge for 1.15 with Eclipse: Package Explorer Empty?
GenElectrovise replied to IceMetalPunk's topic in ForgeGradle
Hi what version of java are you using? I'm trying rn to set up a 1.15.2 workspace to also update from 1.12.2, and I fixed the error I was having (When importing the gradle project) by downgrading my java version to 8u241? I think ForgeGradle supports up to java 10? Looking through my old 1.12.2 workspace, I can't see an "eclipse" folder tho. Ps Just realised this thread is from December :/. Hope this helps someone a bit? Have you resolved this issue? -
[1.12.2] GuiContainer not opening onBlockActivated
GenElectrovise replied to GenElectrovise's topic in Modder Support
Also for easier reviewing for future I'm going to make a github repo for this. Also means I'll have a backup! -
[1.12.2] GuiContainer not opening onBlockActivated
GenElectrovise replied to GenElectrovise's topic in Modder Support
Hi again! Sorry for the belated response! I have done the things mentioned above, however, I also noticed that I was only opening the GUI on the server ( !world.isRemote ) and as GUIs don't exist as a GUI on the server -- only the GuiContainer I changed that to openGui if world.isRemote (therefore on the client) and now I get a helpful stacktrace! Even if it should still be !world.isRemote which might seem logical as the client should be getting its prompts from the server, this should still be useful (right?) as it's exposed an error which was unknown and failing silently before. ====== Oh also wasn't me calling it specifically, it was being called from TileEntity.java when I construct my TileEntityAltar and called its super constructor. Again sorry for taking so long and thanks for all the assistance so far! -
[1.12.2] GuiContainer not opening onBlockActivated
GenElectrovise replied to GenElectrovise's topic in Modder Support
Ok, so now I'm getting a loop when the game tries to register the tile entity and its capabilities, which is resulting in a StackOverFlowException. (The loop occurs between the area marked with + in the stacktrace). I think it's because when I try to register the capabilities, I do this: @SubscribeEvent public static void registerGuiRelations(AttachCapabilitiesEvent<TileEntity> event) { event.addCapability(new ResourceLocation(Main.MODID + ":capabilites_altar"), new TileEntityAltar()); } I create a new TileEntityAltar which then calls its superconstructor which goes to line 508 in the TileEntity constructor: private net.minecraftforge.common.capabilities.CapabilityDispatcher capabilities; public TileEntity() { capabilities = net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(this); } Which causes forge to do.... something: @Nullable public static CapabilityDispatcher gatherCapabilities(TileEntity tileEntity) { return gatherCapabilities(new AttachCapabilitiesEvent<TileEntity>(TileEntity.class, tileEntity), null); } So how should I be registering the capabilities? -- it's pretty evident I'm doing this wrong! Also, my updated code from @Animefan8888's post: TileEntityAltar, ContainerAltar, registering capabilities, registering TileEntities Those are the main changes, but I haven't included minor ones like removing my own useless methods. Thanks! -
[1.12.2] GuiContainer not opening onBlockActivated
GenElectrovise replied to GenElectrovise's topic in Modder Support
Right. Ok. That's the explanation I needed. -
[1.12.2] GuiContainer not opening onBlockActivated
GenElectrovise replied to GenElectrovise's topic in Modder Support
Question: How does the container (ContainerAltar) work when using IItemHandler ? Is it still necessary, because I'm getting a lot of errors from when I previously tried to add slots. this.addSlotToContainer(new Slot(tileentity, 0, 305, 185)); Soooooo I'm guessing that's a IInventory thing. Does this have an equivalent with IItemHandler and Capabilities ? Do I even still need the container? The Altar will have an inventory (of 4 slots), so therefore it needs to persist the data, right? So that means that TileEntityAltar should implement ICapabilitySerializable<T extends NBTBase> ? The -
[1.12.2] GuiContainer not opening onBlockActivated
GenElectrovise replied to GenElectrovise's topic in Modder Support
Ok shall make those changes, @Animefan8888. Will post results once done! (will likely be in a few hours) Thanks for the response! Also, for @loordgek, any particular reason for I see that some of his choices aren't the best, but anything else specific? -
Hello all! I'm trying to open a gui when I right click on a block (Altar), but although my logging code says the opening code is running, the gui doesn't appear. I don't know what the problem is, but I think it's just not opening (rather than just not rendering) as the game doesn't make me press Esc before I can move again. The GUI textures are located in magiksmostevile:textures/gui/altar/altar_gui.png and the texture is attached. As in the image, it should have four basic slots in the four areas to the right, and when I can actually see the gui I will add a scrolling menu on the left. I have used the following resources to help: Primarily: https://www.youtube.com/playlist?list=PLiDUvCGH5WEUEV9nc0Ll2pzUFmSFc21uR -- specifically the 5/6 tutorials on the Sintering Furnace Also: https://www.youtube.com/watch?v=MHgS0GTNqq0&t=229s just for another potential way to open a gui And: http://jabelarminecraft.blogspot.com/p/minecraft-modding-containers.html As well as the minecraft source for the Enchantment Table, Furnace, Anvil, Villagers, Chest and this forum post. So after all that, I still don't know the problem. I know there's gotta be something I'm missing, so any help from anyone who knows how to open a gui would be much appreciated! Ps Sorry for the data-dump of code, but I figured it would be better to provide people with hopefully everything they need, rather than having to add more later.
-
[1.12.2] Recipe advancement for conditional recipe
GenElectrovise replied to Daeruin's topic in Modder Support
Couldn't find many but managed to page through the info on the minecraft wiki to find the right JSON format. All done for the moment now! -
[1.12.2] Recipe advancement for conditional recipe
GenElectrovise replied to Daeruin's topic in Modder Support
There must be I think. I'm just trying to get any advancement to work! -- Where did you find out how to add them? In terms of your question, perhaps when the advancement condition is met, you could test the configs? Sorry this is so vague, but I'm struggling with the lack of documentation on this subject too! -
I know what static means (I spent several painful weeks when I was first learning java making everything static and learning why that tends not to be the best idea ) but didn't think to apply the knowledge as I didn't mentally register the static nature of the field. Oops! Anyways this now works! For any future modders having a similar issue the fix in the end was: int potatoAge = (int)world.getBlockState(blockPos).getProperties().get(((BlockPotato) block).AGE); where the block at blockPos is guaranteed to be a BlockPotato. Thanks all! I guess this thread can be closed now? Now time for me to go root through the vanilla code to find out how to spawn EntityItems! (Yay)
-
Yes... I have looked and AGE is created as a new PropertyInteger with the args ' "age", 0, and 7' for 'name max and min' values. When I try passing th..... Wait..... Let me try something... ( *Tests in eclipse* ) I get it. I needed to pass in ((BlockPotato) block).AGE as the property to get. That was..... more obvious than I expected! The clue was in the "static". I can now get the age! Thanks! And this looks like it'll help in future also! I'll try implementing this fully later, but I think the issue of getting the value is solved! If I have any more problems it shouldn't relate to the getting of the value -- just the comparing logic! Many thanks, again! GenElectrovise
-
Maybe I don't -- It wasn't working before (crashing with NullPointerException because it couldn't find the blockstate for some reason)... To use IStateHolder.get(IProperty) you would need to get the blockstate of the block right? And you would do this with: world.getBlockState(blockPos) or block.getBlockState ? Then how would you go about calling the method. Would you need to get said IStateHolder from the block? Also I can't find IStateHolder.java with Crtl+Shift+R. I guess that means it's a subclass?