net.minecraft.client.renderer.block.statemap.StateMapperBase Java Examples

The following examples show how to use net.minecraft.client.renderer.block.statemap.StateMapperBase. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RenderHandler.java    From EmergingTechnology with MIT License 6 votes vote down vote up
public static void registerMeshesAndStatesForBlock(Block block) {

        ModelResourceLocation resourceLocation = new ModelResourceLocation(
                block.getRegistryName(), "fluid");

        ItemMeshDefinition meshDefinition = new ItemMeshDefinition() {
            @Override
            public ModelResourceLocation getModelLocation(ItemStack stack) {
                return resourceLocation;
            }
        };

        StateMapperBase stateMapper = new StateMapperBase() {
            @Override
            public ModelResourceLocation getModelResourceLocation(IBlockState state) {
                return resourceLocation;
            }
        };

        ModelLoader.setCustomMeshDefinition(Item.getItemFromBlock(block), meshDefinition);
        ModelLoader.setCustomStateMapper(block, stateMapper);

    }
 
Example #2
Source File: Fluids.java    From BaseMetals with GNU Lesser General Public License v2.1 6 votes vote down vote up
@SideOnly(Side.CLIENT)
public static void bakeModels(String modID){
	for(Fluid fluid : fluidBlocks.keySet()){
		BlockFluidBase block = fluidBlocks.get(fluid);
		Item item = Item.getItemFromBlock(block);
		final ModelResourceLocation fluidModelLocation = new ModelResourceLocation(
				modID.toLowerCase() + ":" + fluidBlockNames.get(block), "fluid");
           ModelBakery.registerItemVariants(item);
		ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition()
		{
			public ModelResourceLocation getModelLocation(ItemStack stack)
			{
				return fluidModelLocation;
			}
		});
		ModelLoader.setCustomStateMapper(block, new StateMapperBase()
		{
			protected ModelResourceLocation getModelResourceLocation(IBlockState state)
			{
				return fluidModelLocation;
			}
		});
	}
}
 
Example #3
Source File: BlockFload.java    From YouTubeModdingTutorial with MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public void initModel() {
    ModelResourceLocation fluidLocation = new ModelResourceLocation(FLOAD, "fluid");

    StateMapperBase customState = new StateMapperBase() {
        @Override
        protected ModelResourceLocation getModelResourceLocation(IBlockState iBlockState) {
            return fluidLocation;
        }
    };
    ModelLoader.setCustomStateMapper(this, customState);
    ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(this), 0, new ModelResourceLocation(FLOAD, "inventory"));
}
 
Example #4
Source File: ClientProxy.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
private void setupBlockMeshes() 
{
	OBJLoader.INSTANCE.addDomain(Reference.ModID);

	ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(TFCBlocks.LooseRocks), 0, new ModelResourceLocation(Reference.ModID + ":loose_rock", "inventory"));

	Item anvilItem = Item.getItemFromBlock(TFCBlocks.Anvil);
	ModelLoader.setCustomModelResourceLocation(anvilItem, 0, new ModelResourceLocation(Reference.ModID + ":anvil"));
	//Change the StateMapper for this block so that it will point to a different file for a specific Property
	StateMapperBase ignoreState = new StateMapperBase() {
		@Override
		protected ModelResourceLocation getModelResourceLocation(IBlockState iBlockState) 
		{
			if(iBlockState.getValue(BlockLeaves2.META_PROPERTY) == WoodType.Palm)
				return new ModelResourceLocation("tfc2:leaves_palm");
			else return new ModelResourceLocation("tfc2:leaves2");

		}
	};
	ModelLoader.setCustomStateMapper(TFCBlocks.Leaves2, ignoreState);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.Dirt), "Dirt/", Global.STONE_ALL, 0, 16);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.Grass), "Grass/", Global.STONE_ALL, 0, 16);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.Stone), "Stone/", Global.STONE_ALL, 0, 16);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.Rubble), "Rubble/", Global.STONE_ALL, 0, 16);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.Sand), "Sand/", Global.STONE_ALL, 0, 16);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.Gravel), "Gravel/", Global.STONE_ALL, 0, 16);
	//registerVariantModel(Item.getItemFromBlock(TFCBlocks.LooseRocks), "LooseRocks/", Global.STONE_ALL, 0, 16);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.Planks), "Wood/Planks/", WoodType.getNamesArray(), 0, 16);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.Sapling), "Wood/Saplings/", WoodType.getNamesArray(), 0, 16);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.LogVertical), "Wood/Logs/", WoodType.getNamesArray(), 0, 16);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.Leaves), "Wood/Leaves/", WoodType.getNamesArray(), 0, 16);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.Planks2), "Wood/Planks/", WoodType.getNamesArray(), 16, 19);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.Sapling2), "Wood/Saplings/", WoodType.getNamesArray(), 16, 19);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.LogVertical2), "Wood/Logs/", WoodType.getNamesArray(), 16, 19);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.Leaves2), "Wood/Leaves/", WoodType.getNamesArray(), 16, 18);
	ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(TFCBlocks.Leaves2), 18, new ModelResourceLocation(Reference.ModID + ":leaves_palm", "inventory"));
	//registerVariantModel(Item.getItemFromBlock(TFCBlocks.Ore), "Ore/", OreType.getNamesArray(), 0, 13);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.StoneBrick), "StoneBrick/", Global.STONE_ALL, 0, 16);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.StoneSmooth), "StoneSmooth/", Global.STONE_ALL, 0, 16);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.SupportBeam), "Wood/SupportBeams/", WoodType.getNamesArray(), 0, 8);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.SupportBeam2), "Wood/SupportBeams/", WoodType.getNamesArray(), 8, 16);
	registerVariantModel(Item.getItemFromBlock(TFCBlocks.SupportBeam3), "Wood/SupportBeams/", WoodType.getNamesArray(), 16, 19);
	ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(TFCBlocks.TorchOn),0,new ModelResourceLocation(Reference.ModID + ":torch_on", "inventory"));
	ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(TFCBlocks.TorchOff),0,new ModelResourceLocation(Reference.ModID + ":torch_off", "inventory"));
	for(Block b : TFCBlocks.stairsList)
	{
		ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(b),0,new ModelResourceLocation(Reference.ModID + ":Wood/Stairs/"+Core.getUnlocalized(b.getUnlocalizedName()), "inventory"));
	}
	RegistryItemQueue.getInstance().registerMeshes();
	ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(TFCBlocks.Thatch), 0, new ModelResourceLocation(Reference.ModID + ":thatch", "inventory"));
}
 
Example #5
Source File: ClientProxy.java    From AdvancedRocketry with MIT License 3 votes vote down vote up
private void registerFluidModel(IFluidBlock fluidBlock) {
	Item item = Item.getItemFromBlock((Block) fluidBlock);

	ModelBakery.registerItemVariants(item);

	final ModelResourceLocation modelResourceLocation = new ModelResourceLocation("advancedrocketry:fluid", fluidBlock.getFluid().getName());
	
	//ModelLoader.setCustomMeshDefinition(item, MeshDefinitionFix.create(stack -> modelResourceLocation));

	
	StateMapperBase ignoreState = new FluidStateMapper(modelResourceLocation);
	ModelLoader.setCustomStateMapper((Block) fluidBlock, ignoreState);
	ModelLoader.setCustomMeshDefinition(item, new FluidItemMeshDefinition(modelResourceLocation));
	ModelBakery.registerItemVariants(item, modelResourceLocation);
}