Search in sources :

Example 56 with ModelResourceLocation

use of net.minecraft.client.renderer.block.model.ModelResourceLocation in project SilentGems by SilentChaos512.

the class ItemFoodSG method getModels.

@Override
public void getModels(Map<Integer, ModelResourceLocation> models) {
    for (int i = 0; i < NAMES.length; ++i) {
        String name = (SilentGems.RESOURCE_PREFIX + NAMES[i]).toLowerCase();
        models.put(i, new ModelResourceLocation(name, "inventory"));
    }
}
Also used : ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Example 57 with ModelResourceLocation

use of net.minecraft.client.renderer.block.model.ModelResourceLocation in project Charset by CharsetMC.

the class ProxyClient method bakeModels.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void bakeModels(ModelBakeEvent event) {
    if (prismModel != null) {
        for (Orientation o : Orientation.values()) {
            ModelResourceLocation location = new ModelResourceLocation("charset:laser_prism", "orientation=" + o.name().toLowerCase());
            IBakedModel model = prismModel.bake(o.toTransformation(), DefaultVertexFormats.BLOCK, ModelLoader.defaultTextureGetter());
            event.getModelRegistry().putObject(location, model);
        }
    }
    // Patch jars to glow
    for (EnumFacing facing : EnumFacing.VALUES) {
        for (LaserColor color : LaserColor.VALUES) {
            if (color == LaserColor.NONE)
                continue;
            IBlockState state = CharsetLaser.blockJar.getDefaultState().withProperty(CharsetLaser.LASER_COLOR, color).withProperty(Properties.FACING, facing);
            ModelResourceLocation location = new ModelResourceLocation("charset:light_jar", "color=" + color.getName() + ",facing=" + facing.getName());
            IBakedModel model = event.getModelRegistry().getObject(location);
            VertexFormat format = new VertexFormat(DefaultVertexFormats.ITEM);
            format.addElement(DefaultVertexFormats.TEX_2S);
            if (model != null) {
                SimpleMultiLayerBakedModel result = new SimpleMultiLayerBakedModel(model);
                BlockRenderLayer layerPre = MinecraftForgeClient.getRenderLayer();
                for (BlockRenderLayer layer : BlockRenderLayer.values()) {
                    if (CharsetLaser.blockJar.canRenderInLayer(CharsetLaser.blockJar.getDefaultState(), layer)) {
                        ForgeHooksClient.setRenderLayer(layer);
                        for (int i = 0; i <= 6; i++) {
                            EnumFacing facingIn = (i < 6) ? EnumFacing.getFront(i) : null;
                            for (BakedQuad quadIn : model.getQuads(state, facingIn, 0)) {
                                result.addQuad(layer, facingIn, ModelTransformer.transform(quadIn, (quad, element, data) -> {
                                    if (quad.getTintIndex() == 1 && element == DefaultVertexFormats.TEX_2S) {
                                        return new float[] { 15f * 0x20 / 0xFFFF, 0, 0, 0 };
                                    }
                                    return data;
                                }, (bakedQuad -> {
                                    if (bakedQuad.getTintIndex() == 1) {
                                        return format;
                                    } else {
                                        return bakedQuad.getFormat();
                                    }
                                })));
                            }
                        }
                    }
                }
                ForgeHooksClient.setRenderLayer(layerPre);
                event.getModelRegistry().putObject(location, result);
            }
        }
    }
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) SimpleMultiLayerBakedModel(pl.asie.charset.lib.render.model.SimpleMultiLayerBakedModel) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ModelBakeEvent(net.minecraftforge.client.event.ModelBakeEvent) ModelRegistryEvent(net.minecraftforge.client.event.ModelRegistryEvent) Properties(pl.asie.charset.lib.Properties) LaserRenderer(pl.asie.charset.module.optics.laser.system.LaserRenderer) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) MinecraftForgeClient(net.minecraftforge.client.MinecraftForgeClient) LaserTintHandler(pl.asie.charset.module.optics.laser.blocks.LaserTintHandler) DefaultVertexFormats(net.minecraft.client.renderer.vertex.DefaultVertexFormats) PixelOperationSprite(pl.asie.charset.lib.render.sprite.PixelOperationSprite) Side(net.minecraftforge.fml.relauncher.Side) CommandCharset(pl.asie.charset.lib.command.CommandCharset) RegistryUtils(pl.asie.charset.lib.utils.RegistryUtils) TextureStitchEvent(net.minecraftforge.client.event.TextureStitchEvent) ColorHandlerEvent(net.minecraftforge.client.event.ColorHandlerEvent) ModelLoader(net.minecraftforge.client.model.ModelLoader) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) ModelTransformer(pl.asie.charset.lib.render.model.ModelTransformer) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) LaserColor(pl.asie.charset.api.laser.LaserColor) EnumFacing(net.minecraft.util.EnumFacing) SubCommandDebugLasersClient(pl.asie.charset.module.optics.laser.system.SubCommandDebugLasersClient) BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) IModel(net.minecraftforge.client.model.IModel) RenderUtils(pl.asie.charset.lib.utils.RenderUtils) IBlockState(net.minecraft.block.state.IBlockState) MinecraftForge(net.minecraftforge.common.MinecraftForge) Orientation(pl.asie.charset.lib.utils.Orientation) ResourceLocation(net.minecraft.util.ResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) ForgeHooksClient(net.minecraftforge.client.ForgeHooksClient) SimpleMultiLayerBakedModel(pl.asie.charset.lib.render.model.SimpleMultiLayerBakedModel) IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) Orientation(pl.asie.charset.lib.utils.Orientation) LaserColor(pl.asie.charset.api.laser.LaserColor) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 58 with ModelResourceLocation

use of net.minecraft.client.renderer.block.model.ModelResourceLocation in project Charset by CharsetMC.

the class CharsetMiscShelf method onPostBake.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onPostBake(ModelBakeEvent event) {
    for (Boolean backValue : BlockShelf.BACK.getAllowedValues()) {
        for (EnumFacing facingValue : Properties.FACING4.getAllowedValues()) {
            event.getModelRegistry().putObject(new ModelResourceLocation("charset:shelf", "back=" + BlockShelf.BACK.getName(backValue) + ",facing=" + Properties.FACING4.getName(facingValue)), ModelShelf.INSTANCE);
        }
    }
    event.getModelRegistry().putObject(new ModelResourceLocation("charset:shelf", "inventory"), ModelShelf.INSTANCE);
    ModelShelf.shelfModel = RenderUtils.getModel(new ResourceLocation("charset:block/shelf"));
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 59 with ModelResourceLocation

use of net.minecraft.client.renderer.block.model.ModelResourceLocation in project Charset by CharsetMC.

the class CharsetPowerMechanical method onModelRegistry.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onModelRegistry(ModelRegistryEvent event) {
    RegistryUtils.registerModel(itemAxle, 0, "charset:axle");
    RegistryUtils.registerModel(itemCreativeGenerator, 0, "charset:creative_generator_mechanical");
    RegistryUtils.registerModel(itemGearbox, 0, "charset:gearbox");
    RegistryUtils.registerModel(itemSocket, 0, "charset:socket_mechanical");
    ModelLoader.setCustomStateMapper(blockGearbox, new StateMapperBase() {

        @Override
        protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
            return new ModelResourceLocation("charset:gearbox", "inventory");
        }
    });
}
Also used : StateMapperBase(net.minecraft.client.renderer.block.statemap.StateMapperBase) IBlockState(net.minecraft.block.state.IBlockState) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 60 with ModelResourceLocation

use of net.minecraft.client.renderer.block.model.ModelResourceLocation in project Charset by CharsetMC.

the class TileAxleRenderer method onModelBake.

@SubscribeEvent
public void onModelBake(ModelBakeEvent event) {
    for (int i = 0; i < 3; i++) {
        bakedModels[i] = event.getModelRegistry().getObject(new ModelResourceLocation("charset:axle", TAGS[i]));
    }
    ModelResourceLocation invLoc = new ModelResourceLocation("charset:axle", "inventory");
    event.getModelRegistry().putObject(invLoc, new AxleItemModel(event.getModelRegistry().getObject(invLoc)));
}
Also used : ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)320 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)129 ResourceLocation (net.minecraft.util.ResourceLocation)101 Item (net.minecraft.item.Item)55 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)52 IBlockState (net.minecraft.block.state.IBlockState)48 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)26 ArrayList (java.util.ArrayList)25 Block (net.minecraft.block.Block)21 StateMapperBase (net.minecraft.client.renderer.block.statemap.StateMapperBase)20 ItemStack (net.minecraft.item.ItemStack)16 EnumFacing (net.minecraft.util.EnumFacing)13 Map (java.util.Map)12 ItemMeshDefinition (net.minecraft.client.renderer.ItemMeshDefinition)11 IModel (net.minecraftforge.client.model.IModel)11 Nonnull (javax.annotation.Nonnull)10 IProperty (net.minecraft.block.properties.IProperty)9 Side (net.minecraftforge.fml.relauncher.Side)9 DefaultStateMapper (net.minecraft.client.renderer.block.statemap.DefaultStateMapper)8 RenderItem (net.minecraft.client.renderer.RenderItem)7