本文整理汇总了Java中ic2.api.energy.EnergyNet类的典型用法代码示例。如果您正苦于以下问题:Java EnergyNet类的具体用法?Java EnergyNet怎么用?Java EnergyNet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EnergyNet类属于ic2.api.energy包,在下文中一共展示了EnergyNet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: register
import ic2.api.energy.EnergyNet; //导入依赖的package包/类
@Method(modid = "IC2")
public void register()
{
if(!worldObj.isRemote)
{
TileEntity registered = EnergyNet.instance.getTileEntity(worldObj, xCoord, yCoord, zCoord);
if(registered != this)
{
if(registered instanceof IEnergyTile)
{
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)registered));
}
else if(registered == null)
{
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
ic2Registered = true;
}
}
}
}
示例2: updateEntity
import ic2.api.energy.EnergyNet; //导入依赖的package包/类
@Override
public void updateEntity() {
if (!init) {
initData();
markDirty();
}
if (!worldObj.isRemote) {
if (!addedToEnergyNet) {
EnergyTileLoadEvent event = new EnergyTileLoadEvent(this);
MinecraftForge.EVENT_BUS.post(event);
addedToEnergyNet = true;
}
if (updateTicker-- == 0) {
updateTicker = tickRate - 1;
counter += EnergyNet.instance.getTotalEnergyEmitted(this); //So sue me
this.setPowerType((byte)EnergyStorageData.TARGET_TYPE_IC2);
}
}
}
示例3: BasicSource
import ic2.api.energy.EnergyNet; //导入依赖的package包/类
/**
* Constructor for a new BasicSource delegate.
*
* @param parent1 Base TileEntity represented by this energy source.
* @param capacity1 Maximum amount of eu to store.
* @param tier1 IC2 tier, 1 = LV, 2 = MV, ...
*/
public BasicSource(TileEntity parent1, double capacity1, int tier1) {
double power = EnergyNet.instance.getPowerFromTier(tier1);
this.parent = parent1;
this.capacity = capacity1 < power ? power : capacity1;
this.tier = tier1;
this.power = power;
}
示例4: setTier
import ic2.api.energy.EnergyNet; //导入依赖的package包/类
/**
* Set the IC2 energy tier for this source.
*
* @param tier1 IC2 Tier.
*/
public void setTier(int tier1) {
double power = EnergyNet.instance.getPowerFromTier(tier1);
if (capacity < power) capacity = power;
this.tier = tier1;
this.power = power;
}
示例5: tileFactorize
import ic2.api.energy.EnergyNet; //导入依赖的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");
}
示例6: inputEnergy
import ic2.api.energy.EnergyNet; //导入依赖的package包/类
@Override
public long inputEnergy(long amount, boolean sim) {
if (amount < CFG_EU_VALUE) return 0;
if (delegate.sink != null) {
final long e = (long) delegate.sink.getDemandedEnergy() * CFG_EU_VALUE;
long r = amount - (amount % CFG_EU_VALUE);
if (r > e)
r = e;
if (!sim) {
delegate.sink.injectEnergy(face, r / CFG_EU_VALUE, EnergyNet.instance.getPowerFromTier(delegate.sink.getSinkTier()));
}
return r;
}
return 0;
}
示例7: BasicSource
import ic2.api.energy.EnergyNet; //导入依赖的package包/类
/**
* Constructor for a new BasicSource delegate.
*
* @param parent1 Base TileEntity represented by this energy source.
* @param capacity1 Maximum amount of eu to store.
* @param tier1 IC2 tier, 1 = LV, 2 = MV, ...
*/
public BasicSource(TileEntity parent1, double capacity1, int tier1) {
double power = EnergyNet.instance.getPowerFromTier(tier1);
this.parent = parent1;
this.capacity = capacity1 < power ? power : capacity1;
this.tier = tier1;
this.power = power;
}
示例8: setTier
import ic2.api.energy.EnergyNet; //导入依赖的package包/类
/**
* Set the IC2 energy tier for this source.
*
* @param tier1 IC2 Tier.
*/
public void setTier(int tier1) {
double power = EnergyNet.instance.getPowerFromTier(tier1);
if (capacity < power) capacity = power;
this.tier = tier1;
this.power = power;
}
示例9: deregister
import ic2.api.energy.EnergyNet; //导入依赖的package包/类
@Method(modid = "IC2")
public void deregister()
{
if(!worldObj.isRemote)
{
TileEntity registered = EnergyNet.instance.getTileEntity(worldObj, xCoord, yCoord, zCoord);
if(registered instanceof IEnergyTile)
{
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)registered));
}
}
}
示例10: emit_do_do
import ic2.api.energy.EnergyNet; //导入依赖的package包/类
private static double emit_do_do(IEnergyWrapper from, TileEntity tileEntity, ForgeDirection side, double currentSending, boolean tryAgain)
{
double sent = 0;
if(tileEntity instanceof IStrictEnergyAcceptor)
{
IStrictEnergyAcceptor acceptor = (IStrictEnergyAcceptor)tileEntity;
if(acceptor.canReceiveEnergy(side.getOpposite()))
{
sent += acceptor.transferEnergyToAcceptor(side.getOpposite(), currentSending);
}
}
else if(MekanismUtils.useRF() && tileEntity instanceof IEnergyReceiver)
{
IEnergyReceiver handler = (IEnergyReceiver)tileEntity;
if(handler.canConnectEnergy(side.getOpposite()))
{
int used = handler.receiveEnergy(side.getOpposite(), (int)Math.round(currentSending*general.TO_TE), false);
sent += used*general.FROM_TE;
}
}
else if(MekanismUtils.useIC2() && tileEntity instanceof IEnergySink)
{
if(((IEnergySink)tileEntity).acceptsEnergyFrom((TileEntity)from, side.getOpposite()))
{
double toSend = Math.min(currentSending, EnergyNet.instance.getPowerFromTier(((IEnergySink)tileEntity).getSinkTier())*general.FROM_IC2);
toSend = Math.min(toSend, ((IEnergySink)tileEntity).getDemandedEnergy()*general.FROM_IC2);
sent += (toSend - (((IEnergySink)tileEntity).injectEnergy(side.getOpposite(), toSend*general.TO_IC2, 0)*general.FROM_IC2));
}
}
return sent;
}
示例11: TileEUStorage
import ic2.api.energy.EnergyNet; //导入依赖的package包/类
public TileEUStorage(int tier, int maxStorage) {
super((int) EnergyNet.instance.getPowerFromTier(tier), maxStorage, tier);
this.redstoneMode = RedstoneMode.NONE;
// if (!(this instanceof TileParallelSpaceSU)) {
// this.tileSlots.add(new TileSlotDischarge(this, TileSlot.SlotMode.NULL));
// this.tileSlots.add(new TileSlotCharge(this, TileSlot.SlotMode.INPUT));
// }
}
示例12: updateEntity
import ic2.api.energy.EnergyNet; //导入依赖的package包/类
@Override
public void updateEntity() {
if (!init) {
initData();
markDirty();
}
if (FMLCommonHandler.instance().getEffectiveSide().isClient())
return;
if (!worldObj.isRemote){
if (!addedToEnergyNet){
EnergyTileLoadEvent event = new EnergyTileLoadEvent(this);
MinecraftForge.EVENT_BUS.post(event);
addedToEnergyNet = true;
}
index = (index + 1) % DATA_POINTS;
data[index] = 0;
this.getAverage();
double total = EnergyNet.instance.getTotalEnergyEmitted(this);
if(IC2NuclearControl.instance.crossIc2.getType() == IC2Type.SPEIGER){
double realTotal = total - lastReceivedPower;
lastReceivedPower = total;
data[index] = realTotal;
}else
data[index] = total;
this.setPowerType((byte)EnergyStorageData.TARGET_TYPE_IC2);
}
super.updateEntity();
}
示例13: updateGenerator
import ic2.api.energy.EnergyNet; //导入依赖的package包/类
public CardState updateGenerator(World world, ICardWrapper card, int range) {
ChunkCoordinates target = card.getTarget();
if(target == null) return CardState.NO_TARGET;
TileEntity entity = world.getTileEntity(target.posX, target.posY, target.posZ);
if (entity instanceof TileEntityBaseGenerator) {
// int production = ((TileEntityBaseGenerator)entity).production;
int production = (int) EnergyNet.instance.getNodeStats(entity).getEnergyOut();
card.setInt("production", production);
card.setDouble("range_trigger_amount", (double)production);
return CardState.OK;
} else {
return CardState.NO_TARGET;
}
}
示例14: BasicSource
import ic2.api.energy.EnergyNet; //导入依赖的package包/类
/**
* Constructor for a new BasicSource delegate.
*
* @param parent1 Base TileEntity represented by this energy source.
* @param capacity1 Maximum amount of eu to store.
* @param tier1 IC2 tier, 1 = LV, 2 = MV, ...
*/
public BasicSource(TileEntity parent1, double capacity1, int tier1) {
double power = EnergyNet.instance.getPowerFromTier(tier1);
this.parent = parent1;
this.capacity = capacity1 < power ? power : capacity1;
this.tier = tier1;
this.power = power;
}
示例15: setTier
import ic2.api.energy.EnergyNet; //导入依赖的package包/类
/**
* Set the IC2 energy tier for this source.
*
* @param tier1 IC2 Tier.
*/
public void setTier(int tier1) {
double power = EnergyNet.instance.getPowerFromTier(tier1);
if (capacity < power) {
capacity = power;
}
this.tier = tier1;
this.power = power;
}