Jump to content

[1.12.2] Basic metadata block, wrong inventory textures [SOLVED!]


Recommended Posts

Posted (edited)

I'm trying to get the swing of modding in 1.12, with my last modding experience back in 1.7.10. I've been following various tutorials, but I've run into an issue - probably because i'm mixing 1.8-1.11 ways of doing things with 1.12.2. I've been pounding my head against a wall FOR TWO DAYS (LOL), and I KNOW I'm missing something stupid and basic...but I can't seem to find it.

 

I've got a metadata block, representing all the soil types I want to use. They work in the world perfectly. They *ALMOST* work in the inventory perfectly, except that they take on whatever texture i've got set in the "defaults" section of the blockstate .json file. I've reread every tutorial I can find, and still can't figure out what the heck i'm doing wrong here. My previous method had each soil type in its own separate block, and though cumbersome, it worked. I just can't figure out how to get property textures to apply in the inventory. :(

 

There are no errors in the client log file, and NO FML-CLIENT log files (?!!?). I've read through most of the other posts regarding this issue, but they don't offer anything new, that I can see.

 

the metadata BlockSoil block

Spoiler

package mrwisski.agetech.blocks.layerstone;

import com.google.common.collect.ImmutableList;

import mrwisski.agetech.ATCore;
import mrwisski.agetech.ModCreativeTabs;
import mrwisski.agetech.enums.SoilType;
import mrwisski.agetech.items.ItemBlockSoil;
import mrwisski.agetech.util.Log;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyBool;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.block.statemap.DefaultStateMapper;
import net.minecraft.client.renderer.block.statemap.StateMapperBase;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlockSoil extends Block {
    public String uName = "blocksoil";
    public Material mat = Material.GROUND;

   
    public static final PropertyEnum<SoilType> TYPE = PropertyEnum.<SoilType>create("type", SoilType.class);
    public static final PropertyBool TILEENT = PropertyBool.create("tileent");
    
    
    public BlockSoil() {
        super(Material.GROUND);
        setUnlocalizedName(ATCore.MODID + "." + uName);
         setRegistryName(uName);
        this.setCreativeTab(ModCreativeTabs.worldStones);
        //setDefaultState(blockState.getBaseState().withProperty(TYPE, SoilType.LOAM));
        
    }
    
    
    public BlockSoil(SoilType T, boolean hasTileEnt){
        
        super(T.getMaterial());
        this.mat = T.getMaterial();
        this.uName = T.getName();
        this.setHarvestLevel("shovel", 0);
        setUnlocalizedName(ATCore.MODID + "." + uName);
        setRegistryName(uName);
        this.setCreativeTab(ModCreativeTabs.worldStones);
        setDefaultState(blockState.getBaseState().withProperty(TYPE, T).withProperty(TILEENT, hasTileEnt));
    }
    
    @Override
    public ItemStack getPickBlock(IBlockState p_getPickBlock_1_, RayTraceResult p_getPickBlock_2_,
            World world, BlockPos pos, EntityPlayer p_getPickBlock_5_) {
        // TODO Auto-generated method stub
        
        return new ItemStack(Item.getItemFromBlock(this), 1, this.getMetaFromState(world.getBlockState(pos)));
        
    }
    

        
    @Override
    public boolean hasTileEntity(IBlockState state) {
        return state.getValue(TILEENT).booleanValue();
    }
    
     // used by the renderer to control lighting and visibility of other blocks.
      // set to false because this block doesn't fill the entire 1x1x1 space
      @Override
      public boolean isOpaqueCube(IBlockState iBlockState) {
        return true;
      }

      // used by the renderer to control lighting and visibility of other blocks, also by
      // (eg) wall or fence to control whether the fence joins itself to this block
      // set to false because this block doesn't fill the entire 1x1x1 space
      @Override
      public boolean isFullCube(IBlockState iBlockState) {
        return true;
    }
      
      @Override
    public boolean isBlockNormalCube(IBlockState p_isBlockNormalCube_1_) {
        // TODO Auto-generated method stub
        return true;
    }
    
    @SideOnly(Side.CLIENT)
    public void initModel() {
        StateMapperBase b = new DefaultStateMapper();
        BlockStateContainer bsc = this.getBlockState();
        ImmutableList<IBlockState> values = bsc.getValidStates();
        ResourceLocation mrla[] = new ResourceLocation[values.size()];
        for(IBlockState state : values) {
            String str = b.getPropertyString(state.getProperties());
            //registerBlockItemModelForMeta(this, this.getMetaFromState(state), str);
            ModelResourceLocation mrl = new ModelResourceLocation(state.getBlock().getRegistryName(), "inventory");
            Log.info("Registering variant : " + str + " -- Meta : " + this.getMetaFromState(state) + " @ " + mrl.toString());
            Item.getItemFromBlock(state.getBlock()).getMetadata(0);
            
            ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(state.getBlock()), this.getMetaFromState(state), mrl);
            //ModelLoader.setCustomModelResourceLocation(new ItemBlockSoil(state.getBlock()), this.getMetaFromState(state), m);
        }
        //ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, new ModelResourceLocation(getRegistryName(), "inventory"));
    }
    
    @Override
    protected BlockStateContainer createBlockState() {
        return new BlockStateContainer(this, TYPE, TILEENT);
    }
    
    @Override
    public IBlockState getStateFromMeta(int meta) {
        //Log.info("SetStateFromMeta("+meta+")");
        //Log.info("meta & 7 = " + (meta & 7));
        return getDefaultState()
                .withProperty(TYPE, SoilType.fromMeta(meta & 7))
                .withProperty(TILEENT, (meta & 8) != 0);
    }

    @Override
    public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
        // TODO Auto-generated method stub
        for(SoilType t : TYPE.getAllowedValues()){
            list.add(new ItemStack(this, 1, t.getMeta()));
        }
    }
    
    @Override
    public int damageDropped(IBlockState state) {
        return (getMetaFromState(state) & 7);
    }
    
    @Override
    public int getMetaFromState(IBlockState state) {
        return state.getValue(TYPE).getMeta() + (state.getValue(TILEENT) ? 8 : 0);
    }
}

 

The ItemBlockSoil class

Spoiler

package mrwisski.agetech.items;

import mrwisski.agetech.blocks.layerstone.BlockSoil;
import mrwisski.agetech.util.Log;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;

public class ItemBlockSoil extends ItemBlock
{
  // you must use Block in the constructor, not BlockVariants, otherwise you won't be able to register the block properly.
  //   i.e. using GameRegistry.registerBlock(block, ItemBlockVariants.class, name)
  public ItemBlockSoil(BlockSoil block)
  {
    super(block);
    this.setMaxDamage(0);
    this.setHasSubtypes(true);
    Log.info("Setting registry name : " + block.getRegistryName());
    this.setRegistryName(block.getRegistryName());
  }

  @Override
  public int getMetadata(int metadata)
  {
    return metadata;
  }

  // create a unique unlocalised name for each colour, so that we can give each one a unique name
  @Override
  public String getUnlocalizedName(ItemStack stack)
  {
      //Log.info("Returning unlocalized name : " + super.getUnlocalizedName() + "." + SoilType.fromMeta(stack.getMetadata()).getName());
      return super.getUnlocalizedName() + "." + BlockSoil.SoilType.fromMeta(stack.getMetadata()).getName();
    //BlockVariants.EnumColour colour = BlockVariants.EnumColour.byMetadata(stack.getMetadata());
    //return super.getUnlocalizedName() + "." + colour.toString();
  }
}

registration class

Spoiler

package mrwisski.agetech;

import mrwisski.agetech.blocks.layerstone.BlockSoil;
import mrwisski.agetech.blocks.layerstone.igneous.extrusive.Andesite;
import mrwisski.agetech.blocks.layerstone.igneous.extrusive.Basalt;
import mrwisski.agetech.blocks.layerstone.igneous.extrusive.Dacite;
import mrwisski.agetech.blocks.layerstone.igneous.extrusive.Obsidian;
import mrwisski.agetech.blocks.layerstone.igneous.extrusive.Rhyolite;
import mrwisski.agetech.blocks.layerstone.igneous.intrusive.Diorite;
import mrwisski.agetech.blocks.layerstone.igneous.intrusive.Gabbro;
import mrwisski.agetech.blocks.layerstone.igneous.intrusive.Granite;
import mrwisski.agetech.blocks.layerstone.metamorphic.Gneiss;
import mrwisski.agetech.blocks.layerstone.metamorphic.Marble;
import mrwisski.agetech.blocks.layerstone.metamorphic.Quartzite;
import mrwisski.agetech.blocks.layerstone.metamorphic.Schist;
import mrwisski.agetech.blocks.layerstone.metamorphic.Slate;
import mrwisski.agetech.blocks.layerstone.sedimentary.Chalk;
import mrwisski.agetech.blocks.layerstone.sedimentary.Chert;
import mrwisski.agetech.blocks.layerstone.sedimentary.ConglomerateDIS;
import mrwisski.agetech.blocks.layerstone.sedimentary.Dolomite;
import mrwisski.agetech.blocks.layerstone.sedimentary.Limestone;
import mrwisski.agetech.blocks.layerstone.sedimentary.RockSalt;
import mrwisski.agetech.blocks.layerstone.sedimentary.Sandstone;
import mrwisski.agetech.blocks.layerstone.sedimentary.Shale;
import mrwisski.agetech.items.ItemBlockSoil;
/*
import mrwisski.agetech.blocks.layerstone.soil.Clay;
import mrwisski.agetech.blocks.layerstone.soil.Loam;
import mrwisski.agetech.blocks.layerstone.soil.Peat;
import mrwisski.agetech.blocks.layerstone.soil.Sand;
import mrwisski.agetech.blocks.layerstone.soil.Silt;
*/
import mrwisski.agetech.util.Log;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class ModLayerStones {
    //Sedimentary layer
    @GameRegistry.ObjectHolder("agetech:chalk") public static Chalk chalk;
    @GameRegistry.ObjectHolder("agetech:chert") public static Chert chert;
    @GameRegistry.ObjectHolder("agetech:conglomerate") public static ConglomerateDIS conglomerate;
    @GameRegistry.ObjectHolder("agetech:dolomite") public static Dolomite dolomite;
    @GameRegistry.ObjectHolder("agetech:limestone") public static Limestone limestone;
    @GameRegistry.ObjectHolder("agetech:rocksalt") public static RockSalt rocksalt;
    @GameRegistry.ObjectHolder("agetech:sandstone") public static Sandstone sandstone;
    @GameRegistry.ObjectHolder("agetech:shale") public static Shale shale;

    //Soil layer
    @GameRegistry.ObjectHolder("agetech:blocksoil") public static BlockSoil blocksoil;
    /*
    @GameRegistry.ObjectHolder("agetech:clay") public static BlockSoil clay;
    @GameRegistry.ObjectHolder("agetech:grass") public static BlockSoil grass;
    @GameRegistry.ObjectHolder("agetech:farmland") public static BlockSoil farmland;
    @GameRegistry.ObjectHolder("agetech:peat") public static BlockSoil peat;
    @GameRegistry.ObjectHolder("agetech:loam") public static BlockSoil loam;
    @GameRegistry.ObjectHolder("agetech:sand") public static BlockSoil sand;
    @GameRegistry.ObjectHolder("agetech:silt") public static BlockSoil silt;    
    */
    //Metamorphic layer
    @GameRegistry.ObjectHolder("agetech:gneiss") public static Gneiss gneiss;
    @GameRegistry.ObjectHolder("agetech:marble") public static Marble marble;
    @GameRegistry.ObjectHolder("agetech:quartzite") public static Quartzite quartzite;
    @GameRegistry.ObjectHolder("agetech:schist") public static Schist schist;
    @GameRegistry.ObjectHolder("agetech:slate") public static Slate slate;
    
    //Igneous layer
    @GameRegistry.ObjectHolder("agetech:diorite") public static Diorite diorite;
    @GameRegistry.ObjectHolder("agetech:gabbro") public static Gabbro gabbro;
    @GameRegistry.ObjectHolder("agetech:granite") public static Granite granite;
    
    @GameRegistry.ObjectHolder("agetech:andesite") public static Andesite andesite;
    @GameRegistry.ObjectHolder("agetech:basalt") public static Basalt basalt;
    @GameRegistry.ObjectHolder("agetech:dacite") public static Dacite dacite;
    @GameRegistry.ObjectHolder("agetech:obsidian") public static Obsidian obsidian;
    @GameRegistry.ObjectHolder("agetech:rhyolite") public static Rhyolite rhyolite;
    
    public static void registerBlocks(RegistryEvent.Register<Block> event) {
        Log.info("Registering Layer Stone blocks...");
        event.getRegistry().register(new Chalk());
        event.getRegistry().register(new Chert());
        event.getRegistry().register(new ConglomerateDIS());
        event.getRegistry().register(new Dolomite());
        event.getRegistry().register(new Limestone());
        event.getRegistry().register(new RockSalt());
        event.getRegistry().register(new Sandstone());
        event.getRegistry().register(new Shale());
        
        event.getRegistry().register(new BlockSoil());
//        for(SoilType t : SoilType.values()){
//            event.getRegistry().register(new BlockSoil(t,false));
//        }
        
        /*
        event.getRegistry().register(new Loam());
        event.getRegistry().register(new Clay());
        event.getRegistry().register(new Peat());
        event.getRegistry().register(new Sand());
        event.getRegistry().register(new Silt());
        */
        event.getRegistry().register(new Gneiss());
        event.getRegistry().register(new Marble());
        event.getRegistry().register(new Quartzite());
        event.getRegistry().register(new Schist());
        event.getRegistry().register(new Slate());
        
        event.getRegistry().register(new Andesite());
        event.getRegistry().register(new Basalt());
        event.getRegistry().register(new Dacite());
        event.getRegistry().register(new Obsidian());
        event.getRegistry().register(new Rhyolite());
        
        event.getRegistry().register(new Diorite());
        event.getRegistry().register(new Gabbro());
        event.getRegistry().register(new Granite());
        
        //event.getRegistry().register(new ());
        
        
    }
    
    public static void registerBlockItems(RegistryEvent.Register<Item> event) {
        event.getRegistry().register(new ItemBlock(chalk).setRegistryName(chalk.getRegistryName()));
        event.getRegistry().register(new ItemBlock(chert).setRegistryName(chert.getRegistryName()));
        event.getRegistry().register(new ItemBlock(conglomerate).setRegistryName(conglomerate.getRegistryName()));
        event.getRegistry().register(new ItemBlock(dolomite).setRegistryName(dolomite.getRegistryName()));
        event.getRegistry().register(new ItemBlock(limestone).setRegistryName(limestone.getRegistryName()));
        event.getRegistry().register(new ItemBlock(rocksalt).setRegistryName(rocksalt.getRegistryName()));
        event.getRegistry().register(new ItemBlock(sandstone).setRegistryName(sandstone.getRegistryName()));
        event.getRegistry().register(new ItemBlock(shale).setRegistryName(shale.getRegistryName()));
        
        event.getRegistry().register(new ItemBlockSoil(blocksoil));
        
        
        
        /*
        event.getRegistry().register(new ItemBlock(loam).setRegistryName(loam.getRegistryName()));
        event.getRegistry().register(new ItemBlock(grass).setRegistryName(grass.getRegistryName()));
        event.getRegistry().register(new ItemBlock(farmland).setRegistryName(farmland.getRegistryName()));
        event.getRegistry().register(new ItemBlock(clay).setRegistryName(clay.getRegistryName()));
        event.getRegistry().register(new ItemBlock(peat).setRegistryName(peat.getRegistryName()));
        event.getRegistry().register(new ItemBlock(sand).setRegistryName(sand.getRegistryName()));
        event.getRegistry().register(new ItemBlock(silt).setRegistryName(silt.getRegistryName()));
        */
        
        event.getRegistry().register(new ItemBlock(gneiss).setRegistryName(gneiss.getRegistryName()));
        event.getRegistry().register(new ItemBlock(marble).setRegistryName(marble.getRegistryName()));
        event.getRegistry().register(new ItemBlock(quartzite).setRegistryName(quartzite.getRegistryName()));
        event.getRegistry().register(new ItemBlock(schist).setRegistryName(schist.getRegistryName()));
        event.getRegistry().register(new ItemBlock(slate).setRegistryName(slate.getRegistryName()));
        
        event.getRegistry().register(new ItemBlock(andesite).setRegistryName(andesite.getRegistryName()));
        event.getRegistry().register(new ItemBlock(basalt).setRegistryName(basalt.getRegistryName()));
        event.getRegistry().register(new ItemBlock(dacite).setRegistryName(dacite.getRegistryName()));
        event.getRegistry().register(new ItemBlock(obsidian).setRegistryName(obsidian.getRegistryName()));
        event.getRegistry().register(new ItemBlock(rhyolite).setRegistryName(rhyolite.getRegistryName()));
        
        event.getRegistry().register(new ItemBlock(diorite).setRegistryName(diorite.getRegistryName()));
        event.getRegistry().register(new ItemBlock(gabbro).setRegistryName(gabbro.getRegistryName()));
        event.getRegistry().register(new ItemBlock(granite).setRegistryName(granite.getRegistryName()));
        
        //event.getRegistry().register(new ItemBlock().setRegistryName(.getRegistryName()));
        
    }
    
    @SideOnly(Side.CLIENT)
    public static void initModels() {
        Log.info("Initializing layer stone models...");
        chalk.initModel();
        chert.initModel();
        conglomerate.initModel();
        dolomite.initModel();
        limestone.initModel();
        rocksalt.initModel();
        sandstone.initModel();
        shale.initModel();
        
        blocksoil.initModel();
        //ModelLoader.setCustomModelResourceLocation(itemblocksoil, 0, new ModelResourceLocation(blocksoil.getRegistryName(), "inventory"));
        /*
        clay.initModel();
        grass.initModel();
        farmland.initModel();
        loam.initModel();
        peat.initModel();
        sand.initModel();
        silt.initModel();
        */
        gneiss.initModel();
        marble.initModel();
        quartzite.initModel();
        schist.initModel();
        slate.initModel();
        
        andesite.initModel();
        basalt.initModel();
        dacite.initModel();
        obsidian.initModel();
        rhyolite.initModel();
        
        diorite.initModel();
        gabbro.initModel();
        granite.initModel();
    }    
}

Registration event calls

Spoiler

COMMONPROXY :


    @SubscribeEvent
    public static void registerBlocks(RegistryEvent.Register<Block> event) {
        Log.trace();
        ModLayerStones.registerBlocks(event);
        
        event.getRegistry().register(new StateTexturedBlock());
        event.getRegistry().register(new BlinkingBlock());
        //event.getRegistry().register(new FirstBlock());
        event.getRegistry().register(new SimpleTexturedBlock());
        event.getRegistry().register(new MultiTexturedBlock());
        event.getRegistry().register(new BakedModelBlock());
        event.getRegistry().register(new TestContainerBlock());
        event.getRegistry().register(new DataBlock());
        event.getRegistry().register(new ModelBlock());
        event.getRegistry().register(new PedestalBlock());

        GameRegistry.registerTileEntity(BlinkingTileEntity.class, ATCore.MODID + "_blinkingblock");
        GameRegistry.registerTileEntity(TestContainerTileEntity.class, ATCore.MODID + "_testcontainerblock");
        GameRegistry.registerTileEntity(DataTileEntity.class, ATCore.MODID + "_datablock");
        GameRegistry.registerTileEntity(PedestalTileEntity.class, ATCore.MODID + "_pedestalblock");
    }

    @SubscribeEvent
    public static void registerItems(RegistryEvent.Register<Item> event) {
        ModLayerStones.registerBlockItems(event);
        
        //event.getRegistry().register(new FirstItem());
        event.getRegistry().register(new SimpleTexturedItem());
        event.getRegistry().register(new MultiModelItem());

        event.getRegistry().register(new ItemBlock(ModBlocks.stateTexturedBlock).setRegistryName(ModBlocks.stateTexturedBlock.getRegistryName()));
        event.getRegistry().register(new ItemBlock(ModBlocks.blinkingBlock).setRegistryName(ModBlocks.blinkingBlock.getRegistryName()));
        //event.getRegistry().register(new ItemBlock(ModBlocks.firstBlock).setRegistryName(ModBlocks.firstBlock.getRegistryName()));
        event.getRegistry().register(new ItemBlock(ModBlocks.simpleTexturedBlock).setRegistryName(ModBlocks.simpleTexturedBlock.getRegistryName()));
        event.getRegistry().register(new ItemBlock(ModBlocks.multiTexturedBlock).setRegistryName(ModBlocks.multiTexturedBlock.getRegistryName()));
        event.getRegistry().register(new ItemBlock(ModBlocks.bakedModelBlock).setRegistryName(ModBlocks.bakedModelBlock.getRegistryName()));
        event.getRegistry().register(new ItemBlock(ModBlocks.testContainerBlock).setRegistryName(ModBlocks.testContainerBlock.getRegistryName()));
        event.getRegistry().register(new ItemBlock(ModBlocks.dataBlock).setRegistryName(ModBlocks.dataBlock.getRegistryName()));
        event.getRegistry().register(new ItemBlock(ModBlocks.modelBlock).setRegistryName(ModBlocks.modelBlock.getRegistryName()));
        event.getRegistry().register(new ItemBlock(ModBlocks.pedestalBlock).setRegistryName(ModBlocks.pedestalBlock.getRegistryName()));
    }

}

 

CLIENTPROXY:

 

   @SubscribeEvent
    public static void registerModels(ModelRegistryEvent event) {
        Log.trace();
        ModBlocks.initModels();
        ModItems.initModels();
        ModLayerStones.initModels();
    }

blockstates/blocksoil.json

Spoiler

{
  "forge_marker": 1,
  "defaults": {
        "textures": {
            "all": "agetech:blocks/clay",
            "particle": "agetech:blocks/loam"
        },
        "model": "cube_all"
    },
    "variants": {
        "inventory": [{
             "transform": "forge:default-block"
        }],
        "tileent" : {
            "true" : {},
            "false" : {}
        },
        "type" : {
            "loam": {"textures": {"all": "agetech:blocks/loam"}},
            "grass": {"textures": {"all": "agetech:blocks/grass"}},
            "farmland": {"textures": {"all": "agetech:blocks/farmland"}},
            "clay": {"textures": {"all": "agetech:blocks/clay"}},
            "peat": {"textures": {"all": "agetech:blocks/peat"}},
            "sand": {"textures": {"all": "agetech:blocks/sand"}},
            "silt": {"textures": {"all": "agetech:blocks/silt"}}
        }
    }
}

 

Edited by MrWisski
Issue solved, updating thread title! :D
Posted

        ModBlocks.initModels();
        ModItems.initModels();
        ModLayerStones.initModels();

oh good, we have no idea how you're registering your models. The exact code you're having a problem with.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Oh, and then it redirects back into the block class. :V

You're making things unnecessarily complicated and duplicate code.

 

All of this:

    public void initModel() {
        StateMapperBase b = new DefaultStateMapper();
        BlockStateContainer bsc = this.getBlockState();
        ImmutableList<IBlockState> values = bsc.getValidStates();
        ResourceLocation mrla[] = new ResourceLocation[values.size()];
        for(IBlockState state : values) {
            String str = b.getPropertyString(state.getProperties());
            ModelResourceLocation mrl = new ModelResourceLocation(state.getBlock().getRegistryName(), "inventory");
            Log.info("Registering variant : " + str + " -- Meta : " + this.getMetaFromState(state) + " @ " + mrl.toString());
            Item.getItemFromBlock(state.getBlock()).getMetadata(0);
            
            ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(state.getBlock()), this.getMetaFromState(state), mrl);
        }
    }

Can easily be inside a library class and you pass in the relevant block/item instead of using "this."

Like this.

 

Now then...
This is unused:

ResourceLocation mrla[] = new ResourceLocation[values.size()];

This does nothing:

Item.getItemFromBlock(state.getBlock()).getMetadata(0);

 

Beyond that...it looks exactly like my own code, so I can't see the error.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
1 minute ago, Draco18s said:

Beyond that...it looks exactly like my own code, so I can't see the error.

:( I've read a lot of your posts here, so this might BE some of your code ROFL. As for the sloppy, yeah, I've changed a lot of things around, trying to get things to work. Once things ACTUALLY work, I can distill it down, get rid of the rest of the troubleshooting garbage/stuff from other tutorials that don't work/etc.

 

Is there any way to assign textures inside the "inventory" variant of the blockstate json? I've tried various permutations, but none of them did anything useful. It seems like, somehow, inventory blocks are picking up everything except the property that assigns the texture.

Posted
11 minutes ago, MrWisski said:

Is there any way to assign textures inside the "inventory" variant of the blockstate json? I've tried various permutations, but none of them did anything useful. It seems like, somehow, inventory blocks are picking up everything except the property that assigns the texture.

You're not using the inventory variant, you're using the other variants:

String str = b.getPropertyString(state.getProperties());

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
2 minutes ago, Draco18s said:

You're not using the inventory variant, you're using the other variants:

That's just some debugging code for the info Log underneath it. The inventory (should) be applied with :

			ModelResourceLocation mrl = new ModelResourceLocation(state.getBlock().getRegistryName(), "inventory");     
            ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(state.getBlock()), this.getMetaFromState(state), mrl);

 

Posted (edited)

Hello MrWisski, long time no see o/
 

Are you sure that BlockSoil:: initModel is actually called? Your ClientProxy#registerModels calls ModBlocks::initModels but does that reach BlockSoil::initModel?
Are you sure that BlockStateContainer::getValidStates return the appropriate states, or does it only return a list containing the default state?

 

If worse comes to worst, you can likely create your own ICustomModelLoader and create the baked models specifically for these ItemBlocks, but that's like lighting a candle with a flamethrower mounted on a tank.

Edited by Matryoshika
  • Like 1

Also previously known as eAndPi.

"Pi, is there a station coming up where we can board your train of thought?" -Kronnn

Published Mods: Underworld

Handy links: Vic_'s Forge events Own WIP Tutorials.

Posted
3 hours ago, MrWisski said:

That's just some debugging code for the info Log underneath it. The inventory (should) be applied with :


			ModelResourceLocation mrl = new ModelResourceLocation(state.getBlock().getRegistryName(), "inventory");     
            ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(state.getBlock()), this.getMetaFromState(state), mrl);

 

You don't use "inventory" for metadata blocks. Well, you can, but you need to then supply a JSON item model file to specify which texture to use (this is how vanilla does it). It's way easier to reuse the blockstate json for item models when possible (all hail Forge).

 

This is why there's all that StateMapper#getPropertyString() stuff: we need to know what the state mapper says the variant string is so we can tell the Model Loader what variant model to go locate data for from the blockstate json.

  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
1 minute ago, Matryoshika said:

Hello MrWisski, long time no see o/

EYYYYYY whats up there pi? xD

 

1 minute ago, Matryoshika said:

Are you sure that BlockSoil:: initModel is actually called? Your ClientProxy#registerModels calls ModBlocks::initModels but does that reach BlockSoil::initModel?

ModLayerStones.initModels(); is where it's called.

 

5 minutes ago, Matryoshika said:

Are you sure that BlockStateContainer::getValidStates return the appropriate states, or does it only return a list containing the default state?

Debugging output :

[23:44:15] [main/INFO]: {CLIENT] [ModLayerStones.initModels] Initializing layer stone models...
[23:44:15] [main/INFO]: {CLIENT] [BlockSoil.initModel] Registering variant : type=loam -- Meta : 0 @ agetech:blocksoil#inventory
[23:44:15] [main/INFO]: {CLIENT] [BlockSoil.initModel] Registering variant : type=grass -- Meta : 1 @ agetech:blocksoil#inventory
[23:44:15] [main/INFO]: {CLIENT] [BlockSoil.initModel] Registering variant : type=farmland -- Meta : 2 @ agetech:blocksoil#inventory
[23:44:15] [main/INFO]: {CLIENT] [BlockSoil.initModel] Registering variant : type=clay -- Meta : 3 @ agetech:blocksoil#inventory
[23:44:15] [main/INFO]: {CLIENT] [BlockSoil.initModel] Registering variant : type=peat -- Meta : 4 @ agetech:blocksoil#inventory

 

I even dropped the "tileent" property...no change. :(
[23:44:15] [main/INFO]: {CLIENT] [BlockSoil.initModel] Registering variant : type=sand -- Meta : 5 @ agetech:blocksoil#inventory
[23:44:15] [main/INFO]: {CLIENT] [BlockSoil.initModel] Registering variant : type=silt -- Meta : 6 @ agetech:blocksoil#inventory

Posted

AH HA, that debug output solves it:

            String str = b.getPropertyString(state.getProperties());
            ModelResourceLocation mrl = new ModelResourceLocation(state.getBlock().getRegistryName(), str); // HERE
            Log.info("Registering variant : " + str + " -- Meta : " + this.getMetaFromState(state) + " @ " + mrl.toString());
            ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(state.getBlock()), this.getMetaFromState(state), mrl);

 

  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted (edited)

for anyone curious later, what the proper output looks like :

Spoiler

[00:23:31] [main/INFO]: {CLIENT] [BlockSoil.initModel] Registering variant : type=loam -- Meta : 0 @ agetech:blocksoil#type=loam
[00:23:31] [main/INFO]: {CLIENT] [BlockSoil.initModel] Registering variant : type=grass -- Meta : 1 @ agetech:blocksoil#type=grass
[00:23:31] [main/INFO]: {CLIENT] [BlockSoil.initModel] Registering variant : type=farmland -- Meta : 2 @ agetech:blocksoil#type=farmland
[00:23:31] [main/INFO]: {CLIENT] [BlockSoil.initModel] Registering variant : type=clay -- Meta : 3 @ agetech:blocksoil#type=clay
[00:23:31] [main/INFO]: {CLIENT] [BlockSoil.initModel] Registering variant : type=peat -- Meta : 4 @ agetech:blocksoil#type=peat
[00:23:31] [main/INFO]: {CLIENT] [BlockSoil.initModel] Registering variant : type=sand -- Meta : 5 @ agetech:blocksoil#type=sand
[00:23:31] [main/INFO]: {CLIENT] [BlockSoil.initModel] Registering variant : type=silt -- Meta : 6 @ agetech:blocksoil#type=silt

 

 

for(int i = 0; i < Int.MaxValue(); i++){ Emoticon.Facepalm.Show();} NOW I see what you meant before...I kind of misread, sorry LOL

 

That fixed it. Blocks now show perfect in the inventory. THANK YOU SIR. My sanity level can return to normal now. Knew it was something stupid like that. :(

Edited by MrWisski
Posted
10 hours ago, MrWisski said:

My sanity level can return to normal now. Knew it was something stupid like that. :(

No worries! We all have days like that.

Heck, there have been times when writing up a post to as a question or figure out a bug, I'll arrive at the solution.

It's called rubber duck debugging.

  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.