Sorry, this is my first time creating a metadata block in Minecraft 1.8. I've created the block and it has its two metadata which are in the creative tab. The first Metadata has a texture in the inventory, but the second metadata does not. And when i place the two blocks on the ground neither of them have a texture. I would really appreciate it if someone helped me, this is my first time coding in 1.8 and im still not used to it. Oh, and the metadata block is scorchstone cobble.
Blocks Init
package com.killerjdog51.scorchstone.init;
import com.killerjdog51.scorchstone.Reference;
import com.killerjdog51.scorchstone.Scorchstone_Mod;
import com.killerjdog51.scorchstone.blocks.BlockScorchStone;
import com.killerjdog51.scorchstone.blocks.BlockScorchStoneCobble;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class ScorchstoneBlocks {
public static Block scorch_stone;
public static Block scorch_cobble;
public static void init() {
scorch_stone = new BlockScorchStone(Material.rock).setUnlocalizedName("scorched_stone").setCreativeTab(Scorchstone_Mod.tabScorchstone);
scorch_cobble = new BlockScorchStoneCobble(Material.rock).setUnlocalizedName("scorched_cobble").setCreativeTab(Scorchstone_Mod.tabScorchstone);
}
public static void register() {
GameRegistry.registerBlock(scorch_stone, scorch_stone.getUnlocalizedName().substring(5));
GameRegistry.registerBlock(scorch_cobble, scorch_cobble.getUnlocalizedName().substring(5));
}
public static void registerRenders() {
registerRender(scorch_stone);
registerRender(scorch_cobble);
}
public static void registerRender(Block block) {
Item itemScorchedStone = Item.getItemFromBlock(scorch_stone);
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemScorchedStone, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + itemScorchedStone.getUnlocalizedName().substring(5), "inventory"));
Item itemScorchedCobble = Item.getItemFromBlock(scorch_cobble);
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemScorchedCobble, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + itemScorchedCobble.getUnlocalizedName().substring(5), "inventory"));
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemScorchedCobble, 1, new ModelResourceLocation(Reference.MOD_ID + ":" + "scorched_cobble_corrupt".substring(5), "inventory"));
ModelBakery.addVariantName(itemScorchedCobble, new String[]{"ssm:scorched_cobble", "ssm:scorched_cobble_corrupt"});
}
}
Scorchstone Cobble
package com.killerjdog51.scorchstone.blocks;
import java.util.List;
import java.util.List;
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.IStringSerializable;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class BlockScorchStoneCobble extends Block
{
public static final PropertyEnum VARIANT = PropertyEnum.create("variant", BlockScorchStoneCobble.EnumType.class);
public static final int DEFAULT_META = BlockScorchStoneCobble.EnumType.DEFAULT.getMetadata();
public static final int CORRUPT_META = BlockScorchStoneCobble.EnumType.CORRUPT.getMetadata();
private static final String __OBFID = "CL_00000318";
public BlockScorchStoneCobble(Material materialIn)
{
super(materialIn);
this.setDefaultState(this.blockState.getBaseState().withProperty(VARIANT, BlockScorchStoneCobble.EnumType.DEFAULT));
}
/**
* Get the damage value that this Block should drop
*/
public int damageDropped(IBlockState state)
{
return ((BlockScorchStoneCobble.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 list)
{
BlockScorchStoneCobble.EnumType[] aenumtype = BlockScorchStoneCobble.EnumType.values();
int i = aenumtype.length;
for (int j = 0; j < i; ++j)
{
BlockScorchStoneCobble.EnumType enumtype = aenumtype[j];
list.add(new ItemStack(itemIn, 1, enumtype.getMetadata()));
}
}
/**
* Convert the given metadata into a BlockState for this Block
*/
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState().withProperty(VARIANT, BlockScorchStoneCobble.EnumType.byMetadata(meta));
}
/**
* Convert the BlockState into the correct metadata value
*/
public int getMetaFromState(IBlockState state)
{
return ((BlockScorchStoneCobble.EnumType)state.getValue(VARIANT)).getMetadata();
}
protected BlockState createBlockState()
{
return new BlockState(this, new IProperty[] {VARIANT});
}
public static enum EnumType implements IStringSerializable
{
DEFAULT(0, "cobble", "default"),
CORRUPT(1, "corrupt", "corrupt");
private static final BlockScorchStoneCobble.EnumType[] META_LOOKUP = new BlockScorchStoneCobble.EnumType[values().length];
private final int meta;
private final String name;
private final String unlocalizedName;
private static final String __OBFID = "CL_00002057";
private EnumType(int meta, String name, String unlocalizedName)
{
this.meta = meta;
this.name = name;
this.unlocalizedName = unlocalizedName;
}
public int getMetadata()
{
return this.meta;
}
public String toString()
{
return this.name;
}
public static BlockScorchStoneCobble.EnumType byMetadata(int meta)
{
if (meta < 0 || meta >= META_LOOKUP.length)
{
meta = 0;
}
return META_LOOKUP[meta];
}
public String getName()
{
return this.name;
}
public String getUnlocalizedName()
{
return this.unlocalizedName;
}
static
{
BlockScorchStoneCobble.EnumType[] var0 = values();
int var1 = var0.length;
for (int var2 = 0; var2 < var1; ++var2)
{
BlockScorchStoneCobble.EnumType var3 = var0[var2];
META_LOOKUP[var3.getMetadata()] = var3;
}
}
}
}
Use Gist to post code with syntax highlighting, the code formatting here is terrible.
Your blockstates file should have each variant in the "variants" object, not "variant". It should also be using the block models, not the item models.
Your registerRender method doesn't use its block argument and registers models for both of your blocks. You call this method twice, which means you're registering each block's item models twice.
You're registering the wrong model for metadata 1 of scorch_cobble because you're calling substring(5) on the model name ("scorched_cobble_corrupt"). This cuts off the first 5 characters of the string, leaving you with "hed_cobble_corrupt". Block#getUnlocalizedName returns a string with the 5 character prefix "tile.", which substring(5) cuts off.
You can call RegistryNamespaced#getNameForObject on Item.itemRegistry to get the registry name of an Item as a ResourceLocation, then convert it to a string in the format "modid:name" with the Object#toString method. This is the same name you passed to GameRegistry.registerItem/registerBlock.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
You're missing a comma between the two variants, which is a syntax error. Did you not get a message in the log telling you this?
I suggest running your JSON files through JSONLint when you're having model issues.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
The Grey Ghost has a guide to troubleshooting block and item rendering here, I suggest you follow it.
If you follow the guide and the textures still aren't working, upload your FML log to Gist and link it here.
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Ok, so i followed the guide, but honestly im not sure if ive moved forward in troubleshooting this problem or if i went backwords. so i still havent found a fix. But first it was unable to load the definition (FML). Then when I changed "variant" to "variants" it was unable to find the model definition (FML). Now ive added the resource location in the top line of every single file like it shows in guide, which im not sure if its saying not to do or to do but either way i added it, and now the game isnt loading and keeps crashing. Heres my current FML. Honestly i dont know if im on the right track, because it feels like i took one step forward and two steps backwards.
Ok, after some more work while I wasn't tired I found this Guide specifically for metadata blocks. And i was able to fix my texture problem, A little bit. The block now has the texture for the first variant. But also for not for the second variant, the second variant of my block has the same texture as the first variant.
I tried adding an Itemblock class to see if that would work like it did in 1.7. But it didnt. anyone have any sugestions to fix my blocks from having the same texture?
I tried to post something yesterday, but my internet glitched and I guess it was erased.
Anyway, I only noticed one weird bit, in your Blocks Init you do this:
public static void registerRenders() {
registerRender(scorch_stone);
registerRender(scorch_cobble);
}
Which calls this twice:
public static void registerRender(Block block) {
Item itemScorchedStone = Item.getItemFromBlock(scorch_stone);
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemScorchedStone, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + itemScorchedStone.getUnlocalizedName().substring(5), "inventory"));
Item itemScorchedCobble = GameRegistry.findItem("ssm", "scorched_cobble");
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemScorchedCobble, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + itemScorchedCobble.getUnlocalizedName().substring(5), "inventory"));
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(itemScorchedCobble, 1, new ModelResourceLocation(Reference.MOD_ID + ":" + "scorched_cobble_corrupt", "inventory"));
ModelBakery.addVariantName(itemScorchedCobble, new String[]{"ssm:scorched_cobble", "ssm:scorched_cobble_corrupt"});
}
Which is rather useless because registerRender doesn't use the value you passed in (Block block). Try moving the code currently in registerRender into registerRenders (replacing its code, of course) so you have one less problem to worry about.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
Alright, I've replaced that. It looks cleaner. thanks. Although its odd that the textures are still the same. In the past you'd just have to use an Itemblock class to handle it. Now you use json files, which wont work for some reason.
Are ssm:blocks/scorched_cobble and ssm:blocks/scorched_cobble_corrupt definitely different textures?
Rollback Post to RevisionRollBack
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Yes, They are different textures. They're similar, but still different enough to tell the difference.
Heres scorched cobble
Heres corrupted cobble
Ive noticed that the scorched cobble's inventory texture changes when i change it's block texture. I think if I change it to regular cobble the inventory will change also.
Yep, I was right. so the scorched cobble's texture is linked to the inventory texture as well, which i guess should be normal. But the problem is that it affects the corrupt cobble's world texture, although not the corrupt cobble's inventory texture.
Ok, pressed F3 and found out that both blocks are the cobble variant. So now the problem is why isnt my corrupt variant being placed into the world? For some reason the corrupt variant is placing the cobble variant by mistake.
So what are possible reasons for my metadata 1 block to be placing my metadata 0 block. doesnt say anything about that on the guide.
If you call World#setBlock it takes the parameters BlockPos and BlockState, correct?
You did not post your ItemBlock code so I'm assuming you just use getDefaultState when you should use getStateFromMeta(int). If you do use getStateFromMeta there, make sure you are passing different values for the different types of blocks.
If none of this helps, post your ItemBlock code.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
Thank you, It worked. not sure why it was on default state sense I got this from an older piece of code from 1.7 that worked fine. but it works now. Thanks for your help
Sorry, this is my first time creating a metadata block in Minecraft 1.8. I've created the block and it has its two metadata which are in the creative tab. The first Metadata has a texture in the inventory, but the second metadata does not. And when i place the two blocks on the ground neither of them have a texture. I would really appreciate it if someone helped me, this is my first time coding in 1.8 and im still not used to it. Oh, and the metadata block is scorchstone cobble.
Blocks Init
Scorchstone Cobble
blockstats scorched_cobble.json
model item scorched_cobble.json
model item scorched_cobble_corrupt.json
model block scorched_cobble.json
model block scorched_cobble_corrupt.json
Use Gist to post code with syntax highlighting, the code formatting here is terrible.
Your blockstates file should have each variant in the "variants" object, not "variant". It should also be using the block models, not the item models.
Your registerRender method doesn't use its block argument and registers models for both of your blocks. You call this method twice, which means you're registering each block's item models twice.
You're registering the wrong model for metadata 1 of scorch_cobble because you're calling substring(5) on the model name ("scorched_cobble_corrupt"). This cuts off the first 5 characters of the string, leaving you with "hed_cobble_corrupt". Block#getUnlocalizedName returns a string with the 5 character prefix "tile.", which substring(5) cuts off.
You can call RegistryNamespaced#getNameForObject on Item.itemRegistry to get the registry name of an Item as a ResourceLocation, then convert it to a string in the format "modid:name" with the Object#toString method. This is the same name you passed to GameRegistry.registerItem/registerBlock.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Alright, my blocks now show up in my inventory correctly. but they're still missing their textures when i place them on the ground.
blockstats scorched_cobble.json
You're missing a comma between the two variants, which is a syntax error. Did you not get a message in the log telling you this?
I suggest running your JSON files through JSONLint when you're having model issues.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
No, I never got a message. And after the JsonLint validated all of my JSON files the textures still won't work.
The Grey Ghost has a guide to troubleshooting block and item rendering here, I suggest you follow it.
If you follow the guide and the textures still aren't working, upload your FML log to Gist and link it here.
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Ok, so i followed the guide, but honestly im not sure if ive moved forward in troubleshooting this problem or if i went backwords. so i still havent found a fix. But first it was unable to load the definition (FML). Then when I changed "variant" to "variants" it was unable to find the model definition (FML). Now ive added the resource location in the top line of every single file like it shows in guide, which im not sure if its saying not to do or to do but either way i added it, and now the game isnt loading and keeps crashing. Heres my current FML. Honestly i dont know if im on the right track, because it feels like i took one step forward and two steps backwards.
Ok, after some more work while I wasn't tired I found this Guide specifically for metadata blocks. And i was able to fix my texture problem, A little bit. The block now has the texture for the first variant. But also for not for the second variant, the second variant of my block has the same texture as the first variant.
Post your updated code and make sure scorched_cobble.json and scorched_cobble_corrupt.json lead to different textures.
Heres the updated code:
Blocks Init
Scorched Cobble Block
Block Stat
Scorched Cobble
Models Item
Scorched Cobble
Scorched Cobble Corrupt
Models Block
Scorched Cobble
Scorched Cobble Corrupt
I tried adding an Itemblock class to see if that would work like it did in 1.7. But it didnt. anyone have any sugestions to fix my blocks from having the same texture?
I tried to post something yesterday, but my internet glitched and I guess it was erased.
Anyway, I only noticed one weird bit, in your Blocks Init you do this:
Which calls this twice:
Which is rather useless because registerRender doesn't use the value you passed in (Block block). Try moving the code currently in registerRender into registerRenders (replacing its code, of course) so you have one less problem to worry about.
Alright, I've replaced that. It looks cleaner. thanks. Although its odd that the textures are still the same. In the past you'd just have to use an Itemblock class to handle it. Now you use json files, which wont work for some reason.
Are ssm:blocks/scorched_cobble and ssm:blocks/scorched_cobble_corrupt definitely different textures?
Chisel Facades: For all your decorative pipe-hiding needs.
Please don't PM me to ask for help or to join your mod development team. Asking your question in a public thread preserves it for people who are having the same problem in the future. I'm not interested in developing mods with people.
Yes, They are different textures. They're similar, but still different enough to tell the difference.
Heres scorched cobble
Heres corrupted cobble
Ive noticed that the scorched cobble's inventory texture changes when i change it's block texture. I think if I change it to regular cobble the inventory will change also.
Yep, I was right. so the scorched cobble's texture is linked to the inventory texture as well, which i guess should be normal. But the problem is that it affects the corrupt cobble's world texture, although not the corrupt cobble's inventory texture.
Ok, pressed F3 and found out that both blocks are the cobble variant. So now the problem is why isnt my corrupt variant being placed into the world? For some reason the corrupt variant is placing the cobble variant by mistake.
So what are possible reasons for my metadata 1 block to be placing my metadata 0 block. doesnt say anything about that on the guide.
If you call World#setBlock it takes the parameters BlockPos and BlockState, correct?
You did not post your ItemBlock code so I'm assuming you just use getDefaultState when you should use getStateFromMeta(int). If you do use getStateFromMeta there, make sure you are passing different values for the different types of blocks.
If none of this helps, post your ItemBlock code.
Thank you, It worked. not sure why it was on default state sense I got this from an older piece of code from 1.7 that worked fine. but it works now. Thanks for your help