Posted September 7, 20169 yr I can't seem to figure out how to make my log display a texture here's an error message: Exception loading blockstate for the variant mymod:modlogs#axis=z,variant=corwood: java.lang.Exception: Could not load model definition for variant mymod:modlogs and here are the classes for my custom log: Logs package mymod.blocks; import java.util.List; import javax.annotation.Nullable; import net.minecraft.block.BlockLog; import net.minecraft.block.material.MapColor; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import com.google.common.base.Predicate; public class ModdedLogs extends BlockLog implements IMetaBlockName { public static final PropertyEnum<ModdedPlanks.EnumType> VARIANT = PropertyEnum.<ModdedPlanks.EnumType>create("variant", ModdedPlanks.EnumType.class, new Predicate<ModdedPlanks.EnumType>() { public boolean apply(@Nullable ModdedPlanks.EnumType p_apply_1_) { return p_apply_1_.getMetadata() < 4; } }); public ModdedLogs() { this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, ModdedPlanks.EnumType.Dark).withProperty(LOG_AXIS, BlockLog.EnumAxis.Y)); } /** * Get the MapColor for this Block and the given BlockState */ public MapColor getMapColor(IBlockState state) { ModdedPlanks.EnumType blockplanks$enumtype = (ModdedPlanks.EnumType)state.getValue(VARIANT); switch ((BlockLog.EnumAxis)state.getValue(LOG_AXIS)) { case X: case Z: case NONE: default: switch (blockplanks$enumtype) { case Dark: default: return ModdedPlanks.EnumType.Dark.getMapColor(); case Corrupted: return ModdedPlanks.EnumType.Corrupted.getMapColor(); } case Y: return blockplanks$enumtype.getMapColor(); } } /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @SideOnly(Side.CLIENT) public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list) { list.add(new ItemStack(itemIn, 1, ModdedPlanks.EnumType.Dark.getMetadata())); list.add(new ItemStack(itemIn, 1, ModdedPlanks.EnumType.Corrupted.getMetadata())); } /** * Convert the given metadata into a BlockState for this Block */ public IBlockState getStateFromMeta(int meta) { IBlockState iblockstate = this.getDefaultState().withProperty(VARIANT, ModdedPlanks.EnumType.byMetadata((meta & 3) + 4)); switch (meta & 12) { case 0: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Y); break; case 4: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.X); break; case 8: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.Z); break; default: iblockstate = iblockstate.withProperty(LOG_AXIS, BlockLog.EnumAxis.NONE); } return iblockstate; } /** * Convert the BlockState into the correct metadata value */ @SuppressWarnings("incomplete-switch") public int getMetaFromState(IBlockState state) { int i = 0; i = i | ((ModdedPlanks.EnumType)state.getValue(VARIANT)).getMetadata(); switch ((BlockLog.EnumAxis)state.getValue(LOG_AXIS)) { case X: i |= 4; break; case Z: i |= 8; break; case NONE: i |= 12; } return i; } protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {VARIANT, LOG_AXIS}); } protected ItemStack createStackedBlock(IBlockState state) { return new ItemStack(Item.getItemFromBlock(this), 1, ((ModdedPlanks.EnumType)state.getValue(VARIANT)).getMetadata()); } /** * Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It * returns the metadata of the dropped item based on the old metadata of the block. */ public int damageDropped(IBlockState state) { return ((ModdedPlanks.EnumType)state.getValue(VARIANT)).getMetadata(); } @Override public String getSpecialName(ItemStack stack) { // TODO Auto-generated method stub return stack.getItemDamage() == 0 ? "white" : "black"; } } Planks package mymod.blocks; import java.util.List; import net.minecraft.block.Block; import net.minecraft.block.material.MapColor; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockStateContainer; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IStringSerializable; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class ModdedPlanks extends Block implements IMetaBlockName { public static final PropertyEnum<ModdedPlanks.EnumType> VARIANT = PropertyEnum.<ModdedPlanks.EnumType>create("variant", ModdedPlanks.EnumType.class); public ModdedPlanks() { super(Material.WOOD); this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, ModdedPlanks.EnumType.Dark)); this.setCreativeTab(CreativeTabs.BUILDING_BLOCKS); } /** * Gets the metadata of the item this Block can drop. This method is called when the block gets destroyed. It * returns the metadata of the dropped item based on the old metadata of the block. */ public int damageDropped(IBlockState state) { return ((ModdedPlanks.EnumType)state.getValue(VARIANT)).getMetadata(); } /** * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks) */ @SideOnly(Side.CLIENT) public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list) { for (ModdedPlanks.EnumType blockplanks$enumtype : ModdedPlanks.EnumType.values()) { list.add(new ItemStack(itemIn, 1, blockplanks$enumtype.getMetadata())); } } /** * Convert the given metadata into a BlockState for this Block */ @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(VARIANT, ModdedPlanks.EnumType.byMetadata(meta)); } /** * Get the MapColor for this Block and the given BlockState */ public MapColor getMapColor(IBlockState state) { return ((ModdedPlanks.EnumType)state.getValue(VARIANT)).getMapColor(); } /** * Convert the BlockState into the correct metadata value */ @Override public int getMetaFromState(IBlockState state) { return ((ModdedPlanks.EnumType)state.getValue(VARIANT)).getMetadata(); } protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {VARIANT}); } public static enum EnumType implements IStringSerializable { Dark(0, "darkwood", MapColor.WOOD), Corrupted(1, "corwood", MapColor.OBSIDIAN); private static final ModdedPlanks.EnumType[] META_LOOKUP = new ModdedPlanks.EnumType[values().length]; private final int meta; private final String name; private final String unlocalizedName; /** The color that represents this entry on a map. */ private final MapColor mapColor; private EnumType(int metaIn, String nameIn, MapColor mapColorIn) { this(metaIn, nameIn, nameIn, mapColorIn); } private EnumType(int metaIn, String nameIn, String unlocalizedNameIn, MapColor mapColorIn) { this.meta = metaIn; this.name = nameIn; this.unlocalizedName = unlocalizedNameIn; this.mapColor = mapColorIn; System.out.println(nameIn); } public int getMetadata() { return this.meta; } /** * The color which represents this entry on a map. */ public MapColor getMapColor() { return this.mapColor; } public String toString() { return this.name; } public static ModdedPlanks.EnumType byMetadata(int meta) { if (meta < 0 || meta >= META_LOOKUP.length) { meta = 0; } return META_LOOKUP[meta]; } @Override public String getName() { return this.name; } public String getUnlocalizedName() { return this.unlocalizedName; } static { for (ModdedPlanks.EnumType blockplanks$enumtype : values()) { META_LOOKUP[blockplanks$enumtype.getMetadata()] = blockplanks$enumtype; } } } @Override public String getSpecialName(ItemStack stack) { return stack.getItemDamage() == 0 ? "white" : "black"; } } it's most likely i have something named wrong, but i can't find what that would be.
September 7, 20169 yr Where do you register the render for these? (main or proxies?) When do you register them? (preInit, init, postInit) How do you render them? Minecraft::getItemModelMesher() (think that's the method name) or with ModelLoader? Post your classes that deals with these. Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
September 7, 20169 yr Do you have a json blockstate file? 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.
September 8, 20169 yr Author i've been doing a lot of testing and i actually have multiple blockstate files i don't know which one is being called so here they are darkwood.json { "variants": { "normal": { "model": "mymod:DarkStone" } } } darkwood_modlogs.json { "variants": { "axis=y": { "model": "acacia_log" }, "axis=z": { "model": "acacia_log", "x": 90 }, "axis=x": { "model": "acacia_log", "x": 90, "y": 90 }, "axis=none": { "model": "acacia_bark" } } } modlogs.json { "variants": { "variant=darkwood": { "axis=y": { "model": "acacia_log" }, "axis=z": { "model": "acacia_log", "x": 90 }, "axis=x": { "model": "acacia_log", "x": 90, "y": 90 }, "axis=none": { "model": "acacia_bark" } } } }
September 8, 20169 yr Author this is in my main file in preinit ModBlocks.inti(); ModBlocks.register(); modblocks file info public static void register() { GameRegistry.registerBlock(l = new ModdedLogs(), ItemBlockMeta.class,"modlogs").setUnlocalizedName("modlogs"); } reg(ModBlocks.l, 0, "darkwood"); reg(ModBlocks.l, 1, "corwood"); public static void reg(Block block, int meta, String file) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher() .register(Item.getItemFromBlock(block), meta, new ModelResourceLocation("mymod:" + file, "inventory")); } proxy public class ClientProxy extends CommonProxy { @Override public void preInit( FMLPreInitializationEvent event ) { super.preInit(event); ModEntities.RegisterEntity(); } @Override public void init( FMLInitializationEvent event ) { ModBlocks.registerRenders(); } @Override public void postInit( FMLPostInitializationEvent event ) { super.postInit(event); } }
September 8, 20169 yr You can't use client side code in common code. You must move that stuff to your client proxy. Also, you must use ModelLoader.setCustomModelResourceLocation https://github.com/Draco18s/ReasonableRealism/blob/master/src/main/java/com/draco18s/ores/client/ClientProxy.java Also don't use GameRegistry.registerBlock, it's deprecated for a reason. 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.
September 8, 20169 yr Author i have other blocks that work just fine l have multiple versions of sand and planks it's just the logs that don't work. so i still have to move my "common code" over to the client proxy
September 8, 20169 yr Just use GameRegistry#register(Object) to register your blocks and items. ModelLoader also has to be called in preInit, after your registration of the blocks. Also, for the ModelResourceLocation , do not manually prefix the name. Simply call block.getRegistryName , and it will prefix it for you. If I have a block that I call "superblock", in a mod called "supermod", getRegistryName will return "supermod:superblock" for me. This also means that the files for which the blockstate & models will try to look for, have to have the same name as what was used for the setRegistryName , which here would be "superblock". Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
September 8, 20169 yr i have other blocks that work just fine l have multiple versions of sand and planks it's just the logs that don't work. It's deprecated because it's slated for removal. Not deprecated because it doesn't function. 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.