本文整理汇总了Java中ic2.api.energy.tile.IEnergySource类的典型用法代码示例。如果您正苦于以下问题:Java IEnergySource类的具体用法?Java IEnergySource怎么用?Java IEnergySource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IEnergySource类属于ic2.api.energy.tile包,在下文中一共展示了IEnergySource类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: injectEnergyUnits
import ic2.api.energy.tile.IEnergySource; //导入依赖的package包/类
@VersionSpecific(version = "[1.7.2]")
@RuntimeInterface(clazz = "ic2.api.energy.tile.IEnergySink", modID = "IC2")
public double injectEnergyUnits(ForgeDirection directionFrom, double amount)
{
TileEntity tile = new BlockVec3(this).getTileEntityOnSide(this.worldObj, directionFrom);
int tier = 1;
if (tile instanceof IEnergySource && ((IEnergySource) tile).getOfferedEnergy() >= 128)
{
tier = 2;
}
float convertedEnergy = (float) amount * EnergyConfigHandler.IC2_RATIO;
float surplus = this.getNetwork().produce(convertedEnergy, true, tier, this, tile);
if (surplus >= 0.001F)
{
this.IC2surplusJoules = surplus;
}
else
{
this.IC2surplusJoules = 0F;
}
return 0D;
}
示例2: injectEnergy
import ic2.api.energy.tile.IEnergySource; //导入依赖的package包/类
@VersionSpecific(version = "[1.7.10]")
@RuntimeInterface(clazz = "ic2.api.energy.tile.IEnergySink", modID = "IC2")
public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage)
{
TileEntity tile = new BlockVec3(this).getTileEntityOnSide(this.worldObj, directionFrom);
int tier = ((int) voltage > 120) ? 2 : 1;
if (tile instanceof IEnergySource && ((IEnergySource) tile).getOfferedEnergy() >= 128)
{
tier = 2;
}
float convertedEnergy = (float) amount * EnergyConfigHandler.IC2_RATIO;
float surplus = this.getNetwork().produce(convertedEnergy, true, tier, this, tile);
if (surplus >= 0.001F)
{
this.IC2surplusJoules = surplus;
}
else
{
this.IC2surplusJoules = 0F;
}
return 0D;
}
示例3: addInformation
import ic2.api.energy.tile.IEnergySource; //导入依赖的package包/类
@Override
public void addInformation(World world, BlockPos pos, TileEntity te, List<String> infoList) {
infoList.add("blockTracker.info.ic2");
if (te instanceof IEnergySource) {
infoList.add("Providing Tier " + ((IEnergySource) te).getSourceTier());
}
if (te instanceof IEnergySink) {
infoList.add("Accepting Tier " + ((IEnergySink) te).getSinkTier());
}
}
示例4: tileFactorize
import ic2.api.energy.tile.IEnergySource; //导入依赖的package包/类
private void tileFactorize(LazyEnergyCapProvider lecp) {
if (broken) return;
final ICapabilityProvider cp = lecp.getObject();
if (cp == null || !(cp instanceof TileEntity)) return;
final TileEntity te = (TileEntity) cp;
final IEnergyTile et = EnergyNet.instance.getTile(te.getWorld(), te.getPos());
final IEnergySource esrc = et instanceof IEnergySource ? (IEnergySource) et : null;
final IEnergySink esnk = et instanceof IEnergySink ? (IEnergySink) et : null;
DoubleSupplier cfunc = et instanceof BasicSource ? ((BasicSource) et)::getCapacity : et instanceof BasicSink ? ((BasicSink) et)::getCapacity : null;
DoubleSupplier efunc = et instanceof BasicSource ? ((BasicSource) et)::getEnergyStored : et instanceof BasicSink ? ((BasicSink) et)::getEnergyStored : null;
if (IC2_TEB.isInstance(cp)) {
Object o = null;
try {
o = COMPONENT.invoke(cp, IC2_ENERGY);
} catch (Exception e) {
MCFluxReport.sendException(e, "[IC2] FluxCompat factorize");
}
cfunc = doubleFunc(CAPACITY, o);
efunc = doubleFunc(ENERGY, o);
}
final EUDelegate eud = new EUDelegate(cfunc, efunc, esnk, esrc);
final EnergyTile[] es = new EnergyTile[7];
for (int i = 0; i < U.FANCY_FACING.length; i++) {
EnumFacing f = U.FANCY_FACING[i];
es[i] = new EnergyTile(eud, f);
}
lecp.update(es, new int[0], null, true);
CloudUtils.reportEnergy(cp.getClass(), et.getClass(), "ic2");
}
示例5: canInput
import ic2.api.energy.tile.IEnergySource; //导入依赖的package包/类
/**
* Whether the current item can be inputted.
*
* @param itemStack Input item.
*/
@SuppressWarnings("NumericOverflow")
@Override
public boolean canInput(ItemStack itemStack) {
if (this.tile instanceof IEnergySink) {
return ElectricItem.manager.charge(itemStack, 1.0D / 0.0, ((IEnergySink) this.tile).getSinkTier(), true, true) > 0.0D;
} else if (this.tile instanceof IEnergySource) {
return ElectricItem.manager.charge(itemStack, 1.0D / 0.0, ((IEnergySource) this.tile).getSourceTier(), true, true) > 0.0D;
}
return false;
}
示例6: emitEnergyFrom
import ic2.api.energy.tile.IEnergySource; //导入依赖的package包/类
/**
* Emit energy from an energy source to the energy network.
*
* @param energySource energy source to emit energy from
* @param amount amount of energy to emit in EU
* @return Leftover (unused) power
*
* @deprecated use EnergyTileSourceEvent instead
*/
@Deprecated
public int emitEnergyFrom(IEnergySource energySource, int amount) {
try {
if (EnergyNet_emitEnergyFrom == null) EnergyNet_emitEnergyFrom = Class.forName(getPackage() + ".core.EnergyNet").getMethod("emitEnergyFrom", IEnergySource.class, Integer.TYPE);
return ((Integer) EnergyNet_emitEnergyFrom.invoke(energyNetInstance, energySource, amount)).intValue();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例7: onItemUseFirst
import ic2.api.energy.tile.IEnergySource; //导入依赖的package包/类
@Override
public boolean onItemUseFirst(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if ((((tileEntity instanceof IEnergySource)) || ((tileEntity instanceof IEnergyConductor)) || ((tileEntity instanceof IEnergySink))) && (!FMLCommonHandler.instance().getEffectiveSide().isClient())) {
NBTTagCompound nbtData = AddonUtils.getNBTTag(itemStack);
long currentTotalEnergyEmitted = EnergyNet.getForWorld(world).getTotalEnergyEmitted(tileEntity);
long currentTotalEnergySunken = EnergyNet.getForWorld(world).getTotalEnergySunken(tileEntity);
long currentMeasureTime = world.getWorldTime();
if ((nbtData.getInteger("lastMeasuredTileEntityX") != x) || (nbtData.getInteger("lastMeasuredTileEntityY") != y) || (nbtData.getInteger("lastMeasuredTileEntityZ") != z))
{
nbtData.setInteger("lastMeasuredTileEntityX", x);
nbtData.setInteger("lastMeasuredTileEntityY", y);
nbtData.setInteger("lastMeasuredTileEntityZ", z);
player.sendChatToPlayer("Starting new measurement");
}
else {
long measurePeriod = currentMeasureTime - nbtData.getLong("lastMeasureTime");
if (measurePeriod < 1L) measurePeriod = 1L;
double deltaEmitted = (currentTotalEnergyEmitted - nbtData.getLong("lastTotalEnergyEmitted")) / measurePeriod;
double deltaSunken = (currentTotalEnergySunken - nbtData.getLong("lastTotalEnergySunken")) / measurePeriod;
DecimalFormat powerFormat = new DecimalFormat("0.##");
player.sendChatToPlayer("Measured power [EU/t]: " + powerFormat.format(deltaSunken) + " in " + powerFormat.format(deltaEmitted) + " out " + powerFormat.format(deltaSunken - deltaEmitted) + " gain" + " (avg. over " + measurePeriod + " ticks)");
}
nbtData.setLong("lastTotalEnergyEmitted", currentTotalEnergyEmitted);
nbtData.setLong("lastTotalEnergySunken", currentTotalEnergySunken);
nbtData.setLong("lastMeasureTime", currentMeasureTime);
return true;
}
return false;
}
示例8: EUDelegate
import ic2.api.energy.tile.IEnergySource; //导入依赖的package包/类
private EUDelegate(DoubleSupplier cfunc, DoubleSupplier efunc, IEnergySink snk, IEnergySource src) {
capMethod = cfunc;
energyMethod = efunc;
sink = snk;
source = src;
}
示例9: isOutputter
import ic2.api.energy.tile.IEnergySource; //导入依赖的package包/类
public static boolean isOutputter(TileEntity tileEntity, ForgeDirection side)
{
return (tileEntity instanceof ICableOutputter && ((ICableOutputter)tileEntity).canOutputTo(side.getOpposite())) ||
(MekanismUtils.useIC2() && tileEntity instanceof IEnergySource && ((IEnergySource)tileEntity).emitsEnergyTo(null, side.getOpposite())) ||
(MekanismUtils.useRF() && tileEntity instanceof IEnergyProvider && ((IEnergyConnection)tileEntity).canConnectEnergy(side.getOpposite()));
}
示例10: getTargetClass
import ic2.api.energy.tile.IEnergySource; //导入依赖的package包/类
@Override
public Class<?> getTargetClass() {
return IEnergySource.class;
}
示例11: getOfferedEnergy
import ic2.api.energy.tile.IEnergySource; //导入依赖的package包/类
@ScriptCallable(description = "Get the EU output", returnTypes = ReturnType.NUMBER)
public double getOfferedEnergy(IEnergySource source) {
return source.getOfferedEnergy();
}
示例12: source
import ic2.api.energy.tile.IEnergySource; //导入依赖的package包/类
@ScriptCallable(description = "Determine the tier of this energy source (1 = LV, 2 = MV, 3 = HV, 4 = EV)", returnTypes = ReturnType.NUMBER)
public int getEUSourceTier(IEnergySource sink) {
return sink.getSourceTier();
}
示例13: EnergyTileSourceEvent
import ic2.api.energy.tile.IEnergySource; //导入依赖的package包/类
public EnergyTileSourceEvent(IEnergySource energySource, int amount) {
super(energySource);
this.amount = amount;
}
示例14: updateServerSide
import ic2.api.energy.tile.IEnergySource; //导入依赖的package包/类
@Override
public void updateServerSide() {
// Check inventory slots for fuel
// Check if we have suitable items waiting in the item slot
if (inventoryStacks[SLOT_CAN] != null) {
LiquidContainerData container = LiquidHelper.getLiquidContainer(inventoryStacks[SLOT_CAN]);
if (container != null)
if (GeneratorFuel.fuels.containsKey(container.stillLiquid.itemID)) {
inventoryStacks[SLOT_CAN] = StackUtils.replenishByContainer(this, inventoryStacks[SLOT_CAN], container, resourceTank);
if (inventoryStacks[SLOT_CAN].stackSize <= 0) {
inventoryStacks[SLOT_CAN] = null;
}
}
}
// No work to be done if IC2 is unavailable.
if (!PluginIC2.instance.isAvailable()) {
setErrorState(EnumErrorCode.NOENERGYNET);
return;
}
if (!isAddedToEnergyNet) {
EnergyNet.getForWorld(worldObj).addTileEntity(this);
this.isAddedToEnergyNet = true;
}
if (resourceTank.quantity > 0 && energyStored <= energyMax - 10) {
if (GeneratorFuel.fuels.containsKey(resourceTank.liquidId)) {
GeneratorFuel fuel = GeneratorFuel.fuels.get(resourceTank.liquidId);
this.tickCount++;
if (tickCount >= fuel.rate) {
tickCount = 0;
energyStored += EnergyNet.getForWorld(worldObj).emitEnergyFrom((IEnergySource) this, fuel.eu);
resourceTank.drain(fuel.fuelConsumed.amount, true);
}
}
} else if (energyStored > 0) {
int emit;
if (energyStored >= 32) {
emit = 32;
energyStored -= 32;
} else {
emit = energyStored;
energyStored = 0;
}
energyStored += EnergyNet.getForWorld(worldObj).emitEnergyFrom((IEnergySource) this, emit);
}
if (resourceTank.quantity <= 0) {
setErrorState(EnumErrorCode.NOFUEL);
} else {
setErrorState(EnumErrorCode.OK);
}
}