Search in sources :

Example 1 with BlockIEFluid

use of blusunrize.immersiveengineering.common.blocks.BlockIEFluid in project ImmersiveEngineering by BluSunrize.

the class ClientProxy method preInitEnd.

@Override
public void preInitEnd() {
    //Going through registered stuff at the end of preInit, because of compat modules possibly adding items
    for (Block block : IEContent.registeredIEBlocks) {
        Item blockItem = Item.getItemFromBlock(block);
        final ResourceLocation loc = GameData.getBlockRegistry().getNameForObject(block);
        if (block instanceof IIEMetaBlock) {
            IIEMetaBlock ieMetaBlock = (IIEMetaBlock) block;
            if (ieMetaBlock.useCustomStateMapper())
                ModelLoader.setCustomStateMapper(block, IECustomStateMapper.getStateMapper(ieMetaBlock));
            ModelLoader.setCustomMeshDefinition(blockItem, new ItemMeshDefinition() {

                @Override
                public ModelResourceLocation getModelLocation(ItemStack stack) {
                    return new ModelResourceLocation(loc, "inventory");
                }
            });
            for (int meta = 0; meta < ieMetaBlock.getMetaEnums().length; meta++) {
                String location = loc.toString();
                String prop = ieMetaBlock.appendPropertiesToState() ? ("inventory," + ieMetaBlock.getMetaProperty().getName() + "=" + ieMetaBlock.getMetaEnums()[meta].toString().toLowerCase(Locale.US)) : null;
                if (ieMetaBlock.useCustomStateMapper()) {
                    String custom = ieMetaBlock.getCustomStateMapping(meta, true);
                    if (custom != null)
                        location += "_" + custom;
                }
                try {
                    ModelLoader.setCustomModelResourceLocation(blockItem, meta, new ModelResourceLocation(location, prop));
                } catch (NullPointerException npe) {
                    throw new RuntimeException("WELP! apparently " + ieMetaBlock + " lacks an item!", npe);
                }
            }
        } else if (block instanceof BlockIEFluid)
            mapFluidState(block, ((BlockIEFluid) block).getFluid());
        else
            ModelLoader.setCustomModelResourceLocation(blockItem, 0, new ModelResourceLocation(loc, "inventory"));
    }
    for (Item item : IEContent.registeredIEItems) {
        if (item instanceof ItemIEBase) {
            ItemIEBase ieMetaItem = (ItemIEBase) item;
            if (ieMetaItem.registerSubModels && ieMetaItem.getSubNames() != null && ieMetaItem.getSubNames().length > 0) {
                for (int meta = 0; meta < ieMetaItem.getSubNames().length; meta++) {
                    ResourceLocation loc = new ResourceLocation("immersiveengineering", ieMetaItem.itemName + "/" + ieMetaItem.getSubNames()[meta]);
                    ModelBakery.registerItemVariants(ieMetaItem, loc);
                    ModelLoader.setCustomModelResourceLocation(ieMetaItem, meta, new ModelResourceLocation(loc, "inventory"));
                }
            } else {
                final ResourceLocation loc = new ResourceLocation("immersiveengineering", ieMetaItem.itemName);
                ModelBakery.registerItemVariants(ieMetaItem, loc);
                ModelLoader.setCustomMeshDefinition(ieMetaItem, new ItemMeshDefinition() {

                    @Override
                    public ModelResourceLocation getModelLocation(ItemStack stack) {
                        return new ModelResourceLocation(loc, "inventory");
                    }
                });
            }
        } else {
            final ResourceLocation loc = GameData.getItemRegistry().getNameForObject(item);
            ModelBakery.registerItemVariants(item, loc);
            ModelLoader.setCustomMeshDefinition(item, new ItemMeshDefinition() {

                @Override
                public ModelResourceLocation getModelLocation(ItemStack stack) {
                    return new ModelResourceLocation(loc, "inventory");
                }
            });
        }
    }
    for (IECompatModule compat : IECompatModule.modules) try {
        compat.clientPreInit();
    } catch (Exception exception) {
        IELogger.error("Compat module for " + compat + " could not be client pre-initialized");
    }
}
Also used : BlockIEFluid(blusunrize.immersiveengineering.common.blocks.BlockIEFluid) IIEMetaBlock(blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IIEMetaBlock) IECompatModule(blusunrize.immersiveengineering.common.util.compat.IECompatModule) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) IOException(java.io.IOException) ItemMeshDefinition(net.minecraft.client.renderer.ItemMeshDefinition) IGuiItem(blusunrize.immersiveengineering.common.items.IEItemInterfaces.IGuiItem) IColouredItem(blusunrize.immersiveengineering.common.items.IEItemInterfaces.IColouredItem) Item(net.minecraft.item.Item) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) Block(net.minecraft.block.Block) IColouredBlock(blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IColouredBlock) IIEMetaBlock(blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IIEMetaBlock) ItemStack(net.minecraft.item.ItemStack) PositionedItemStack(blusunrize.lib.manual.ManualPages.PositionedItemStack)

Example 2 with BlockIEFluid

use of blusunrize.immersiveengineering.common.blocks.BlockIEFluid in project ImmersiveEngineering by BluSunrize.

the class TConstructHelper method preInit.

@Override
public void preInit() {
    //		sendFluidForMelting("Uranium", 0x596552, 600);
    fluidUranium = new FluidColouredMetal("uranium", 0x596552, 600);
    sendFluidForMelting("Uranium", fluidUranium);
    blockMoltenUranium = new BlockIEFluid("molten_uranium", fluidUranium, net.minecraft.block.material.Material.LAVA);
    //		Fluid fluidCons = sendFluidForMelting("Constantan", 0xf7866c, 518);
    fluidConstantan = new FluidColouredMetal("constantan", 0xf7866c, 518);
    sendFluidForMelting("Constantan", fluidUranium);
    blockMoltenConstantan = new BlockIEFluid("molten_constantan", fluidConstantan, net.minecraft.block.material.Material.LAVA);
    sendAlloyForMelting(new FluidStack(fluidConstantan, 2), "copper", 1, "nickel", 1);
    //		FluidStack output = fluids.get(0);
    //		FluidStack[] input = new FluidStack[fluids.size()-1];
    //		input = fluids.subList(1, fluids.size()).toArray(input);
    //		TinkerRegistry.registerAlloy(new FluidStack(fluidCons, 2), new FluidStack[]{new FluidStack(fluidCons, 2)});
    FMLInterModComms.sendMessage("tconstruct", "blacklistMelting", new ItemStack(IEContent.itemBullet, 1, OreDictionary.WILDCARD_VALUE));
    FMLInterModComms.sendMessage("tconstruct", "blacklistMelting", new ItemStack(IEContent.itemDrillhead, 1, OreDictionary.WILDCARD_VALUE));
    boolean bows = false;
    try {
        String tConVersion = Loader.instance().getIndexedModList().get("tconstruct").getVersion();
        //TCon version format: 1.10.2-[major].[minor].[sub].[jenkins]
        String version = tConVersion.substring(7);
        //reduce to raw version numbers by removing "jenkins"
        version = version.replaceAll("[^\\d.]", "");
        bows = version.compareTo("2.5.6.441") >= 0;
    } catch (Exception e) {
    }
    treatedWood.setCraftable(true);
    treatedWood.addItem("stickTreatedWood", 1, Material.VALUE_Shard);
    treatedWood.addItem("plankTreatedWood", 1, Material.VALUE_Ingot);
    treatedWood.addTrait(TinkerTraits.ecological, MaterialTypes.HEAD);
    treatedWood.addTrait(TinkerTraits.ecological);
    TinkerRegistry.addMaterialStats(treatedWood, new HeadMaterialStats(25, 2.00f, 2.00f, HarvestLevels.STONE), new HandleMaterialStats(1.0f, 35), new ExtraMaterialStats(20));
    if (bows)
        TinkerRegistry.addMaterialStats(treatedWood, new BowMaterialStats(1f, 1.125f, 0), new ArrowShaftMaterialStats(1.2f, 0));
    TinkerIntegration.integrate(treatedWood, "plankTreatedWood").integrate();
    constantan.setCastable(true);
    constantan.addItem("nuggetConstantan", 1, Material.VALUE_Nugget);
    constantan.addItem("ingotConstantan", 1, Material.VALUE_Ingot);
    constantan.addTrait(thermalInversion);
    TinkerRegistry.addMaterialStats(constantan, new HeadMaterialStats(25, 4.70f, 4.00f, HarvestLevels.DIAMOND), new HandleMaterialStats(0.8f, 60), new ExtraMaterialStats(60));
    if (bows)
        TinkerRegistry.addMaterialStats(constantan, new BowMaterialStats(.55f, 1.5f, 5f));
    TinkerIntegration.integrate(constantan, fluidConstantan, "Constantan").toolforge().integrate();
    hemp.addItemIngot("fiberHemp");
    hemp.setRepresentativeItem(new ItemStack(IEContent.itemMaterial, 1, 4));
    TinkerRegistry.addMaterialStats(hemp, new BowStringMaterialStats(1f));
    TinkerIntegration.integrate(hemp).integrate();
    ToolboxHandler.addToolType((s) -> (s.getItem() instanceof TinkersItem));
}
Also used : TinkersItem(slimeknights.tconstruct.library.tinkering.TinkersItem) BlockIEFluid(blusunrize.immersiveengineering.common.blocks.BlockIEFluid) FluidStack(net.minecraftforge.fluids.FluidStack) ItemStack(net.minecraft.item.ItemStack)

Aggregations

BlockIEFluid (blusunrize.immersiveengineering.common.blocks.BlockIEFluid)2 ItemStack (net.minecraft.item.ItemStack)2 IColouredBlock (blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IColouredBlock)1 IIEMetaBlock (blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IIEMetaBlock)1 IColouredItem (blusunrize.immersiveengineering.common.items.IEItemInterfaces.IColouredItem)1 IGuiItem (blusunrize.immersiveengineering.common.items.IEItemInterfaces.IGuiItem)1 IECompatModule (blusunrize.immersiveengineering.common.util.compat.IECompatModule)1 PositionedItemStack (blusunrize.lib.manual.ManualPages.PositionedItemStack)1 IOException (java.io.IOException)1 Block (net.minecraft.block.Block)1 ItemMeshDefinition (net.minecraft.client.renderer.ItemMeshDefinition)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 Item (net.minecraft.item.Item)1 FluidStack (net.minecraftforge.fluids.FluidStack)1 TinkersItem (slimeknights.tconstruct.library.tinkering.TinkersItem)1