Jump to content

Recommended Posts

Posted

I'm trying to make a new block that looks kind of like stairs but in a different shape.

I'm getting an error saying "Don't know how to convert shelvesmod:shelfBlock[facing=north] back into data..."

 

# THIS IS THE BLOCK ITEM MDOEL FILE. IT GOES IN THE assets/shelvesmod/models/item/ folder.
# Generated using sheenrox82's JSON File Generator for Minecraft 1.8.

{
    "parent": "shelvesmod:block/shelfBlock",
    "display": {
        "thirdperson": {
            "rotation": [ 10, -45, 170 ],
            "translation": [ 0, 1.5, -2.75 ],
            "scale": [ 0.375, 0.375, 0.375 ]
        }
    }
}

 

# THIS IS THE BLOCK MDOEL FILE. IT GOES IN THE assets/shelvesmod/models/block/ folder.
# Generated using sheenrox82's JSON File Generator for Minecraft 1.8.

{

    "textures": {
        "all": "shelvesmod:blocks/shelfBlock"
    }


    "elements": [
        {   "from": [ 0, 0, 0 ],
            "to": [ 16, 2, 16 ],
            "faces": {
                "down": { "uv": [ 0, 0, 16, 16 ],  "cullface: "down"},
                "up":   { "uv": [ 0, 0, 16, 16 ] },
                "north": { "uv": [ 0, 0, 16, 2 ], "cullface: "north" },
                "south": { "uv": [ 0, 0, 16, 2 ], "cullface: "south" },
                "west": { "uv": [ 0, 0, 16, 2 ], "cullface: "west" },
                "east": { "uv": [ 0, 0, 16, 2 ], "cullface: "east" }
            }
        },
        {   "from": [ 0, 2, 0 ],
            "to": [ 16, 10, 10 ],
            "faces": {
                "down": { "uv": [ 0, 0, 16, 10 ],  "cullface: "down"},
                "up":   { "uv": [ 0, 0, 16, 10 ] },
                "north": { "uv": [ 0, 2, 16, 10 ], "cullface: "north" },
                "south": { "uv": [ 0, 2, 16, 10 ], "cullface: "south" },
                "west": { "uv": [ 0, 2, 10, 10 ], "cullface: "west" },
                "east": { "uv": [ 0, 2, 10, 10 ], "cullface: "east" }
            }
        },
        {   "from": [ 0, 10, 0 ],
            "to": [ 16, 16, 2 ],
            "faces": {
                "down": { "uv": [ 0, 0, 16, 2 ],  "cullface: "down"},
                "up":   { "uv": [ 0, 0, 16, 2 ] },
                "north": { "uv": [ 0, 10, 16, 16 ], "cullface: "north" },
                "south": { "uv": [ 0, 10, 16, 16 ], "cullface: "south" },
                "west": { "uv": [ 0, 10, 2, 16 ], "cullface: "west" },
                "east": { "uv": [ 0, 10, 2, 16 ], "cullface: "east" }
            }
        }
    ]
}

 

# THIS IS THE BLOCKSTATE FILE. IT GOES IN THE assets/shelvesmod/blockstates/ folder.
# Generated using sheenrox82's JSON File Generator for Minecraft 1.8.


{
    "variants": {
        "facing=east,section=bottom,shape=straight":  { "model": "shelfBlock" },
        "facing=west,section=bottom,shape=straight":  { "model": "shelfBlock", "y": 180, "uvlock": true },
        "facing=south,section=bottom,shape=straight": { "model": "shelfBlock", "y": 90, "uvlock": true },
        "facing=north,section=bottom,shape=straight": { "model": "shelfBlock", "y": 270, "uvlock": true },
        
        "facing=east,section=middle,shape=straight":  { "model": "shelfBlock", "x": 180, "uvlock": true },
        "facing=west,section=middle,shape=straight":  { "model": "shelfBlock", "x": 180, "y": 180, "uvlock": true },
        "facing=south,section=middle,shape=straight": { "model": "shelfBlock", "x": 180, "y": 90, "uvlock": true },
        "facing=north,section=middle,shape=straight": { "model": "shelfBlock", "x": 180, "y": 270, "uvlock": true },

        "facing=east,section=top,shape=straight":  { "model": "shelfBlock", "x": 180, "uvlock": true },
        "facing=west,section=top,shape=straight":  { "model": "shelfBlock", "x": 180, "y": 180, "uvlock": true },
        "facing=south,section=top,shape=straight": { "model": "shelfBlock", "x": 180, "y": 90, "uvlock": true },
        "facing=north,section=top,shape=straight": { "model": "shelfBlock", "x": 180, "y": 270, "uvlock": true }

    }
}

 

Here's the console information:

 

  Reveal hidden contents

 

hw developer in a sw world

Posted

Firstly I did say "Obviously without the : in the middle" for the code tags. Secondly the issue is here

 

"Don't know how to convert shelvesmod:shelfBlock[facing=north] back into data..."

"facing=north,section=top,shape=straight": { "model": "shelfBlock", "x": 180, "y": 270, "uvlock": true }

 

You have a value for "facing" in your blocks possible states, but no "section" or "shape" so it's looking for a model with just the value of "facing=north" which you don't have one of. Try adding the "section" and "shape" properties to your block state as well

Posted

Thanks; it did seem weird that those key words weren't used anywhere else in my code. I think I was using partial examples as templates, and trying to mix them together.  :|

hw developer in a sw world

Posted

I'm looking at the stone brick stairs as an example, and in their blockstates file, they use:

 

{
    "variants": {
        "facing=east,half=bottom,shape=straight":  { "model": "stone_brick_stairs" },
        "facing=west,half=bottom,shape=straight":  { "model": "stone_brick_stairs", "y": 180, "uvlock": true },
        "facing=south,half=bottom,shape=straight": { "model": "stone_brick_stairs", "y": 90, "uvlock": true },
        "facing=north,half=bottom,shape=straight": { "model": "stone_brick_stairs", "y": 270, "uvlock": true },
        "facing=east,half=bottom,shape=outer_right":  { "model": "stone_brick_outer_stairs" },
        "facing=west,half=bottom,shape=outer_right":  { "model": "stone_brick_outer_stairs", "y": 180, "uvlock": true },
        "facing=south,half=bottom,shape=outer_right": { "model": "stone_brick_outer_stairs", "y": 90, "uvlock": true },
        "facing=north,half=bottom,shape=outer_right": { "model": "stone_brick_outer_stairs", "y": 270, "uvlock": true },
        "facing=east,half=bottom,shape=outer_left":  { "model": "stone_brick_outer_stairs", "y": 270, "uvlock": true },
        "facing=west,half=bottom,shape=outer_left":  { "model": "stone_brick_outer_stairs", "y": 90, "uvlock": true },
        "facing=south,half=bottom,shape=outer_left": { "model": "stone_brick_outer_stairs" },
        "facing=north,half=bottom,shape=outer_left": { "model": "stone_brick_outer_stairs", "y": 180, "uvlock": true },
        "facing=east,half=bottom,shape=inner_right":  { "model": "stone_brick_inner_stairs" },
        "facing=west,half=bottom,shape=inner_right":  { "model": "stone_brick_inner_stairs", "y": 180, "uvlock": true },
        "facing=south,half=bottom,shape=inner_right": { "model": "stone_brick_inner_stairs", "y": 90, "uvlock": true },
        "facing=north,half=bottom,shape=inner_right": { "model": "stone_brick_inner_stairs", "y": 270, "uvlock": true },
        "facing=east,half=bottom,shape=inner_left":  { "model": "stone_brick_inner_stairs", "y": 270, "uvlock": true },
        "facing=west,half=bottom,shape=inner_left":  { "model": "stone_brick_inner_stairs", "y": 90, "uvlock": true },
        "facing=south,half=bottom,shape=inner_left": { "model": "stone_brick_inner_stairs" },
        "facing=north,half=bottom,shape=inner_left": { "model": "stone_brick_inner_stairs", "y": 180, "uvlock": true },
        "facing=east,half=top,shape=straight":  { "model": "stone_brick_stairs", "x": 180, "uvlock": true },
        "facing=west,half=top,shape=straight":  { "model": "stone_brick_stairs", "x": 180, "y": 180, "uvlock": true },
        "facing=south,half=top,shape=straight": { "model": "stone_brick_stairs", "x": 180, "y": 90, "uvlock": true },
        "facing=north,half=top,shape=straight": { "model": "stone_brick_stairs", "x": 180, "y": 270, "uvlock": true },
        "facing=east,half=top,shape=outer_right":  { "model": "stone_brick_outer_stairs", "x": 180, "uvlock": true },
        "facing=west,half=top,shape=outer_right":  { "model": "stone_brick_outer_stairs", "x": 180, "y": 180, "uvlock": true },
        "facing=south,half=top,shape=outer_right": { "model": "stone_brick_outer_stairs", "x": 180, "y": 90, "uvlock": true },
        "facing=north,half=top,shape=outer_right": { "model": "stone_brick_outer_stairs", "x": 180, "y": 270, "uvlock": true },
        "facing=east,half=top,shape=outer_left":  { "model": "stone_brick_outer_stairs", "x": 180, "y": 90, "uvlock": true },
        "facing=west,half=top,shape=outer_left":  { "model": "stone_brick_outer_stairs", "x": 180, "y": 270, "uvlock": true },
        "facing=south,half=top,shape=outer_left": { "model": "stone_brick_outer_stairs", "x": 180, "y": 180, "uvlock": true },
        "facing=north,half=top,shape=outer_left": { "model": "stone_brick_outer_stairs", "x": 180, "uvlock": true },
        "facing=east,half=top,shape=inner_right":  { "model": "stone_brick_inner_stairs", "x": 180, "uvlock": true },
        "facing=west,half=top,shape=inner_right":  { "model": "stone_brick_inner_stairs", "x": 180, "y": 180, "uvlock": true },
        "facing=south,half=top,shape=inner_right": { "model": "stone_brick_inner_stairs", "x": 180, "y": 90, "uvlock": true },
        "facing=north,half=top,shape=inner_right": { "model": "stone_brick_inner_stairs", "x": 180, "y": 270, "uvlock": true },
        "facing=east,half=top,shape=inner_left":  { "model": "stone_brick_inner_stairs", "x": 180, "y": 90, "uvlock": true },
        "facing=west,half=top,shape=inner_left":  { "model": "stone_brick_inner_stairs", "x": 180, "y": 270, "uvlock": true },
        "facing=south,half=top,shape=inner_left": { "model": "stone_brick_inner_stairs", "x": 180, "y": 180, "uvlock": true },
        "facing=north,half=top,shape=inner_left": { "model": "stone_brick_inner_stairs", "x": 180, "uvlock": true }
    }
}

 

I found in EnumFacing that the cardinal directions, NORTH, SOUTH, EAST, WEST,  and UP and DOWN, are defined, but I can't find anywhere that the code defines half, top, shape, inner_left, inner_right, outer_right, outer_left, or straight, so I can't figure out how to define these in my code.

So I just deleted the "section" and "shape".  I don't need shape, and I don't think I need section, though I might.

 

I still get the same error.  (I also found various mistakes involving commas and quotation marks and fixed those...).

 

here's the console:

 

  Reveal hidden contents

 

 

 

# THIS IS THE BLOCKSTATE FILE. IT GOES IN THE assets/shelvesmod/blockstates/ folder.
# Generated using sheenrox82's JSON File Generator for Minecraft 1.8.


{
    "variants": {
        "facing=east":  { "model": "shelfBlock" },
        "facing=west":  { "model": "shelfBlock", "y": 180, "uvlock": true },
        "facing=south": { "model": "shelfBlock", "y": 90, "uvlock": true },
        "facing=north": { "model": "shelfBlock", "y": 270, "uvlock": true },     
        "facing=east":  { "model": "shelfBlock", "x": 180, "uvlock": true },
        "facing=west":  { "model": "shelfBlock", "x": 180, "y": 180, "uvlock": true },
        "facing=south": { "model": "shelfBlock", "x": 180, "y": 90, "uvlock": true },
        "facing=north": { "model": "shelfBlock", "x": 180, "y": 270, "uvlock": true },
        "facing=east":  { "model": "shelfBlock", "x": 180, "uvlock": true },
        "facing=west":  { "model": "shelfBlock", "x": 180, "y": 180, "uvlock": true },
        "facing=south": { "model": "shelfBlock", "x": 180, "y": 90, "uvlock": true },
        "facing=north": { "model": "shelfBlock", "x": 180, "y": 270, "uvlock": true }

    }
}

 

# THIS IS THE BLOCK MDOEL FILE. IT GOES IN THE assets/shelvesmod/models/block/ folder.
# Generated using sheenrox82's JSON File Generator for Minecraft 1.8.

{

    "textures": {
        "all": "shelvesmod:blocks/shelfBlock"
    },


    "elements": [
   
        {   
            "from": [ 0, 0, 0 ],
            "to": [ 16, 2, 16 ],
            "faces": {
                "down": { "uv": [ 0, 0, 16, 16 ],  "cullface": "down"},
                "up":   { "uv": [ 0, 0, 16, 16 ] },
                "north": { "uv": [ 0, 0, 16, 2 ], "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 2 ], "cullface": "south" },
                "west": { "uv": [ 0, 0, 16, 2 ], "cullface": "west" },
                "east": { "uv": [ 0, 0, 16, 2 ], "cullface": "east" }
            }
        }, 
        
        {  
            "from": [ 0, 2, 0 ],
            "to": [ 16, 10, 10 ],
            "faces": {
                "down": { "uv": [ 0, 0, 16, 10 ],  "cullface": "down"},
                "up":   { "uv": [ 0, 0, 16, 10 ] },
                "north": { "uv": [ 0, 2, 16, 10 ], "cullface": "north" },
                "south": { "uv": [ 0, 2, 16, 10 ], "cullface": "south" },
                "west": { "uv": [ 0, 2, 10, 10 ], "cullface": "west" },
                "east": { "uv": [ 0, 2, 10, 10 ], "cullface": "east" }
            }
        }, 
        
        {  
            "from": [ 0, 10, 0 ],
            "to": [ 16, 16, 2 ],
            "faces": {
                "down": { "uv": [ 0, 0, 16, 2 ],  "cullface": "down"},
                "up":   { "uv": [ 0, 0, 16, 2 ] },
                "north": { "uv": [ 0, 10, 16, 16 ], "cullface": "north" },
                "south": { "uv": [ 0, 10, 16, 16 ], "cullface": "south" },
                "west": { "uv": [ 0, 10, 2, 16 ], "cullface": "west" },
                "east": { "uv": [ 0, 10, 2, 16 ], "cullface": "east" }
            }
        }
    ]
}

 

# THIS IS THE BLOCK ITEM MDOEL FILE. IT GOES IN THE assets/shelvesmod/models/item/ folder.
# Generated using sheenrox82's JSON File Generator for Minecraft 1.8.

{
    "parent": "shelvesmod:block/shelfBlock",
    "display": {
        "thirdperson": {
            "rotation": [ 10, -45, 170 ],
            "translation": [ 0, 1.5, -2.75 ],
            "scale": [ 0.375, 0.375, 0.375 ]
        }
    }
}

 

Do I need to instantiate an EnumFacing variable in my BlockShelf class or my ShelvesMod to make this work right?

 

UPDATE: now that I look closer at the stone brick stairs (there are 8 json files I'm looking at), I don't see how any of this works at all.  None of the models are defined anywhere, including: stone_brick_stairs, stone_brick_outer_stairs, stone_brick_inner_stairs.  how is this even working?  I'm just calling my model file shelfBlock for each model. 

hw developer in a sw world

Posted

UPDATE: ok I found a missing comma and a missing texture...working on it now...  :)

 

It runs!  it doesn't work, but it doesn't crash with an error.  :P 

And I have a new error now.

 

Console data:

 

  Reveal hidden contents

 

 

Looks like I need to investigate a little more and compare my json files to some good examples.  This is really hard since I'm "simplifying" the stairs model (and changing its shape, but the shape can be tweaked if I could just get the darn thing to load).

 

Here's the current code...  Any ideas on where I'm going wrong with the structure of these json files or am I maybe missing a registration or delcaration in my BlockShelves class??

Thanks for any help.

 

package com.rosecotton.shelvesmod;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderEntityItem;
import net.minecraft.client.renderer.entity.RenderItem;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.registry.LanguageRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraft.util.EnumFacing;

import com.rosecotton.shelvesmod.BlockShelf;



@Mod(modid = ShelvesMod.MODID, name = ShelvesMod.MODNAME, version = ShelvesMod.VERSION) 

public class ShelvesMod 
{


  public static Block shelfBlock;
  //public static Item brickIngot;
  public static final String MODID = "shelvesmod";
  public static final String MODNAME = "RoseCotton's Shelves Mod for 1.8";
  public static final String VERSION = "1.0";
  public static int type;
  
  
  
  
  @Instance(value = "shelvesmod")
  public static ShelvesMod instance = new ShelvesMod();
  

  
  
  public static class MySidedProxyHolder {
	  @SidedProxy(modId="shelvesmod",clientSide="com.rosecotton.shelvesmod.ClientProxy", serverSide="com.rosecotton.shelvesmod.CommonProxy")
	  public static CommonProxy proxy;
	  }
	  
	  public class CommonProxy {
		  // Common or server stuff here that needs to be overridden on the client
	  }
	  public class ClientProxy extends CommonProxy {
		  // Override common stuff with client specific stuff here
	  }
  

  @EventHandler
  public void preInit(FMLPreInitializationEvent event) 
  {
  	//System.out.println("Called method: preInit");
  	

  
  	//blocks
  	shelfBlock = new BlockShelf(type);
  	LanguageRegistry.addName(shelfBlock, "Shelf Block");
  	
  
  	//items
  	//brickIngot = new ItemBrickIngot();
	  //MOVE GAMEREGISTRY TO ITEM CLASS?
  	//GameRegistry.registerItem(brickIngot, ((ItemBrickIngot) brickIngot).getName());
  	//LanguageRegistry.addName(brickIngot, "Brick Ingot");
  }

  @EventHandler
  public void init(FMLInitializationEvent event) 
  {
  	//System.out.println("Called method: init");
  
  	if(event.getSide() == Side.CLIENT)
  	{
  		
  		RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
  		//renderItem.getItemModelMesher().register(brickIngot, 0, new ModelResourceLocation(Testmod01.MODID + ":" + ((ItemBrickIngot)brickIngot).getName(), "brickIngot"));
  		//Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(brickIngot,0, new ModelResourceLocation(Testmod01.MODID + ":" + ((ItemBrickIngot)brickIngot).getName(), "inventory"));

  		renderItem.getItemModelMesher().register(Item.getItemFromBlock(shelfBlock), 0, new ModelResourceLocation(ShelvesMod.MODID + ":" + "shelfBlock", "shelfBlock"));
  		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(shelfBlock),0, new ModelResourceLocation(ShelvesMod.MODID+":"+ "shelfBlock", "inventory"));
  		
  		
  	}
  	
  	//recipes
  	//GameRegistry.addRecipe(new ItemStack(brickBlock), new Object[]{
  	//"AA ",
  	//"AA ",
  	//"   ",
  	//'A', brickIngot
  	//});

  	//GameRegistry.addShapelessRecipe(new ItemStack(brickIngot, 4), new Object[]
  	//{
  	//    	brickBlock//new ItemStack(brickBlock, 1, 1)
  	//});
  	
  	//I left off the third parameter in ItemStack because it means damage
  	//GameRegistry.addSmelting(new ItemStack(brickBlock, 1), new ItemStack(brickIngot, 1), 0.1F);
  	
  	
  }

  @EventHandler
  public void postInit(FMLPostInitializationEvent event) 
  {
  	System.out.println("Called method: postInit");
  }
}

 

Much of this was taken from the stairs code but with a lot deleted and some re-written.  probably a few errors in here, or maybe I need to put @Override on more functions?

package com.rosecotton.shelvesmod;

import java.util.Iterator;
import java.util.Random;

import com.becky.testmod01.Testmod01;

import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryHelper;
import net.minecraft.inventory.InventoryLargeChest;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.ILockableContainer;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry;


public class BlockShelf extends Block {

    public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);
    private final Random rand = new Random();
    //public final int chestType;
    private static final String __OBFID = "CL_00000214";
private final String name = "shelfBlock";
ModelResourceLocation modelresourcelocation = new ModelResourceLocation("shelvesmod"+":"+name, "inventory");
    
    protected BlockShelf(int type)
    {
        super(Material.wood);
        //TEH FOLLOWIONG LINE MIGHT HAVE BEEN USEFUL BUT MAYBE CAUSED AN ERROR AT RUNTIME, TRY AGAIN
        this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH));
        //this.chestType = type;
        this.setCreativeTab(CreativeTabs.tabMisc);
        this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
        this.useNeighborBrightness = true;
	this.setDefaultState(this.blockState.getBaseState());
        GameRegistry.registerBlock(this, name);
    	this.setUnlocalizedName(ShelvesMod.MODID + "_" + name);
    }

    public boolean isOpaqueCube()
    {
        return false;
    }

    public boolean isFullCube()
    {
        return false;
    }

    public int getRenderType()
    {
        return 2;
    }



    public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos)
    {
        if (worldIn.getBlockState(pos.north()).getBlock() == this)
        {
            this.setBlockBounds(0.0625F, 0.0F, 0.0F, 0.9375F, 0.875F, 0.9375F);
        }
        else if (worldIn.getBlockState(pos.south()).getBlock() == this)
        {
            this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 1.0F);
        }
        else if (worldIn.getBlockState(pos.west()).getBlock() == this)
        {
            this.setBlockBounds(0.0F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
        }
        else if (worldIn.getBlockState(pos.east()).getBlock() == this)
        {
            this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 1.0F, 0.875F, 0.9375F);
        }
        else
        {
            this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 0.875F, 0.9375F);
        }
    }

    public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
    {
        //this.checkForSurroundingChests(worldIn, pos, state);
        Iterator iterator = EnumFacing.Plane.HORIZONTAL.iterator();

        while (iterator.hasNext())
        {
            EnumFacing enumfacing = (EnumFacing)iterator.next();
            BlockPos blockpos1 = pos.offset(enumfacing);
            IBlockState iblockstate1 = worldIn.getBlockState(blockpos1);

        }
    }

    public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
    {
        return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing());
    }

    public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
    {
        EnumFacing enumfacing = EnumFacing.getHorizontal(MathHelper.floor_double((double)(placer.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3).getOpposite();
        state = state.withProperty(FACING, enumfacing);
        BlockPos blockpos1 = pos.north();
        BlockPos blockpos2 = pos.south();
        BlockPos blockpos3 = pos.west();
        BlockPos blockpos4 = pos.east();
        boolean flag = this == worldIn.getBlockState(blockpos1).getBlock();
        boolean flag1 = this == worldIn.getBlockState(blockpos2).getBlock();
        boolean flag2 = this == worldIn.getBlockState(blockpos3).getBlock();
        boolean flag3 = this == worldIn.getBlockState(blockpos4).getBlock();

        if (!flag && !flag1 && !flag2 && !flag3)
        {
            worldIn.setBlockState(pos, state, 3);
        }
        else if (enumfacing.getAxis() == EnumFacing.Axis.X && (flag || flag1))
        {
            if (flag)
            {
                worldIn.setBlockState(blockpos1, state, 3);
            }
            else
            {
                worldIn.setBlockState(blockpos2, state, 3);
            }

            worldIn.setBlockState(pos, state, 3);
        }
        else if (enumfacing.getAxis() == EnumFacing.Axis.Z && (flag2 || flag3))
        {
            if (flag2)
            {
                worldIn.setBlockState(blockpos3, state, 3);
            }
            else
            {
                worldIn.setBlockState(blockpos4, state, 3);
            }

            worldIn.setBlockState(pos, state, 3);
        }

        if (stack.hasDisplayName())
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntityChest)
            {
                ((TileEntityChest)tileentity).setCustomName(stack.getDisplayName());
            }
        }
    }


    public IBlockState correctFacing(World worldIn, BlockPos pos, IBlockState state)
    {
        EnumFacing enumfacing = null;
        Iterator iterator = EnumFacing.Plane.HORIZONTAL.iterator();

        while (iterator.hasNext())
        {
            EnumFacing enumfacing1 = (EnumFacing)iterator.next();
            IBlockState iblockstate1 = worldIn.getBlockState(pos.offset(enumfacing1));

            if (iblockstate1.getBlock() == this)
            {
                return state;
            }

            if (iblockstate1.getBlock().isFullBlock())
            {
                if (enumfacing != null)
                {
                    enumfacing = null;
                    break;
                }

                enumfacing = enumfacing1;
            }
        }

        if (enumfacing != null)
        {
            return state.withProperty(FACING, enumfacing.getOpposite());
        }
        else
        {
            EnumFacing enumfacing2 = (EnumFacing)state.getValue(FACING);

            if (worldIn.getBlockState(pos.offset(enumfacing2)).getBlock().isFullBlock())
            {
                enumfacing2 = enumfacing2.getOpposite();
            }

            if (worldIn.getBlockState(pos.offset(enumfacing2)).getBlock().isFullBlock())
            {
                enumfacing2 = enumfacing2.rotateY();
            }

            if (worldIn.getBlockState(pos.offset(enumfacing2)).getBlock().isFullBlock())
            {
                enumfacing2 = enumfacing2.getOpposite();
            }

            return state.withProperty(FACING, enumfacing2);
        }
    }





    public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof IInventory)
        {
            InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory)tileentity);
            worldIn.updateComparatorOutputLevel(pos, this);
        }

        super.breakBlock(worldIn, pos, state);
    }



    public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
    {
       // if (worldIn.isRemote)
       // {
            return true;
       // }
     
    }



   


   public TileEntity createNewTileEntity(World worldIn, int meta)
    {
        return new TileEntityChest();
    }



    private boolean isBlocked(World worldIn, BlockPos pos)
    {
        return this.isBelowSolidBlock(worldIn, pos) || this.isOcelotSittingOnChest(worldIn, pos);
    }

    private boolean isBelowSolidBlock(World worldIn, BlockPos pos)
    {
        return worldIn.getBlockState(pos.up()).getBlock().isNormalCube();
    }




    private boolean isOcelotSittingOnChest(World worldIn, BlockPos pos)
    {
        Iterator iterator = worldIn.getEntitiesWithinAABB(EntityOcelot.class, new AxisAlignedBB((double)pos.getX(), (double)(pos.getY() + 1), (double)pos.getZ(), (double)(pos.getX() + 1), (double)(pos.getY() + 2), (double)(pos.getZ() + 1))).iterator();
        EntityOcelot entityocelot;

        do
        {
            if (!iterator.hasNext())
            {
                return false;
            }

            Entity entity = (Entity)iterator.next();
            entityocelot = (EntityOcelot)entity;
        }
        while (!entityocelot.isSitting());

        return true;
    }

    public boolean hasComparatorInputOverride()
    {
        return true;
    }




    
    @Override
    public IBlockState getStateFromMeta(int meta)
    {
        EnumFacing enumfacing = EnumFacing.getFront(meta);

        if (enumfacing.getAxis() == EnumFacing.Axis.Y)
        {
            enumfacing = EnumFacing.NORTH;
        }

        return this.getDefaultState().withProperty(FACING, enumfacing);
    }

    @Override
    public int getMetaFromState(IBlockState state)
    {
      EnumFacing facing = (EnumFacing)state.getValue(FACING);
      //EnumColour colour = (EnumColour)state.getValue(PROPERTYCOLOUR);

      int facingbits = facing.getHorizontalIndex();
     //int colourbits = colour.getMetadata() << 2;
      return facingbits;// | colourbits;
    }

    protected BlockState createBlockState()
    {
        return new BlockState(this, new IProperty[] {FACING});
    }


    public static enum EnumShape implements IStringSerializable
    {
        TOP("top"),
        MIDDLE("middle"),
        BOTTOM("bottom");

        private final String name;

        private static final String __OBFID = "CL_00003061";

        private EnumShape(String name)
        {
            this.name = name;
        }

        public String toString()
        {
            return this.name;
        }

        public String getName()
        {
            return this.name;
        }

    }

}

 

Well, I can't yet get each facing direction variant to load, but at least it understands my "section" property.  I remember something about a list of possible facing directions, but I can't remember if I need to state it somewhere else....

# THIS IS THE BLOCKSTATE FILE. IT GOES IN THE assets/shelvesmod/blockstates/ folder.
# Generated using sheenrox82's JSON File Generator for Minecraft 1.8.


{
    "variants": {
        "facing=east, section=top":  { "model": "shelvesmod:shelfBlock" },
        "facing=west, section=top":  { "model": "shelvesmod:shelfBlock", "y": 180, "uvlock": true },
        "facing=south, section=top": { "model": "shelvesmod:shelfBlock", "y": 90, "uvlock": true },
        "facing=north, section=top": { "model": "shelvesmod:shelfBlock", "y": 270, "uvlock": true },     
        "facing=east, section=middle":  { "model": "shelvesmod:shelfBlock", "x": 180, "uvlock": true },
        "facing=west, section=middle":  { "model": "shelvesmod:shelfBlock", "x": 180, "y": 180, "uvlock": true },
        "facing=south, section=middle": { "model": "shelvesmod:shelfBlock", "x": 180, "y": 90, "uvlock": true },
        "facing=north, section=middle": { "model": "shelvesmod:shelfBlock", "x": 180, "y": 270, "uvlock": true },
        "facing=east, section=bottom":  { "model": "shelvesmod:shelfBlock", "x": 180, "uvlock": true },
        "facing=west, section=bottom":  { "model": "shelvesmod:shelfBlock", "x": 180, "y": 180, "uvlock": true },
        "facing=south, section=bottom": { "model": "shelvesmod:shelfBlock", "x": 180, "y": 90, "uvlock": true },
        "facing=north, section=bottom": { "model": "shelvesmod:shelfBlock", "x": 180, "y": 270, "uvlock": true }

    }
}

 

# THIS IS THE BLOCK MDOEL FILE. IT GOES IN THE assets/shelvesmod/models/block/ folder.
# Generated using sheenrox82's JSON File Generator for Minecraft 1.8.

{

    "textures": {
        "all": "shelvesmod:blocks/shelfBlock"
    },


    "elements": [
   
        {   
            "from": [ 0, 0, 0 ],
            "to": [ 16, 2, 16 ],
            "faces": {
                "down": { "uv": [ 0, 0, 16, 16 ],  "cullface": "down"},
                "up":   { "uv": [ 0, 0, 16, 16 ] },
                "north": { "uv": [ 0, 0, 16, 2 ], "cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 2 ], "cullface": "south" },
                "west": { "uv": [ 0, 0, 16, 2 ], "cullface": "west" },
                "east": { "uv": [ 0, 0, 16, 2 ], "cullface": "east" }
            }
        }, 
        
        {  
            "from": [ 0, 2, 0 ],
            "to": [ 16, 10, 10 ],
            "faces": {
                "down": { "uv": [ 0, 0, 16, 10 ],  "cullface": "down"},
                "up":   { "uv": [ 0, 0, 16, 10 ] },
                "north": { "uv": [ 0, 2, 16, 10 ], "cullface": "north" },
                "south": { "uv": [ 0, 2, 16, 10 ], "cullface": "south" },
                "west": { "uv": [ 0, 2, 10, 10 ], "cullface": "west" },
                "east": { "uv": [ 0, 2, 10, 10 ], "cullface": "east" }
            }
        }, 
        
        {  
            "from": [ 0, 10, 0 ],
            "to": [ 16, 16, 2 ],
            "faces": {
                "down": { "uv": [ 0, 0, 16, 2 ],  "cullface": "down"},
                "up":   { "uv": [ 0, 0, 16, 2 ] },
                "north": { "uv": [ 0, 10, 16, 16 ], "cullface": "north" },
                "south": { "uv": [ 0, 10, 16, 16 ], "cullface": "south" },
                "west": { "uv": [ 0, 10, 2, 16 ], "cullface": "west" },
                "east": { "uv": [ 0, 10, 2, 16 ], "cullface": "east" }
            }
        }
    ]
}

 

# THIS IS THE BLOCK ITEM MDOEL FILE. IT GOES IN THE assets/shelvesmod/models/item/ folder.
# Generated using sheenrox82's JSON File Generator for Minecraft 1.8.

{
    "parent": "shelvesmod:block/shelfBlock",
    "display": {
        "thirdperson": {
            "rotation": [ 10, -45, 170 ],
            "translation": [ 0, 1.5, -2.75 ],
            "scale": [ 0.375, 0.375, 0.375 ]
        }
    }
}

hw developer in a sw world

Posted

I'm getting closer...

 

UPDATE: Item now shows up in my inventory!  :)

The item now looks like the pink-and-black cube we all know and love...

when i place it, it's invisible.  But I can break it and hear the sound of it breaking.

 

console data:

 

  Reveal hidden contents

 

hw developer in a sw world

Posted

Ok, I changed how I call out my textures and my item now renders, but the directional-facing varients still don't.  :\

Any suggestions?

 

Console data:

 

  Reveal hidden contents

 

 

# THIS IS THE BLOCKSTATE FILE. IT GOES IN THE assets/shelvesmod/blockstates/ folder.
# Generated using sheenrox82's JSON File Generator for Minecraft 1.8.


{
    "variants": {
        "facing=east,section=top":  { "model": "shelvesmod:shelfBlock" },
        "facing=west,section=top":  { "model": "shelvesmod:shelfBlock", "y": 180, "uvlock": true },
        "facing=south,section=top": { "model": "shelvesmod:shelfBlock", "y": 90, "uvlock": true },
        "facing=north,section=top": { "model": "shelvesmod:shelfBlock", "y": 270, "uvlock": true },     
        "facing=east,section=middle":  { "model": "shelvesmod:shelfBlock", "x": 180, "uvlock": true },
        "facing=west,section=middle":  { "model": "shelvesmod:shelfBlock", "x": 180, "y": 180, "uvlock": true },
        "facing=south,section=middle": { "model": "shelvesmod:shelfBlock", "x": 180, "y": 90, "uvlock": true },
        "facing=north,section=middle": { "model": "shelvesmod:shelfBlock", "x": 180, "y": 270, "uvlock": true },
        "facing=east,section=bottom":  { "model": "shelvesmod:shelfBlock", "x": 180, "uvlock": true },
        "facing=west,section=bottom":  { "model": "shelvesmod:shelfBlock", "x": 180, "y": 180, "uvlock": true },
        "facing=south,section=bottom": { "model": "shelvesmod:shelfBlock", "x": 180, "y": 90, "uvlock": true },
        "facing=north,section=bottom": { "model": "shelvesmod:shelfBlock", "x": 180, "y": 270, "uvlock": true }

    }
}

 

# THIS IS THE BLOCK MDOEL FILE. IT GOES IN THE assets/shelvesmod/models/block/ folder.
# Generated using sheenrox82's JSON File Generator for Minecraft 1.8.

{

    "textures": {
        "all": "shelvesmod:blocks/shelfBlock"

    },


    "elements": [
   
        {   "section":"bottom",
            "from": [ 0, 0, 0 ],
            "to": [ 16, 2, 16 ],
            "faces": {
                "down": { "uv": [ 0, 0, 16, 16 ], "texture":"all", "cullface": "down"},
                "up":   { "uv": [ 0, 0, 16, 16 ], "texture":"all" },
                "north": { "uv": [ 0, 0, 16, 2 ], "texture":"all","cullface": "north" },
                "south": { "uv": [ 0, 0, 16, 2 ], "texture":"all", "cullface": "south" },
                "west": { "uv": [ 0, 0, 16, 2 ], "texture":"all", "cullface": "west" },
                "east": { "uv": [ 0, 0, 16, 2 ], "texture":"all", "cullface": "east" }
            }
        }, 
        
        {  "section":"middle",
            "from": [ 0, 2, 0 ],
            "to": [ 16, 10, 10 ],
            "faces": {
                "down": { "uv": [ 0, 0, 16, 10 ], "texture":"all", "cullface": "down"},
                "up":   { "uv": [ 0, 0, 16, 10 ], "texture":"all" },
                "north": { "uv": [ 0, 2, 16, 10 ], "texture":"all", "cullface": "north" },
                "south": { "uv": [ 0, 2, 16, 10 ], "texture":"all", "cullface": "south" },
                "west": { "uv": [ 0, 2, 10, 10 ], "texture":"all", "cullface": "west" },
                "east": { "uv": [ 0, 2, 10, 10 ], "texture":"all", "cullface": "east" }
            }
        }, 
        
        {  "section":"top",
            "from": [ 0, 10, 0 ],
            "to": [ 16, 16, 2 ],
            "faces": {
                "down": { "uv": [ 0, 0, 16, 2 ], "texture":"all", "cullface": "down"},
                "up":   { "uv": [ 0, 0, 16, 2 ] , "texture":"all"},
                "north": { "uv": [ 0, 10, 16, 16 ], "texture":"all", "cullface": "north" },
                "south": { "uv": [ 0, 10, 16, 16 ], "texture":"all", "cullface": "south" },
                "west": { "uv": [ 0, 10, 2, 16 ], "texture":"all", "cullface": "west" },
                "east": { "uv": [ 0, 10, 2, 16 ], "texture":"all", "cullface": "east" }
            }
        }
    ]
}

 

# THIS IS THE BLOCK ITEM MDOEL FILE. IT GOES IN THE assets/shelvesmod/models/item/ folder.
# Generated using sheenrox82's JSON File Generator for Minecraft 1.8.

{
    "parent": "shelvesmod:block/shelfBlock",
    "display": {
        "thirdperson": {
            "rotation": [ 10, -45, 170 ],
            "translation": [ 0, 1.5, -2.75 ],
            "scale": [ 0.375, 0.375, 0.375 ]
        }
    }
}

hw developer in a sw world

Posted

Hi

 

> Unable to load variant: facing=east from shelvesmod:shelfBlock#facing=east

 

This suggests to me that your block state only has a facing property, but your model file expects it to have both facing property and a section property, could that be true?

 

 

-TGG

Posted

Thanks, that is true, and making sure both properties were listed in the createBlockState() method got rid of the error.

So something else is a problem because my block still doesn't render, even as well as it did yesterday before I tried to isolate the problem by removing my other mods.

hw developer in a sw world

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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