Jump to content

Recommended Posts

Posted

In a json file (blockstates), must each listed state be complete (i.e. provide a value for each and every property)?

 

Is there a wildcard like "any" that would allow me to write one line to take the place of many (where one property has no effect in this list)?

 

What I am trying to do is to separate my block's geometry from its skin (texture). I want to use some of the block's properties to control what model to use, and I want to use a separate property to choose texture. Because there are 32 geometries and 15 textures, I desperately want to avoid having to list the complete 480-line Cartesian product of all those models and textures. What I have in mind is something along these lines for my blockstates file (an extension of BlockWall:

 

{
    "textures": {
        "skin=0":  { "texture": "blocks/stonebrick" },
        "skin=1":  { "texture": "blocks/stonebrick_mossy" },
        "skin=2":  { "texture": "blocks/stonebrick_cracked" },
        "skin=3":  { "texture": "blocks/stonebrick_carved" },
        "skin=4":  { "texture": "blocks/brick" },
        "skin=5":  { "texture": "blocks/hardened_clay" },
        "skin=6":  { "texture": "blocks/netherrack" },
        "skin=7":  { "texture": "blocks/quartz_block_chiseled" },
        "skin=8":  { "texture": "blocks/obsidian" },
        "skin=9":  { "texture": "blocks/sandstone_normal" },
        "skin=10": { "texture": "blocks/sandstone_carved" },
        "skin=11": { "texture": "blocks/stone" },
        "skin=12": { "texture": "blocks/stone_andesite_smooth" },
        "skin=13": { "texture": "blocks/stone_diorite_smooth" },
        "skin=14": { "texture": "blocks/stone_granite_smooth" }
    }
    "variants": {
        "east=false,north=false,south=false,up=false,west=false": { "model": "wall_post" },
        "east=false,north=false,south=false,up=true,west=false":  { "model": "wall_post" },
        "east=false,north=true,south=false,up=false,west=false":  { "model": "wall_n" },
        "east=true,north=false,south=false,up=false,west=false":  { "model": "wall_n", "y": 90, "uvlock": true },
        "east=false,north=false,south=true,up=false,west=false":  { "model": "wall_n", "y": 180, "uvlock": true },
        "east=false,north=false,south=false,up=false,west=true":  { "model": "wall_n", "y": 270, "uvlock": true },
        "east=false,north=true,south=false,up=true,west=false":   { "model": "wall_n" },
        "east=true,north=false,south=false,up=true,west=false":   { "model": "wall_n", "y": 90, "uvlock": true },
        "east=false,north=false,south=true,up=true,west=false":   { "model": "wall_n", "y": 180, "uvlock": true },
        "east=false,north=false,south=false,up=true,west=true":   { "model": "wall_n", "y": 270, "uvlock": true },
        "east=true,north=true,south=false,up=false,west=false":   { "model": "wall_ne" },
        "east=true,north=false,south=true,up=false,west=false":   { "model": "wall_ne", "y": 90, "uvlock": true },
        "east=false,north=false,south=true,up=false,west=true":   { "model": "wall_ne", "y": 180, "uvlock": true },
        "east=false,north=true,south=false,up=false,west=true":   { "model": "wall_ne", "y": 270, "uvlock": true },
        "east=true,north=true,south=false,up=true,west=false":    { "model": "wall_ne" },
        "east=true,north=false,south=true,up=true,west=false":    { "model": "wall_ne", "y": 90, "uvlock": true },
        "east=false,north=false,south=true,up=true,west=true":    { "model": "wall_ne", "y": 180, "uvlock": true },
        "east=false,north=true,south=false,up=true,west=true":    { "model": "wall_ne", "y": 270, "uvlock": true },
        "east=false,north=true,south=true,up=false,west=false":   { "model": "wall_ns" },
        "east=true,north=false,south=false,up=false,west=true":   { "model": "wall_ns", "y": 90, "uvlock": true },
        "east=false,north=true,south=true,up=true,west=false":    { "model": "wall_ns_above" },
        "east=true,north=false,south=false,up=true,west=true":    { "model": "wall_ns_above", "y": 90, "uvlock": true },
        "east=true,north=true,south=true,up=false,west=false":    { "model": "wall_nse" },
        "east=true,north=false,south=true,up=false,west=true":    { "model": "wall_nse", "y": 90, "uvlock": true },
        "east=false,north=true,south=true,up=false,west=true":    { "model": "wall_nse", "y": 180, "uvlock": true },
        "east=true,north=true,south=false,up=false,west=true":    { "model": "wall_nse", "y": 270, "uvlock": true },
        "east=true,north=true,south=true,up=true,west=false":     { "model": "wall_nse" },
        "east=true,north=false,south=true,up=true,west=true":     { "model": "wall_nse", "y": 90, "uvlock": true },
        "east=false,north=true,south=true,up=true,west=true":     { "model": "wall_nse", "y": 180, "uvlock": true },
        "east=true,north=true,south=false,up=true,west=true":     { "model": "wall_nse", "y": 270, "uvlock": true },
        "east=true,north=true,south=true,up=false,west=true":     { "model": "wall_nsew" },
        "east=true,north=true,south=true,up=true,west=true":      { "model": "wall_nsew" }
    }
}

Sadly, looking at how vanilla created a full brace of models for each type of wall (mossy and cobble), with each model simply repeating the texture in its own name, I am pessimistic for my chances to do something more elegant. If there's no way to treat independent properties separately, then I'll end up with 15 nearly identical blockstates files and 85 model files, every one of them prone to typing errors  :o

 

It's so ugly that the artist in me has to try to do better.

 

BTW, Does anyone know where the json files get processed? If I could lay eyes on the source code, then I might answer my own question (or make an improvement).

 

Update:

 

By having the debugger blow up on launch, I've found a Forge block properties loader with an interesting bit of Forge magic switching on a "marker" to a custom branch of json loading that I don't yet understand. I'm hoping that what I want to do is or can be supported in there. If property wildcards are not yet supported, then perhaps I should write a wish-list request (either wildcards or something like "intake multiple, disjoint sets and perform the Cartesian product on the fly") in a different subforum.

 

Where may I read up on the features of Forge's enhanced json loader (and how do I set the marker)? Are wildcard property values supported? How about bracketed value-lists? Could an enhanced loader read in a texture list plus a model list and perform a Cartesian product in software? Can you tell that I miss mc1.7.10 where all I had to do was extend class BlockWall and override the texture function to use metadata?

 

UPDATE:

 

Workaround: Forge has a custom json format that can at least break the Cartesian product into tolerable independent variables. See discussion below.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

Hi

 

You can use a custom state mapper for your block properties to ignore some of them

 

http://www.minecraftforge.net/forum/index.php/topic,28997.msg149446.html#msg149446

 

After re-reading your post, I don't think that will help with decoupling skin textures from the blockstates, though. 

You could consider either implementing an ISmartBlockModel with custom block loader to substitute the texture at loading (https://github.com/TheGreyGhost/MinecraftByExample MBE04, MBE05) or perhaps the forge blockstates can do this (I'm not familiar with those).

 

-TGG

Posted

From the doc:

Instead of defining “this combination of properties gives model X” we say “this value for this property has THAT impact on the model”.

 

That's EXACTLY the mindset I have for my mod!

 

Note to tutorial writers: Mention both json structures, and include Lex's link to the doc.

 

I expect success shortly, whereupon I'll add SOLVED to the OP subject line.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

Regarding Forge blockstates:

 

Can I nest properties? Can the effect of one property value be another property with a set of values?

 

In my case, I have two values of one property that then look at another property for a true/false before choosing a model.

 

I'm giving it a try, but I might not intuit the syntax correctly:

    "geometry": {
        "0":  { "model": "wall_post" },
        "4":  { "model": "wall_n" },
        "8":  { "model": "wall_n", "y": 90, "uvlock": true },
        "2":  { "model": "wall_n", "y": 180, "uvlock": true },
        "1":  { "model": "wall_n", "y": 270, "uvlock": true },
        "12": { "model": "wall_ne" },
        "10": { "model": "wall_ne", "y": 90, "uvlock": true },
        "3":  { "model": "wall_ne", "y": 180, "uvlock": true },
        "5":  { "model": "wall_ne", "y": 270, "uvlock": true },
        "6":  {
          "up": {
            "true":  { "model": "wall_ns" },
            "false": { "model": "wall_ns_above" }
          }
        },
        "9":  {
          "up": {
            "true":  { "model": "wall_ns", "y": 90, "uvlock": true },
            "false": { "model": "wall_ns_above", "y": 90, "uvlock": true }
          }
        },
        "14":    { "model": "wall_nse" },
        "11":    { "model": "wall_nse", "y": 90, "uvlock": true },
        "7":    { "model": "wall_nse", "y": 180, "uvlock": true },
        "13":    { "model": "wall_nse", "y": 270, "uvlock": true },
        "15":     { "model": "wall_nsew" },
    }
  }

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

No they can't. The Forge blockstate format is simply a system that builds all the cartesian products for the given entries for you instead of you having to specify them all.

The json is not a scripting system, if you need it to be then you're doing something wrong.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

Posted

Fair enough; I can copy-paste all 32 wall geometries. I'm just happy that I don't need to multiply that by all 15 (and counting) skins!

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

The Forge state loader seems to be working for the walls, but now I'm hung up on a multi-part blockstates file for my iron gate. The error message is "No base model or submodel provided for this MultiModel.Baked". I guess I don't understand the rules for the new json format. Here's my half baked (so to speak) blockstates json (which passes the json lint tool):

 

{
  "forge_marker" : 1,
   "defaults" : {
    "textures" : { "texture" : "blocks/iron_block" }
  },
   "variants" : {
    "context" : {
      "0" : { "model" : "block/fence_gate_closed" },
      "1" : { "model" : "block/wall_gate_closed" },
      "2" : { "model" : "block/fence_gate_open" },
      "3" : { "model" : "block/wall_gate_open" }
    },
    "facing" : {
      "south" : { },
      "west"  : {  "y" : 90,  "uvlock": true  },
      "north" : {  "y" : 180, "uvlock": true  },
      "east"  : {  "y" : 270, "uvlock": true  }
    }
  }
}

 

The "model" is determined by the value of the context property, and every possible value of context is covered, so I can't see why I'm being told that there's no model. What rule am I missing? Based on my (extremely) limited understanding of json format, I was expecting the loader to emit the Cartesian product of 4 models times 4 facings. Is it possible to separate those, or may I only separate textures from "variants"?

 

Here's the full crash report:

[11:08:09] [Client thread/INFO]: Created: 512x512 textures-atlas
[11:08:10] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:663]: ---- Minecraft Crash Report ----
// Daisy, daisy...

Time: 8/25/15 11:08 AM
Description: Initializing game

java.lang.RuntimeException: No base model or submodel provided for this MultiModel.Baked.
at net.minecraftforge.client.model.MultiModel$Baked.<init>(MultiModel.java:50)
at net.minecraftforge.client.model.MultiModel.bake(MultiModel.java:196)
at net.minecraftforge.client.model.ModelLoader$WeightedPartWrapper.bake(ModelLoader.java:393)
at net.minecraftforge.client.model.ModelLoader$WeightedRandomModel.bake(ModelLoader.java:458)
at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:122)
at net.minecraft.client.resources.model.ModelManager.onResourceManagerReload(ModelManager.java:29)
at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:130)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:511)
at net.minecraft.client.Minecraft.run(Minecraft.java:356)
at net.minecraft.client.main.Main.main(Main.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at net.minecraftforge.client.model.MultiModel$Baked.<init>(MultiModel.java:50)
at net.minecraftforge.client.model.MultiModel.bake(MultiModel.java:196)
at net.minecraftforge.client.model.ModelLoader$WeightedPartWrapper.bake(ModelLoader.java:393)
at net.minecraftforge.client.model.ModelLoader$WeightedRandomModel.bake(ModelLoader.java:458)
at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:122)
at net.minecraft.client.resources.model.ModelManager.onResourceManagerReload(ModelManager.java:29)
at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:130)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:511)

-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.Minecraft.run(Minecraft.java:356)
at net.minecraft.client.main.Main.main(Main.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

-- System Details --
Details:
Minecraft Version: 1.8
Operating System: Windows XP (x86) version 5.1
Java Version: 1.7.0_55, Oracle Corporation
Java VM Version: Java HotSpot(TM) Client VM (mixed mode, sharing), Oracle Corporation
Memory: 79954512 bytes (76 MB) / 193601536 bytes (184 MB) up to 259522560 bytes (247 MB)
JVM Flags: 0 total; 
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.10 FML v8.0.99.99 Minecraft Forge 11.14.3.1450 4 mods loaded, 4 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCH	mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) 
UCH	FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.3.1450.jar) 
UCH	Forge{11.14.3.1450} [Minecraft Forge] (forgeSrc-1.8-11.14.3.1450.jar) 
UCH	jrfwalls{v1.7.10-00.01.05 Beta} [uncle Jeff's Walls Mod] (bin) 
Loaded coremods (and transformers): 
GL info: ' Vendor: 'ATI Technologies Inc.' Version: '3.2.9232' Renderer: 'ATI Radeon HD 3200 Graphics'
Launched Version: 1.6
LWJGL: 2.9.1
OpenGL: ATI Radeon HD 3200 Graphics GL version 3.2.9232, ATI Technologies Inc.
GL Caps: Using GL 1.3 multitexturing.
Using GL 1.3 texture combiners.
Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
Shaders are available because OpenGL 2.1 is supported.
VBOs are available because OpenGL 1.5 is supported.

Using VBOs: No
Is Modded: Definitely; Client brand changed to 'fml,forge'
Type: Client (map_client.txt)
Resource Packs: []
Current Language: English (US)
Profiler Position: N/A (disabled)
[11:08:10] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:663]: #@!@# Game crashed!
Crash report saved to: #@!@# D:\Projects\Minecraft\Forge1450\.\crash-reports\crash-2015-08-25_11.08.10-client.txt

 

UPDATE: Solved the latest problem -- "block/" is for textures, not models. I removed "block/" from in front of my model names and the problem went away (D'oh!). I'm in the home stretch now...

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

I *finally* got this to work  :'(

 

Here's my (abstract) block class, which finishes with some ugly guts shamelessly copy-pasted from vanilla's BlockWall class:

 

/**
* Once upon a time (before MC v1., this could be a simple subclass of BlockWall, inheriting many useful methods. Sadly, v1.8
* screwed that up with its egregious implementation of properties (featuring Cartesian products).
* 
* The design now imitates the useful parts of BlockWall, replacing its properties and setting them up for Forge's enhanced json
* reader.
* 
* Being a departure from BlockWall, this becomes the extensible (abstract) class from which two or more concrete classes may be
* derived to provide a wide variety of skins on walls (including the original cobble and mossy cobble).
*/
package jrfwalls;

// import static net.minecraftforge.common.util.ForgeDirection.UP;
import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.block.BlockFenceGate;
import net.minecraft.block.BlockWall;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyInteger;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.Explosion;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

// @SuppressWarnings("rawtypes")
public abstract class classAbstractWall extends Block {

  public static final PropertyInteger GEOMETRY = PropertyInteger.create ("geometry", 0, 17);
  public static final PropertyInteger SKIN = PropertyInteger.create ("skin", 0, 15);
  public String[] subName;                  // Block subtype names defined in each concrete class, copied into ItemBlock

// public classItemWall itemblockAnystoneWall;

  public classAbstractWall(String name, String[] subNameArray) {
    super (Material.rock);
    this.setDefaultState (this.getDefaultState ().withProperty (GEOMETRY, 17));
    this.setUnlocalizedName (name);
    this.subName = subNameArray;
    this.setCreativeTab (CreativeTabs.tabBlock);

    classAnystoneWallsMod.regBlock (this, classItemWall.class);
    this.setHardness (1.5F);                // Default to stone
    this.setResistance (10.0F);             // Ditto (after auto-tripling)
    this.setStepSound (soundTypePiston);    // Ditto
  }

  // Called from ItemBlock to name an item (stack) subtype in menu or inventory or drops
  public String getUnlocalizedName(int meta) {
// return classJRFmod.cutName(getUnlocalizedName ()) + "." + subName[meta];
    return getUnlocalizedName () + "." + subName[meta];
  }

  /**
   * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
   */
  @Override
  @SideOnly(Side.CLIENT)
  public void getSubBlocks(Item i, CreativeTabs t, List list) {
    for (int meta = 0; meta <= 15; meta++ ) {
      list.add (new ItemStack (i, 1, meta));
    }
  }

  // Our replacement (abstract) wall class has only two properties
  //
  @Override
  protected BlockState createBlockState() {
    return new BlockState (this, new IProperty[] { GEOMETRY, SKIN });
  }

  /**
   * Convert the given metadata into a BlockState for this Block
   */
  @Override
  public IBlockState getStateFromMeta(int meta) {               // Block state starts with metadata being injected into default geometry
    return this.getDefaultState ().withProperty (SKIN, meta);
  }

  /**
   * Get the actual Block state of this Block at the given position. This applies properties not visible in the
   * metadata, such as fence connections.
   */
  @Override
  public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
    int g = this.canConnectTo (worldIn, pos.west ()) ? 1 : 0;

    if (this.canConnectTo (worldIn, pos.south ())) g += 2;      // state parm should arrive with meta already in it
    if (this.canConnectTo (worldIn, pos.north ())) {
      g += 4;
    }
    if (this.canConnectTo (worldIn, pos.east ())) {
      g += 8;   // If that makes 9, then we're (E + W) a non post straight unless connected above
      if (g == 9 && !worldIn.isAirBlock (pos.up ())) g = 17;
    } else {    // We din't add 8, so we might be only 6 (N + S), also low-straight looking up
      if (g == 6 && !worldIn.isAirBlock (pos.up ())) g = 16;
    }
    return state.withProperty (GEOMETRY, g);                    // ...so we just add geometry
  }

  /**
   * Convert the BlockState into the correct metadata value
   */
  @Override
  public int getMetaFromState(IBlockState state) {
    return ((Integer) state.getValue (SKIN)).intValue ();
  }

  /**
   * Get the damage value that this Block should drop
   */
  @Override
  public int damageDropped(IBlockState state) {
    return getMetaFromState (state);
  }

  @Override
  @SideOnly(Side.CLIENT)
  public EnumWorldBlockLayer getBlockLayer()
  {
      return EnumWorldBlockLayer.CUTOUT;
  }

  @Override
  abstract public float getExplosionResistance(World world, BlockPos pos, Entity exploder, Explosion explosion);

  // Imitate Block class until the call to abstract method
  @Override
  public int getLightValue(IBlockAccess world, BlockPos pos) {
    IBlockState bs = world.getBlockState (pos);
    Block block = bs.getBlock ();

    if (block != this) {                                // Some other block type replaced me?
      return block.getLightValue (world, pos);
    }

    return getLightValue (this.getMetaFromState (bs));  // Here's where we do something extra
  }

  abstract int getLightValue(int meta);

  /**
   * Return whether this wall can connect to an adjacent block at pos.
   */
  public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos) {
    Block block = worldIn.getBlockState (pos).getBlock ();

    if (block == Blocks.barrier) return false;
    if (block instanceof classAbstractWall || block instanceof BlockWall || block instanceof BlockFenceGate) return true;
    if (block.isFullCube () && !block.isPassable (worldIn, pos)) {
      return block.getMaterial () != Material.gourd;
    } else {
      return false;
    }
  }

  /**
   *  All methods from here down are unaltered copies from class BlockWall. Do not mess!
  */
  @Override
  public boolean canPlaceTorchOnTop(IBlockAccess world, BlockPos pos) {
    return true;
  }

  @Override
  public boolean isFullCube() {
    return false;
  }

  @Override
  public boolean isOpaqueCube() {
    return false;
  }

  @Override
  public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state) {
    this.setBlockBoundsBasedOnState (worldIn, pos);
    this.maxY = 1.5D;
    return super.getCollisionBoundingBox (worldIn, pos, state);
  }

  @SideOnly(Side.CLIENT)
  public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side) {
    return side == EnumFacing.DOWN ? super.shouldSideBeRendered (worldIn, pos, side) : true;
  }

  @Override
  public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) {
    boolean flag = this.canConnectTo (worldIn, pos.north ());
    boolean flag1 = this.canConnectTo (worldIn, pos.south ());
    boolean flag2 = this.canConnectTo (worldIn, pos.west ());
    boolean flag3 = this.canConnectTo (worldIn, pos.east ());
    float f = 0.25F;
    float f1 = 0.75F;
    float f2 = 0.25F;
    float f3 = 0.75F;
    float f4 = 1.0F;

    if (flag) {
      f2 = 0.0F;
    }

    if (flag1) {
      f3 = 1.0F;
    }

    if (flag2) {
      f = 0.0F;
    }

    if (flag3) {
      f1 = 1.0F;
    }

    if (flag && flag1 && !flag2 && !flag3) {
      f4 = 0.8125F;
      f = 0.3125F;
      f1 = 0.6875F;
    } else if (!flag && !flag1 && flag2 && flag3) {
      f4 = 0.8125F;
      f2 = 0.3125F;
      f3 = 0.6875F;
    }

    this.setBlockBounds (f, 0.0F, f2, f1, f4, f3);
  }

}

 

And here's the blockstates.json that I ended up using with it:

 

{
  "forge_marker": 1,
  "variants": {
    "geometry": {
        "0":  { "model": "wall_post" },
        "4":  { "model": "wall_n" },
        "8":  { "model": "wall_n", "y": 90, "uvlock": true },
        "2":  { "model": "wall_n", "y": 180, "uvlock": true },
        "1":  { "model": "wall_n", "y": 270, "uvlock": true },
        "12": { "model": "wall_ne" },
        "10": { "model": "wall_ne", "y": 90, "uvlock": true },
        "3":  { "model": "wall_ne", "y": 180, "uvlock": true },
        "5":  { "model": "wall_ne", "y": 270, "uvlock": true },
        "6":  { "model": "wall_ns" },
        "9":  { "model": "wall_ns", "y": 90, "uvlock": true },
        "14": { "model": "wall_nse" },
        "11": { "model": "wall_nse", "y": 90, "uvlock": true },
        "7":  { "model": "wall_nse", "y": 180, "uvlock": true },
        "13": { "model": "wall_nse", "y": 270, "uvlock": true },
        "15": { "model": "wall_nsew" },
        "16": { "model": "wall_ns_above" },
        "17": { "model": "wall_ns_above", "y": 90, "uvlock": true }
    },
    "skin": {
        "0":  { "textures": { "wall": "blocks/stonebrick" }},
        "1":  { "textures": { "wall": "blocks/stonebrick_mossy" }},
        "2":  { "textures": { "wall": "blocks/stonebrick_cracked" }},
        "3":  { "textures": { "wall": "blocks/stonebrick_carved" }},
        "4":  { "textures": { "wall": "blocks/brick" }},
        "5":  { "textures": { "wall": "blocks/hardened_clay" }},
        "6":  { "textures": { "wall": "blocks/netherrack" }},
        "7":  { "textures": { "wall": "blocks/quartz_block_chiseled" }},
        "8":  { "textures": { "wall": "blocks/obsidian" }},
        "9":  { "textures": { "wall": "blocks/sandstone_normal" }},
        "10": { "textures": { "wall": "blocks/sandstone_carved" }},
        "11": { "textures": { "wall": "blocks/stone" }},
        "12": { "textures": { "wall": "blocks/stone_granite_smooth" }},
        "13": { "textures": { "wall": "blocks/stone_diorite_smooth" }},
        "14": { "textures": { "wall": "blocks/stone_andesite_smooth" }},
        "15": { "textures": { "wall": "blocks/end_stone" }}
    }
  }
}

 

Notes:

 

1) The abstract wall class can be extended to as many sets of walls (16 each) as I want. I've taken to setting some custom hardness, blast resistance and light-values in each.

 

2) Because I have two whole sets of custom walls, I have another json file like this one (but with different textures).

 

3) This only put blocks in the world, not "items" (ItemBlock versions) in inventory. For the item blocks, I was forced to write 32 nearly identical json files for the models/item directory. Fortunately, each was able to declare both a texture and a vanilla parent, so I was able to avoid doing the 32 models/block files that vanilla code-monkeys did for their blocks.

 

Here's an example of the models/item json for one ItemBlock:

 

anystone_wall2.sealantern.json

{
    "parent": "block/wall_inventory",
    "textures" : {
        "wall": "blocks/sea_lantern"
    },
    "display": {
        "firstperson": {
            "rotation": [ 0, -135, 25 ],
            "translation": [ 0, 4, 2 ],
            "scale": [ 1.2, 1.2, 1.2 ]
        },
        "thirdperson": {
            "rotation": [ 10, -45, 170 ],
            "translation": [ 0, 1.5, -2.75 ],
            "scale": [ 0.375, 0.375, 0.375 ]
        }
    }
}

 

The dot-subtype naming was my choice. I just had to make sure that I was consistent between file names and the result of my ItemBlock's getUnlocalizedName (ItemStack).

 

I sincerely hope that Mojang (Microsoft) can find a code-monkey with more than half a brain to come up with an elegant way to specify that a particular item can use one default model for all of its variants, also allowing me to list the skins (textures) for all 16 in one file.

 

Even better: As a default, MC could display an ItemBlock in inventory by rendering the block's default state at .375 scale. That one shortcut could eliminate hundreds of silly files and save modders hundreds of man-days of tedious effort.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.