本文整理汇总了Java中net.minecraftforge.fluids.IFluidHandler.getTankInfo方法的典型用法代码示例。如果您正苦于以下问题:Java IFluidHandler.getTankInfo方法的具体用法?Java IFluidHandler.getTankInfo怎么用?Java IFluidHandler.getTankInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.fluids.IFluidHandler
的用法示例。
在下文中一共展示了IFluidHandler.getTankInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateFluidHandlers
import net.minecraftforge.fluids.IFluidHandler; //导入方法依赖的package包/类
void updateFluidHandlers() {
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 IFluidHandler) {
IFluidHandler fluid = (IFluidHandler) tile;
if (fluid.getTankInfo(ForgeDirection.getOrientation(i).getOpposite()) != null)
handlers[i] = fluid;
else
handlers[i] = null;
} else
handlers[i] = null;
}
cached = true;
}
示例2: applyPlayerContainerInteraction
import net.minecraftforge.fluids.IFluidHandler; //导入方法依赖的package包/类
public static boolean applyPlayerContainerInteraction(final World world, final TileEntity entity, final EntityPlayer player) {
final ItemStack stack = player.getCurrentEquippedItem();
if(stack == null || !FluidContainerRegistry.isContainer(stack))
return false;
boolean update = false;
final IFluidHandler handler = (IFluidHandler)entity;
// Get the fluid from the item. If there is one they are trying
// to fill. Otherwise they are trying to remove.
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
if(liquid != null) {
update = FluidHelper.fillHandlerWithContainer(world, handler, player);
}
else {
liquid = handler.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid;
update = FluidHelper.fillContainerFromHandler(world, handler, player, liquid);
}
if(update)
world.markBlockForUpdate(entity.xCoord, entity.yCoord, entity.zCoord);
return update;
}
示例3: isValidAcceptorOnSide
import net.minecraftforge.fluids.IFluidHandler; //导入方法依赖的package包/类
public static boolean isValidAcceptorOnSide(TileEntity tile, ForgeDirection side)
{
if(tile instanceof ITransmitterTile || !(tile instanceof IFluidHandler))
return false;
IFluidHandler container = (IFluidHandler)tile;
FluidTankInfo[] infoArray = container.getTankInfo(side.getOpposite());
if(container.canDrain(side.getOpposite(), FluidRegistry.WATER)
|| container.canFill(side.getOpposite(), FluidRegistry.WATER)) //I hesitate to pass null to these.
{
return true;
}
else if(infoArray != null && infoArray.length > 0)
{
for(FluidTankInfo info : infoArray)
{
if(info != null)
{
return true;
}
}
}
return false;
}
示例4: tryClearDirectionalTraffic
import net.minecraftforge.fluids.IFluidHandler; //导入方法依赖的package包/类
/**
* Method once called will attempt to resolve the 'last received direction' if applicable.
*
* @param sourceCont container requesting fluid.
* @param world world object as reference.
* @param blockPos BlockPosition.
* @param lastDir last direction received from (prevent continuous looping).
*/
public static void tryClearDirectionalTraffic(IFluidHandler sourceCont, World world, BlockPos blockPos, EnumFacing lastDir) {
boolean shouldSend = false;
final BlockPos pos = BlockUtils.createBlockPos(blockPos.getX() + lastDir.getFrontOffsetX(), blockPos.getY() + lastDir.getFrontOffsetY(),
blockPos.getZ() + lastDir.getFrontOffsetZ());
final TileEntity te = world.getTileEntity(pos);
IFluidHandler cont = null;
if (te != null && te instanceof IFluidContainer) cont = (IFluidContainer) te;
if (cont == null || sourceCont.getTankInfo(lastDir)[0] == null || sourceCont.getTankInfo(lastDir)[0].fluid == null || sourceCont.getTankInfo(lastDir)[0].fluid.amount == 0) {
shouldSend = true;
clearDirectionalTraffic((IFluidContainer) sourceCont);
}
else if (cont instanceof TileEntityLiquiductBase && ((TileEntityLiquiductBase) cont).getLastReceivedDirection().getOpposite() == lastDir) {
if ((((TileEntityLiquiductBase) sourceCont).getFluidID() != ((TileEntityLiquiductBase) cont).getFluidID())
|| (((TileEntityLiquiductBase) sourceCont).getFluidID() == ((TileEntityLiquiductBase) cont).getFluidID() && ((TileEntityLiquiductBase) sourceCont)
.getTank().getFluidAmount() <= ((TileEntityLiquiductBase) cont).getTank().getFluidAmount())) {
shouldSend = true;
clearDirectionalTraffic((IFluidContainer) sourceCont);
}
}
}
示例5: isContainerValid
import net.minecraftforge.fluids.IFluidHandler; //导入方法依赖的package包/类
/**
* Simple function to determine whether a fluid container is valid (has something) or invalid (has nothing).
*
* @param cont container to reference.
* @param world world as reference of existance.
* @return true if has something relavent, else returns false.
*/
public static boolean isContainerValid(IFluidHandler cont, World world) {
boolean flag = false;
if (cont != null) {
for (EnumFacing dir : EnumFacing.VALUES) {
if (cont.getTankInfo(dir) != null && cont.getTankInfo(dir).length > 0) {
for (int i = 0; i < cont.getTankInfo(dir).length; i++) {
if (cont.getTankInfo(dir)[i] != null && cont.getTankInfo(dir)[i].fluid != null && cont.getTankInfo(dir)[i].fluid.amount > 0) {
flag = true;
break;
}
}
if (flag) break;
}
}
}
return flag;
}
示例6: doPull
import net.minecraftforge.fluids.IFluidHandler; //导入方法依赖的package包/类
public static boolean doPull(IFluidHandler into, ForgeDirection fromDir, int maxVolume) {
TileEntity te = (TileEntity) into;
BlockCoord loc = new BlockCoord(te).getLocation(fromDir);
IFluidHandler target = FluidUtil.getFluidHandler(te.getWorldObj(), loc);
if (target != null) {
FluidTankInfo[] infos = target.getTankInfo(fromDir.getOpposite());
if (infos != null) {
for (FluidTankInfo info : infos) {
if (info.fluid != null && info.fluid.amount > 0) {
if (into.canFill(fromDir, info.fluid.getFluid())) {
FluidStack canPull = info.fluid.copy();
canPull.amount = Math.min(maxVolume, canPull.amount);
FluidStack drained = target.drain(fromDir.getOpposite(), canPull, false);
if (drained != null && drained.amount > 0) {
int filled = into.fill(fromDir, drained, false);
if (filled > 0) {
drained = target.drain(fromDir.getOpposite(), filled, true);
into.fill(fromDir, drained, true);
return true;
}
}
}
}
}
}
}
return false;
}
示例7: drain
import net.minecraftforge.fluids.IFluidHandler; //导入方法依赖的package包/类
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
IFluidHandler handler = this.getFluidTankInDirection(ForgeDirection.UP);
FluidStack stack = null;
if(handler != null && handler.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid != null &&
fluidTank.getFluid() != null && fluidTank.getFluid().getFluidID() ==
handler.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid.getFluidID()) {
stack = handler.drain(from, maxDrain, doDrain);
}
if(stack != null)
return stack;
FluidStack stack2 = super.drain(from, maxDrain - (stack != null ? stack.amount : 0), doDrain);
if(stack != null && stack2 != null)
stack2.amount += stack.amount;
if(stack2 != null && doDrain) {
fluidChanged = true;
}
checkForUpdate();
return stack2;
}
示例8: useBucket
import net.minecraftforge.fluids.IFluidHandler; //导入方法依赖的package包/类
@Override
protected boolean useBucket(int slot, ItemStack stack) {
boolean bucketUsed = super.useBucket(slot, stack);
if(bucketUsed) {
IFluidHandler handler = getFluidTankInDirection(ForgeDirection.DOWN);
if(handler != null) {
FluidStack othertank = handler.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid;
if(othertank == null || (othertank.amount < handler.getTankInfo(ForgeDirection.UNKNOWN)[0].capacity))
fluidTank.drain(handler.fill(ForgeDirection.UNKNOWN, fluidTank.getFluid(), true),true);
}
}
return bucketUsed;
}
示例9: renderTileEntityAt
import net.minecraftforge.fluids.IFluidHandler; //导入方法依赖的package包/类
@Override
public void renderTileEntityAt(TileEntity tile, double x,
double y, double z, float p_147500_8_) {
IFluidHandler fluidTile = (IFluidHandler)tile;
FluidStack fluid = fluidTile.getTankInfo(ForgeDirection.UNKNOWN)[0].fluid;
if(fluid != null && fluid.getFluid() != null)
{
GL11.glPushMatrix();
GL11.glTranslatef((float)x, (float)y, (float)z);
IIcon icon = fluid.getFluid().getIcon();
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
int color = fluid.getFluid().getColor();
GL11.glColor4f(((color >>> 16) & 0xFF)/255f, ((color >>> 8) & 0xFF)/255f, ((color& 0xFF)/255f),1f);
Block block = tile.getBlockType();
Tessellator tess = Tessellator.instance;
float amt = fluid.amount / (float)fluidTile.getTankInfo(ForgeDirection.UNKNOWN)[0].capacity;
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
tess.startDrawingQuads();
RenderHelper.renderCubeWithUV(tess, block.getBlockBoundsMinX() + 0.01, block.getBlockBoundsMinY() + 0.01, block.getBlockBoundsMinZ() + 0.01, block.getBlockBoundsMaxX() - 0.01, block.getBlockBoundsMaxY()*amt - 0.01, block.getBlockBoundsMaxZ() - 0.01, icon.getMinU(), icon.getMaxU(), icon.getMinV(), icon.getMaxV());
tess.draw();
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
GL11.glColor3f(1f, 1f, 1f);
}
}
示例10: containsFluid
import net.minecraftforge.fluids.IFluidHandler; //导入方法依赖的package包/类
/**
* Static method to check if container/tank contains any fluid.
*
* @param container cotnainer/tank to check.
* @return true if has any fluid, else returns false.
*/
public static boolean containsFluid(IFluidHandler container) {
if (container != null) {
for (EnumFacing dir : EnumFacing.VALUES) {
if (container.getTankInfo(dir) != null) {
for (FluidTankInfo info : container.getTankInfo(dir)) {
if (info.fluid != null && info.fluid.amount > 0) return true;
}
}
}
}
return false;
}
示例11: getAmountFromTank
import net.minecraftforge.fluids.IFluidHandler; //导入方法依赖的package包/类
private int getAmountFromTank(IFluidHandler tank, FluidStack stack, EnumFacing dir) {
if (tank != null && stack != null && stack.amount > 0 && dir != null && tank.getTankInfo(dir) != null &&tank.getTankInfo(dir).length > 0) {
for (int i = 0; i < tank.getTankInfo(dir).length; i++) {
if (tank.getTankInfo(dir)[i].fluid != null && tank.getTankInfo(dir)[i].fluid.amount > 0
&& tank.getTankInfo(dir)[i].fluid.isFluidEqual(stack)) return tank.getTankInfo(dir)[i].fluid.amount;
}
}
return 0;
}
示例12: getTankInfo
import net.minecraftforge.fluids.IFluidHandler; //导入方法依赖的package包/类
public FluidTankInfo[] getTankInfo(IFluidHandler tank)
{
if (tank != null)
{
if (tank.getTankInfo(facing) != null && tank.getTankInfo(facing).length != 0)
{
return tank.getTankInfo(facing);
} else if (tank.getTankInfo(ForgeDirection.UNKNOWN) != null && tank.getTankInfo(ForgeDirection.UNKNOWN).length != 0)
{
return tank.getTankInfo(ForgeDirection.UNKNOWN);
}
}
return null;
}
示例13: transferFluid
import net.minecraftforge.fluids.IFluidHandler; //导入方法依赖的package包/类
@LuaFunction
public int transferFluid(String source, ForgeDirection sourceSide, int sourceTankId, String target, ForgeDirection targetSide, int amount) throws Exception {
sourceTankId--;
if (!posByName.containsKey(source)) {
throw new Exception("Invalid source '" + source + "'. Not specified, use setName(x,y,z,name) first.");
}
if (!posByName.containsKey(target)) {
throw new Exception("Invalid target '" + target + "'. Not specified, use setName(x,y,z,name) first.");
}
if (amount <= 0) {
throw new Exception("At least 1mb needs to be transferred.");
}
RelativePos sourcePos = posByName.get(source);
TileEntity sourceTile = worldObj.getTileEntity(xCoord + sourcePos.x, yCoord + sourcePos.y, zCoord + sourcePos.z);
if (!(sourceTile instanceof IFluidHandler)) {
throw new Exception("Source tile is no fluid handler.");
}
RelativePos targetPos = posByName.get(target);
TileEntity targetTile = worldObj.getTileEntity(xCoord + targetPos.x, yCoord + targetPos.y, zCoord + targetPos.z);
if (!(targetTile instanceof IFluidHandler)) {
throw new Exception("Target tile is no fluid handler.");
}
IFluidHandler sourceHandler = (IFluidHandler) sourceTile;
FluidTankInfo sourceTankInfos[] = sourceHandler.getTankInfo(sourceSide);
if (sourceTankInfos.length == 0) {
return 0;
}
if (sourceTankId >= sourceTankInfos.length) {
throw new Exception("Source tile has no tank " + sourceTankId + " on side '" + sourceSide + "'.");
}
FluidTankInfo sourceTankInfo = sourceTankInfos[sourceTankId];
if (sourceTankInfo.fluid == null) {
return 0;
}
FluidStack sourceFluid = sourceTankInfo.fluid.copy();
if (sourceHandler.canDrain(sourceSide, sourceFluid.getFluid())) {
sourceFluid.amount = amount;
FluidStack sourceDrainageSim = sourceHandler.drain(sourceSide, sourceFluid, false);
if (sourceDrainageSim.amount > 0) {
// Drain simulation successful
IFluidHandler targetHandler = (IFluidHandler) targetTile;
if (targetHandler.canFill(targetSide, sourceFluid.getFluid())) {
int filledSim = targetHandler.fill(targetSide, sourceDrainageSim, false);
if (filledSim > 0) {
// Fill simulation successful
FluidStack sourceDrainage = sourceHandler.drain(sourceSide, sourceFluid, true);
int filled = targetHandler.fill(targetSide, sourceDrainage, true);
sourceTile.markDirty();
targetTile.markDirty();
return filled;
}
}
}
}
return 0;
}
示例14: getTankInfo
import net.minecraftforge.fluids.IFluidHandler; //导入方法依赖的package包/类
@ScriptCallable(returnTypes = ReturnType.TABLE, description = "A table of tanks will be returned, each with a table of information")
public FluidTankInfo[] getTankInfo(IFluidHandler fluidHandler,
@Optionals @Arg(name = "direction", description = "The internal direction of the tank. If you're not sure, use 'unknown' (north, south, east, west, up, down or unknown)") ForgeDirection direction) {
return fluidHandler.getTankInfo(direction != null? direction : ForgeDirection.UNKNOWN);
}
示例15: pushFluid
import net.minecraftforge.fluids.IFluidHandler; //导入方法依赖的package包/类
public void pushFluid()
{
int sideAttached = worldObj.getBlockMetadata(xCoord, yCoord, zCoord) ^ 1;
if(this.tank.getFluidAmount()>= 1000)
{
lastDir[worldObj.getBlockMetadata(xCoord, yCoord, zCoord)] = 0;
for(int ix = 0; ix < 6; ix++)
{
if(lastDir[0] == 0 && lastDir[1] == 0 && lastDir[2] == 0 && lastDir[3] == 0 && lastDir[4] == 0 && lastDir[5] == 0)
{
lastDir[0] = 1;
lastDir[1] = 1;
lastDir[2] = 1;
lastDir[3] = 1;
lastDir[4] = 1;
lastDir[5] = 1;
lastDir[worldObj.getBlockMetadata(xCoord, yCoord, zCoord)] = 0;
}
ForgeDirection dir = ForgeDirection.getOrientation(ix);
if(lastDir[ix] == 0 || worldObj.getTileEntity(xCoord+dir.offsetX, yCoord+dir.offsetY, zCoord+dir.offsetZ) == null || !(worldObj.getTileEntity(xCoord+dir.offsetX, yCoord+dir.offsetY, zCoord+dir.offsetZ) instanceof IFluidHandler))
{
lastDir[ix] = 0;
continue;
}
else if(worldObj.getTileEntity(xCoord+dir.offsetX, yCoord+dir.offsetY, zCoord+dir.offsetZ) != null && worldObj.getTileEntity(xCoord+dir.offsetX, yCoord+dir.offsetY, zCoord+dir.offsetZ) instanceof IFluidHandler)
{
try
{
IFluidHandler tile = (IFluidHandler) (worldObj.getTileEntity(xCoord+dir.offsetX, yCoord+dir.offsetY, dir.offsetZ+zCoord));
if(tile.canFill(dir, this.tank.getFluid().getFluid()) && this.canDrain(dir.getOpposite(), tank.getFluid().getFluid()))
{
if(!(tile instanceof TileEntityTank) && tile.getTankInfo(dir)[0]!=null && tile.getTankInfo(dir)[0].fluid != null)
{
if(tile.getTankInfo(dir)[0].fluid.amount+this.transferAmount <= tile.getTankInfo(dir)[0].capacity)
{
tile.fill(dir, this.drain(dir.getOpposite(), new FluidStack(tank.getFluid().getFluid(), this.transferAmount), true), true);
lastDir[ix] = 0;
}
}
else
{
lastDir[ix] = 0;
tile.fill(dir, this.drain(dir.getOpposite(), new FluidStack(tank.getFluid().getFluid(), this.transferAmount), true), true);
}
}
}
catch(Exception e)
{
}
}
}
}
}