
swordkorn
Members-
Posts
86 -
Joined
-
Last visited
-
Days Won
1
Everything posted by swordkorn
-
[1.12.2] Rendering block as inventory Item
swordkorn replied to American2050's topic in Modder Support
Hi pal! I'm not really knowledgable about rendering TESR as blocks in the inventory, but as long as you at least register a renderer for your ItemBlock it should at least call from that as long as your JSON files points to the block model as its parent and you give it the "inventory" variant in blockstates. Hopefully someone with experience in this will be along shortly but I will ask my friends for you and get back to you if they have a solution. Best of luck! -
Yeah thanks Jerry! I intended to get it working first THEN worry about tidying up after so it's on my list of to-dos!
-
[1.10.2] [SOLVED] Block missing texture in inventory
swordkorn replied to Bektor's topic in Modder Support
Also you are registering a renderer twice. Once for the block and itemBlock and then again for the itemBlock. Why? -
[1.10.2] [SOLVED] Block missing texture in inventory
swordkorn replied to Bektor's topic in Modder Support
Another possibility is mismatched registry names between the itemBlock and block. Maybe investigate that? -
[1.10.2] [SOLVED] Block missing texture in inventory
swordkorn replied to Bektor's topic in Modder Support
If you specify in your modelLoader to look for a variant of name "inventory" it REQUIRES that variant to render in the inventory. You miss it out and it's not our problem when it fails to render. -
public boolean getPlayer(World world, EntityPlayer player) { if(!world.isRemote) { if(player.capabilities.isCreativeMode) { isCreative = true; }else{ isCreative = false; } } return isCreative; } @Override public EnumBlockRenderType getRenderType(IBlockState state) { if (!isCreative) { return EnumBlockRenderType.MODEL; }else{ return EnumBlockRenderType.INVISIBLE; } }
-
[1.10.2] [SOLVED] Block missing texture in inventory
swordkorn replied to Bektor's topic in Modder Support
If you are specifying a variant default as inventory, you have to define it in the blockstates json file otherwise it has no model definition to reference and therefore will not render in slot as it's missing that variant. Check your console log for the MissingModelVariantException that shows up. The fix is simpler still: { "forge_marker": 1, "defaults": { "textures": { "all" "primevalforest:blocks/torch_on" }, "model": "cube_all" }, "variants": { "facing": { "up": { "model": "primevalforest:normal_torch" }, "east": { "model": "primevalforest:normal_torch_wall" }, "south": { "model": "primevalforest:normal_torch_wall", "y": 90 }, "west": { "model": "primevalforest:normal_torch_wall", "y": 180 }, "north": { "model": "primevalforest:normal_torch_wall", "y": 270 } }, "inventory": { "model": "priemevalforest:normal_torch" } } } -
Oh and before I get told off for not showing why I'm using it, here's my code as it stands: public class GameRegHelper { public static Block findBlock(String id) { String[] names = id.split(":"); /*DEPRECATED! Placeholder until I figure something better out!!! */ Block block = GameRegistry.findBlock(names[0], names[1]); return block; } public static Item findItem(String id) { String[] names = id.split(":"); /*DEPRECATED! Placeholder until I figure something better out!!! */ Item item = GameRegistry.findItem(names[0], names[1]); return item; } }
-
Hey guys. So I'm trying to basically check the registry for blocks by mod ID and item name and store them in a small list so that my mod has access to all blocks available in the game at a given time for use with my Tile Entities. The old method of findBlock is deprecated and I don't understand what findRegistry is actually asking for so I'm wary to mess with it. Cheers in advance!
-
Well that was incredibly simple once you pointed that out diesie! Here's my code for people wanting to know how I made this work and I'm marking this as solved! Thanks very much everyone for all your help! @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if (heldItem == null) { return false; }else{ if (!world.isRemote) { if (!player.capabilities.isCreativeMode) { if (world.getBlockState(pos) == BlockReg.tableBlock0.getDefaultState()) { Item item = heldItem.getItem(); IBlockState iBlockStateStone = Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.STONE); IBlockState iBlockStateAndesite = Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.ANDESITE); IBlockState iBlockStateGranite = Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.GRANITE); IBlockState iBlockStateDiorite = Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.DIORITE); Item itemStone = Item.getItemFromBlock(Blocks.STONE); ItemStack stone = new ItemStack(itemStone, 1, Blocks.STONE.damageDropped(iBlockStateStone)); ItemStack andesite = new ItemStack(itemStone, 1, Blocks.STONE.damageDropped(iBlockStateAndesite)); ItemStack granite = new ItemStack(itemStone, 1, Blocks.STONE.damageDropped(iBlockStateGranite)); ItemStack diorite = new ItemStack(itemStone, 1, Blocks.STONE.damageDropped(iBlockStateDiorite)); boolean itemIsStone = ItemStack.areItemsEqual(heldItem, stone); boolean itemIsAndesite = ItemStack.areItemsEqual(heldItem, andesite); boolean itemIsGranite = ItemStack.areItemsEqual(heldItem, granite); boolean itemIsDiorite = ItemStack.areItemsEqual(heldItem, diorite); if (item == Item.getItemFromBlock(Blocks.COBBLESTONE)) { world.setBlockState(pos, BlockReg.tableBlock1.getDefaultState()); heldItem.stackSize -= 1; } if (itemIsStone) { world.setBlockState(pos, BlockReg.tableBlock2.getDefaultState()); heldItem.stackSize -= 1; } if (itemIsAndesite) { world.setBlockState(pos, BlockReg.tableBlock4.getDefaultState()); heldItem.stackSize -= 1; System.out.println("Boolean is TRUE"); } if (itemIsGranite) { world.setBlockState(pos, BlockReg.tableBlock6.getDefaultState()); heldItem.stackSize -= 1; System.out.println("Boolean is TRUE"); } if (itemIsDiorite) { world.setBlockState(pos, BlockReg.tableBlock5.getDefaultState()); heldItem.stackSize -= 1; System.out.println("Boolean is TRUE"); } if (item == Item.getItemFromBlock(Blocks.STONEBRICK)) { world.setBlockState(pos, BlockReg.tableBlock3.getDefaultState()); heldItem.stackSize -= 1; } } } } return true; } }
-
Yes You just told me what I just said... I was passing the metadata value in as the stack size
-
So... OH I get you! So the metadata is returning the stack size! That makes perfect sense now I think about it! Good catch Diesie! Hmm... so now it comes down to a way to simply ignore that value or set it to an integer value that just fills in a value based on reading the stack size in the slot. I'll do some more messing around and let you know what I come up with.
-
Well I have deduced that: Item itemStone = Item.getItemFromBlock(Blocks.STONE); May be the reason only the default state activates all booleans. I came to this conclusion when I looked at: ItemStack stone = new ItemStack(itemStone, Blocks.STONE.damageDropped(iBlockStateStone)); ItemStack andesite = new ItemStack(itemStone, Blocks.STONE.damageDropped(iBlockStateAndesite)); ItemStack granite = new ItemStack(itemStone, Blocks.STONE.damageDropped(iBlockStateGranite)); ItemStack diorite = new ItemStack(itemStone, Blocks.STONE.damageDropped(iBlockStateDiorite)); As you can see, every instance of the ItemStack calls on the default variant and as my IDE so kindly pointed out; "Argument 'itemStone' might be null"
-
Well actually... now that I think about it... Every ItemStack variant calls on itemStone which only checks for the default state of Stone in the player's hand. Therefore calling on itemStone may make them only actve when the default variant is located. In which case, I'm back to square one more or less.
-
It doesn't. This way causes the bug I described above. Using this method, only regular stone will activate ALL the booleans, and no other variant accesses their relevant boolean firing them all as false. It's a weird one for sure!
-
if (!world.isRemote) { if (world.getBlockState(pos) == BlockReg.tableBlock0.getDefaultState()) { Item item = heldItem.getItem(); IBlockState iBlockStateStone = Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.STONE); IBlockState iBlockStateAndesite = Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.ANDESITE); IBlockState iBlockStateGranite = Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.GRANITE); IBlockState iBlockStateDiorite = Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.DIORITE); Item itemStone = Item.getItemFromBlock(Blocks.STONE); ItemStack stone = new ItemStack(itemStone, Blocks.STONE.damageDropped(iBlockStateStone)); ItemStack andesite = new ItemStack(itemStone, Blocks.STONE.damageDropped(iBlockStateAndesite)); ItemStack granite = new ItemStack(itemStone, Blocks.STONE.damageDropped(iBlockStateGranite)); ItemStack diorite = new ItemStack(itemStone, Blocks.STONE.damageDropped(iBlockStateDiorite)); boolean itemIsStone = ItemStack.areItemsEqual(heldItem, stone); boolean itemIsAndesite = ItemStack.areItemsEqual(heldItem, andesite); boolean itemIsGranite = ItemStack.areItemsEqual(heldItem, granite); boolean itemIsDiorite = ItemStack.areItemsEqual(heldItem, diorite); if (item == Item.getItemFromBlock(Blocks.COBBLESTONE)) { world.setBlockState(pos, BlockReg.tableBlock1.getDefaultState()); } if (itemIsStone) { world.setBlockState(pos, BlockReg.tableBlock2.getDefaultState()); } if (itemIsAndesite) { world.setBlockState(pos, BlockReg.tableBlock4.getDefaultState()); System.out.println("Boolean is TRUE"); } if (itemIsGranite) { world.setBlockState(pos, BlockReg.tableBlock6.getDefaultState()); System.out.println("Boolean is TRUE"); } if (itemIsDiorite) { world.setBlockState(pos, BlockReg.tableBlock5.getDefaultState()); System.out.println("Boolean is TRUE"); } if (item == Item.getItemFromBlock(Blocks.STONEBRICK)) { world.setBlockState(pos, BlockReg.tableBlock3.getDefaultState()); } } } return true; }
-
I just tried that and it came up with an interesting behaviour! All the other block types didn't work at all and normal Stone called them all so that was fun! Trying to work around that as I speak.
-
And I apologise for the messy over use of conditionals. Just want to get it working before I try clean up with a case and select
-
Sorry not a physical coded list, just my list of boolean check states is what I meant
-
So you're saying I need to just add regular Stone to my list and call that instead?
-
If you only register your renderer in the ClientProxy, you don't even need to use this code: @SideOnly(Side = CLIENT)
-
Well the CommonProxy handles all the main behaviours for both Server and Client side. Therefore making the Client and Server Proxies extend it will call on that specific side. At least... that's how I've always seen it anyway. Feel free to correct me if I'm wrong, but you are correct. Implementing a class is generally used for interfaces. Extending a class means it will inherit all the behaviours of that class. Implementing an Interface allows access to the methods and will call an individual instance of your class type with those methods implemented.
-
Oh sorry diesie... I will. Let me rewrite it and I'll modify this post when I've reimplemented everything EDIT @Override public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if (heldItem == null) { return false; }else{ if (!world.isRemote) { if (world.getBlockState(pos) == BlockReg.tableBlock0.getDefaultState()) { Item item = heldItem.getItem(); heldItem = player.getHeldItemMainhand(); IBlockState iBlockStateAndesite = Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.ANDESITE); IBlockState iBlockStateGranite = Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.GRANITE); IBlockState iBlockStateDiorite = Blocks.STONE.getDefaultState().withProperty(BlockStone.VARIANT, BlockStone.EnumType.DIORITE); Item itemStone = Item.getItemFromBlock(Blocks.STONE); ItemStack andesite = new ItemStack(itemStone, Blocks.STONE.damageDropped(iBlockStateAndesite)); ItemStack granite = new ItemStack(itemStone, Blocks.STONE.damageDropped(iBlockStateGranite)); ItemStack diorite = new ItemStack(itemStone, Blocks.STONE.damageDropped(iBlockStateDiorite)); boolean itemIsAndesite = ItemStack.areItemsEqual(heldItem, andesite); boolean itemIsGranite = ItemStack.areItemsEqual(heldItem, granite); boolean itemIsDiorite = ItemStack.areItemsEqual(heldItem, diorite); if (item == Item.getItemFromBlock(Blocks.COBBLESTONE)) { world.setBlockState(pos, BlockReg.tableBlock1.getDefaultState()); } if (item == Item.getItemFromBlock(Blocks.STONE)) { world.setBlockState(pos, BlockReg.tableBlock2.getDefaultState()); System.out.println(itemIsAndesite + " " + itemIsGranite + " " + itemIsDiorite); } if (item == Item.getItemFromBlock(Blocks.STONEBRICK)) { world.setBlockState(pos, BlockReg.tableBlock3.getDefaultState()); } if (itemIsAndesite) { world.setBlockState(pos, BlockReg.tableBlock4.getDefaultState()); System.out.println("Boolean is TRUE"); } if (itemIsDiorite) { world.setBlockState(pos, BlockReg.tableBlock5.getDefaultState()); System.out.println("Boolean is TRUE"); } if (itemIsGranite) { world.setBlockState(pos, BlockReg.tableBlock6.getDefaultState()); System.out.println("Boolean is TRUE"); } } } return true; } }