Jump to content

Cadmium-X

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by Cadmium-X

  1. Thank both of you very much. I will go see if I can get it figured out with this info.
  2. I found that problem and its the area I mentioned that I could change the names of the enumtypes but for the life of me I cant figure out how to add more to it. Everytime I try adding the other names to that list I get errors to the whole section of code. If I change one of the existing ones it does change the block texture placed in game. Also the same goes for the .getspecialname if I change the types there it changes the names but if I try to add more I get errors on that entire section of code as well.
  3. Hey I am trying to make a mod for my daughter so she can make textures/designs for it. However I have no programming experience and have run into an issue I cant figure out. I am creating a set of metadata blocks and they all show the different textures in the inventory. The issue is there are only two names from the first 2 items. I have 1 Black Dyed Stone and 14 Blue Dyed Stone. Also because of this only the black and blue stones can be placed in the world. I can change the stone names for the two that appear as well as the textures that appear in the world in the areas that I believe the problem is in but cannot figure out how to add more names to the list without errors. StoneBLocksProperties.java package com.panex.coloryourworld.blocks; import java.util.List; import com.panex.coloryourworld.creativetabs.MTabs; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.block.state.BlockState; 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.BlockPos; import net.minecraft.util.IStringSerializable; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; public class StoneBlockProperties extends Block implements IMetaBlockName { public static final PropertyEnum TYPE = PropertyEnum.create("type", StoneBlockProperties.EnumType.class); public StoneBlockProperties(String unlocalizedName) { super(Material.iron); this.setUnlocalizedName(unlocalizedName); this.setCreativeTab(MTabs.tabblock); this.setHardness(2); this.setResistance(6); this.setHarvestLevel("pickaxe", 0); this.setLightOpacity(16); this.setLightLevel(0); this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, EnumType.BLACK)); } @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(TYPE, meta == 0 ? EnumType.BLACK : EnumType.BLUE) ; } @Override public int getMetaFromState(IBlockState state) { EnumType type = (EnumType) state.getValue(TYPE); return type.getID(); } @Override public int damageDropped(IBlockState state) { return getMetaFromState(state); } @Override protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { TYPE }); } @SuppressWarnings({ "unchecked", "rawtypes" }) @Override public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) { list.add(new ItemStack(itemIn, 1, 0)); list.add(new ItemStack(itemIn, 1, 1)); list.add(new ItemStack(itemIn, 1, 2)); list.add(new ItemStack(itemIn, 1, 3)); list.add(new ItemStack(itemIn, 1, 4)); list.add(new ItemStack(itemIn, 1, 5)); list.add(new ItemStack(itemIn, 1, 6)); list.add(new ItemStack(itemIn, 1, 7)); list.add(new ItemStack(itemIn, 1, ); list.add(new ItemStack(itemIn, 1, 9)); list.add(new ItemStack(itemIn, 1, 10)); list.add(new ItemStack(itemIn, 1, 11)); list.add(new ItemStack(itemIn, 1, 12)); list.add(new ItemStack(itemIn, 1, 13)); list.add(new ItemStack(itemIn, 1, 14)); } @Override public String getSpecialName(ItemStack stack) { return stack.getItemDamage() == 0 ? "black" : "blue"; } @Override public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos) { return new ItemStack(Item.getItemFromBlock(this), 1, this.getMetaFromState(world.getBlockState(pos))); } public enum EnumType implements IStringSerializable { BLACK(0, "black"), BLUE(1, "blue"), BROWN(2, "brown"), CYAN(3, "cyan"), GREEN(4, "green"), LIGHTBLUE(5, "lightblue"), LIGHTGRAY(6, "lightgray"), LIME(7, "lime"), MAGENTA(8, "magenta"), ORANGE(9, "orange"), PINK(10, "pink"), PURPLE(11, "purple"), RED(12, "red"), WHITE(13, "white"), YELLOW(14, "yellow"); private int ID; private String name; private EnumType(int ID, String name) { this.ID = ID; this.name = name; } @Override public String getName() { return this.name; } public int getID() { return this.ID; } @Override public String toString() { return this.getName(); } } } IMetaBlockName.java package com.panex.coloryourworld.blocks; import net.minecraft.item.ItemStack; public interface IMetaBlockName { String getSpecialName(ItemStack stack); } ItemBlockMeta.java package com.panex.coloryourworld.blocks; import net.minecraft.block.Block; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; public class ItemBlockMeta extends ItemBlock { public ItemBlockMeta(Block block) { super(block); if (!(block instanceof IMetaBlockName)) { throw new IllegalArgumentException(String.format("The given Block %s is not an instance of ISpecialBlockName!", block.getUnlocalizedName())); } this.setMaxDamage(0); this.setHasSubtypes(true); } @Override public int getMetadata(int damage) { return damage; } @Override public String getUnlocalizedName(ItemStack stack) { return super.getUnlocalizedName(stack) + "." + ((IMetaBlockName)this.block).getSpecialName(stack); } } MBlocks.java package com.panex.coloryourworld.blocks; import com.panex.coloryourworld.items.MItems; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraftforge.fml.common.registry.GameRegistry; public final class MBlocks { //gray stone public static Block stoneBlock; //gem blocks public static Block ruby_block; public static Block amethyst_block; public static Block amber_block; public static Block aquamarine_block; public static Block lepidolite_block; public static Block onyx_block; public static Block opal_block; public static Block peridot_block; public static Block rubellite_block; public static Block sapphire_block; public static Block silvertopaz_block; public static Block tigerseye_block; public static Block topaz_block; public static Block tourmaline_block; //gem ore public static Block ruby_ore; public static Block amethyst_ore; public static Block amber_ore; public static Block aquamarine_ore; public static Block lepidolite_ore; public static Block onyx_ore; public static Block opal_ore; public static Block peridot_ore; public static Block rubellite_ore; public static Block sapphire_ore; public static Block silvertopaz_ore; public static Block tigerseye_ore; public static Block topaz_ore; public static Block tourmaline_ore; public static void createBlocks() { //gray stone GameRegistry.registerBlock(stoneBlock = new StoneBlockProperties("stoneblock_properties"), ItemBlockMeta.class, "stoneblock_properties"); //gem block GameRegistry.registerBlock(amethyst_block = new GemBlock("amethyst_block", Material.rock), "amethyst_block"); GameRegistry.registerBlock(amber_block = new GemBlock("amber_block", Material.rock), "amber_block"); GameRegistry.registerBlock(aquamarine_block = new GemBlock("aquamarine_block", Material.rock), "aquamarine_block"); GameRegistry.registerBlock(lepidolite_block = new GemBlock("lepidolite_block", Material.rock), "lepidolite_block"); GameRegistry.registerBlock(onyx_block = new GemBlock("onyx_block", Material.rock), "onyx_block"); GameRegistry.registerBlock(opal_block = new GemBlock("opal_block", Material.rock), "opal_block"); GameRegistry.registerBlock(peridot_block = new GemBlock("peridot_block", Material.rock), "peridot_block"); GameRegistry.registerBlock(rubellite_block = new GemBlock("rubellite_block", Material.rock), "rubellite_block"); GameRegistry.registerBlock(ruby_block = new GemBlock("ruby_block", Material.rock), "ruby_block"); GameRegistry.registerBlock(sapphire_block = new GemBlock("sapphire_block", Material.rock), "sapphire_block"); GameRegistry.registerBlock(silvertopaz_block = new GemBlock("silvertopaz_block", Material.rock), "silvertopaz_block"); GameRegistry.registerBlock(tigerseye_block = new GemBlock("tigerseye_block", Material.rock), "tigerseye_block"); GameRegistry.registerBlock(topaz_block = new GemBlock("topaz_block", Material.rock), "topaz_block"); GameRegistry.registerBlock(tourmaline_block = new GemBlock("tourmaline_block", Material.rock), "tourmaline_block"); //gem ore GameRegistry.registerBlock(amethyst_ore = new OreBlock("amethyst_ore", Material.rock, MItems.amethystgem, 1, 2), "amethyst_ore"); GameRegistry.registerBlock(ruby_ore = new OreBlock("ruby_ore", Material.rock, MItems.rubygem, 1, 2), "ruby_ore"); GameRegistry.registerBlock(amber_ore = new OreBlock("amber_ore", Material.rock, MItems.ambergem, 1, 2), "amber_ore"); GameRegistry.registerBlock(aquamarine_ore = new OreBlock("aquamarine_ore", Material.rock, MItems.aquamarinegem, 1, 2), "aquamarine_ore"); GameRegistry.registerBlock(lepidolite_ore = new OreBlock("lepidolite_ore", Material.rock, MItems.lepidolitegem, 1, 2), "lepidolite_ore"); GameRegistry.registerBlock(onyx_ore = new OreBlock("onyx_ore", Material.rock, MItems.onyxgem, 1, 2), "onyx_ore"); GameRegistry.registerBlock(opal_ore = new OreBlock("opal_ore", Material.rock, MItems.opalgem, 1, 2), "opal_ore"); GameRegistry.registerBlock(peridot_ore = new OreBlock("peridot_ore", Material.rock, MItems.peridotgem, 1, 2), "peridot_ore"); GameRegistry.registerBlock(rubellite_ore = new OreBlock("rubellite_ore", Material.rock, MItems.rubellitegem, 1, 2), "rubellite_ore"); GameRegistry.registerBlock(sapphire_ore = new OreBlock("sapphire_ore", Material.rock, MItems.sapphiregem, 1, 2), "sapphire_ore"); GameRegistry.registerBlock(silvertopaz_ore = new OreBlock("silvertopaz_ore", Material.rock, MItems.silvertopazgem, 1, 2), "silvertopaz_ore"); GameRegistry.registerBlock(tigerseye_ore = new OreBlock("tigerseye_ore", Material.rock, MItems.tigerseyegem, 1, 2), "tigerseye_ore"); GameRegistry.registerBlock(topaz_ore = new OreBlock("topaz_ore", Material.rock, MItems.topazgem, 1, 2), "topaz_ore"); GameRegistry.registerBlock(tourmaline_ore = new OreBlock("tourmaline_ore", Material.rock, MItems.tourmalinegem, 1, 2), "tourmaline_ore"); } } BlockRenderRegister.java package com.panex.coloryourworld.client.render.blocks; import com.panex.coloryourworld.Main; import com.panex.coloryourworld.blocks.MBlocks; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.item.Item; public final class BlockRenderRegister { public static void preInit() { ModelBakery.addVariantName(Item.getItemFromBlock(MBlocks.stoneBlock), "coloryourworld:stoneblock_properties_black", "coloryourworld:stoneblock_properties_blue", "coloryourworld:stoneblock_properties_brown", "coloryourworld:stoneblock_properties_cyan", "coloryourworld:stoneblock_properties_green", "coloryourworld:stoneblock_properties_lightblue", "coloryourworld:stoneblock_properties_lightgray", "coloryourworld:stoneblock_properties_lime", "coloryourworld:stoneblock_properties_magenta", "coloryourworld:stoneblock_properties_orange", "coloryourworld:stoneblock_properties_pink", "coloryourworld:stoneblock_properties_purple", "coloryourworld:stoneblock_properties_red", "coloryourworld:stoneblock_properties_white", "coloryourworld:stoneblock_properties_yellow" ); } public static void registerBlockRenderer() { //stone blocks reg(MBlocks.stoneBlock, 0, "stoneblock_properties_black"); reg(MBlocks.stoneBlock, 1, "stoneblock_properties_blue"); reg(MBlocks.stoneBlock, 2, "stoneblock_properties_brown"); reg(MBlocks.stoneBlock, 3, "stoneblock_properties_cyan"); reg(MBlocks.stoneBlock, 4, "stoneblock_properties_green"); reg(MBlocks.stoneBlock, 5, "stoneblock_properties_lightblue"); reg(MBlocks.stoneBlock, 6, "stoneblock_properties_lightgray"); reg(MBlocks.stoneBlock, 7, "stoneblock_properties_lime"); reg(MBlocks.stoneBlock, 8, "stoneblock_properties_magenta"); reg(MBlocks.stoneBlock, 9, "stoneblock_properties_orange"); reg(MBlocks.stoneBlock, 10, "stoneblock_properties_pink"); reg(MBlocks.stoneBlock, 11, "stoneblock_properties_purple"); reg(MBlocks.stoneBlock, 12, "stoneblock_properties_red"); reg(MBlocks.stoneBlock, 13, "stoneblock_properties_white"); reg(MBlocks.stoneBlock, 14, "stoneblock_properties_yellow"); //gem block reg(MBlocks.ruby_block); reg(MBlocks.amethyst_block); reg(MBlocks.amber_block); reg(MBlocks.aquamarine_block); reg(MBlocks.lepidolite_block); reg(MBlocks.onyx_block); reg(MBlocks.opal_block); reg(MBlocks.peridot_block); reg(MBlocks.rubellite_block); reg(MBlocks.sapphire_block); reg(MBlocks.silvertopaz_block); reg(MBlocks.tigerseye_block); reg(MBlocks.topaz_block); reg(MBlocks.tourmaline_block); //gem ore reg(MBlocks.ruby_ore); reg(MBlocks.amethyst_ore); reg(MBlocks.amber_ore); reg(MBlocks.aquamarine_ore); reg(MBlocks.lepidolite_ore); reg(MBlocks.onyx_ore); reg(MBlocks.opal_ore); reg(MBlocks.peridot_ore); reg(MBlocks.rubellite_ore); reg(MBlocks.sapphire_ore); reg(MBlocks.silvertopaz_ore); reg(MBlocks.tigerseye_ore); reg(MBlocks.topaz_ore); reg(MBlocks.tourmaline_ore); } public static String modid = Main.MODID; public static void reg(Block block) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(modid + ":" + block.getUnlocalizedName().substring(5), "inventory")); } public static void reg(Block block, int meta, String file) { Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), meta, new ModelResourceLocation(modid + ":" + file, "inventory")); } } Lang tile.stoneblock_properties.black.name=Black Dyed Stone tile.stoneblock_properties.blue.name=Blue Dyed Stone tile.stoneblock_properties.brown.name=Brown Dyed Stone tile.stoneblock_properties.cyan.name=Cyan Dyed Stone tile.stoneblock_properties.green.name=Green Dyed Stone tile.stoneblock_properties.lightblue.name=Light Blue Dyed Stone tile.stoneblock_properties.lightgray.name=Light Gray Dyed Stone tile.stoneblock_properties.lime.name=Lime Dyed Stone tile.stoneblock_properties.magenta.name=Magenta Dyed Stone tile.stoneblock_properties.orange.name=Orange Dyed Stone tile.stoneblock_properties.pink.name=Pink Dyed Stone tile.stoneblock_properties.purple.name=Purple Dyed Stone tile.stoneblock_properties.red.name=Red Dyed Stone tile.stoneblock_properties.white.name=White Dyed Stone tile.stoneblock_properties.yellow.name=Yellow Dyed Stone blockstates/stoneblock_properties.json { "variants": { "type=black": { "model":"coloryourworld:stoneblock_properties_black" }, "type=blue": { "model":"coloryourworld:stoneblock_properties_blue" }, "type=brown": { "model":"coloryourworld:stoneblock_properties_brown" }, "type=cyan": { "model":"coloryourworld:stoneblock_properties_cyan" }, "type=green": { "model":"coloryourworld:stoneblock_properties_green" }, "type=lightblue": { "model":"coloryourworld:stoneblock_properties_lightblue" }, "type=lightgray": { "model":"coloryourworld:stoneblock_properties_lightgray" }, "type=lime": { "model":"coloryourworld:stoneblock_properties_lime" }, "type=magenta": { "model":"coloryourworld:stoneblock_properties_magenta" }, "type=orange": { "model":"coloryourworld:stoneblock_properties_orange" }, "type=pink": { "model":"coloryourworld:stoneblock_properties_pink" }, "type=purple": { "model":"coloryourworld:stoneblock_properties_purple" }, "type=red": { "model":"coloryourworld:stoneblock_properties_red" }, "type=white": { "model":"coloryourworld:stoneblock_properties_white" }, "type=yellow": { "model":"coloryourworld:stoneblock_properties_yellow" } } } model/blocks stoneblock_properties_black.json this is one of the 15 files all the rest are the same except for the color names change both in name of file and inside the file. { "parent":"block/cube_all", "textures": { "all": "coloryourworld:blocks/stoneblock_properties_black" } } model/items stoneblock_properties_black.json this is one of the 15 files all the rest are the same except for the color names change both in name of file and inside the file. { "parent":"coloryourworld:block/stoneblock_properties_black", "display": { "thirdperson": { "rotation": [ 10, -45, 170 ], "translation": [ 0, 1.5, -2.75 ], "scale": [ 0.375, 0.375, 0.375 ] } } } If I have forgotten to put in anything that will help please let me know and I will get it posted. Also like I said I am new to programming so the dumber the explanation can be the better. I really appreciate any help that can be given. Thank you.
×
×
  • Create New...

Important Information

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