Search in sources :

Example 11 with Material

use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.

the class SurfaceRockPopulator method findUndergroundMaterials.

private Set<Material> findUndergroundMaterials(Collection<IBlockState> generatedBlocks) {
    HashSet<Material> result = new HashSet<>();
    for (IBlockState blockState : generatedBlocks) {
        Material resultMaterial;
        if (blockState.getBlock() instanceof IFluidBlock || blockState.getBlock() instanceof BlockLiquid) {
            Fluid fluid = FluidRegistry.lookupFluidForBlock(blockState.getBlock());
            resultMaterial = fluid == null ? null : MetaFluids.getMaterialFromFluid(fluid);
        } else {
            ItemStack itemStack = new ItemStack(blockState.getBlock(), 1, blockState.getBlock().damageDropped(blockState));
            UnificationEntry entry = OreDictUnifier.getUnificationEntry(itemStack);
            if (entry != null && entry.material != null && entry.material.hasProperty(PropertyKey.ORE))
                resultMaterial = entry.material;
            else
                resultMaterial = null;
        }
        if (resultMaterial != null) {
            result.add(resultMaterial);
        }
    }
    return result;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Fluid(net.minecraftforge.fluids.Fluid) UnificationEntry(gregtech.api.unification.stack.UnificationEntry) Material(gregtech.api.unification.material.Material) ItemStack(net.minecraft.item.ItemStack) HashSet(java.util.HashSet)

Example 12 with Material

use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.

the class CommonProxy method registerBlocks.

@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event) {
    GTLog.logger.info("Registering Blocks...");
    IForgeRegistry<Block> registry = event.getRegistry();
    registry.register(MACHINE);
    StoneType.init();
    for (Material material : GregTechAPI.MATERIAL_REGISTRY) {
        if (material.hasProperty(PropertyKey.ORE)) {
            createOreBlock(material);
        }
        if (material.hasProperty(PropertyKey.WIRE)) {
            for (BlockCable cable : CABLES) {
                if (!cable.getItemPipeType(null).isCable() || !material.getProperty(PropertyKey.WIRE).isSuperconductor())
                    cable.addCableMaterial(material, material.getProperty(PropertyKey.WIRE));
            }
        }
        if (material.hasProperty(PropertyKey.FLUID_PIPE)) {
            for (BlockFluidPipe pipe : FLUID_PIPES) {
                if (!pipe.getItemPipeType(pipe.getItem(material)).getOrePrefix().isIgnored(material)) {
                    pipe.addPipeMaterial(material, material.getProperty(PropertyKey.FLUID_PIPE));
                }
            }
        }
        if (material.hasProperty(PropertyKey.ITEM_PIPE)) {
            for (BlockItemPipe pipe : ITEM_PIPES) {
                if (!pipe.getItemPipeType(pipe.getItem(material)).getOrePrefix().isIgnored(material)) {
                    pipe.addPipeMaterial(material, material.getProperty(PropertyKey.ITEM_PIPE));
                }
            }
        }
    }
    for (BlockFluidPipe pipe : FLUID_PIPES) {
        if (!pipe.getItemPipeType(pipe.getItem(Materials.Wood)).getOrePrefix().isIgnored(Materials.Wood) || !pipe.getItemPipeType(pipe.getItem(Materials.TreatedWood)).getOrePrefix().isIgnored(Materials.TreatedWood)) {
            pipe.addPipeMaterial(Materials.Wood, new FluidPipeProperties(310, 5, false));
            pipe.addPipeMaterial(Materials.TreatedWood, new FluidPipeProperties(310, 8, false));
        }
    }
    for (BlockCable cable : CABLES) registry.register(cable);
    for (BlockFluidPipe pipe : FLUID_PIPES) registry.register(pipe);
    for (BlockItemPipe pipe : ITEM_PIPES) registry.register(pipe);
    registry.register(HERMETIC_CASING);
    registry.register(FOAM);
    registry.register(REINFORCED_FOAM);
    registry.register(PETRIFIED_FOAM);
    registry.register(REINFORCED_PETRIFIED_FOAM);
    registry.register(BOILER_CASING);
    registry.register(BOILER_FIREBOX_CASING);
    registry.register(METAL_CASING);
    registry.register(TURBINE_CASING);
    registry.register(MACHINE_CASING);
    registry.register(STEAM_CASING);
    registry.register(MULTIBLOCK_CASING);
    registry.register(TRANSPARENT_CASING);
    registry.register(WIRE_COIL);
    registry.register(FUSION_CASING);
    registry.register(WARNING_SIGN);
    registry.register(ASPHALT);
    registry.register(STONE_SMOOTH);
    registry.register(STONE_COBBLE);
    registry.register(STONE_COBBLE_MOSSY);
    registry.register(STONE_POLISHED);
    registry.register(STONE_BRICKS);
    registry.register(STONE_BRICKS_CRACKED);
    registry.register(STONE_BRICKS_MOSSY);
    registry.register(STONE_CHISELED);
    registry.register(STONE_TILED);
    registry.register(STONE_TILED_SMALL);
    registry.register(STONE_BRICKS_SMALL);
    registry.register(STONE_WINDMILL_A);
    registry.register(STONE_WINDMILL_B);
    registry.register(STONE_BRICKS_SQUARE);
    registry.register(RUBBER_LOG);
    registry.register(RUBBER_LEAVES);
    registry.register(RUBBER_SAPLING);
    registry.register(PLANKS);
    COMPRESSED.values().stream().distinct().forEach(registry::register);
    FRAMES.values().stream().distinct().forEach(registry::register);
    SURFACE_ROCK.values().stream().distinct().forEach(registry::register);
    ORES.forEach(registry::register);
}
Also used : BlockItemPipe(gregtech.common.pipelike.itempipe.BlockItemPipe) ItemBlockItemPipe(gregtech.common.pipelike.itempipe.ItemBlockItemPipe) FluidPipeProperties(gregtech.api.unification.material.properties.FluidPipeProperties) Block(net.minecraft.block.Block) MachineItemBlock(gregtech.api.block.machines.MachineItemBlock) ItemBlock(net.minecraft.item.ItemBlock) Material(gregtech.api.unification.material.Material) ItemBlockFluidPipe(gregtech.common.pipelike.fluidpipe.ItemBlockFluidPipe) BlockFluidPipe(gregtech.common.pipelike.fluidpipe.BlockFluidPipe) ItemBlockCable(gregtech.common.pipelike.cable.ItemBlockCable) BlockCable(gregtech.common.pipelike.cable.BlockCable) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 13 with Material

use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.

the class CommonProxy method modifyFuelBurnTime.

@SubscribeEvent
public static void modifyFuelBurnTime(FurnaceFuelBurnTimeEvent event) {
    ItemStack stack = event.getItemStack();
    Block block = Block.getBlockFromItem(stack.getItem());
    // handle sapling and log burn rates
    if (block == RUBBER_LOG || block == PLANKS) {
        event.setBurnTime(300);
    } else if (block == RUBBER_SAPLING) {
        event.setBurnTime(100);
    }
    // handle material blocks burn value
    if (stack.getItem() instanceof CompressedItemBlock) {
        CompressedItemBlock itemBlock = (CompressedItemBlock) stack.getItem();
        Material material = itemBlock.getBlockState(stack).getValue(itemBlock.compressedBlock.variantProperty);
        DustProperty property = material.getProperty(PropertyKey.DUST);
        if (property != null && property.getBurnTime() > 0) {
            // compute burn value for block prefix, taking amount of material in block into account
            double materialUnitsInBlock = OrePrefix.block.getMaterialAmount(material) / (GTValues.M * 1.0);
            event.setBurnTime((int) (materialUnitsInBlock * property.getBurnTime()));
        }
    }
}
Also used : Block(net.minecraft.block.Block) MachineItemBlock(gregtech.api.block.machines.MachineItemBlock) ItemBlock(net.minecraft.item.ItemBlock) Material(gregtech.api.unification.material.Material) DustProperty(gregtech.api.unification.material.properties.DustProperty) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 14 with Material

use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.

the class BlockCompressed method onTextureStitch.

@Override
@SideOnly(Side.CLIENT)
public void onTextureStitch(TextureStitchEvent.Pre event) {
    for (IBlockState state : this.getBlockState().getValidStates()) {
        Material m = state.getValue(variantProperty);
        event.getMap().registerSprite(MaterialIconType.block.getBlockPath(m.getMaterialIconSet()));
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) PropertyMaterial(gregtech.common.blocks.properties.PropertyMaterial) Material(gregtech.api.unification.material.Material) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 15 with Material

use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.

the class MetaBlocks method registerOreDict.

public static void registerOreDict() {
    OreDictUnifier.registerOre(new ItemStack(RUBBER_LOG, 1, GTValues.W), OrePrefix.log, Materials.Wood);
    OreDictUnifier.registerOre(new ItemStack(RUBBER_LEAVES, 1, GTValues.W), "treeLeaves");
    OreDictUnifier.registerOre(new ItemStack(RUBBER_SAPLING, 1, GTValues.W), "treeSapling");
    OreDictUnifier.registerOre(PLANKS.getItemVariant(BlockGregPlanks.BlockType.RUBBER_PLANK), OrePrefix.plank, Materials.Wood);
    OreDictUnifier.registerOre(PLANKS.getItemVariant(BlockGregPlanks.BlockType.TREATED_PLANK), OrePrefix.plank, Materials.TreatedWood);
    GameRegistry.addSmelting(RUBBER_LOG, new ItemStack(Items.COAL, 1, 1), 0.15F);
    for (Entry<Material, BlockCompressed> entry : COMPRESSED.entrySet()) {
        Material material = entry.getKey();
        BlockCompressed block = entry.getValue();
        ItemStack itemStack = block.getItem(material);
        OreDictUnifier.registerOre(itemStack, OrePrefix.block, material);
    }
    for (Entry<Material, BlockFrame> entry : FRAMES.entrySet()) {
        Material material = entry.getKey();
        BlockFrame block = entry.getValue();
        ItemStack itemStack = block.getItem(material);
        OreDictUnifier.registerOre(itemStack, OrePrefix.frameGt, material);
    }
    for (BlockOre blockOre : ORES) {
        Material material = blockOre.material;
        for (StoneType stoneType : blockOre.STONE_TYPE.getAllowedValues()) {
            if (stoneType == null)
                continue;
            ItemStack normalStack = blockOre.getItem(blockOre.getDefaultState().withProperty(blockOre.STONE_TYPE, stoneType));
            OreDictUnifier.registerOre(normalStack, stoneType.processingPrefix, material);
        }
    }
    for (BlockCable cable : CABLES) {
        for (Material pipeMaterial : cable.getEnabledMaterials()) {
            ItemStack itemStack = cable.getItem(pipeMaterial);
            OreDictUnifier.registerOre(itemStack, cable.getPrefix(), pipeMaterial);
        }
    }
    for (BlockFluidPipe pipe : FLUID_PIPES) {
        for (Material pipeMaterial : pipe.getEnabledMaterials()) {
            ItemStack itemStack = pipe.getItem(pipeMaterial);
            OreDictUnifier.registerOre(itemStack, pipe.getPrefix(), pipeMaterial);
        }
    }
    for (BlockItemPipe pipe : ITEM_PIPES) {
        for (Material pipeMaterial : pipe.getEnabledMaterials()) {
            ItemStack itemStack = pipe.getItem(pipeMaterial);
            OreDictUnifier.registerOre(itemStack, pipe.getPrefix(), pipeMaterial);
        }
    }
}
Also used : BlockItemPipe(gregtech.common.pipelike.itempipe.BlockItemPipe) StoneType(gregtech.api.unification.ore.StoneType) Material(gregtech.api.unification.material.Material) BlockFluidPipe(gregtech.common.pipelike.fluidpipe.BlockFluidPipe) ItemStack(net.minecraft.item.ItemStack) BlockCable(gregtech.common.pipelike.cable.BlockCable)

Aggregations

Material (gregtech.api.unification.material.Material)76 ItemStack (net.minecraft.item.ItemStack)31 UnificationEntry (gregtech.api.unification.stack.UnificationEntry)19 OrePrefix (gregtech.api.unification.ore.OrePrefix)13 MaterialStack (gregtech.api.unification.stack.MaterialStack)12 Nonnull (javax.annotation.Nonnull)10 PropertyKey (gregtech.api.unification.material.properties.PropertyKey)9 Block (net.minecraft.block.Block)8 IBlockState (net.minecraft.block.state.IBlockState)8 GTValues (gregtech.api.GTValues)7 Collectors (java.util.stream.Collectors)7 Nullable (javax.annotation.Nullable)7 Materials (gregtech.api.unification.material.Materials)6 DustProperty (gregtech.api.unification.material.properties.DustProperty)6 ToolProperty (gregtech.api.unification.material.properties.ToolProperty)6 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)6 GregTechAPI (gregtech.api.GregTechAPI)5 OreDictUnifier (gregtech.api.unification.OreDictUnifier)5 MarkerMaterial (gregtech.api.unification.material.MarkerMaterial)5 ItemMaterialInfo (gregtech.api.unification.stack.ItemMaterialInfo)5