Posted August 30, 20196 yr After reading several pages on the forums I have realized that my mod uses several bad practices including IHasModel and a weird convoluted way of registering blocks and items it is very confusing to try to fix without a point of reference so I was wondering if anyone could point me to a good example of block and item registration.
August 31, 20196 yr Create the registry event. Create your items/blocks/biomes/whatever in it. Register them. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
August 31, 20196 yr 39 minutes ago, Eilux said: Is there somewhere where I could find sample code of this. Probably all over github. But it is as simple as draco said. You should already have a registry event if you are using a modern version. So step one complete. Step two is to only call new BlahItem in the Item Registry Event, and likewise for Blocks. Then you need to register those items and blocks in the event. Now if you need to have access to those values use the ObjectHolder annotation. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
August 31, 20196 yr Author Is it necessary to make a new class for every block or item added or is it acceptable to make a generic block class that takes in parameters the one that i had been using previously was this. package mod.eilux.mcge.blocks; import mod.eilux.mcge.McGE; import mod.eilux.mcge.init.ModBlocks; import mod.eilux.mcge.init.ModItems; import mod.eilux.mcge.util.IHasModel; import net.minecraft.block.Block; import net.minecraft.block.SoundType; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import java.util.Collections; import java.util.HashMap; import java.util.Map; public class BlockBase extends Block implements IHasModel { private static final Map<String, SoundType> soundIndex; private static final Map<String,CreativeTabs> tabIndex; static { Map<String, SoundType> tempSoundIndex = new HashMap<>(); tempSoundIndex.put("metal", SoundType.METAL); tempSoundIndex.put("stone", SoundType.STONE); tempSoundIndex.put("anvil", SoundType.ANVIL); tempSoundIndex.put("cloth", SoundType.CLOTH); tempSoundIndex.put("glass", SoundType.GLASS); tempSoundIndex.put("ground", SoundType.GROUND); tempSoundIndex.put("ladder", SoundType.LADDER); tempSoundIndex.put("plant", SoundType.PLANT); tempSoundIndex.put("sand", SoundType.SAND); tempSoundIndex.put("slime", SoundType.SLIME); tempSoundIndex.put("snow", SoundType.SNOW); tempSoundIndex.put("wood", SoundType.WOOD); soundIndex = Collections.unmodifiableMap(tempSoundIndex); Map<String, CreativeTabs> tempTabIndex = new HashMap<>(); tempTabIndex.put("misc", CreativeTabs.MISC); tempTabIndex.put("brewing", CreativeTabs.BREWING); tempTabIndex.put("building_blocks", CreativeTabs.BUILDING_BLOCKS); tempTabIndex.put("combat", CreativeTabs.COMBAT); tempTabIndex.put("decorations", CreativeTabs.DECORATIONS); tempTabIndex.put("food", CreativeTabs.FOOD); tempTabIndex.put("redstone", CreativeTabs.REDSTONE); tempTabIndex.put("tools", CreativeTabs.TOOLS); tempTabIndex.put("transportation", CreativeTabs.TRANSPORTATION); tabIndex = Collections.unmodifiableMap(tempTabIndex); } public BlockBase(String name, Material material, String tab, String soundType, Float hardness, Float blastRes, String harvestTool, int harvestLevel, Float lightLevel, int opacity){ super(material); setTranslationKey(name); setRegistryName(name); setCreativeTab(tabIndex.get(tab)); setSoundType(soundIndex.get(soundType)); setHardness(hardness); setResistance(blastRes); setHarvestLevel(harvestTool,harvestLevel); setLightLevel(lightLevel); setLightOpacity(opacity); ModBlocks.BLOCKS.add(this); ModItems.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName())); } @Override public void registerModels() { McGE.proxy.registerItemRenderer(Item.getItemFromBlock(this),0,"inventory"); } } *I am still in the process of removing IHasModel
August 31, 20196 yr 17 minutes ago, Eilux said: Is it necessary to make a new class for every block or item added or is it acceptable to make a generic block class that takes in parameters You just described the Block and Item class. You should not make a "base" class for your mod because it already exists. You only need a new class if your block needs custom behavior(right click, a te, etc). VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
August 31, 20196 yr Author whenever I add .setHarvestLevel() to the Block class it gives me an incompatible type error: expected: Block, got: void
August 31, 20196 yr 8 minutes ago, Eilux said: whenever I add .setHarvestLevel() to the Block class it gives me an incompatible type error: expected: Block, got: void Show your code. Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
August 31, 20196 yr Author new Block(Material.IRON).setRegistryName("ruby_block").setCreativeTab(CreativeTabs.BUILDING_BLOCKS).setHardness(5.0F).setResistance(10.0F).setHarvestLevel("pickaxe",2);
September 1, 20196 yr If you're on 1.14 its two methods. harvestTool and harvestLevel https://github.com/Draco18s/ReasonableRealism/blob/1.14.4/src/main/java/com/draco18s/harderores/HarderOres.java#L112 Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.