Search in sources :

Example 1 with ModelResourceLocation

use of net.minecraft.client.resources.model.ModelResourceLocation in project Galacticraft by micdoodle8.

the class ClientProxyCore method registerVariants.

@Override
public void registerVariants() {
    Item fuel = Item.getItemFromBlock(GCBlocks.fuel);
    ModelBakery.registerItemVariants(fuel, new ResourceLocation("galacticraftcore:fuel"));
    ModelLoader.setCustomMeshDefinition(fuel, IItemMeshDefinitionCustom.create((ItemStack stack) -> fuelLocation));
    ModelLoader.setCustomStateMapper(GCBlocks.fuel, new StateMapperBase() {

        @Override
        protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
            return fuelLocation;
        }
    });
    Item oil = Item.getItemFromBlock(GCBlocks.crudeOil);
    ModelBakery.registerItemVariants(oil, new ResourceLocation("galacticraftcore:oil"));
    ModelLoader.setCustomMeshDefinition(oil, IItemMeshDefinitionCustom.create((ItemStack stack) -> oilLocation));
    ModelLoader.setCustomStateMapper(GCBlocks.crudeOil, new StateMapperBase() {

        @Override
        protected ModelResourceLocation getModelResourceLocation(IBlockState state) {
            return oilLocation;
        }
    });
    Item nasaWorkbench = Item.getItemFromBlock(GCBlocks.nasaWorkbench);
    ModelResourceLocation modelResourceLocation = new ModelResourceLocation("galacticraftcore:rocket_workbench", "inventory");
    ModelLoader.setCustomModelResourceLocation(nasaWorkbench, 0, modelResourceLocation);
    modelResourceLocation = new ModelResourceLocation("galacticraftcore:rocket_t1", "inventory");
    for (int i = 0; i < 5; ++i) {
        ModelLoader.setCustomModelResourceLocation(GCItems.rocketTier1, i, modelResourceLocation);
    }
    for (int i = 0; i < 4; ++i) {
        modelResourceLocation = new ModelResourceLocation("galacticraftcore:buggy" + (i > 0 ? "_" + i : ""), "inventory");
        ModelLoader.setCustomModelResourceLocation(GCItems.buggy, i, modelResourceLocation);
    }
    // for (PartialCanister container : ClientProxyCore.canisters)
    // {
    // modelResourceLocation = new ModelResourceLocation(container.getModID() + ":" + container.getBaseName() + "_0", "inventory");
    // for (int i = 0; i < container.getItem().getMaxDamage(); ++i)
    // {
    // ModelLoader.setCustomModelResourceLocation(container.getItem(), i, modelResourceLocation);
    // }
    // }
    modelResourceLocation = new ModelResourceLocation("galacticraftcore:flag", "inventory");
    ModelLoader.setCustomModelResourceLocation(GCItems.flag, 0, modelResourceLocation);
    ModelLoader.setCustomStateMapper(GCBlocks.oxygenDetector, new StateMap.Builder().ignore(BlockOxygenDetector.ACTIVE).build());
    ModelLoader.setCustomStateMapper(GCBlocks.panelLighting, new StateMap.Builder().ignore(BlockPanelLighting.TYPE).build());
    ModelLoader.setCustomStateMapper(GCBlocks.concealedRedstone, new StateMap.Builder().ignore(BlockConcealedRedstone.POWER).build());
    ModelLoader.setCustomStateMapper(GCBlocks.concealedRepeater_Powered, new StateMap.Builder().ignore(BlockConcealedRepeater.FACING, BlockConcealedRepeater.DELAY, BlockConcealedRepeater.LOCKED).build());
    ModelLoader.setCustomStateMapper(GCBlocks.concealedRepeater_Unpowered, new StateMap.Builder().ignore(BlockConcealedRepeater.FACING, BlockConcealedRepeater.DELAY, BlockConcealedRepeater.LOCKED).build());
    ModelLoader.setCustomStateMapper(GCBlocks.concealedDetector, new StateMap.Builder().ignore(BlockConcealedDetector.FACING, BlockConcealedDetector.DETECTED).build());
}
Also used : StateMapperBase(net.minecraft.client.renderer.block.statemap.StateMapperBase) Item(net.minecraft.item.Item) IBlockState(net.minecraft.block.state.IBlockState) ResourceLocation(net.minecraft.util.ResourceLocation) ModelResourceLocation(net.minecraft.client.resources.model.ModelResourceLocation) StateMap(net.minecraft.client.renderer.block.statemap.StateMap) ModelResourceLocation(net.minecraft.client.resources.model.ModelResourceLocation) ItemStack(net.minecraft.item.ItemStack)

Example 2 with ModelResourceLocation

use of net.minecraft.client.resources.model.ModelResourceLocation in project Galacticraft by micdoodle8.

the class RenderTier3Rocket method updateModel.

private void updateModel() {
    if (rocketModel == null) {
        Function<ResourceLocation, TextureAtlasSprite> textureGetter = new Function<ResourceLocation, TextureAtlasSprite>() {

            @Override
            public TextureAtlasSprite apply(ResourceLocation input) {
                return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(input.toString());
            }
        };
        ModelResourceLocation modelResourceLocation = new ModelResourceLocation(GalacticraftPlanets.TEXTURE_PREFIX + "rocket_t3", "inventory");
        rocketModel = (ItemModelRocketT3) FMLClientHandler.instance().getClient().getRenderItem().getItemModelMesher().getModelManager().getModel(modelResourceLocation);
    }
}
Also used : Function(com.google.common.base.Function) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ModelResourceLocation(net.minecraft.client.resources.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) ModelResourceLocation(net.minecraft.client.resources.model.ModelResourceLocation)

Example 3 with ModelResourceLocation

use of net.minecraft.client.resources.model.ModelResourceLocation in project Galacticraft by micdoodle8.

the class ClientUtil method replaceModel.

public static void replaceModel(String modid, ModelBakeEvent event, String resLoc, String objLoc, List<String> visibleGroups, Class<? extends ModelTransformWrapper> clazz, IModelState parentState, String... variants) {
    if (variants.length == 0) {
        variants = new String[] { "inventory" };
    }
    IBakedModel newModel;
    try {
        newModel = modelFromOBJ(new ResourceLocation(modid, objLoc), visibleGroups, parentState);
        if (clazz != null) {
            newModel = clazz.getConstructor(IBakedModel.class).newInstance(newModel);
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    for (String variant : variants) {
        ModelResourceLocation modelResourceLocation = new ModelResourceLocation(modid + ":" + resLoc, variant);
        IBakedModel object = event.modelRegistry.getObject(modelResourceLocation);
        if (object != null) {
            event.modelRegistry.putObject(modelResourceLocation, newModel);
        }
    }
}
Also used : ModelResourceLocation(net.minecraft.client.resources.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) IBakedModel(net.minecraft.client.resources.model.IBakedModel) ModelResourceLocation(net.minecraft.client.resources.model.ModelResourceLocation) IOException(java.io.IOException)

Example 4 with ModelResourceLocation

use of net.minecraft.client.resources.model.ModelResourceLocation in project Galacticraft by micdoodle8.

the class AsteroidsModuleClient method registerVariants.

@Override
public void registerVariants() {
    Item receiver = Item.getItemFromBlock(AsteroidBlocks.beamReceiver);
    ModelResourceLocation modelResourceLocation = new ModelResourceLocation("galacticraftplanets:beam_receiver", "inventory");
    ModelLoader.setCustomModelResourceLocation(receiver, 0, modelResourceLocation);
    Item reflector = Item.getItemFromBlock(AsteroidBlocks.beamReflector);
    modelResourceLocation = new ModelResourceLocation("galacticraftplanets:beam_reflector", "inventory");
    ModelLoader.setCustomModelResourceLocation(reflector, 0, modelResourceLocation);
    Item teleporter = Item.getItemFromBlock(AsteroidBlocks.shortRangeTelepad);
    modelResourceLocation = new ModelResourceLocation("galacticraftplanets:telepad_short", "inventory");
    ModelLoader.setCustomModelResourceLocation(teleporter, 0, modelResourceLocation);
    modelResourceLocation = new ModelResourceLocation("galacticraftplanets:grapple", "inventory");
    ModelLoader.setCustomModelResourceLocation(AsteroidsItems.grapple, 0, modelResourceLocation);
    modelResourceLocation = new ModelResourceLocation("galacticraftplanets:rocket_t3", "inventory");
    for (int i = 0; i < 5; ++i) {
        ModelLoader.setCustomModelResourceLocation(AsteroidsItems.tier3Rocket, i, modelResourceLocation);
    }
    modelResourceLocation = new ModelResourceLocation("galacticraftplanets:astro_miner", "inventory");
    ModelLoader.setCustomModelResourceLocation(AsteroidsItems.astroMiner, 0, modelResourceLocation);
}
Also used : Item(net.minecraft.item.Item) ModelResourceLocation(net.minecraft.client.resources.model.ModelResourceLocation)

Example 5 with ModelResourceLocation

use of net.minecraft.client.resources.model.ModelResourceLocation in project BuildCraft by BuildCraft.

the class BuildCraftTransport method registerModels.

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void registerModels(ModelBakeEvent event) {
    ModelResourceLocation mrl = new ModelResourceLocation("buildcrafttransport:pipeBlock");
    event.modelRegistry.putObject(mrl, new PipeBlockModel());
    PipeTransportRendererFluids.INSTANCE.modelBake();
    for (ItemPipe itemPipe : BlockGenericPipe.pipes.keySet()) {
        for (int i = 0; i < 17; i++) {
            mrl = ModelHelper.getItemResourceLocation(itemPipe, "_" + i);
            event.modelRegistry.putObject(mrl, PipeItemModel.create(itemPipe, i));
        }
    }
    if (lensItem != null) {
        for (int i = 0; i < 34; i++) {
            mrl = ModelHelper.getItemResourceLocation(lensItem, "_" + i);
            event.modelRegistry.putObject(mrl, LensPluggableModel.create(lensItem, i));
        }
    }
    if (plugItem != null) {
        mrl = ModelHelper.getItemResourceLocation(plugItem, "");
        event.modelRegistry.putObject(mrl, PlugPluggableModel.create());
    }
    if (powerAdapterItem != null) {
        mrl = ModelHelper.getItemResourceLocation(powerAdapterItem, "");
        event.modelRegistry.putObject(mrl, ModelPowerAdapter.create());
    }
    if (pipeGate != null) {
        mrl = ModelHelper.getItemResourceLocation(pipeGate, "");
        event.modelRegistry.putObject(mrl, GateItemModel.INSTANCE);
    }
    if (facadeItem != null) {
        mrl = ModelHelper.getItemResourceLocation(facadeItem, "");
        event.modelRegistry.putObject(mrl, FacadeItemModel.INSTANCE);
    }
}
Also used : ModelResourceLocation(net.minecraft.client.resources.model.ModelResourceLocation) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

ModelResourceLocation (net.minecraft.client.resources.model.ModelResourceLocation)28 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)13 ItemStack (net.minecraft.item.ItemStack)11 ItemMeshDefinition (net.minecraft.client.renderer.ItemMeshDefinition)8 ResourceLocation (net.minecraft.util.ResourceLocation)7 IBlockState (net.minecraft.block.state.IBlockState)5 StateMapperBase (net.minecraft.client.renderer.block.statemap.StateMapperBase)5 Item (net.minecraft.item.Item)5 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)4 IBakedModel (net.minecraft.client.resources.model.IBakedModel)3 Function (com.google.common.base.Function)2 DimletType (mcjty.rftoolsdim.dimensions.dimlets.types.DimletType)2 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)2 Joiner (com.google.common.base.Joiner)1 HashMultimap (com.google.common.collect.HashMultimap)1 Multimap (com.google.common.collect.Multimap)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1