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;
}
}
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());
}
}
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));
}
}
}
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());
}
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;
}
Aggregations