當前位置: 首頁>>代碼示例>>Java>>正文


Java IEnergyHandler類代碼示例

本文整理匯總了Java中cofh.api.energy.IEnergyHandler的典型用法代碼示例。如果您正苦於以下問題:Java IEnergyHandler類的具體用法?Java IEnergyHandler怎麽用?Java IEnergyHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IEnergyHandler類屬於cofh.api.energy包,在下文中一共展示了IEnergyHandler類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: otherModCanProduce

import cofh.api.energy.IEnergyHandler; //導入依賴的package包/類
/**
   * Test whether a tile can output energy using other mods' energy methods.
   * Currently restricted to IC2 and RF mods - Mekanism tiles do not provide an interface to "output" energy
   * 
   * Parameters:
   * @param tileAdj - the tile under test, it might be an energy tile from another mod
   * @param side - the energy output side for that tile which is under test
   */
public static boolean otherModCanProduce(TileEntity tileAdj, ForgeDirection side)
{
      if (tileAdj instanceof TileBaseConductor || tileAdj instanceof EnergyStorageTile)
      	return false;  //Do not try using other mods' methods to connect to GC's own tiles
      
      if (isIC2Loaded && tileAdj instanceof IEnergyEmitter)
      {
          return ((IEnergyEmitter) tileAdj).emitsEnergyTo(null, side);
      }
      else if (isRF1Loaded && tileAdj instanceof IEnergyHandler || isRF2Loaded && tileAdj instanceof IEnergyProvider)
      {
      	return ((IEnergyConnection)tileAdj).canConnectEnergy(side);
      }
	
      return false;
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:25,代碼來源:EnergyUtil.java

示例2: updateEnergyHandlers

import cofh.api.energy.IEnergyHandler; //導入依賴的package包/類
void updateEnergyHandlers() {
    for (int i = 0; i < 6; i++) {
        BlockPos c = BlockPos.offset(getBlockPos(), ForgeDirection.getOrientation(i));
        TileEntity tile = WorldUtilities.getTileEntity(getWorldObj(), c);

        if (tile != null && tile instanceof IEnergyHandler) {
            IEnergyHandler energy = (IEnergyHandler) tile;

            if (energy.canConnectEnergy(ForgeDirection.getOrientation(i).getOpposite()))
                handlers[i] = energy;
            else
                handlers[i] = null;
        } else
            handlers[i] = null;
    }

    cached = true;
}
 
開發者ID:enhancedportals,項目名稱:enhancedportals,代碼行數:19,代碼來源:TileTransferEnergy.java

示例3: update

import cofh.api.energy.IEnergyHandler; //導入依賴的package包/類
@Override
       public CardState update(TileEntity panel, ICardWrapper card, int range) {
      ChunkCoordinates target = card.getTarget();
if(target == null) return CardState.NO_TARGET;
      TileEntity tile = panel.getWorldObj().getTileEntity(target.posX, target.posY, target.posZ);
      //NCLog.fatal(tile instanceof IEnergyHandler);
      if(tile instanceof IEnergyHandler) {
          IEnergyHandler iEnergyStorage = (IEnergyHandler) tile;
          card.setInt("energyL", iEnergyStorage.getEnergyStored(ForgeDirection.UNKNOWN));
          card.setInt("maxStorageL", iEnergyStorage.getMaxEnergyStored(ForgeDirection.UNKNOWN));
          card.setInt("range_trigger_amount", iEnergyStorage.getEnergyStored(ForgeDirection.UNKNOWN));
          return CardState.OK;
      } else {
          return CardState.NO_TARGET;
      }
  }
 
開發者ID:xbony2,項目名稱:Nuclear-Control,代碼行數:17,代碼來源:ItemCardRFEnergyLocation.java

示例4: checkConnections

import cofh.api.energy.IEnergyHandler; //導入依賴的package包/類
public void checkConnections(World world, int x, int y, int z) {
	for (int i = 0; i < 6; i++) {
		ForgeDirection dir = dirs[i];
		int dx = x + dir.offsetX;
		int dy = y + dir.offsetY;
		int dz = z + dir.offsetZ;
		connections[i] = shouldConnectTo(world.getTileEntity(dx, dy, dz), dir);
		world.func_147479_m(dx, dy, dz);
		if (network != null) {
			TileEntity te = world.getTileEntity(dx, dy, dz);
			if (te instanceof IEnergyHandler) {
				IEnergyHandler ih = (IEnergyHandler) te;
				if (ih.canConnectEnergy(dir.getOpposite())) {
					network.addConnection(ih, dir.getOpposite());
				}
			}
		}
	}
	world.func_147479_m(x, y, z);
}
 
開發者ID:modmuss50,項目名稱:Network,代碼行數:21,代碼來源:ModCablePart.java

示例5: updateEntity

import cofh.api.energy.IEnergyHandler; //導入依賴的package包/類
@Override
public void updateEntity()
{
	if (!worldObj.isRemote)
	{
		for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
		{
			TileEntity tile = this.worldObj.getTileEntity(this.xCoord + side.offsetX, this.yCoord + side.offsetY, this.zCoord + side.offsetZ);
			if ((tile instanceof IEnergyHandler))
			{
				this.storage.extractEnergy(((IEnergyHandler) tile).receiveEnergy(side.getOpposite(), this.storage.extractEnergy(perTick, true), false), false);
			}
		}
	}
	
	if (animationProgress > Math.PI * 2)
		animationProgress -= Math.PI * 2;
}
 
開發者ID:tterrag1098,項目名稱:TreeGrowingSimulator2014,代碼行數:19,代碼來源:TileEngine.java

示例6: WidgetEnergy

import cofh.api.energy.IEnergyHandler; //導入依賴的package包/類
public WidgetEnergy(final IEnergyHandler tile, final ForgeDirection dir, final int x, final int y) {
    this.dir = dir;
    this.tile = tile;
    this.x = x;
    this.y = y;
    this.curEnergy = 0;
    this.curMax = 0;
}
 
開發者ID:sameer,項目名稱:ExtraUtilities,代碼行數:9,代碼來源:WidgetEnergy.java

示例7: getStoredPower

import cofh.api.energy.IEnergyHandler; //導入依賴的package包/類
@Override
public long getStoredPower() {
    if(entity instanceof IEnergyHandler){
        return ((IEnergyHandler) entity).getEnergyStored(dir);
    }
    return 0;
}
 
開發者ID:modmuss50,項目名稱:Tesla-Flux,代碼行數:8,代碼來源:TeslaRFContainer.java

示例8: getCapacity

import cofh.api.energy.IEnergyHandler; //導入依賴的package包/類
@Override
public long getCapacity() {
    if(entity instanceof IEnergyHandler){
        return ((IEnergyHandler) entity).getMaxEnergyStored(dir);
    }
    return 0;
}
 
開發者ID:modmuss50,項目名稱:Tesla-Flux,代碼行數:8,代碼來源:TeslaRFContainer.java

示例9: otherModCanReceive

import cofh.api.energy.IEnergyHandler; //導入依賴的package包/類
/**
    * Test whether an energy connection can be made to a tile using other mods' energy methods.
    * 
    * Parameters:
    * @param tileAdj - the tile under test, it might be an energy tile from another mod
    * @param inputAdj - the energy input side for that tile which is under test
    */
public static boolean otherModCanReceive(TileEntity tileAdj, ForgeDirection inputAdj)
{
       if (tileAdj instanceof TileBaseConductor || tileAdj instanceof EnergyStorageTile)
       	return false;  //Do not try using other mods' methods to connect to GC's own tiles
       
	if (isMekLoaded && tileAdj instanceof IStrictEnergyAcceptor)
       {
           return ((IStrictEnergyAcceptor) tileAdj).canReceiveEnergy(inputAdj);
       }
       else if (isIC2Loaded && tileAdj instanceof IEnergyAcceptor)
       {
           return ((IEnergyAcceptor) tileAdj).acceptsEnergyFrom(null, inputAdj);
       }
       else if (isRF1Loaded && tileAdj instanceof IEnergyHandler || isRF2Loaded && tileAdj instanceof IEnergyReceiver)
       {
       	return ((IEnergyConnection)tileAdj).canConnectEnergy(inputAdj);
       }
       else if (isBC6Loaded && MjAPI.getMjBattery(tileAdj, MjAPI.DEFAULT_POWER_FRAMEWORK, inputAdj) != null)
       //New BC API
       {
           return true;
       }
       else if (isBCLoaded && tileAdj instanceof IPowerReceptor)
       //Legacy BC API
       {
           return ((IPowerReceptor) tileAdj).getPowerReceiver(inputAdj) != null;
       }
	
	return false;
}
 
開發者ID:4Space,項目名稱:4Space-5,代碼行數:38,代碼來源:EnergyUtil.java

示例10: setTile

import cofh.api.energy.IEnergyHandler; //導入依賴的package包/類
public void setTile(TileEntity entity){
    if(entity instanceof IEnergyReceiver){
        receiver = (IEnergyReceiver) entity;
    }
    if(entity instanceof IEnergyProvider){
        provider = (IEnergyProvider) entity;
    }
    if(entity instanceof IEnergyHandler){
        handler = (IEnergyHandler) entity;
    }
}
 
開發者ID:modmuss50,項目名稱:RF-Bridge,代碼行數:12,代碼來源:RFContainer.java

示例11: receiveEnergy

import cofh.api.energy.IEnergyHandler; //導入依賴的package包/類
@Override
public int receiveEnergy(ForgeDirection fd, int amount, boolean simulate)
{
    ForgeDirection opposite = fd.getOpposite();
    TileEntity te = worldObj.getTileEntity(xCoord + opposite.offsetX, yCoord, zCoord + opposite.offsetZ);
    if (canConnectEnergy(fd) && te instanceof IEnergyHandler && (((IEnergyHandler)te).receiveEnergy(fd, amount, true) > 0))
    {
        transferedRF = transferedRF + ((IEnergyHandler)te).receiveEnergy(fd, amount, true);
        return lastRF = ((IEnergyHandler)te).receiveEnergy(fd, amount, simulate);
    }
    else
    {
        return 0;
    }
}
 
開發者ID:XFactHD,項目名稱:RFUtilities,代碼行數:16,代碼來源:TileEntityRFMeter.java

示例12: getComparatorInputOverride

import cofh.api.energy.IEnergyHandler; //導入依賴的package包/類
@Override
public int getComparatorInputOverride(World world, BlockPos pos)
{
	TileEntity tileEntity = world.getTileEntity(pos);
	if(tileEntity instanceof TileRFLoader)
	{
		return ComparatorUtils.scaleStoredEnergyTo(15, (IEnergyHandler)tileEntity);
	}
	return 0;
}
 
開發者ID:BrassGoggledCoders,項目名稱:MoarCarts,代碼行數:11,代碼來源:BlockRFLoader.java

示例13: onComparatorTrack

import cofh.api.energy.IEnergyHandler; //導入依賴的package包/類
public void onComparatorTrack(ComparatorTrackEvent event)
{
	if(event.entity instanceof IEnergyHandler)
	{
		event.setIntResult(ComparatorUtils.scaleStoredEnergyTo(15, (IEnergyHandler)event.entity));
	}
}
 
開發者ID:BrassGoggledCoders,項目名稱:MoarCarts,代碼行數:8,代碼來源:RFComparatorTrackHandler.java

示例14: getWailaBody

import cofh.api.energy.IEnergyHandler; //導入依賴的package包/類
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor,
		IWailaConfigHandler config)
{
	TileEntity tileEntity = accessor.getTileEntity();
	if(tileEntity instanceof IEnergyHandler)
	{
		IEnergyHandler energyHandler = (IEnergyHandler)tileEntity;
		currenttip.add(String.format("%d / %d RF", energyHandler.getEnergyStored(null),
				energyHandler.getMaxEnergyStored(null)));
	}
	return currenttip;
}
 
開發者ID:BrassGoggledCoders,項目名稱:MoarCarts,代碼行數:14,代碼來源:BlockProviderRF.java

示例15: getNeibough

import cofh.api.energy.IEnergyHandler; //導入依賴的package包/類
private boolean getNeibough(){
    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
        TileEntity tile = getWorldObj().getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
        if (!(tile instanceof RFTileEntityAverageCounter)) {
            if (tile instanceof IEnergyHandler) {
                return true;
            }
        }
    }
    return false;
}
 
開發者ID:xbony2,項目名稱:Nuclear-Control,代碼行數:12,代碼來源:RFTileEntityAverageCounter.java


注:本文中的cofh.api.energy.IEnergyHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。