public static void registerMelting(MeltingRecipe recipe) { if(new TinkerRegisterEvent.MeltingRegisterEvent(recipe).fire()) { meltingRegistry.add(recipe); } else { try { String input = recipe.input.getInputs().stream().findFirst().map(ItemStack::getUnlocalizedName).orElse("?"); log.debug("Registration of melting recipe for " + recipe.getResult().getUnlocalizedName() + " from " + input + " has been cancelled by event"); } catch(Exception e) { log.error("Error when logging melting event", e); } } }
public static void registerAlloy(AlloyRecipe recipe) { if(new TinkerRegisterEvent.AlloyRegisterEvent(recipe).fire()) { alloyRegistry.add(recipe); } else { try { String input = recipe.getFluids().stream().map(FluidStack::getUnlocalizedName).collect(Collectors.joining(", ")); String output = recipe.getResult().getUnlocalizedName(); log.debug("Registration of alloy recipe for " + output + " from [" + input + "] has been cancelled by event"); } catch(Exception e) { log.error("Error when logging alloy event", e); } } }
/** * Registers a liquid to be used as smeltery fuel. * Temperature is derived from fluid temperature. * * @param fluidStack The fluid. Amount is the minimal increment that is consumed at once. * @param fuelDuration How many ticks the consumtpion of the fluidStack lasts. */ public static void registerSmelteryFuel(FluidStack fluidStack, int fuelDuration) { if(new TinkerRegisterEvent.SmelteryFuelRegisterEvent(fluidStack, fuelDuration).fire()) { smelteryFuels.put(fluidStack, fuelDuration); } else { try { String input = fluidStack.getUnlocalizedName(); log.debug("Registration of smeltery fuel " + input + " has been cancelled by event"); } catch(Exception e) { log.error("Error when logging smeltery fuel event", e); } } }
/** Register an entity to melt into the given fluidstack. The fluidstack is returned for 1 heart damage */ public static void registerEntityMelting(Class<? extends Entity> clazz, FluidStack liquid) { ResourceLocation name = EntityList.getKey(clazz); if(name == null) { error("Entity Melting: Entity %s is not registered in the EntityList", clazz.getSimpleName()); } TinkerRegisterEvent.EntityMeltingRegisterEvent event = new TinkerRegisterEvent.EntityMeltingRegisterEvent(clazz, liquid); if(event.fire()) { entityMeltingRegistry.put(name, event.getNewFluidStack()); } else { try { String output = liquid.getUnlocalizedName(); log.debug("Registration of entity melting for " + clazz.getName() + " into " + output + " has been cancelled by event"); } catch(Exception e) { log.error("Error when logging entity melting event", e); } } }
public static String getFluidDisplayName( Object o ) { if( o == null ) { return "** Null"; } FluidStack fluidStack = null; if( o instanceof AEFluidStack ) { fluidStack = ( (AEFluidStack) o ).getFluidStack(); } else if( o instanceof FluidStack ) { fluidStack = (FluidStack) o; } else { return "**Invalid Object"; } String n = fluidStack.getLocalizedName(); if( n == null || "".equalsIgnoreCase( n ) ) { n = fluidStack.getUnlocalizedName(); } return n == null ? "** Null" : n; }
public void writeToNBT(NBTTagCompound tag) { NBTTagList taglist = new NBTTagList(); for(FluidStack liquid : liquids) { if(FluidRegistry.getFluidName(liquid.getFluid()) == null) { TinkerSmeltery.log.error("Error trying to save fluids inside smeltery! Invalid Liquid found! Smeltery contents:"); for(FluidStack liquid2 : liquids) { TinkerSmeltery.log.error(" " + liquid2.getUnlocalizedName() + "/" + liquid2.amount + "mb"); } continue; } NBTTagCompound fluidTag = new NBTTagCompound(); liquid.writeToNBT(fluidTag); taglist.appendTag(fluidTag); } tag.setTag("Liquids", taglist); tag.setInteger("LiquidCapacity", maxCapacity); }
if(!drained.isFluidEqual(toDrain) || drained.amount != toDrain.amount) { log.error("Smeltery alloy creation drained incorrect amount: was %s:%d, should be %s:%d", drained .getUnlocalizedName(), drained.amount, toDrain.getUnlocalizedName(), toDrain.amount); if(filled != recipe.getResult().amount) { log.error("Smeltery alloy creation filled incorrect amount: was %d, should be %d (%s)", filled, recipe.getResult().amount * matched, recipe.getResult().getUnlocalizedName());
@SuppressWarnings("unused") private static String fluidString(FluidStack stack) { return stack == null ? "nothing" : stack.amount + "x" + stack.getUnlocalizedName(); }
@Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, @Nullable World player, List<String> tooltip, boolean advanced) { tooltip.add(I18n.format("gregtech.universal.tooltip.fluid_storage_capacity", tankSize)); NBTTagCompound tagCompound = stack.getTagCompound(); if(tagCompound != null && tagCompound.hasKey("Fluid", NBT.TAG_COMPOUND)) { FluidStack fluidStack = FluidStack.loadFluidStackFromNBT(tagCompound.getCompoundTag("Fluid")); if(fluidStack == null) return; tooltip.add(I18n.format("gregtech.machine.fluid_tank.fluid", fluidStack.amount, I18n.format(fluidStack.getUnlocalizedName()))); } }
private List<ITextComponent> getStatus(IFluidTank tank) { FluidStack stack = tank.getFluid(); if (stack == null) { return Collections.emptyList(); } return Collections.singletonList(new TextComponentString(API.instance().getQuantityFormatter().format(stack.amount) + " mB ").appendSibling(new TextComponentTranslation(stack.getUnlocalizedName()))); }
@Override protected void addDisplayText(List<ITextComponent> textList) { if(isStructureFormed()) { FluidStack lubricantStack = importFluidHandler.drain(Materials.Lubricant.getFluid(Integer.MAX_VALUE), false); FluidStack oxygenStack = importFluidHandler.drain(Materials.Oxygen.getFluid(Integer.MAX_VALUE), false); FluidStack fuelStack = ((DieselEngineWorkableHandler) workableHandler).getFuelStack(); int lubricantAmount = lubricantStack == null ? 0 : lubricantStack.amount; int oxygenAmount = oxygenStack == null ? 0 : oxygenStack.amount; int fuelAmount = fuelStack == null ? 0 : fuelStack.amount; ITextComponent fuelName = new TextComponentTranslation(fuelAmount == 0 ? "gregtech.fluid.empty" : fuelStack.getUnlocalizedName()); textList.add(new TextComponentTranslation("gregtech.multiblock.diesel_engine.lubricant_amount", lubricantAmount)); textList.add(new TextComponentTranslation("gregtech.multiblock.diesel_engine.fuel_amount", fuelAmount, fuelName)); textList.add(new TextComponentTranslation("gregtech.multiblock.diesel_engine.oxygen_amount", oxygenAmount)); textList.add(new TextComponentTranslation(oxygenAmount >= 2 ? "gregtech.multiblock.diesel_engine.oxygen_boosted" : "gregtech.multiblock.diesel_engine.supply_oxygen_to_boost")); } super.addDisplayText(textList); }
@Override protected void addDisplayText(List<ITextComponent> textList) { if(isStructureFormed()) { MetaTileEntityRotorHolder rotorHolder = getAbilities(ABILITY_ROTOR_HOLDER).get(0); FluidStack fuelStack = ((LargeTurbineWorkableHandler) workableHandler).getFuelStack(); int fuelAmount = fuelStack == null ? 0 : fuelStack.amount; ITextComponent fuelName = new TextComponentTranslation(fuelAmount == 0 ? "gregtech.fluid.empty" : fuelStack.getUnlocalizedName()); textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.fuel_amount", fuelAmount, fuelName)); if(rotorHolder.getRotorEfficiency() > 0.0) { textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.rotor_speed", rotorHolder.getCurrentRotorSpeed(), rotorHolder.getMaxRotorSpeed())); textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.rotor_efficiency", (int) (rotorHolder.getRotorEfficiency() * 100))); int rotorDurability = (int) (rotorHolder.getRotorDurability() * 100); if(rotorDurability > MIN_DURABILITY_TO_WARN) { textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.rotor_durability", rotorDurability)); } else { textList.add(new TextComponentTranslation("gregtech.multiblock.turbine.low_rotor_durability", MIN_DURABILITY_TO_WARN, rotorDurability).setStyle(new Style().setColor(TextFormatting.RED))); } } } super.addDisplayText(textList); }
@Override @SideOnly(Side.CLIENT) public String getItemStackDisplayName(ItemStack stack) { if (stack.getItemDamage() >= metaItemOffset) { T item = getItem(stack); if(item == null) { return "unnamed"; } IFluidHandlerItem fluidHandlerItem = ItemHandlerHelper.copyStackWithSize(stack, 1) .getCapability(CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, null); if(fluidHandlerItem != null) { FluidStack fluidInside = fluidHandlerItem.drain(Integer.MAX_VALUE, false); String name = fluidInside == null ? "metaitem.fluid_cell.empty" : fluidInside.getUnlocalizedName(); return I18n.format("metaitem." + item.unlocalizedName + ".name", I18n.format(name)); } return I18n.format("metaitem." + item.unlocalizedName + ".name"); } return super.getItemStackDisplayName(stack); }