Search in sources :

Example 41 with OreDictItemData

use of gregapi.oredict.OreDictItemData in project gregtech6 by GregTech6.

the class MT method wood.

/**
 * Making the Table a little bit more overviewable. DO NOT USE THESE FUNCTIONS YOURSELF!!! Use "OreDictMaterial.createMaterial(YOUR-ID-AS-SPECIFIED-IN-THE-ID-RANGES, OREDICT-NAME, LOCALISED-NAME)"
 */
static OreDictMaterial wood(int aID, String aNameOreDict, TextureSet[] aSets, long aR, long aG, long aB, long aA, Object... aRandomData) {
    OreDictMaterial rMaterial = create(aID, aNameOreDict, aSets, aR, aG, aB, aA, aRandomData, G_WOOD, ANY.Wood, ANY.WoodPlastic, WOOD, MORTAR);
    String tPlank = "plank" + rMaterial.mNameInternal;
    OreDictManager.INSTANCE.addAutoBlackListing(tPlank);
    OreDictManager.INSTANCE.addReRegistration(tPlank, OD.plankAnyWood);
    if ("Wood".equalsIgnoreCase(rMaterial.mNameInternal))
        return rMaterial;
    OreDictManager.INSTANCE.setAutomaticItemData(tPlank, new OreDictItemData(rMaterial, U));
    OreDictManager.INSTANCE.addReRegistrationWithReversal("plate" + rMaterial.mNameInternal, tPlank);
    return rMaterial;
}
Also used : OreDictMaterial(gregapi.oredict.OreDictMaterial) OreDictItemData(gregapi.oredict.OreDictItemData)

Example 42 with OreDictItemData

use of gregapi.oredict.OreDictItemData in project gregtech6 by GregTech6.

the class MultiTileEntityPlaceable method readFromNBT2.

@Override
public void readFromNBT2(NBTTagCompound aNBT) {
    mStack = ST.load(aNBT, NBT_VALUE);
    if (ST.valid(mStack)) {
        mSize = UT.Code.bindStack(ST.size(mStack));
        OreDictItemData tData = OM.anydata(mStack);
        if (tData != null && tData.hasValidMaterialData() && tData.mMaterial.mMaterial.mID > 0)
            mMaterial = tData.mMaterial.mMaterial;
    }
    super.readFromNBT2(aNBT);
}
Also used : OreDictItemData(gregapi.oredict.OreDictItemData)

Example 43 with OreDictItemData

use of gregapi.oredict.OreDictItemData in project gregtech6 by GregTech6.

the class GT_API_Proxy method getBurnTime.

@Override
public int getBurnTime(ItemStack aFuel) {
    if (ST.invalid(aFuel) || FL.getFluid(aFuel, T) != null)
        return 0;
    Block aBlock = ST.block(aFuel);
    // Needed so Railcrafts Tunnel Bore works properly and doesn't try to burn its Rails while laying them.
    if (aBlock instanceof BlockRailBase)
        return 0;
    if (aBlock instanceof BlockHugeMushroom)
        return (3 * TICKS_PER_SMELT) / 2;
    if (aBlock == BlocksGT.BalesGrass)
        return (9 * TICKS_PER_SMELT) / ((ST.meta_(aFuel) & 3) == 1 ? 2 : 4);
    if (aBlock instanceof BlockBaseBale)
        return (9 * TICKS_PER_SMELT) / 4;
    if (aBlock instanceof BlockBasePlanks)
        return (3 * TICKS_PER_SMELT) / 2;
    if (aBlock instanceof BlockBaseSapling)
        return TICKS_PER_SMELT / 2;
    if (aBlock instanceof BlockBaseBeam || aBlock instanceof BlockBaseLog)
        return TICKS_PER_SMELT * 6;
    long rFuelValue = 0;
    if (aFuel.getItem() instanceof MultiItemRandom) {
        Short tFuelValue = ((MultiItemRandom) aFuel.getItem()).mBurnValues.get(ST.meta_(aFuel));
        if (tFuelValue != null)
            rFuelValue = Math.max(rFuelValue, tFuelValue);
    } else {
        if (OD.logWood.is_(aFuel))
            return TICKS_PER_SMELT * 6;
        if (OD.itemResin.is_(aFuel))
            return TICKS_PER_SMELT / 2;
    }
    NBTTagCompound tNBT = aFuel.getTagCompound();
    if (tNBT != null) {
        rFuelValue = Math.max(rFuelValue, tNBT.getLong(NBT_FUEL_VALUE));
    }
    OreDictItemData tData = OM.anydata_(aFuel);
    if (tData != null) {
        long tBurnTime = 0;
        if (tData.mPrefix == OP.oreRaw) {
            tBurnTime = tData.mMaterial.mMaterial.mFurnaceBurnTime;
        } else if (tData.mPrefix == OP.blockRaw) {
            tBurnTime = tData.mMaterial.mMaterial.mFurnaceBurnTime * 10;
        } else if (tData.mPrefix == null || tData.mPrefix.contains(TD.Prefix.BURNABLE)) {
            for (OreDictMaterialStack tMaterial : tData.getAllMaterialStacks()) tBurnTime += (tData.mPrefix == OP.oreRaw ? tMaterial.mMaterial.mFurnaceBurnTime : tData.mPrefix == OP.blockRaw ? tMaterial.mMaterial.mFurnaceBurnTime * 10 : UT.Code.units(tMaterial.mMaterial.mFurnaceBurnTime, U, tMaterial.mAmount, F));
            if (tData.mPrefix == OP.stick && ANY.Wood.mToThis.contains(tData.mMaterial.mMaterial))
                return (int) UT.Code.bind(0, 32000, Math.max(TICKS_PER_SMELT / 2, tBurnTime));
            if (tData.mPrefix == OP.stickLong && ANY.Wood.mToThis.contains(tData.mMaterial.mMaterial))
                return (int) UT.Code.bind(0, 32000, Math.max(TICKS_PER_SMELT, tBurnTime));
            if (tData.mPrefix == OP.blockPlate && ANY.Wood.mToThis.contains(tData.mMaterial.mMaterial))
                return (int) UT.Code.bind(0, 32000, Math.max((TICKS_PER_SMELT * 27) / 2, tBurnTime));
            if (tData.mPrefix == OP.crateGtPlate && ANY.Wood.mToThis.contains(tData.mMaterial.mMaterial))
                return (int) UT.Code.bind(0, 32000, Math.max((TICKS_PER_SMELT * 51) / 2, tBurnTime));
            if (tData.mPrefix == OP.crateGt64Plate && ANY.Wood.mToThis.contains(tData.mMaterial.mMaterial))
                return (int) UT.Code.bind(0, 32000, Math.max((TICKS_PER_SMELT * 195) / 2, tBurnTime));
        }
        rFuelValue = Math.max(rFuelValue, tBurnTime);
    }
    // return at most 160 Smelts, without any fraction smelts.
    return (int) UT.Code.bind(0, 32000, rFuelValue);
}
Also used : OreDictItemData(gregapi.oredict.OreDictItemData) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) OreDictMaterialStack(gregapi.oredict.OreDictMaterialStack) BlockBaseBale(gregapi.block.misc.BlockBaseBale) BlockRailBase(net.minecraft.block.BlockRailBase) BlockBaseSapling(gregapi.block.tree.BlockBaseSapling) BlockBasePlanks(gregapi.block.metatype.BlockBasePlanks) BlockBaseBeam(gregapi.block.tree.BlockBaseBeam) MultiItemRandom(gregapi.item.multiitem.MultiItemRandom) Block(net.minecraft.block.Block) BlockHugeMushroom(net.minecraft.block.BlockHugeMushroom) BlockBaseLog(gregapi.block.tree.BlockBaseLog) IItemNoGTOverride(gregapi.item.IItemNoGTOverride)

Example 44 with OreDictItemData

use of gregapi.oredict.OreDictItemData in project gregtech6 by GregTech6.

the class NEI_RecipeMap method loadCraftingRecipes.

@Override
public void loadCraftingRecipes(ItemStack aResult) {
    if (!CODE_CLIENT)
        return;
    if (ST.invalid(aResult))
        return;
    try {
        OreDictItemData tPrefixMaterial = OM.association_(aResult);
        ArrayList<ItemStack> tResults = new ArrayListNoNulls<>();
        tResults.add(aResult);
        tResults.add(OM.get_(aResult));
        ArrayList<ItemStack> tRedirects = ItemsGT.sNEIRedirects.get(new ItemStackContainer(aResult));
        if (tRedirects != null)
            tResults.addAll(tRedirects);
        tRedirects = ItemsGT.sNEIRedirects.get(new ItemStackContainer(aResult, W));
        if (tRedirects != null)
            tResults.addAll(tRedirects);
        if (tPrefixMaterial != null && !tPrefixMaterial.mBlackListed) {
            if (tPrefixMaterial.mMaterial.mMaterial.mID > 0 && BlocksGT.ore != null && BlocksGT.oreBroken != null && tPrefixMaterial.mPrefix.containsAny(TD.Prefix.ORE, TD.Prefix.ORE_PROCESSING_BASED)) {
                tResults.add(ST.make((Block) BlocksGT.ore, 1, tPrefixMaterial.mMaterial.mMaterial.mID));
                tResults.add(ST.make((Block) BlocksGT.oreBroken, 1, tPrefixMaterial.mMaterial.mMaterial.mID));
            }
            for (OreDictPrefix tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) {
                tResults.add(tPrefix.mat(tPrefixMaterial.mMaterial.mMaterial, 1));
            }
        }
        if (!ItemsGT.NEI_DONT_SHOW_FLUIDS.contains(aResult, T)) {
            FluidStack tFluid = FL.getFluid(aResult, T);
            if (tFluid != null) {
                tResults.add(FL.display(tFluid, F, F));
                for (FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) {
                    if (tData.fluid.isFluidEqual(tFluid))
                        tResults.add(ST.copy(tData.filledContainer));
                }
            }
        }
        ArrayList<Recipe> tRecipes = new ArrayListNoNulls<>();
        for (Recipe tRecipe : mRecipeMap.getNEIRecipes(tResults.toArray(ZL_IS))) if (!tRecipes.contains(tRecipe))
            tRecipes.add(tRecipe);
        for (Recipe tRecipe : tRecipes) arecipes.add(new CachedDefaultRecipe(tRecipe));
        sortRecipes();
    } catch (Throwable e) {
        e.printStackTrace(ERR);
    }
}
Also used : Recipe(gregapi.recipes.Recipe) OreDictItemData(gregapi.oredict.OreDictItemData) FluidStack(net.minecraftforge.fluids.FluidStack) FluidContainerData(net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData) ArrayListNoNulls(gregapi.code.ArrayListNoNulls) OreDictPrefix(gregapi.oredict.OreDictPrefix) ItemStackContainer(gregapi.code.ItemStackContainer) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack)

Example 45 with OreDictItemData

use of gregapi.oredict.OreDictItemData in project gregtech6 by GregTech6.

the class NEI_RecipeMap method loadUsageRecipes.

@Override
public void loadUsageRecipes(ItemStack aInput) {
    if (!CODE_CLIENT)
        return;
    if (ST.invalid(aInput))
        return;
    try {
        OreDictItemData tPrefixMaterial = OM.association_(aInput);
        ArrayList<ItemStack> tInputs = new ArrayListNoNulls<>();
        tInputs.add(aInput);
        tInputs.add(OreDictManager.INSTANCE.getStack_(F, aInput));
        ArrayList<ItemStack> tRedirects = ItemsGT.sNEIRedirects.get(new ItemStackContainer(aInput));
        if (tRedirects != null)
            tInputs.addAll(tRedirects);
        tRedirects = ItemsGT.sNEIRedirects.get(new ItemStackContainer(aInput, W));
        if (tRedirects != null)
            tInputs.addAll(tRedirects);
        if (tPrefixMaterial != null) {
            for (OreDictPrefix tPrefix : tPrefixMaterial.mPrefix.mFamiliarPrefixes) {
                tInputs.add(tPrefix.mat(tPrefixMaterial.mMaterial.mMaterial, 1));
            }
        }
        if (!ItemsGT.NEI_DONT_SHOW_FLUIDS.contains(aInput, T)) {
            FluidStack tFluid = FL.getFluid(aInput, T);
            if (tFluid != null) {
                tInputs.add(FL.display(tFluid, F, F));
                for (FluidContainerData tData : FluidContainerRegistry.getRegisteredFluidContainerData()) {
                    if (tData.fluid.isFluidEqual(tFluid))
                        tInputs.add(ST.copy(tData.filledContainer));
                }
            }
        }
        ArrayList<Recipe> tRecipes = new ArrayListNoNulls<>();
        for (Recipe tRecipe : mRecipeMap.getNEIUsages(tInputs.toArray(ZL_IS))) if (!tRecipes.contains(tRecipe))
            tRecipes.add(tRecipe);
        for (Recipe tRecipe : tRecipes) arecipes.add(new CachedDefaultRecipe(tRecipe));
        sortRecipes();
    } catch (Throwable e) {
        e.printStackTrace(ERR);
    }
}
Also used : OreDictPrefix(gregapi.oredict.OreDictPrefix) ItemStackContainer(gregapi.code.ItemStackContainer) Recipe(gregapi.recipes.Recipe) OreDictItemData(gregapi.oredict.OreDictItemData) FluidStack(net.minecraftforge.fluids.FluidStack) ItemStack(net.minecraft.item.ItemStack) FluidContainerData(net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData) ArrayListNoNulls(gregapi.code.ArrayListNoNulls)

Aggregations

OreDictItemData (gregapi.oredict.OreDictItemData)64 ItemStack (net.minecraft.item.ItemStack)41 OreDictMaterial (gregapi.oredict.OreDictMaterial)20 FluidStack (net.minecraftforge.fluids.FluidStack)16 ArrayListNoNulls (gregapi.code.ArrayListNoNulls)12 OreDictMaterialStack (gregapi.oredict.OreDictMaterialStack)11 EntityPlayer (net.minecraft.entity.player.EntityPlayer)10 Recipe (gregapi.recipes.Recipe)9 Block (net.minecraft.block.Block)9 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)5 List (java.util.List)5 OreDictPrefix (gregapi.oredict.OreDictPrefix)4 IOreDictListenerEvent (gregapi.oredict.event.IOreDictListenerEvent)4 OreDictListenerEvent_Names (gregapi.oredict.event.OreDictListenerEvent_Names)4 HashSetNoNulls (gregapi.code.HashSetNoNulls)3 IItemContainer (gregapi.code.IItemContainer)3 ItemStackContainer (gregapi.code.ItemStackContainer)3 PacketDeathPoint (gregapi.network.packets.PacketDeathPoint)3 EntityLivingBase (net.minecraft.entity.EntityLivingBase)3 Item (net.minecraft.item.Item)3