So I've never actually used the IProperties before, and am trying to get them to work. I am pretty sure that the JSON files are correct. I've ran them through jsonlint.com and also they don't return any render issues/errors when launching the game or placing the block.
I guess there are two issues. One is,
How do I properly set the property data from a different class? In my chunk loader, I have this but after printing it shows index=0 (index is the property)
(the chunks are being created in a 14x14 square starting offset by 1)
I doubt this is the correct way to set the data but then again, it might be something in my block class actually, I'm pretty dang sure it is.
Here are the two methods I am unsure on what to do with:
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState();
}
@Override
public int getMetaFromState(IBlockState state)
{
return 0;
}
Like I said, I have absolutely no clue how to start these out or what I'm trying to do with them. I thought metadata only went up to 16 for blocks, but my property needs 196 :/
Here is the full Block class pertaining to blockstate:
public static final PropertyInteger INDEX = PropertyInteger.create("index", 0, 195);
public BlockBlockholeWall(BlockData blockdata)
{
super(blockdata);
this.setBlockUnbreakable();
this.setLightLevel(1.0F);
this.setDefaultState(this.blockState.getBaseState().withProperty(INDEX, 0));
}
@Override
protected BlockStateContainer createBlockState()
{
return new BlockStateContainer(this, new IProperty[]{INDEX});
}
@Override
public IBlockState getStateFromMeta(int meta)
{
return this.getDefaultState();
}
@Override
public int getMetaFromState(IBlockState state)
{
return 0;
}
I don't even know what to ask because I'm unsure how this works entirely lol
Rollback Post to RevisionRollBack
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
Block metadata is indeed limited to 4 bits (16 possible values), you can't store a property with 196 possible values in the metadata. Instead, you need to store the value in a TileEntity.
What is the INDEX property actually used for? If it affects which model is rendered, override Block#getActualState to set it from the value stored in the TileEntity. If it doesn't affect the model, remove the property entirely instead.
Forge's documentation has a guide to block states here, you may find this useful.
In future, please use Gist or Pastebin to post logs/crash reports (if applicable) and code with syntax highlighting. To get syntax highlighting on Gist, give each file the appropriate extension (.java for Java code). To get syntax highlighting on Pastebin, select the language from the dropdown at the bottom of the page.
It's much easier to read code with proper formatting and syntax highlighting.
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.
I read through the documentation and it says to call Block#getActualState when you need the extra data. How would I go about getting it when placing the block down?
I am having trouble accessing certain information from within the Block#onBlockPlaced method and in the ChunkProvider#provideChunk
@Override
public IBlockState onBlockPlaced(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
TileEntityBlockholeWall tile = (TileEntityBlockholeWall)world.getTileEntity(pos);
// Not sure how to get the CORRECT information to be stored into the block in the first place.
tile.setIndex(this.getActualState(world.getBlockState(pos), world, pos).getValue(INDEX));
return this.getActualState(world.getBlockState(pos), world, pos);
}
I'm trying to create a block that acts as a cube (currently only testing the floor platform) and has a different texture based on the order it is placed. The cubes are 14x14x14, so each floor/wall/ceiling has 196 blocks to texture differently.
I'm still sort of confused after reading the documentation where exactly I should set the blocks' INDEX property.
Rollback Post to RevisionRollBack
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
Block#onBlockPlaced is called before the Block and its TileEntity have actually been placed in the world, which is why it's been renamed to Block#getStateForPlacement in newer MCP mappings. You should override Block#onBlockPlacedBy instead, as this is called after the block has been placed.
In your Block#onBlockPlacedBy override, you need to calculate the index value and store it in the TileEntity. Don't call Block#getActualState here.
Minecraft calls Block#getActualState before choosing which model to render for a block, allowing the model to be chosen based on values not stored in the metadata (e.g. adjacent blocks or data stored in a TileEntity). You should call it whenever you need an IBlockState with the INDEX property set.
Edit: Block#getStateForPlacement and Block#onBlockPlacedBy are only called when the block is placed by an entity (usually a player). Since you're generating these blocks rather than placing them, you'll need to set the index value in each TileEntity after creating the Chunk from the ChunkPrimer.
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.
So if I'm understanding right, as far as setting the INDEX property goes and retrieving the state with the property saved, these should technically be working? (Just setting it to a value of 0 for testing, btw)
You're trying to use Forge's blockstate format but you haven't included the forge_marker property, so your file is being parsed with the vanilla format's deserialiser.
If your block isn't rendering at all, you're probably extending BlockContainer, which overrides Block#getRenderType to return EnumBlockRenderType.INVISIBLE. You could override this to return EnumBlockRenderType.MODEL, but instead I suggest extending Block (without implementing ITileEntityProvider) and overriding Block#hasTileEntity(IBlockState) and Block#createTileEntity(World, IBlockState).
In future, please post whole classes instead of snippets.
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.
I did forget the forge_marker property, but that didn't seem to fix it. (Sorry for the delayed response, was sleeping then classes). The block wasn't extending BlockContainer and I already had included the EnumBlockRenderType.MODEL but have no luck there. I swapped it out from implementing ITileEntityProvider to just overriding the two methods indicated, but it still is appearing invisible. I'm not sure if my indexes are mapping correctly, but at the very least they should be set to INDEX=0 since the TileEntityBlockholeWall is setting the index to 0 to start, but even the first texture isn't showing up -- just an invisible opaque block.
Here is the full code for the Block, TileEntity, Blockstate.JSON, and BlockModel.JSON. Maybe you'll catch something that isn't registering with me for some reason or something I just simply wasn't aware of.
Note: BlockBasic is just a regular class extending Block for the simpler blocks to use. I also am registering exactly like my other Blocks and TileEntities.
You've overridden the wrong overload of Block#hasTileEntity, you need to override the one with the single IBlockState argument.
Your Block#getActualState override gets the TileEntity from the world but then ignore it, create a new one and immediately set its index value. If the index value is derived from the block's position and never changes (and isn't too expensive to calculate), there's no reason to store it at all; just calculate it in the Block#getActualState override.
You posted two blockstates files (one in the vanilla format, one in Forge's format) instead of a blockstates file and a model.
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.
I'm sorry this is such a struggle for me, I skipped out on the transition from 1.7.10 to 1.8+ and am just starting to get back into this. I guess I don't understand the difference between the vanilla and the forge system as well as where to properly set things such as texture dependent on variants. I don't know if stuff should be put in the model or the blockstate :/
This is where I currently am at in terms of the blockstate and model:
Your blockstates file is fine, though you don't need to specify the particle texture in every variant since you've specified it in the defaults section and it's always the same.
You also don't need to specify the textures for each side in the defaults section, since they're different for every variant.
Your model should work, though it also has some unnecessary parts to it:
You extend minecraft:block/cube, which has a single full-sized cube element with a unique texture on each side and then overwrite that element with an identical one. Any elements you specify in a model completely overwrite the elements of the parent model.
You specify the texture paths for each side's texture in the model, even though these will always be overridden by the textures you specify in the blockstates file.
You should use the minecraft:block/cube model in your blockstates file directly and delete the blockhole:block/blockholewall model.
If you were using the vanilla blockstates format, you'd need to create a separate model with the appropriate textures for each variant. Forge's blockstates format allows you to specify the textures in the blockstates and generates the models at runtime.
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.
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.
Thank you so much for your patience with me. The textures work 100% now besides the equation I use for setting them, but that is just some double checking of math Thanks again!
So I've never actually used the IProperties before, and am trying to get them to work. I am pretty sure that the JSON files are correct. I've ran them through jsonlint.com and also they don't return any render issues/errors when launching the game or placing the block.
I guess there are two issues. One is,
How do I properly set the property data from a different class? In my chunk loader, I have this but after printing it shows index=0 (index is the property)
(the chunks are being created in a 14x14 square starting offset by 1)
I doubt this is the correct way to set the data but then again, it might be something in my block class actually, I'm pretty dang sure it is.
Here are the two methods I am unsure on what to do with:
Like I said, I have absolutely no clue how to start these out or what I'm trying to do with them. I thought metadata only went up to 16 for blocks, but my property needs 196 :/
Here is the full Block class pertaining to blockstate:
I don't even know what to ask because I'm unsure how this works entirely lol
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
Block metadata is indeed limited to 4 bits (16 possible values), you can't store a property with 196 possible values in the metadata. Instead, you need to store the value in a TileEntity.
What is the INDEX property actually used for? If it affects which model is rendered, override Block#getActualState to set it from the value stored in the TileEntity. If it doesn't affect the model, remove the property entirely instead.
Forge's documentation has a guide to block states here, you may find this useful.
In future, please use Gist or Pastebin to post logs/crash reports (if applicable) and code with syntax highlighting. To get syntax highlighting on Gist, give each file the appropriate extension (.java for Java code). To get syntax highlighting on Pastebin, select the language from the dropdown at the bottom of the page.
It's much easier to read code with proper formatting and syntax highlighting.
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.
Am I setting this appropriately?
http://pastebin.com/649jyxj9
I read through the documentation and it says to call Block#getActualState when you need the extra data. How would I go about getting it when placing the block down?
I am having trouble accessing certain information from within the Block#onBlockPlaced method and in the ChunkProvider#provideChunk
Here is the pastebin for the chunk provider:
http://pastebin.com/Sy2eD56E
I'm trying to create a block that acts as a cube (currently only testing the floor platform) and has a different texture based on the order it is placed. The cubes are 14x14x14, so each floor/wall/ceiling has 196 blocks to texture differently.
I'm still sort of confused after reading the documentation where exactly I should set the blocks' INDEX property.
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
Block#onBlockPlaced is called before the Block and its TileEntity have actually been placed in the world, which is why it's been renamed to Block#getStateForPlacement in newer MCP mappings. You should override Block#onBlockPlacedBy instead, as this is called after the block has been placed.
In your Block#onBlockPlacedBy override, you need to calculate the index value and store it in the TileEntity. Don't call Block#getActualState here.
Minecraft calls Block#getActualState before choosing which model to render for a block, allowing the model to be chosen based on values not stored in the metadata (e.g. adjacent blocks or data stored in a TileEntity). You should call it whenever you need an IBlockState with the INDEX property set.
Edit: Block#getStateForPlacement and Block#onBlockPlacedBy are only called when the block is placed by an entity (usually a player). Since you're generating these blocks rather than placing them, you'll need to set the index value in each TileEntity after creating the Chunk from the ChunkPrimer.
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.
So if I'm understanding right, as far as setting the INDEX property goes and retrieving the state with the property saved, these should technically be working? (Just setting it to a value of 0 for testing, btw)
http://pastebin.com/f7BbewdY
If so, the block currently is rendering as invisible. I'm assuming its because my variants in my JSON is structured wrong. Is this the correct format?
http://pastebin.com/pNV0vzAX
I have more cases than that, and the log doesn't spit out any missing texture locations etc. Maybe I am misunderstanding how to set up variants.
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
You're trying to use Forge's blockstate format but you haven't included the forge_marker property, so your file is being parsed with the vanilla format's deserialiser.
If your block isn't rendering at all, you're probably extending BlockContainer, which overrides Block#getRenderType to return EnumBlockRenderType.INVISIBLE. You could override this to return EnumBlockRenderType.MODEL, but instead I suggest extending Block (without implementing ITileEntityProvider) and overriding Block#hasTileEntity(IBlockState) and Block#createTileEntity(World, IBlockState).
In future, please post whole classes instead of snippets.
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.
I did forget the forge_marker property, but that didn't seem to fix it. (Sorry for the delayed response, was sleeping then classes). The block wasn't extending BlockContainer and I already had included the EnumBlockRenderType.MODEL but have no luck there. I swapped it out from implementing ITileEntityProvider to just overriding the two methods indicated, but it still is appearing invisible. I'm not sure if my indexes are mapping correctly, but at the very least they should be set to INDEX=0 since the TileEntityBlockholeWall is setting the index to 0 to start, but even the first texture isn't showing up -- just an invisible opaque block.
Here is the full code for the Block, TileEntity, Blockstate.JSON, and BlockModel.JSON. Maybe you'll catch something that isn't registering with me for some reason or something I just simply wasn't aware of.
Block
TileEntity
Blockstate.JSON
BlockModel.JSON
Note: BlockBasic is just a regular class extending Block for the simpler blocks to use. I also am registering exactly like my other Blocks and TileEntities.
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
You've overridden the wrong overload of Block#hasTileEntity, you need to override the one with the single IBlockState argument.
Your Block#getActualState override gets the TileEntity from the world but then ignore it, create a new one and immediately set its index value. If the index value is derived from the block's position and never changes (and isn't too expensive to calculate), there's no reason to store it at all; just calculate it in the Block#getActualState override.
You posted two blockstates files (one in the vanilla format, one in Forge's format) instead of a blockstates file and a model.
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.
I'm sorry this is such a struggle for me, I skipped out on the transition from 1.7.10 to 1.8+ and am just starting to get back into this. I guess I don't understand the difference between the vanilla and the forge system as well as where to properly set things such as texture dependent on variants. I don't know if stuff should be put in the model or the blockstate :/
This is where I currently am at in terms of the blockstate and model:
Blockstate
Model
All I'm trying to accomplish is a different texture on all 6 sides based on INDEX.
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
Your blockstates file is fine, though you don't need to specify the particle texture in every variant since you've specified it in the defaults section and it's always the same.
You also don't need to specify the textures for each side in the defaults section, since they're different for every variant.
Your model should work, though it also has some unnecessary parts to it:
You should use the minecraft:block/cube model in your blockstates file directly and delete the blockhole:block/blockholewall model.
If you were using the vanilla blockstates format, you'd need to create a separate model with the appropriate textures for each variant. Forge's blockstates format allows you to specify the textures in the blockstates and generates the models at runtime.
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.
Is there anything special I need to do for 32x32 textures or higher quality textures?
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.
I don't think so, you should be able to use any resolution of square texture.
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.
Thank you so much for your patience with me. The textures work 100% now besides the equation I use for setting them, but that is just some double checking of math Thanks again!
Mod Author and Owner of Blockhole
Owner of other discontinued or status frozen work: LimpCraft2, LimpCore, InventoryCalculator, VillageTech, Bitto'Color.