Search in sources :

Example 6 with StateMapperBase

use of net.minecraft.client.renderer.block.statemap.StateMapperBase in project NetherEx by LogicTechCorp.

the class NetherExModels method registerModel.

private static void registerModel(IFluidBlock block) {
    Item item = Item.getItemFromBlock((Block) block);
    ModelBakery.registerItemVariants(item);
    ModelResourceLocation modelLocation = new ModelResourceLocation(NetherEx.MOD_ID + ":fluid", block.getFluid().getName());
    ModelLoader.setCustomMeshDefinition(item, MeshDefinitionFix.create(stack -> modelLocation));
    ModelLoader.setCustomStateMapper((Block) block, new StateMapperBase() {

        @Override
        protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
            return modelLocation;
        }
    });
}
Also used : nex.block(nex.block) NetherExItems(nex.init.NetherExItems) Item(net.minecraft.item.Item) ModelRegistryEvent(net.minecraftforge.client.event.ModelRegistryEvent) ModelBakery(net.minecraft.client.renderer.block.model.ModelBakery) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) Block(net.minecraft.block.Block) Side(net.minecraftforge.fml.relauncher.Side) Mod(net.minecraftforge.fml.common.Mod) ModelLoader(net.minecraftforge.client.model.ModelLoader) NetherExBlocks(nex.init.NetherExBlocks) BlockWall(net.minecraft.block.BlockWall) ItemMeshDefinition(net.minecraft.client.renderer.ItemMeshDefinition) EnumFacing(net.minecraft.util.EnumFacing) BlockSlab(net.minecraft.block.BlockSlab) NetherEx(nex.NetherEx) BlockFenceGate(net.minecraft.block.BlockFenceGate) IBlockState(net.minecraft.block.state.IBlockState) StateMapperBase(net.minecraft.client.renderer.block.statemap.StateMapperBase) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Logger(org.apache.logging.log4j.Logger) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) ItemSalamanderHide(nex.item.ItemSalamanderHide) StateMap(net.minecraft.client.renderer.block.statemap.StateMap) LogManager(org.apache.logging.log4j.LogManager) StateMapperBase(net.minecraft.client.renderer.block.statemap.StateMapperBase) Item(net.minecraft.item.Item) IBlockState(net.minecraft.block.state.IBlockState) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Example 7 with StateMapperBase

use of net.minecraft.client.renderer.block.statemap.StateMapperBase in project SecurityCraft by Geforce132.

the class ClientProxy method registerTextureFiles.

/**
	 * Register the texture files used by blocks with metadata/variants with the ModelBakery.
	 */
@Override
@SideOnly(Side.CLIENT)
public void registerTextureFiles() {
    Item reinforcedWoodPlanks = GameRegistry.findItem(mod_SecurityCraft.MODID, "reinforcedPlanks");
    ModelBakery.registerItemVariants(reinforcedWoodPlanks, new ResourceLocation("securitycraft:reinforcedPlanks_Oak"), new ResourceLocation("securitycraft:reinforcedPlanks_Spruce"), new ResourceLocation("securitycraft:reinforcedPlanks_Birch"), new ResourceLocation("securitycraft:reinforcedPlanks_Jungle"), new ResourceLocation("securitycraft:reinforcedPlanks_Acacia"), new ResourceLocation("securitycraft:reinforcedPlanks_DarkOak"));
    Item reinforcedStainedGlass = GameRegistry.findItem(mod_SecurityCraft.MODID, "reinforcedStainedGlass");
    ModelBakery.registerItemVariants(reinforcedStainedGlass, new ResourceLocation("securitycraft:reinforcedStainedGlass_white"), new ResourceLocation("securitycraft:reinforcedStainedGlass_orange"), new ResourceLocation("securitycraft:reinforcedStainedGlass_magenta"), new ResourceLocation("securitycraft:reinforcedStainedGlass_light_blue"), new ResourceLocation("securitycraft:reinforcedStainedGlass_yellow"), new ResourceLocation("securitycraft:reinforcedStainedGlass_lime"), new ResourceLocation("securitycraft:reinforcedStainedGlass_pink"), new ResourceLocation("securitycraft:reinforcedStainedGlass_gray"), new ResourceLocation("securitycraft:reinforcedStainedGlass_silver"), new ResourceLocation("securitycraft:reinforcedStainedGlass_cyan"), new ResourceLocation("securitycraft:reinforcedStainedGlass_purple"), new ResourceLocation("securitycraft:reinforcedStainedGlass_blue"), new ResourceLocation("securitycraft:reinforcedStainedGlass_brown"), new ResourceLocation("securitycraft:reinforcedStainedGlass_green"), new ResourceLocation("securitycraft:reinforcedStainedGlass_red"), new ResourceLocation("securitycraft:reinforcedStainedGlass_black"));
    Item reinforcedStainedGlassPanes = GameRegistry.findItem(mod_SecurityCraft.MODID, "reinforcedStainedGlassPanes");
    ModelBakery.registerItemVariants(reinforcedStainedGlassPanes, new ResourceLocation("securitycraft:reinforcedStainedGlassPanes_white"), new ResourceLocation("securitycraft:reinforcedStainedGlassPanes_orange"), new ResourceLocation("securitycraft:reinforcedStainedGlassPanes_magenta"), new ResourceLocation("securitycraft:reinforcedStainedGlassPanes_light_blue"), new ResourceLocation("securitycraft:reinforcedStainedGlassPanes_yellow"), new ResourceLocation("securitycraft:reinforcedStainedGlassPanes_lime"), new ResourceLocation("securitycraft:reinforcedStainedGlassPanes_pink"), new ResourceLocation("securitycraft:reinforcedStainedGlassPanes_gray"), new ResourceLocation("securitycraft:reinforcedStainedGlassPanes_silver"), new ResourceLocation("securitycraft:reinforcedStainedGlassPanes_cyan"), new ResourceLocation("securitycraft:reinforcedStainedGlassPanes_purple"), new ResourceLocation("securitycraft:reinforcedStainedGlassPanes_blue"), new ResourceLocation("securitycraft:reinforcedStainedGlassPanes_brown"), new ResourceLocation("securitycraft:reinforcedStainedGlassPanes_green"), new ResourceLocation("securitycraft:reinforcedStainedGlassPanes_red"), new ResourceLocation("securitycraft:reinforcedStainedGlassPanes_black"));
    Item reinforcedSandstone = GameRegistry.findItem(mod_SecurityCraft.MODID, "reinforcedSandstone");
    ModelBakery.registerItemVariants(reinforcedSandstone, new ResourceLocation("securitycraft:reinforcedSandstone_normal"), new ResourceLocation("securitycraft:reinforcedSandstone_chiseled"), new ResourceLocation("securitycraft:reinforcedSandstone_smooth"));
    Item reinforcedWoodSlabs = GameRegistry.findItem(mod_SecurityCraft.MODID, "reinforcedWoodSlabs");
    ModelBakery.registerItemVariants(reinforcedWoodSlabs, new ResourceLocation("securitycraft:reinforcedWoodSlabs_oak"), new ResourceLocation("securitycraft:reinforcedWoodSlabs_spruce"), new ResourceLocation("securitycraft:reinforcedWoodSlabs_birch"), new ResourceLocation("securitycraft:reinforcedWoodSlabs_jungle"), new ResourceLocation("securitycraft:reinforcedWoodSlabs_acacia"), new ResourceLocation("securitycraft:reinforcedWoodSlabs_darkoak"));
    Item reinforcedStoneSlabs = GameRegistry.findItem(mod_SecurityCraft.MODID, "reinforcedStoneSlabs");
    ModelBakery.registerItemVariants(reinforcedStoneSlabs, new ResourceLocation("securitycraft:reinforcedStoneSlabs_stone"), new ResourceLocation("securitycraft:reinforcedStoneSlabs_cobblestone"), new ResourceLocation("securitycraft:reinforcedStoneSlabs_sandstone"), new ResourceLocation("securitycraft:reinforcedDirtSlab"));
    Item fakeWater = GameRegistry.findItem(mod_SecurityCraft.MODID, "bogusWater");
    ModelBakery.registerItemVariants(fakeWater);
    ModelLoader.setCustomMeshDefinition(fakeWater, new ItemMeshDefinition() {

        @Override
        public ModelResourceLocation getModelLocation(ItemStack stack) {
            return new ModelResourceLocation("securitycraft:fakeLiquids", "water");
        }
    });
    ModelLoader.setCustomStateMapper(mod_SecurityCraft.bogusWater, new StateMapperBase() {

        @Override
        protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
            return new ModelResourceLocation("securitycraft:fakeLiquids", "water");
        }
    });
    Item fakeWaterFlowing = GameRegistry.findItem(mod_SecurityCraft.MODID, "bogusWaterFlowing");
    ModelBakery.registerItemVariants(fakeWaterFlowing);
    ModelLoader.setCustomMeshDefinition(fakeWaterFlowing, new ItemMeshDefinition() {

        @Override
        public ModelResourceLocation getModelLocation(ItemStack stack) {
            return new ModelResourceLocation("securitycraft:fakeLiquids", "water_flowing");
        }
    });
    ModelLoader.setCustomStateMapper(mod_SecurityCraft.bogusWaterFlowing, new StateMapperBase() {

        @Override
        protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
            return new ModelResourceLocation("securitycraft:fakeLiquids", "water_flowing");
        }
    });
    Item fakeLava = GameRegistry.findItem(mod_SecurityCraft.MODID, "bogusLava");
    ModelBakery.registerItemVariants(fakeLava);
    ModelLoader.setCustomMeshDefinition(fakeLava, new ItemMeshDefinition() {

        @Override
        public ModelResourceLocation getModelLocation(ItemStack stack) {
            return new ModelResourceLocation("securitycraft:fakeLiquids", "lava");
        }
    });
    ModelLoader.setCustomStateMapper(mod_SecurityCraft.bogusLava, new StateMapperBase() {

        @Override
        protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
            return new ModelResourceLocation("securitycraft:fakeLiquids", "lava");
        }
    });
    Item fakeLavaFlowing = GameRegistry.findItem(mod_SecurityCraft.MODID, "bogusLavaFlowing");
    ModelBakery.registerItemVariants(fakeLavaFlowing);
    ModelLoader.setCustomMeshDefinition(fakeLavaFlowing, new ItemMeshDefinition() {

        @Override
        public ModelResourceLocation getModelLocation(ItemStack stack) {
            return new ModelResourceLocation("securitycraft:fakeLiquids", "lava_flowing");
        }
    });
    ModelLoader.setCustomStateMapper(mod_SecurityCraft.bogusLavaFlowing, new StateMapperBase() {

        @Override
        protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
            return new ModelResourceLocation("securitycraft:fakeLiquids", "lava_flowing");
        }
    });
}
Also used : ItemMeshDefinition(net.minecraft.client.renderer.ItemMeshDefinition) StateMapperBase(net.minecraft.client.renderer.block.statemap.StateMapperBase) Item(net.minecraft.item.Item) IBlockState(net.minecraft.block.state.IBlockState) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ItemStack(net.minecraft.item.ItemStack) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

StateMapperBase (net.minecraft.client.renderer.block.statemap.StateMapperBase)7 IBlockState (net.minecraft.block.state.IBlockState)5 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)5 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 Item (net.minecraft.item.Item)3 ItemMeshDefinition (net.minecraft.client.renderer.ItemMeshDefinition)2 Nonnull (javax.annotation.Nonnull)1 BlockMachineActuator (mods.railcraft.common.blocks.machine.wayobjects.actuators.BlockMachineActuator)1 Block (net.minecraft.block.Block)1 BlockFenceGate (net.minecraft.block.BlockFenceGate)1 BlockSlab (net.minecraft.block.BlockSlab)1 BlockWall (net.minecraft.block.BlockWall)1 ModelBakery (net.minecraft.client.renderer.block.model.ModelBakery)1 DefaultStateMapper (net.minecraft.client.renderer.block.statemap.DefaultStateMapper)1 StateMap (net.minecraft.client.renderer.block.statemap.StateMap)1 ItemStack (net.minecraft.item.ItemStack)1 EnumFacing (net.minecraft.util.EnumFacing)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 ModelRegistryEvent (net.minecraftforge.client.event.ModelRegistryEvent)1 ModelLoader (net.minecraftforge.client.model.ModelLoader)1