Search in sources :

Example 1 with SolidMaterial

use of gregtech.api.unification.material.type.SolidMaterial 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 2 with SolidMaterial

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

the class ProcessingCrushed method registerOre.

/*public static void register() {
	    ProcessingCrushed processing = new ProcessingCrushed();
		OrePrefix.clump.addProcessingHandler(processing);
		OrePrefix.shard.addProcessingHandler(processing);
		OrePrefix.crushed.addProcessingHandler(processing);
		OrePrefix.dirtyGravel.addProcessingHandler(processing);
	}*/
public void registerOre(UnificationEntry entry, String modName, SimpleItemStack simpleStack) {
    ItemStack stack = simpleStack.asItemStack();
    if (entry.material instanceof SolidMaterial) {
        SolidMaterial material = (SolidMaterial) entry.material;
        ItemStack impureDustStack = OreDictUnifier.get(OrePrefix.dustImpure, material);
        ItemStack dustStack = OreDictUnifier.get(OrePrefix.dust, material);
        DustMaterial byproductMaterial = GTUtility.selectItemInList(0, material, material.oreByProducts, DustMaterial.class);
        // fallback for dirtyGravel, shard & clump
        if (impureDustStack.isEmpty()) {
            impureDustStack = dustStack;
        }
        RecipeMap.HAMMER_RECIPES.recipeBuilder().inputs(stack).outputs(impureDustStack).duration(10).EUt(16).buildAndRegister();
        RecipeMap.MACERATOR_RECIPES.recipeBuilder().inputs(stack).outputs(impureDustStack).duration(100).EUt(24).chancedOutput(OreDictUnifier.get(OrePrefix.dust, byproductMaterial), 1000);
        RecipeMap.ORE_WASHER_RECIPES.recipeBuilder().inputs(stack).fluidInputs(ModHandler.getWater(1000)).outputs(OreDictUnifier.get(entry.orePrefix == OrePrefix.crushed ? OrePrefix.crushedPurified : OrePrefix.dustPure, material), OreDictUnifier.get(OrePrefix.dustTiny, byproductMaterial), OreDictUnifier.get(OrePrefix.dust, Materials.Stone)).buildAndRegister();
        RecipeMap.THERMAL_CENTRIFUGE_RECIPES.recipeBuilder().inputs(stack).duration((int) entry.material.getMass() * 20).outputs(OreDictUnifier.get(entry.orePrefix == OrePrefix.crushed ? OrePrefix.crushedCentrifuged : OrePrefix.dust, entry.material), OreDictUnifier.get(OrePrefix.dustTiny, byproductMaterial), OreDictUnifier.get(OrePrefix.dust, Materials.Stone)).buildAndRegister();
        if (material.washedIn != null) {
            DustMaterial washingByproduct = GTUtility.selectItemInList(3, material, material.oreByProducts, DustMaterial.class);
            RecipeMap.CHEMICAL_BATH_RECIPES.recipeBuilder().inputs(stack).fluidInputs(material.washedIn.getFluid(1000)).outputs(OreDictUnifier.get(entry.orePrefix == OrePrefix.crushed ? OrePrefix.crushedPurified : OrePrefix.dustPure, entry.material)).chancedOutput(OreDictUnifier.get(OrePrefix.dust, washingByproduct), 7000).chancedOutput(OreDictUnifier.get(OrePrefix.dust, Materials.Stone), 4000).duration(800).EUt(8).buildAndRegister();
        }
    }
}
Also used : SolidMaterial(gregtech.api.unification.material.type.SolidMaterial) DustMaterial(gregtech.api.unification.material.type.DustMaterial) SimpleItemStack(gregtech.api.unification.stack.SimpleItemStack) ItemStack(net.minecraft.item.ItemStack)

Example 3 with SolidMaterial

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

the class ProcessingCrushedCentrifuged method registerOre.

public void registerOre(UnificationEntry entry, String modName, SimpleItemStack itemStack) {
    if (entry.material instanceof SolidMaterial) {
        ItemStack stack = itemStack.asItemStack();
        SolidMaterial solidMaterial = (SolidMaterial) entry.material;
        ItemStack dustStack = OreDictUnifier.get(OrePrefix.dust, solidMaterial);
        ItemStack byproductStack = OreDictUnifier.get(OrePrefix.dust, GTUtility.selectItemInList(2, solidMaterial, solidMaterial.oreByProducts, DustMaterial.class), 1);
        RecipeMap.HAMMER_RECIPES.recipeBuilder().inputs(stack).outputs(dustStack).duration(10).EUt(16).buildAndRegister();
        RecipeMap.MACERATOR_RECIPES.recipeBuilder().inputs(stack).outputs(dustStack).chancedOutput(byproductStack, 1000).buildAndRegister();
    }
}
Also used : SolidMaterial(gregtech.api.unification.material.type.SolidMaterial) DustMaterial(gregtech.api.unification.material.type.DustMaterial) ItemStack(net.minecraft.item.ItemStack) SimpleItemStack(gregtech.api.unification.stack.SimpleItemStack)

Example 4 with SolidMaterial

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

the class ProcessingCrushedPurified method registerOre.

// public static void register() {
// OrePrefix.crushedPurified.addProcessingHandler(new ProcessingCrushedPurified());
// }
// @Override
public void registerOre(UnificationEntry entry, String modName, SimpleItemStack itemStack) {
    if (entry.material instanceof SolidMaterial) {
        ItemStack crushedPurifiedStack = itemStack.asItemStack();
        SolidMaterial solidMaterial = (SolidMaterial) entry.material;
        ItemStack crushedCentrifugedStack = OreDictUnifier.get(OrePrefix.crushedCentrifuged, solidMaterial);
        ItemStack dustStack = OreDictUnifier.get(OrePrefix.dust, solidMaterial);
        ItemStack byproductStack = OreDictUnifier.get(OrePrefix.dustTiny, GTUtility.selectItemInList(1, solidMaterial, solidMaterial.oreByProducts, DustMaterial.class));
        if (!crushedCentrifugedStack.isEmpty()) {
            RecipeMap.THERMAL_CENTRIFUGE_RECIPES.recipeBuilder().inputs(crushedPurifiedStack).outputs(crushedCentrifugedStack, byproductStack).duration((int) (entry.material.getMass() * 20)).EUt(60).buildAndRegister();
        } else {
            RecipeMap.THERMAL_CENTRIFUGE_RECIPES.recipeBuilder().inputs(crushedPurifiedStack).outputs(dustStack, byproductStack).duration((int) (entry.material.getMass() * 20)).EUt(60).buildAndRegister();
        }
        if (entry.material instanceof GemMaterial) {
            ItemStack exquisiteStack = OreDictUnifier.get(OrePrefix.gemExquisite, entry.material);
            ItemStack flawlessStack = OreDictUnifier.get(OrePrefix.gemFlawless, entry.material);
            ItemStack gemStack = OreDictUnifier.get(OrePrefix.gem, entry.material);
            ItemStack flawedStack = OreDictUnifier.get(OrePrefix.gemFlawed, entry.material);
            ItemStack chippedStack = OreDictUnifier.get(OrePrefix.gemChipped, entry.material);
            if (entry.material.hasFlag(GemMaterial.MatFlags.HIGH_SIFTER_OUTPUT)) {
                RecipeMap.SIFTER_RECIPES.recipeBuilder().inputs(crushedPurifiedStack).chancedOutput(exquisiteStack, 300).chancedOutput(flawlessStack, 1200).chancedOutput(gemStack, 4500).chancedOutput(flawedStack, 1400).chancedOutput(chippedStack, 2800).chancedOutput(dustStack, 3500).duration(800).EUt(16).buildAndRegister();
            } else {
                RecipeMap.SIFTER_RECIPES.recipeBuilder().inputs(crushedPurifiedStack).chancedOutput(exquisiteStack, 100).chancedOutput(flawlessStack, 400).chancedOutput(gemStack, 1500).chancedOutput(flawedStack, 2000).chancedOutput(chippedStack, 4000).chancedOutput(dustStack, 5000).duration(800).EUt(16).buildAndRegister();
            }
        }
    }
}
Also used : SolidMaterial(gregtech.api.unification.material.type.SolidMaterial) DustMaterial(gregtech.api.unification.material.type.DustMaterial) ItemStack(net.minecraft.item.ItemStack) SimpleItemStack(gregtech.api.unification.stack.SimpleItemStack) GemMaterial(gregtech.api.unification.material.type.GemMaterial)

Example 5 with SolidMaterial

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

the class ProcessingPure method registerOre.

public void registerOre(UnificationEntry entry, String modName, SimpleItemStack simpleStack) {
    if (entry.material instanceof SolidMaterial) {
        SolidMaterial material = (SolidMaterial) entry.material;
        ItemStack stack = simpleStack.asItemStack();
        DustMaterial byproductMaterial = GTUtility.selectItemInList(1, material, material.oreByProducts, DustMaterial.class);
        ItemStack pureDustStack = OreDictUnifier.get(OrePrefix.dustPure, material);
        if (pureDustStack.isEmpty()) {
            // fallback for reduced & cleanGravel
            pureDustStack = OreDictUnifier.get(OrePrefix.dust, material);
        }
        RecipeMap.HAMMER_RECIPES.recipeBuilder().inputs(stack).outputs(OreDictUnifier.get(OrePrefix.dustPure, material)).duration(10).EUt(16).buildAndRegister();
        RecipeMap.MACERATOR_RECIPES.recipeBuilder().inputs(stack).outputs(pureDustStack).chancedOutput(OreDictUnifier.get(OrePrefix.dust, byproductMaterial), 1000).buildAndRegister();
    }
}
Also used : SolidMaterial(gregtech.api.unification.material.type.SolidMaterial) DustMaterial(gregtech.api.unification.material.type.DustMaterial) ItemStack(net.minecraft.item.ItemStack) SimpleItemStack(gregtech.api.unification.stack.SimpleItemStack)

Aggregations

SolidMaterial (gregtech.api.unification.material.type.SolidMaterial)15 SimpleItemStack (gregtech.api.unification.stack.SimpleItemStack)9 ItemStack (net.minecraft.item.ItemStack)9 DustMaterial (gregtech.api.unification.material.type.DustMaterial)4 Material (gregtech.api.unification.material.type.Material)3 UnificationEntry (gregtech.api.unification.stack.UnificationEntry)3 Nullable (javax.annotation.Nullable)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 HashMultimap (com.google.common.collect.HashMultimap)1 Multimap (com.google.common.collect.Multimap)1 GTValues (gregtech.api.GTValues)1 GregTechAPI (gregtech.api.GregTechAPI)1 IElectricItem (gregtech.api.capability.IElectricItem)1 EnchantmentData (gregtech.api.enchants.EnchantmentData)1 IDamagableItem (gregtech.api.items.IDamagableItem)1 ToolDictNames (gregtech.api.items.ToolDictNames)1 MetaItem (gregtech.api.items.metaitem.MetaItem)1 IMetaItemStats (gregtech.api.items.metaitem.stats.IMetaItemStats)1 Materials (gregtech.api.unification.material.Materials)1 GemMaterial (gregtech.api.unification.material.type.GemMaterial)1