Search in sources :

Example 1 with Material

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

the class MaterialMetaItem method registerOreDict.

public void registerOreDict() {
    for (short metaItem : generatedItems) {
        OrePrefix prefix = this.orePrefixes[metaItem / 1000];
        Material material = Material.MATERIAL_REGISTRY.getObjectById(metaItem % 1000);
        OreDictUnifier.registerOre(new ItemStack(this, 1, metaItem), prefix, material);
    }
}
Also used : OrePrefix(gregtech.api.unification.ore.OrePrefix) Material(gregtech.api.unification.material.type.Material) MarkerMaterial(gregtech.api.unification.material.type.MarkerMaterial) ItemStack(net.minecraft.item.ItemStack)

Example 2 with Material

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

the class MaterialMetaItem method addInformation.

// TODO DELETE ON RELEASE
@Override
public void addInformation(ItemStack itemStack, @Nullable World worldIn, List<String> lines, ITooltipFlag tooltipFlag) {
    if (itemStack.getMetadata() >= 32000)
        return;
    OrePrefix prefix = this.orePrefixes[itemStack.getMetadata() / 1000];
    Material material = Material.MATERIAL_REGISTRY.getObjectById(itemStack.getMetadata() % 1000);
    if (prefix != null) {
        lines.add("IconType: " + prefix.materialIconType);
    }
    if (material != null) {
        lines.add("IconSet: " + material.materialIconSet);
    }
}
Also used : OrePrefix(gregtech.api.unification.ore.OrePrefix) Material(gregtech.api.unification.material.type.Material) MarkerMaterial(gregtech.api.unification.material.type.MarkerMaterial)

Example 3 with Material

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

the class ToolMetaItem method onCreated.

@Override
public void onCreated(ItemStack stack, World world, EntityPlayer player) {
    T metaToolValueItem = getItem(stack);
    if (metaToolValueItem != null) {
        IToolStats toolStats = metaToolValueItem.getToolStats();
        toolStats.onToolCrafted(stack, player);
        ArrayList<EnchantmentData> enchantments = new ArrayList<>(toolStats.getEnchantments(stack));
        SolidMaterial material = getPrimaryMaterial(stack);
        if (material == null) {
            return;
        }
        for (EnchantmentData enchantmentData : material.toolEnchantments) {
            Optional<EnchantmentData> sameEnchantment = enchantments.stream().filter(it -> it.enchantment == enchantmentData.enchantment).findAny();
            if (sameEnchantment.isPresent()) {
                enchantments.remove(sameEnchantment.get());
                int level = Math.min(enchantmentData.level + sameEnchantment.get().level, enchantmentData.enchantment.getMaxLevel());
                enchantments.add(new EnchantmentData(enchantmentData.enchantment, level));
            } else {
                enchantments.add(enchantmentData);
            }
        }
        for (EnchantmentData enchantmentData : enchantments) {
            stack.addEnchantment(enchantmentData.enchantment, enchantmentData.level);
        }
    }
}
Also used : ToolDictNames(gregtech.api.items.ToolDictNames) SolidMaterial(gregtech.api.unification.material.type.SolidMaterial) SimpleItemStack(gregtech.api.unification.stack.SimpleItemStack) Constants(net.minecraftforge.common.util.Constants) Materials(gregtech.api.unification.material.Materials) EntityEquipmentSlot(net.minecraft.inventory.EntityEquipmentSlot) Multimap(com.google.common.collect.Multimap) IDamagableItem(gregtech.api.items.IDamagableItem) EnchantmentData(gregtech.api.enchants.EnchantmentData) Material(gregtech.api.unification.material.type.Material) ModelBakery(net.minecraft.client.renderer.block.model.ModelBakery) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) HashMultimap(com.google.common.collect.HashMultimap) GregTechAPI(gregtech.api.GregTechAPI) Side(net.minecraftforge.fml.relauncher.Side) OreDictionary(net.minecraftforge.oredict.OreDictionary) MetaItem(gregtech.api.items.metaitem.MetaItem) CreativeTabs(net.minecraft.creativetab.CreativeTabs) ModelLoader(net.minecraftforge.client.model.ModelLoader) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) SoundCategory(net.minecraft.util.SoundCategory) Nullable(javax.annotation.Nullable) IMetaItemStats(gregtech.api.items.metaitem.stats.IMetaItemStats) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) Entity(net.minecraft.entity.Entity) AttributeModifier(net.minecraft.entity.ai.attributes.AttributeModifier) World(net.minecraft.world.World) Collection(java.util.Collection) BlockPos(net.minecraft.util.math.BlockPos) SharedMonsterAttributes(net.minecraft.entity.SharedMonsterAttributes) IElectricItem(gregtech.api.capability.IElectricItem) IBlockState(net.minecraft.block.state.IBlockState) GTValues(gregtech.api.GTValues) Validate(org.apache.commons.lang3.Validate) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityDamageSource(net.minecraft.util.EntityDamageSource) ResourceLocation(net.minecraft.util.ResourceLocation) Optional(java.util.Optional) GTUtility(gregtech.api.util.GTUtility) SoundEvent(net.minecraft.util.SoundEvent) SolidMaterial(gregtech.api.unification.material.type.SolidMaterial) ArrayList(java.util.ArrayList) EnchantmentData(gregtech.api.enchants.EnchantmentData)

Example 4 with Material

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

the class MetaBlocks method init.

public static void init() {
    MACHINE = new BlockMachine();
    MACHINE.setRegistryName("machine");
    CABLE = new BlockCable(64, 2, 0);
    CABLE.setRegistryName("cable");
    BOILER_CASING = new BlockBoilerCasing();
    BOILER_CASING.setRegistryName("boiler_casing");
    METAL_CASING = new BlockMetalCasing();
    METAL_CASING.setRegistryName("metal_casing");
    TURBINE_CASING = new BlockTurbineCasing();
    TURBINE_CASING.setRegistryName("turbine_casing");
    MACHINE_CASING = new BlockMachineCasing();
    MACHINE_CASING.setRegistryName("machine_casing");
    MUTLIBLOCK_CASING = new BlockMultiblockCasing();
    MUTLIBLOCK_CASING.setRegistryName("multiblock_casing");
    WIRE_COIL = new BlockWireCoil();
    WIRE_COIL.setRegistryName("wire_coil");
    WARNING_SIGN = new BlockWarningSign();
    WARNING_SIGN.setRegistryName("warning_sign");
    GRANITE = new BlockGranite();
    GRANITE.setRegistryName("granite");
    BLACK_GRANITE = new StoneType(12, "black_granite", OrePrefix.oreBlackgranite, Materials.GraniteBlack, "gregtech:blocks/stones/granite/granite_black_stone", () -> GRANITE.withVariant(GraniteVariant.BLACK_GRANITE, ChiselingVariant.NORMAL), state -> state.getBlock() instanceof BlockGranite && ((BlockGranite) state.getBlock()).getVariant(state) == GraniteVariant.BLACK_GRANITE);
    RED_GRANITE = new StoneType(13, "red_granite", OrePrefix.oreRedgranite, Materials.GraniteRed, "gregtech:blocks/stones/granite/granite_red_stone", () -> GRANITE.withVariant(GraniteVariant.RED_GRANITE, ChiselingVariant.NORMAL), state -> state.getBlock() instanceof BlockGranite && ((BlockGranite) state.getBlock()).getVariant(state) == GraniteVariant.RED_GRANITE);
    MINERAL = new BlockMineral();
    MINERAL.setRegistryName("mineral");
    MARBLE = new StoneType(14, "marble", OrePrefix.oreMarble, Materials.Marble, "gregtech:blocks/stones/marble/marble_stone", () -> MINERAL.withVariant(MineralVariant.MARBLE, ChiselingVariant.NORMAL), state -> state.getBlock() instanceof BlockMineral && ((BlockMineral) state.getBlock()).getVariant(state) == BlockMineral.MineralVariant.MARBLE);
    BASALT = new StoneType(15, "basalt", OrePrefix.oreBasalt, Materials.Basalt, "gregtech:blocks/stones/basalt/basalt_stone", () -> MINERAL.withVariant(MineralVariant.BASALT, ChiselingVariant.NORMAL), state -> state.getBlock() instanceof BlockMineral && ((BlockMineral) state.getBlock()).getVariant(state) == BlockMineral.MineralVariant.BASALT);
    CONCRETE = new BlockConcrete();
    CONCRETE.setRegistryName("concrete");
    COMPRESSED = new HashMap<>();
    ORES = new ArrayList<>();
    StoneType.init();
    Material[] materialBuffer = new Material[16];
    Arrays.fill(materialBuffer, Materials._NULL);
    int generationIndex = 0;
    for (Material material : Material.MATERIAL_REGISTRY.getObjectsWithIds()) {
        if (material instanceof DustMaterial) {
            int id = Material.MATERIAL_REGISTRY.getIDForObject(material);
            int index = id / 16;
            if (index > generationIndex) {
                createCompressedBlock(materialBuffer, generationIndex);
                Arrays.fill(materialBuffer, Materials._NULL);
            }
            if (!OrePrefix.block.isIgnored(material)) {
                materialBuffer[id % 16] = material;
                generationIndex = index;
            }
            if (material.hasFlag(DustMaterial.MatFlags.GENERATE_ORE)) {
                createOreBlock((DustMaterial) material);
            }
        }
    }
    createCompressedBlock(materialBuffer, generationIndex);
}
Also used : java.util(java.util) GraniteVariant(gregtech.common.blocks.BlockGranite.GraniteVariant) Item(net.minecraft.item.Item) MetaTileEntities(gregtech.common.metatileentities.MetaTileEntities) MetaTileEntityRenderer(gregtech.api.render.MetaTileEntityRenderer) Materials(gregtech.api.unification.material.Materials) StoneType(gregtech.api.unification.ore.StoneType) Material(gregtech.api.unification.material.type.Material) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) StoneTypes(gregtech.api.unification.ore.StoneTypes) IProperty(net.minecraft.block.properties.IProperty) GregTechAPI(gregtech.api.GregTechAPI) Block(net.minecraft.block.Block) Minecraft(net.minecraft.client.Minecraft) Side(net.minecraftforge.fml.relauncher.Side) ChiselingVariant(gregtech.common.blocks.StoneBlock.ChiselingVariant) OrePrefix(gregtech.api.unification.ore.OrePrefix) ModelLoader(net.minecraftforge.client.model.ModelLoader) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) DefaultStateMapper(net.minecraft.client.renderer.block.statemap.DefaultStateMapper) ClientProxy(gregtech.common.ClientProxy) Streams(com.google.common.collect.Streams) Collectors(java.util.stream.Collectors) IBlockState(net.minecraft.block.state.IBlockState) DustMaterial(gregtech.api.unification.material.type.DustMaterial) MineralVariant(gregtech.common.blocks.BlockMineral.MineralVariant) BlockMachine(gregtech.api.block.machines.BlockMachine) BlockMachine(gregtech.api.block.machines.BlockMachine) StoneType(gregtech.api.unification.ore.StoneType) Material(gregtech.api.unification.material.type.Material) DustMaterial(gregtech.api.unification.material.type.DustMaterial) DustMaterial(gregtech.api.unification.material.type.DustMaterial)

Example 5 with Material

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

the class MetaItem1 method onEntityItemUpdate.

@Override
public boolean onEntityItemUpdate(EntityItem itemEntity) {
    int damage = itemEntity.getItem().getMetadata();
    if (damage < this.metaItemOffset && damage >= 0 && !itemEntity.getEntityWorld().isRemote) {
        Material material = Material.MATERIAL_REGISTRY.getObjectById(damage % 1000);
        if (material != null) {
            int posX = MathHelper.floor(itemEntity.posX);
            int posY = MathHelper.floor(itemEntity.posY);
            int posZ = MathHelper.floor(itemEntity.posZ);
            OrePrefix prefix = this.orePrefixes[(damage / 1000)];
            if (prefix == OrePrefix.dustImpure || prefix == OrePrefix.dustPure || prefix == OrePrefix.crushed || prefix == OrePrefix.dust) {
                IBlockState blockState = itemEntity.getEntityWorld().getBlockState(new BlockPos(posX, posY, posZ));
                if (blockState.getBlock() == Blocks.CAULDRON) {
                    int waterLevel = blockState.getValue(BlockCauldron.LEVEL);
                    if (waterLevel > 0) {
                        boolean waterConsumed = false;
                        if (prefix == OrePrefix.crushed) {
                            itemEntity.setItem(OreDictUnifier.get(OrePrefix.crushedPurified, material, itemEntity.getItem().getCount()));
                            waterConsumed = true;
                        } else if (prefix == OrePrefix.dustImpure || prefix == OrePrefix.dustPure) {
                            itemEntity.setItem(OreDictUnifier.get(OrePrefix.dust, material, itemEntity.getItem().getCount()));
                            waterConsumed = true;
                        }
                        if (waterConsumed) {
                            itemEntity.getEntityWorld().setBlockState(new BlockPos(posX, posY, posZ), blockState.withProperty(BlockCauldron.LEVEL, waterLevel - 1));
                        }
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) OrePrefix(gregtech.api.unification.ore.OrePrefix) Material(gregtech.api.unification.material.type.Material) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

Material (gregtech.api.unification.material.type.Material)17 OrePrefix (gregtech.api.unification.ore.OrePrefix)11 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)6 DustMaterial (gregtech.api.unification.material.type.DustMaterial)5 MarkerMaterial (gregtech.api.unification.material.type.MarkerMaterial)5 java.util (java.util)4 Nullable (javax.annotation.Nullable)4 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)4 ItemStack (net.minecraft.item.ItemStack)4 GregTechAPI (gregtech.api.GregTechAPI)3 Materials (gregtech.api.unification.material.Materials)3 SolidMaterial (gregtech.api.unification.material.type.SolidMaterial)3 SimpleItemStack (gregtech.api.unification.stack.SimpleItemStack)3 IBlockState (net.minecraft.block.state.IBlockState)3 CaseFormat (com.google.common.base.CaseFormat)2 Joiner (com.google.common.base.Joiner)2 ImmutableList (com.google.common.collect.ImmutableList)2 Streams (com.google.common.collect.Streams)2 M (gregtech.api.GTValues.M)2 BlockMachine (gregtech.api.block.machines.BlockMachine)2