Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/05/18 in all areas

  1. No. And if anyone can point me at a tutorial that is saying to do this, link it, so I can go punch that person in the face for being an idiot. Problematic Code Issue #1
    2 points
  2. Your issue is in your Provider https://github.com/Oeku/RPG-Mod/blob/master/src/main/java/net/zeldadungeons/capability/CapabilityProvider.java as you don't check if the capability is of the same type but just cast to it without any checks
    1 point
  3. YOU DON'T HAVE TO. NO ONE SAID YOU DID. YOUR the one who started asking about Forge blockstates. And this isn't even your thread! The whole reason the Forge format exists is to simplify complex state mappings (two or more different values) as Forge will do the cartesian grid for you (so you a) don't have to type out 366 lines of JSON and b) don't have to sort them alphabetically and get it wrong by fucking up and adding a space where one shouldn't be).
    1 point
  4. I'm not sure I can in any way explain how this works, but I know it does: https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/ores/client/ProspectorParticle.java I only render the particles on one client (not all clients) and I use packets to tell the affected client it needs to render the particle and then handle the message via my client proxy.
    1 point
  5. I also have an easy way of handling block and item registration. I do endeavor you (the original poster) to write your own code to register blocks and items first (do it once) so that you understand how its achieved. But I wrote a couple of classes that clean up my main mod class significantly while also being highly flexible and capable of registering blocks and items with any possible deviation (that I know of). I've also got some other hooks that are incomplete (does not yet handle everything, just everything I've needed) such as enchantments and advancement triggers (currently requires reflection). https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/EasyRegistry.java https://github.com/Draco18s/ReasonableRealism/blob/1.12.1/src/main/java/com/draco18s/hardlib/client/ClientEasyRegistry.java These two classes act as CommonProxy and ClientProxy in a library mod (yes, yes, code style #1) hence lines 55-81 in the first class, which redirects static method calls through the HardLib proxy. Example usage: millstone = new BlockMillstone(); EasyRegistry.registerBlockWithItem(millstone, "millstone");
    1 point
  6. I'm brand new to modding and a noob programmer. I learned the old way to register blocks and items using GameRegistry.register() then I found out there is actually a new, better way to register blocks, items, and even models. The new way is to use RegistryEvents and I'm a sucker for new and better things so I tried to figure out how it works. My goal with this post is to see if anything I did can be done better and whether or not this is correct. Just because it works doesn't mean it's correct. I want to have a solid base before I build on it too much. Here is what I came up with: RegistryEventHandler.java @Mod.EventBusSubscriber public class RegistryEventHandler { @SubscribeEvent public static void registerBlocks(RegistryEvent.Register<Block> event) { event.getRegistry().registerAll(ModBlocks.BLOCKS); Utils.getLogger().info("Registered blocks"); } @SubscribeEvent public static void registerItems(RegistryEvent.Register<Item> event) { event.getRegistry().registerAll(ModItems.ITEMS); for (Block block : ModBlocks.BLOCKS) { event.getRegistry().register(new ItemBlock(block).setRegistryName(block.getRegistryName())); } Utils.getLogger().info("Registered items"); } @SubscribeEvent public static void registerModels(ModelRegistryEvent event) { for (Block block: ModBlocks.BLOCKS) { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(block.getRegistryName(), "inventory")); } for (Item item: ModItems.ITEMS) { ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory")); } Utils.getLogger().info("Registered models"); } } ModBlocks.java public class ModBlocks { public static final Block[] BLOCKS = { new BlockTinOre("tin_ore", Material.ROCK), new BlockTinBlock("tin_block", Material.ROCK) }; } ModItems.java public class ModItems { public static final Item[] ITEMS = { new ItemTinIngot("tin_ingot") }; } BlockTinOre.java public class BlockTinOre extends BlockBase { public BlockTinOre(String name, Material material) { super(name, material); } } BlockTinBlock.java public class BlockTinBlock extends BlockBase { public BlockTinBlock(String name, Material material) { super(name, material); } } BlockBase.java public class BlockBase extends Block { BlockBase(String name, Material material) { super(material); this.setRegistryName(Reference.MODID, name); this.setUnlocalizedName(this.getRegistryName().toString()); } } ItemTinIngot.java public class ItemTinIngot extends ItemBase { public ItemTinIngot(String name) { super(name); } } ItemBase.java public class ItemBase extends Item { ItemBase(String name) { this.setRegistryName(new ResourceLocation(Reference.MODID, name)); this.setUnlocalizedName(this.getRegistryName().toString()); } }
    1 point
×
×
  • Create New...

Important Information

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