Search in sources :

Example 26 with OreDictItemData

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

the class MultiTileEntityMoldCoinage method onBlockActivated3.

@Override
public boolean onBlockActivated3(EntityPlayer aPlayer, byte aSide, float aHitX, float aHitY, float aHitZ) {
    if (isServerSide() && SIDES_TOP_HORIZONTAL[aSide]) {
        ItemStack tOutputStack = slot(0);
        ItemStack aStack = aPlayer.getCurrentEquippedItem();
        if (tOutputStack == null) {
            OreDictItemData tData = OM.anyassociation(aStack);
            if (tData != null && tData.mPrefix == OP.plateTiny) {
                if (!UT.Entities.hasInfiniteItems(aPlayer))
                    aStack.stackSize--;
                slot(0, ST.amount(1, aStack));
                UT.Sounds.send(SFX.MC_CLICK, this);
                return T;
            }
        } else {
            if (UT.Inventories.addStackToPlayerInventory(aPlayer, tOutputStack, F))
                slotKill(0);
        }
    }
    return F;
}
Also used : OreDictItemData(gregapi.oredict.OreDictItemData) ItemStack(net.minecraft.item.ItemStack)

Example 27 with OreDictItemData

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

the class MultiTileEntityDustFunnel method onTick2.

@Override
public void onTick2(long aTimer, boolean aIsServerSide) {
    if (aIsServerSide) {
        boolean temp = (mInventoryChanged || aTimer % 100 == 0);
        slotNull(0);
        if (temp && !slotHas(0))
            ST.move(getAdjacentInventory(SIDE_TOP), delegator(SIDE_TOP));
        if (slotHas(0) && (mContent == null || mContent.mAmount < DUST_TYPES[mMode].mAmount)) {
            OreDictItemData tData = OM.anydata(slot(0));
            if (OM.prefixcontainsmaterialmatches(tData, mContent == null || mContent.mMaterial == MT.NULL ? null : mContent.mMaterial, TD.Prefix.DUST_BASED)) {
                int tSize = (int) Math.min(slot(0).stackSize, UT.Code.divup(DUST_TYPES[mMode].mAmount - (mContent == null ? 0 : mContent.mAmount), tData.mMaterial.mAmount));
                mContent = OM.stack(tData.mMaterial.mMaterial, tData.mMaterial.mAmount * tSize + (mContent == null ? 0 : mContent.mAmount));
                decrStackSize(0, tSize);
                temp = T;
            }
        }
        mDust = (mContent != null && (mContent.mAmount > 0 || slotHas(1)) ? mContent.mMaterial.mID : 0);
        if (mContent != null && !slotHas(1) && mContent.mAmount >= DUST_TYPES[mMode].mAmount) {
            ItemStack tStack = DUST_TYPES[mMode].mat(mContent.mMaterial, 1);
            if (tStack != null) {
                slot(1, tStack);
                mContent.mAmount -= DUST_TYPES[mMode].mAmount;
                if (mContent.mAmount <= 0)
                    mContent = null;
                temp = T;
            }
        }
        if (temp && slotHas(1))
            ST.move(delegator(SIDE_BOTTOM), getAdjacentInventory(SIDE_BOTTOM));
    }
}
Also used : OreDictItemData(gregapi.oredict.OreDictItemData) ItemStack(net.minecraft.item.ItemStack)

Example 28 with OreDictItemData

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

the class MultiTileEntityRock method onToolClick.

@Override
public long onToolClick(String aTool, long aRemainingDurability, long aQuality, Entity aPlayer, List<String> aChatReturn, IInventory aPlayerInventory, boolean aSneaking, ItemStack aStack, byte aSide, float aHitX, float aHitY, float aHitZ) {
    if (isServerSide() && aTool.equals(TOOL_magnifyingglass)) {
        if (aPlayer instanceof EntityPlayer && aSneaking) {
            UT.Inventories.addStackToPlayerInventoryOrDrop((EntityPlayer) aPlayer, mRock == null ? getDefaultRock(1) : ST.amount(1, mRock), T, worldObj, xCoord + 0.5, yCoord + 0.5, zCoord + 0.5);
            playCollect();
            setToAir();
            return 0;
        }
        if (aChatReturn == null)
            return 1;
        if (mRock == null) {
            if (worldObj.provider.dimensionId == -1) {
                aChatReturn.add(LH.Chat.GRAY + "This is definitely a Rack");
                return 1;
            }
            if (worldObj.provider.dimensionId == 0) {
                aChatReturn.add(LH.Chat.GRAY + "This is definitely a Rock");
                return 1;
            }
            if (worldObj.provider.dimensionId == +1) {
                aChatReturn.add(LH.Chat.GRAY + "There is definitely an End");
                return 1;
            }
            if (WD.dimAETHER(worldObj)) {
                aChatReturn.add(LH.Chat.GRAY + "Holy $#!T, it's a Rock..");
                return 1;
            }
            if (WD.dimALF(worldObj)) {
                aChatReturn.add(LH.Chat.GRAY + "Wait that Rock is alive?!");
                return 1;
            }
            if (WD.dimTROPIC(worldObj)) {
                aChatReturn.add(LH.Chat.GRAY + "Seems to be a Chunk o'Head");
                return 1;
            }
            if (BIOMES_MOON.contains(getBiome().biomeName)) {
                aChatReturn.add(LH.Chat.GRAY + "This is definitely not made of Cheese");
                return 1;
            }
            if (BIOMES_MARS.contains(getBiome().biomeName)) {
                aChatReturn.add(LH.Chat.GRAY + "This is definitely from Mars");
                return 1;
            }
            if (BIOMES_SPACE.contains(getBiome().biomeName)) {
                aChatReturn.add(LH.Chat.GRAY + "This is definitely a Space Rock");
                return 1;
            }
            aChatReturn.add(LH.Chat.GRAY + "This definitely is a Rock");
            return 1;
        }
        if (OD.itemFlint.is_(mRock)) {
            aChatReturn.add(LH.Chat.GRAY + (APRIL_FOOLS || rng(WOODMANS_BDAY ? 10 : XMAS_IN_JULY ? 100 : 1000) == 0 ? "Flintstones, meet the Flintstones, they're the modern Stone Age family" : "It's a Flint"));
            return 1;
        }
        OreDictItemData tData = OM.anydata_(mRock);
        if (tData != null && tData.hasValidMaterialData()) {
            if (tData.mMaterial.mMaterial == MT.MeteoricIron || tData.mMaterial.mMaterial == MT.Meteorite) {
                aChatReturn.add(LH.Chat.ORANGE + "Looks like it fell from the Sky!");
                return 1;
            }
            if (tData.mMaterial.mMaterial == MT.AncientDebris) {
                aChatReturn.add(LH.Chat.PINK + "Looks quite old and broken");
                return 1;
            }
            if (tData.mMaterial.mMaterial == MT.Stone) {
                aChatReturn.add(LH.Chat.GRAY + "This is definitely a Rock");
                return 1;
            }
            if (tData.mMaterial.mMaterial == MT.Netherrack) {
                aChatReturn.add(LH.Chat.GRAY + "This is definitely a Rack");
                return 1;
            }
            if (tData.mMaterial.mMaterial == MT.Endstone) {
                aChatReturn.add(LH.Chat.GRAY + "There is definitely an End");
                return 1;
            }
            if (tData.mMaterial.mMaterial == MT.PetrifiedWood) {
                aChatReturn.add(LH.Chat.GRAY + "Looks like a nice piece of Wood" + LH.Chat._BLACK + ">:]");
                return 1;
            }
            if (tData.mMaterial.mMaterial.contains(TD.Properties.GLOWING)) {
                aChatReturn.add(LH.Chat.YELLOW + "Glows a little");
                return 1;
            }
            if (tData.mMaterial.mMaterial.contains(TD.Properties.STONE)) {
                aChatReturn.add(LH.Chat.GRAY + "This Rock consists out of " + LH.Chat.WHITE + tData.mMaterial.mMaterial.getLocal());
                return 1;
            }
            aChatReturn.add(LH.Chat.GRAY + "This Rock is bearing " + LH.Chat.CYAN + tData.mMaterial.mMaterial.getLocal());
            return 1;
        }
        return 1;
    }
    return 0;
}
Also used : OreDictItemData(gregapi.oredict.OreDictItemData) EntityPlayer(net.minecraft.entity.player.EntityPlayer)

Example 29 with OreDictItemData

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

the class MultiTileEntityAnvil method onTick2.

@Override
public void onTick2(long aTimer, boolean aIsServerSide) {
    if (aIsServerSide) {
        if (mInventoryChanged) {
            mShapeA = mShapeB = 0;
            if (ToolsGT.contains(TOOL_hammer, slot(0))) {
                mMaterialA = MultiItemTool.getPrimaryMaterial(slot(0), MT.Steel).mID;
                if (mMaterialA <= 0)
                    mMaterialA = MT.Steel.mID;
                mShapeA = 8;
            } else if (ToolsGT.contains(TOOL_hammer, slot(1))) {
                mMaterialA = MultiItemTool.getSecondaryMaterial(slot(1), MT.WOODS.Spruce).mID;
                if (mMaterialA <= 0)
                    mMaterialA = MT.WOODS.Spruce.mID;
                mShapeA = 9;
            } else if (slotHas(0)) {
                mMaterialA = MT.Fe.mID;
                OreDictItemData tData = OM.anydata(slot(0));
                if (tData != null) {
                    if (tData.mMaterial != null && tData.mMaterial.mMaterial.mID > 0)
                        mMaterialA = tData.mMaterial.mMaterial.mID;
                    if (tData.mPrefix != null) {
                        if (tData.mPrefix.containsAny(TD.Prefix.INGOT_BASED))
                            mShapeA = 1;
                        else if (tData.mPrefix.mNameInternal.startsWith("plate"))
                            mShapeA = 2;
                        else if (tData.mPrefix.mNameInternal.startsWith("plank"))
                            mShapeA = 2;
                        else if (tData.mPrefix.mNameInternal.startsWith("stick"))
                            mShapeA = 3;
                        else if (tData.mPrefix.mNameInternal.startsWith("wire"))
                            mShapeA = 3;
                        else if (tData.mPrefix.mNameInternal.startsWith("chunk"))
                            mShapeA = 4;
                        else if (tData.mPrefix.mNameInternal.startsWith("ring"))
                            mShapeA = 5;
                        else if (tData.mPrefix.mNameInternal.startsWith("gem"))
                            mShapeA = 6;
                        else if (tData.mPrefix.mNameInternal.startsWith("ore"))
                            mShapeA = 7;
                        else if (tData.mPrefix.mNameInternal.startsWith("rock"))
                            mShapeA = 7;
                        else if (tData.mPrefix.containsAny(TD.Prefix.ORE, TD.Prefix.ORE_PROCESSING_BASED))
                            mShapeA = 7;
                        else
                            mShapeA = 0;
                    }
                }
            } else {
                mMaterialA = 0;
            }
            if (ToolsGT.contains(TOOL_hammer, slot(1))) {
                mMaterialB = MultiItemTool.getPrimaryMaterial(slot(1), MT.Steel).mID;
                if (mMaterialB <= 0)
                    mMaterialB = MT.Steel.mID;
                mShapeB = 8;
            } else if (ToolsGT.contains(TOOL_hammer, slot(0))) {
                mMaterialB = MultiItemTool.getSecondaryMaterial(slot(0), MT.WOODS.Spruce).mID;
                if (mMaterialB <= 0)
                    mMaterialB = MT.WOODS.Spruce.mID;
                mShapeB = 9;
            } else if (slotHas(1)) {
                mMaterialB = MT.Fe.mID;
                OreDictItemData tData = OM.anydata(slot(1));
                if (tData != null) {
                    if (tData.mMaterial != null && tData.mMaterial.mMaterial.mID > 0)
                        mMaterialB = tData.mMaterial.mMaterial.mID;
                    if (tData.mPrefix != null) {
                        if (tData.mPrefix.containsAny(TD.Prefix.INGOT_BASED))
                            mShapeB = 1;
                        else if (tData.mPrefix.mNameInternal.startsWith("plate"))
                            mShapeB = 2;
                        else if (tData.mPrefix.mNameInternal.startsWith("plank"))
                            mShapeB = 2;
                        else if (tData.mPrefix.mNameInternal.startsWith("stick"))
                            mShapeB = 3;
                        else if (tData.mPrefix.mNameInternal.startsWith("wire"))
                            mShapeB = 3;
                        else if (tData.mPrefix.mNameInternal.startsWith("chunk"))
                            mShapeB = 4;
                        else if (tData.mPrefix.mNameInternal.startsWith("ring"))
                            mShapeB = 5;
                        else if (tData.mPrefix.mNameInternal.startsWith("gem"))
                            mShapeB = 6;
                        else if (tData.mPrefix.mNameInternal.startsWith("ore"))
                            mShapeB = 7;
                        else if (tData.mPrefix.mNameInternal.startsWith("rock"))
                            mShapeB = 7;
                        else if (tData.mPrefix.containsAny(TD.Prefix.ORE, TD.Prefix.ORE_PROCESSING_BASED))
                            mShapeB = 7;
                        else
                            mShapeB = 0;
                    }
                }
            } else {
                mMaterialB = 0;
            }
            updateClientData();
        }
    }
}
Also used : OreDictItemData(gregapi.oredict.OreDictItemData)

Example 30 with OreDictItemData

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

the class MultiTileEntityBathingPot method onTick2.

@Override
public void onTick2(long aTimer, boolean aIsServerSide) {
    if (aIsServerSide) {
        if (SERVER_TIME % 600 == 10 && worldObj.isRaining() && getRainOffset(0, 1, 0)) {
            BiomeGenBase tBiome = getBiome();
            if (tBiome.rainfall > 0 && tBiome.temperature >= 0.2) {
                Block tInFront = getBlockAtSide(SIDE_TOP);
                if (!(tInFront instanceof BlockLiquid) && !(tInFront instanceof IFluidBlock) && !tInFront.isSideSolid(worldObj, xCoord, yCoord + 1, zCoord, FORGE_DIR_OPPOSITES[SIDE_TOP]) && !tInFront.isSideSolid(worldObj, xCoord, yCoord + 1, zCoord, FORGE_DIR[SIDE_TOP])) {
                    FluidStack tWater = FL.Water.make((long) Math.max(1, tBiome.rainfall * 200) * (worldObj.isThundering() ? 2 : 1));
                    if (tWater != null) {
                        IFluidTank tTank = getFluidTankFillable2(SIDE_TOP, tWater);
                        if (tTank != null)
                            tTank.fill(tWater, T);
                    }
                }
            }
        }
        boolean tBreak = F;
        mDisplay = 0;
        for (FluidTankGT tTank : mTanksOutput) if (tTank.has()) {
            mDisplay = (short) (-2 - tTank.getFluid().getFluidID());
            tBreak = T;
            break;
        }
        if (!tBreak) {
            for (FluidTankGT tTank : mTanksInput) if (tTank.has()) {
                mDisplay = (short) (-2 - tTank.getFluid().getFluidID());
                tBreak = T;
                break;
            }
            if (!tBreak) {
                ItemStack tStack;
                for (int i = 0; i < 7; i++) if (ST.valid(tStack = slot(6 - i))) {
                    OreDictItemData tData = OM.data_(tStack);
                    if (tData == null || tData.mMaterial == null) {
                        mDisplay = -1;
                    } else {
                        mDisplay = tData.mMaterial.mMaterial.mID;
                    }
                    tBreak = T;
                    break;
                }
            }
        }
    }
}
Also used : BlockLiquid(net.minecraft.block.BlockLiquid) FluidStack(net.minecraftforge.fluids.FluidStack) FluidTankGT(gregapi.fluid.FluidTankGT) OreDictItemData(gregapi.oredict.OreDictItemData) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Block(net.minecraft.block.Block) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) BiomeGenBase(net.minecraft.world.biome.BiomeGenBase) ItemStack(net.minecraft.item.ItemStack) IFluidTank(net.minecraftforge.fluids.IFluidTank)

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