本文整理匯總了Java中cofh.api.energy.IEnergyReceiver.canConnectEnergy方法的典型用法代碼示例。如果您正苦於以下問題:Java IEnergyReceiver.canConnectEnergy方法的具體用法?Java IEnergyReceiver.canConnectEnergy怎麽用?Java IEnergyReceiver.canConnectEnergy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cofh.api.energy.IEnergyReceiver
的用法示例。
在下文中一共展示了IEnergyReceiver.canConnectEnergy方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onTick
import cofh.api.energy.IEnergyReceiver; //導入方法依賴的package包/類
public void onTick(){
super.onTick();
int counter = 0;
for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS){
TileEntity te = reactor.getWorldObj().getTileEntity(direction.offsetX + reactor.xCoord, direction.offsetY + reactor.yCoord, direction.offsetZ + reactor.zCoord);
if(te instanceof IEnergyReceiver){
IEnergyReceiver ier = (IEnergyReceiver) te;
int attemptedAmount = storedEnergy / (ForgeDirection.VALID_DIRECTIONS.length - counter++); //I support fourth-dimensional rights
if(ier.canConnectEnergy(direction.getOpposite())){
int actualAmount = ier.receiveEnergy(direction.getOpposite(), attemptedAmount, false);
storedEnergy -= actualAmount;
}
}
}
}
示例2: emit_do_do
import cofh.api.energy.IEnergyReceiver; //導入方法依賴的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;
}
示例3: updateEntity
import cofh.api.energy.IEnergyReceiver; //導入方法依賴的package包/類
@Override
public void updateEntity(){
super.updateEntity();
if(!worldObj.isRemote) {
if(worldObj.getTotalWorldTime() % 20 == 0) {
int efficiency = Config.pneumaticDynamoEfficiency;
if(efficiency < 1) efficiency = 1;
airPerTick = (int)(40 * this.getSpeedUsageMultiplierFromUpgrades() * 100 / efficiency);
rfPerTick = (int)(40 * this.getSpeedUsageMultiplierFromUpgrades() * getEfficiency() / 100);
}
boolean newEnabled;
if(redstoneAllows() && getPressure(ForgeDirection.UNKNOWN) > PneumaticValues.MIN_PRESSURE_PNEUMATIC_DYNAMO && getMaxEnergyStored(ForgeDirection.UNKNOWN) - getEnergyStored(ForgeDirection.UNKNOWN) >= rfPerTick) {
this.addAir(-airPerTick, ForgeDirection.UNKNOWN);
heatExchanger.addHeat(airPerTick / 100D);
energy.receiveEnergy(rfPerTick, false);
newEnabled = true;
} else {
newEnabled = false;
}
if(worldObj.getTotalWorldTime() % 20 == 0 && newEnabled != isEnabled) {
isEnabled = newEnabled;
sendDescriptionPacket();
}
TileEntity receiver = getTileCache()[getRotation().getOpposite().ordinal()].getTileEntity();
if(receiver instanceof IEnergyReceiver) {
IEnergyReceiver recv = (IEnergyReceiver)receiver;
if(recv.canConnectEnergy(getRotation())) {
int extracted = energy.extractEnergy(rfPerTick * 2, true);
int energyPushed = recv.receiveEnergy(getRotation(), extracted, true);
if(energyPushed > 0) {
recv.receiveEnergy(getRotation(), energy.extractEnergy(energyPushed, false), false);
}
}
}
}
}