Posted January 30, 20187 yr Hello! My block Drill's name is not displaying correctly. The block has the three properties, PropertyEnum for types, PropertyDirection for model rotation and PropertyBool for redstone activation. For some reason, both the basic drill and advanced drill, in the inventory show the same block.drill.basic.name. Yet, the placed blocks display (using Waila) the block.drill.basic.name and block.drill.advanced.name. I'm presuming it's an issue with it's unlocalized name in my block's BlockDrill.java? Basic Drill Image https://ibb.co/jpWM16 Advanced Drill Image https://ibb.co/d1XiER BlockDrill.java package archieab.andustry.blocks; import java.util.List; import archieab.andustry.Reference; import archieab.andustry.blocks.item.IMetaBlockName; import archieab.andustry.handlers.EnumHandler.MacTypes; import net.minecraft.block.Block; import net.minecraft.block.BlockPistonBase; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyBool; import net.minecraft.block.properties.PropertyDirection; 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.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; public class BlockDrill extends Block implements IMetaBlockName { public static final PropertyEnum TYPE = PropertyEnum.create("type", MacTypes.class); public static final PropertyDirection FACING = PropertyDirection.create("facing"); public static final PropertyBool ACTIVATED = PropertyBool.create("activated"); public BlockDrill(String unlocalizedName) { super(Material.IRON); this.setUnlocalizedName(unlocalizedName); this.setRegistryName(new ResourceLocation(Reference.MODID, unlocalizedName)); this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, MacTypes.BASIC).withProperty(FACING, EnumFacing.NORTH).withProperty(ACTIVATED, Boolean.valueOf(false))); } @Override protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {TYPE,FACING,ACTIVATED}); } @Override public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand) { return this.getDefaultState().withProperty(FACING, EnumFacing.getDirectionFromEntityLiving(pos, placer)).withProperty(ACTIVATED, Boolean.valueOf(false)).withProperty(TYPE, getStateFromMeta(meta * EnumFacing.values().length).getValue(TYPE)); } @Override public int getMetaFromState(IBlockState state) { MacTypes type = (MacTypes) state.getValue(TYPE); EnumFacing facing = (EnumFacing) state.getValue(FACING); int meta = type.getID() * EnumFacing.values().length + facing.ordinal(); return meta; } @Override public IBlockState getStateFromMeta(int meta) { MacTypes type = MacTypes.values()[(int)(meta / EnumFacing.values().length) % MacTypes.values().length]; EnumFacing facing = EnumFacing.values()[meta % EnumFacing.values().length]; return this.getDefaultState().withProperty(TYPE, type).withProperty(FACING, facing); } @Override public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) { return new ItemStack(Item.getItemFromBlock(this), 1, (int) (getMetaFromState(world.getBlockState(pos)) / EnumFacing.values().length)); } @Override public int damageDropped(IBlockState state) { return (int) (getMetaFromState(state) / EnumFacing.values().length); } @Override public String getSpecialName(ItemStack stack) { return MacTypes.values()[stack.getItemDamage() / EnumFacing.values().length].getName(); } @Override public void getSubBlocks(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> list) { for (int i = 0; i < MacTypes.values().length; i++) { list.add(new ItemStack(itemIn, 1, i)); } } } Any help would be greatly appreciated!
January 30, 20187 yr Author Just now, Sunser said: Can you show us your language file (en_US.lang I guess) ? It's not to do with the lang. I haven't added the block's into the lang purely so you can see the raw name. I'm almost certain the issue is to do with it's SpecialName or UnlocalizedName.
January 30, 20187 yr Sorry, my bad. Have you check when you register your blocks that the String is correct ? It could be a copy/paste which has not been edited.
January 30, 20187 yr Author 1 minute ago, Sunser said: Sorry, my bad. Have you check when you register your blocks that the String is correct ? It could be a copy/paste which has not been edited. Are you talking about my ModBlocks.java? If so, here's the code: package archieab.andustry.init; import archieab.andustry.Andustry; import archieab.andustry.Reference; import archieab.andustry.blocks.BlockCopperOre; import archieab.andustry.blocks.BlockDrill; import archieab.andustry.blocks.BlockMachineFrameAdvanced; import archieab.andustry.blocks.BlockMachineFrameBasic; import archieab.andustry.blocks.BlockTinOre; import archieab.andustry.blocks.BlockCoalCatalystBlock; import archieab.andustry.blocks.item.ItemBlockDrill; import archieab.andustry.handlers.EnumHandler; import archieab.andustry.util.Utils; import net.minecraft.block.Block; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.item.Item; import net.minecraft.item.ItemBlock; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.common.registry.GameRegistry; public class ModBlocks { public static Block copper_ore; public static Block tin_ore; public static Block machineframebasic; public static Block machineframeadvanced; public static Block drill; public static Block coalcatalystblock; public static void init() { copper_ore = new BlockCopperOre("copper_ore", "copper_ore"); tin_ore = new BlockTinOre("tin_ore", "tin_ore"); machineframebasic = new BlockMachineFrameBasic("machineframebasic", "machineframebasic"); machineframeadvanced = new BlockMachineFrameAdvanced("machineframeadvanced", "machineframeadvanced"); drill = new BlockDrill("drill"); coalcatalystblock = new BlockCoalCatalystBlock("coal_catalyst_block", "coal_catalyst_block"); } public static void register() { registerBlock(copper_ore); registerBlock(tin_ore); registerBlock(machineframebasic); registerBlock(machineframeadvanced); registerBlock(drill, new ItemBlockDrill(drill)); registerBlock(coalcatalystblock); } public static void registerRenders() { registerRender(copper_ore); registerRender(tin_ore); registerRender(machineframebasic); registerRender(machineframeadvanced); for(int i = 0; i < EnumHandler.MacTypes.values().length; i++) { registerRender(drill, i, "block_drill_" + EnumHandler.MacTypes.values()[i].getName()); } registerRender(coalcatalystblock); } public static void registerBlock(Block block) { block.setCreativeTab(Andustry.Blocks); GameRegistry.register(block); GameRegistry.register(new ItemBlock(block).setRegistryName(block.getRegistryName())); Utils.getLogger().info("Registered Block: " + block.getUnlocalizedName().substring(5)); } public static void registerBlock(Block block, ItemBlock itemBlock) { block.setCreativeTab(Andustry.Blocks); GameRegistry.register(block); GameRegistry.register(itemBlock.setRegistryName(block.getRegistryName())); Utils.getLogger().info("Registered Block: " + block.getUnlocalizedName().substring(5)); } public static void registerRender(Block block) { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), 0, new ModelResourceLocation(new ResourceLocation(Reference.MODID, block.getUnlocalizedName().substring(5)), "inventory")); Utils.getLogger().info("Registered render for " + block.getUnlocalizedName().substring(5)); } public static void registerRender(Block block, int meta, String fileName) { ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block), meta, new ModelResourceLocation(new ResourceLocation(Reference.MODID, fileName), "inventory")); Utils.getLogger().info("Register render for " + block.getUnlocalizedName().substring(5)); } }
January 30, 20187 yr I'm sorry, I'm not good enough to help you. Maybe take a look at Thermal Expansion mod which has something similar with upgrades.
January 30, 20187 yr Author Just now, Sunser said: I'm sorry, I'm not good enough to help you. Maybe take a look at Thermal Expansion mod which has something similar with upgrades. Okay, thanks for you help.
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.