Search in sources :

Example 1 with IItemEmc

use of moze_intel.projecte.api.item.IItemEmc in project ProjectE by sinkillerj.

the class CollectorMK1Tile method checkFuelOrKlein.

private void checkFuelOrKlein() {
    if (getUpgrading() != null && getUpgrading().getItem() instanceof IItemEmc) {
        IItemEmc itemEmc = ((IItemEmc) getUpgrading().getItem());
        if (itemEmc.getStoredEmc(getUpgrading()) != itemEmc.getMaximumEmc(getUpgrading())) {
            hasChargeableItem = true;
            hasFuel = false;
        } else {
            hasChargeableItem = false;
        }
    } else if (getUpgrading() != null) {
        hasFuel = true;
        hasChargeableItem = false;
    } else {
        hasFuel = false;
        hasChargeableItem = false;
    }
}
Also used : IItemEmc(moze_intel.projecte.api.item.IItemEmc)

Example 2 with IItemEmc

use of moze_intel.projecte.api.item.IItemEmc in project ProjectE by sinkillerj.

the class ComparatorHelper method getForCollector.

public static int getForCollector(World world, BlockPos pos) {
    CollectorMK1Tile tile = ((CollectorMK1Tile) world.getTileEntity(pos));
    ItemStack charging = tile.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP).getStackInSlot(CollectorMK1Tile.UPGRADING_SLOT);
    if (charging != null) {
        if (charging.getItem() instanceof IItemEmc) {
            IItemEmc itemEmc = ((IItemEmc) charging.getItem());
            double max = itemEmc.getMaximumEmc(charging);
            double current = itemEmc.getStoredEmc(charging);
            return MathUtils.scaleToRedstone(current, max);
        } else {
            double needed = tile.getEmcToNextGoal();
            double current = tile.getStoredEmc();
            return MathUtils.scaleToRedstone(current, needed);
        }
    } else {
        return MathUtils.scaleToRedstone(tile.getStoredEmc(), tile.getMaximumEmc());
    }
}
Also used : CollectorMK1Tile(moze_intel.projecte.gameObjs.tiles.CollectorMK1Tile) ItemStack(net.minecraft.item.ItemStack) IItemEmc(moze_intel.projecte.api.item.IItemEmc)

Example 3 with IItemEmc

use of moze_intel.projecte.api.item.IItemEmc in project ProjectE by sinkillerj.

the class ToolTipEvent method tTipEvent.

@SubscribeEvent
public static void tTipEvent(ItemTooltipEvent event) {
    ItemStack current = event.getItemStack();
    Item currentItem = current.getItem();
    Block currentBlock = Block.getBlockFromItem(currentItem);
    if (ProjectEConfig.showPedestalTooltip && currentItem instanceof IPedestalItem) {
        event.getToolTip().add(TextFormatting.DARK_PURPLE + I18n.format("pe.pedestal.on_pedestal") + " ");
        List<String> description = ((IPedestalItem) currentItem).getPedestalDescription();
        if (description.isEmpty()) {
            event.getToolTip().add(IPedestalItem.TOOLTIPDISABLED);
        } else {
            event.getToolTip().addAll(((IPedestalItem) currentItem).getPedestalDescription());
        }
    }
    if (ProjectEConfig.showODNames) {
        for (int id : OreDictionary.getOreIDs(current)) {
            event.getToolTip().add("OD: " + OreDictionary.getOreName(id));
        }
        if (currentBlock instanceof BlockFluidBase) {
            event.getToolTip().add("Fluid: " + ((BlockFluidBase) currentBlock).getFluid().getName());
        }
    }
    if (ProjectEConfig.showEMCTooltip) {
        if (EMCHelper.doesItemHaveEmc(current)) {
            int value = EMCHelper.getEmcValue(current);
            event.getToolTip().add(TextFormatting.YELLOW + I18n.format("pe.emc.emc_tooltip_prefix") + " " + TextFormatting.WHITE + Constants.EMC_FORMATTER.format(value) + TextFormatting.BLUE + EMCHelper.getEmcSellString(current, 1));
            if (current.stackSize > 1) {
                long total;
                try {
                    total = LongMath.checkedMultiply(value, current.stackSize);
                } catch (ArithmeticException e) {
                    total = Long.MAX_VALUE;
                }
                if (total < 0 || total <= value || total > Integer.MAX_VALUE) {
                    event.getToolTip().add(TextFormatting.YELLOW + I18n.format("pe.emc.stackemc_tooltip_prefix") + " " + TextFormatting.OBFUSCATED + I18n.format("pe.emc.too_much"));
                } else {
                    event.getToolTip().add(TextFormatting.YELLOW + I18n.format("pe.emc.stackemc_tooltip_prefix") + " " + TextFormatting.WHITE + Constants.EMC_FORMATTER.format(value * current.stackSize) + TextFormatting.BLUE + EMCHelper.getEmcSellString(current, current.stackSize));
                }
            }
        }
    }
    if (ProjectEConfig.showStatTooltip) {
        /**
         * Collector ToolTips
         */
        String unit = I18n.format("pe.emc.name");
        String rate = I18n.format("pe.emc.rate");
        if (currentBlock == ObjHandler.energyCollector) {
            event.getToolTip().add(TextFormatting.DARK_PURPLE + String.format(I18n.format("pe.emc.maxgenrate_tooltip") + TextFormatting.BLUE + " %d " + rate, Constants.COLLECTOR_MK1_GEN));
            event.getToolTip().add(TextFormatting.DARK_PURPLE + String.format(I18n.format("pe.emc.maxstorage_tooltip") + TextFormatting.BLUE + " %d " + unit, Constants.COLLECTOR_MK1_MAX));
        }
        if (currentBlock == ObjHandler.collectorMK2) {
            event.getToolTip().add(TextFormatting.DARK_PURPLE + String.format(I18n.format("pe.emc.maxgenrate_tooltip") + TextFormatting.BLUE + " %d " + rate, Constants.COLLECTOR_MK2_GEN));
            event.getToolTip().add(TextFormatting.DARK_PURPLE + String.format(I18n.format("pe.emc.maxstorage_tooltip") + TextFormatting.BLUE + " %d " + unit, Constants.COLLECTOR_MK2_MAX));
        }
        if (currentBlock == ObjHandler.collectorMK3) {
            event.getToolTip().add(TextFormatting.DARK_PURPLE + String.format(I18n.format("pe.emc.maxgenrate_tooltip") + TextFormatting.BLUE + " %d " + rate, Constants.COLLECTOR_MK3_GEN));
            event.getToolTip().add(TextFormatting.DARK_PURPLE + String.format(I18n.format("pe.emc.maxstorage_tooltip") + TextFormatting.BLUE + " %d " + unit, Constants.COLLECTOR_MK3_MAX));
        }
        /**
         * Relay ToolTips
         */
        if (currentBlock == ObjHandler.relay) {
            event.getToolTip().add(TextFormatting.DARK_PURPLE + String.format(I18n.format("pe.emc.maxoutrate_tooltip") + TextFormatting.BLUE + " %d " + rate, Constants.RELAY_MK1_OUTPUT));
            event.getToolTip().add(TextFormatting.DARK_PURPLE + String.format(I18n.format("pe.emc.maxstorage_tooltip") + TextFormatting.BLUE + " %d " + unit, Constants.RELAY_MK1_MAX));
        }
        if (currentBlock == ObjHandler.relayMK2) {
            event.getToolTip().add(TextFormatting.DARK_PURPLE + String.format(I18n.format("pe.emc.maxoutrate_tooltip") + TextFormatting.BLUE + " %d " + rate, Constants.RELAY_MK2_OUTPUT));
            event.getToolTip().add(TextFormatting.DARK_PURPLE + String.format(I18n.format("pe.emc.maxstorage_tooltip") + TextFormatting.BLUE + " %d " + unit, Constants.RELAY_MK2_MAX));
        }
        if (currentBlock == ObjHandler.relayMK3) {
            event.getToolTip().add(TextFormatting.DARK_PURPLE + String.format(I18n.format("pe.emc.maxoutrate_tooltip") + TextFormatting.BLUE + " %d " + rate, Constants.RELAY_MK3_OUTPUT));
            event.getToolTip().add(TextFormatting.DARK_PURPLE + String.format(I18n.format("pe.emc.maxstorage_tooltip") + TextFormatting.BLUE + " %d " + unit, Constants.RELAY_MK3_MAX));
        }
    }
    if (current.hasTagCompound()) {
        if (current.getItem() instanceof IItemEmc || current.getTagCompound().hasKey("StoredEMC")) {
            double value = 0;
            if (current.getTagCompound().hasKey("StoredEMC")) {
                value = current.getTagCompound().getDouble("StoredEMC");
            } else {
                value = ((IItemEmc) current.getItem()).getStoredEmc(current);
            }
            event.getToolTip().add(TextFormatting.YELLOW + I18n.format("pe.emc.storedemc_tooltip") + " " + TextFormatting.RESET + Constants.EMC_FORMATTER.format(value));
        }
    }
}
Also used : Item(net.minecraft.item.Item) IPedestalItem(moze_intel.projecte.api.item.IPedestalItem) IPedestalItem(moze_intel.projecte.api.item.IPedestalItem) BlockFluidBase(net.minecraftforge.fluids.BlockFluidBase) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) IItemEmc(moze_intel.projecte.api.item.IItemEmc) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 4 with IItemEmc

use of moze_intel.projecte.api.item.IItemEmc in project ProjectE by sinkillerj.

the class SlotLock method putStack.

@Override
public void putStack(ItemStack stack) {
    if (stack == null) {
        return;
    }
    super.putStack(stack);
    if (stack.getItem() instanceof IItemEmc) {
        IItemEmc itemEmc = ((IItemEmc) stack.getItem());
        int remainEmc = Constants.TILE_MAX_EMC - (int) Math.ceil(inv.provider.getEmc());
        if (itemEmc.getStoredEmc(stack) >= remainEmc) {
            inv.addEmc(remainEmc);
            itemEmc.extractEmc(stack, remainEmc);
        } else {
            inv.addEmc(itemEmc.getStoredEmc(stack));
            itemEmc.extractEmc(stack, itemEmc.getStoredEmc(stack));
        }
    }
    inv.handleKnowledge(stack.copy());
}
Also used : IItemEmc(moze_intel.projecte.api.item.IItemEmc)

Example 5 with IItemEmc

use of moze_intel.projecte.api.item.IItemEmc in project ProjectE by sinkillerj.

the class DMFurnaceContainer method transferStackInSlot.

@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
    Slot slot = this.getSlot(slotIndex);
    if (slot == null || !slot.getHasStack()) {
        return null;
    }
    ItemStack stack = slot.getStack();
    ItemStack newStack = stack.copy();
    if (slotIndex <= 18) {
        if (!this.mergeItemStack(stack, 19, 55, false)) {
            return null;
        }
    } else {
        if (TileEntityFurnace.isItemFuel(newStack) || newStack.getItem() instanceof IItemEmc) {
            if (!this.mergeItemStack(stack, 0, 1, false)) {
                return null;
            }
        } else if (FurnaceRecipes.instance().getSmeltingResult(newStack) != null) {
            if (!this.mergeItemStack(stack, 1, 10, false)) {
                return null;
            }
        } else {
            return null;
        }
    }
    if (stack.stackSize == 0) {
        slot.putStack(null);
    } else {
        slot.onSlotChanged();
    }
    return newStack;
}
Also used : Slot(net.minecraft.inventory.Slot) ValidatedSlot(moze_intel.projecte.gameObjs.container.slots.ValidatedSlot) ItemStack(net.minecraft.item.ItemStack) IItemEmc(moze_intel.projecte.api.item.IItemEmc)

Aggregations

IItemEmc (moze_intel.projecte.api.item.IItemEmc)15 ItemStack (net.minecraft.item.ItemStack)9 IItemHandler (net.minecraftforge.items.IItemHandler)5 Block (net.minecraft.block.Block)3 ValidatedSlot (moze_intel.projecte.gameObjs.container.slots.ValidatedSlot)2 Slot (net.minecraft.inventory.Slot)2 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 Nonnull (javax.annotation.Nonnull)1 IPedestalItem (moze_intel.projecte.api.item.IPedestalItem)1 MatterFurnace (moze_intel.projecte.gameObjs.blocks.MatterFurnace)1 CollectorMK1Tile (moze_intel.projecte.gameObjs.tiles.CollectorMK1Tile)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 IInventory (net.minecraft.inventory.IInventory)1 ISidedInventory (net.minecraft.inventory.ISidedInventory)1 Item (net.minecraft.item.Item)1 TileEntity (net.minecraft.tileentity.TileEntity)1 TileEntityDropper (net.minecraft.tileentity.TileEntityDropper)1 TileEntityHopper (net.minecraft.tileentity.TileEntityHopper)1