本文整理汇总了Java中net.minecraftforge.fluids.IFluidHandler类的典型用法代码示例。如果您正苦于以下问题:Java IFluidHandler类的具体用法?Java IFluidHandler怎么用?Java IFluidHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IFluidHandler类属于net.minecraftforge.fluids包,在下文中一共展示了IFluidHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addData
import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
@Override
public void addData(final Object tile, final List<String> data, final ForgeDirection side, final EntityPlayer player) {
final FluidTankInfo[] tanks = ((IFluidHandler)tile).getTankInfo(side);
if (tanks != null) {
if (tanks.length == 1) {
if (tanks[0].fluid != null && tanks[0].fluid.amount > 0) {
data.add("Fluid Tank: " + tanks[0].fluid.getFluid().getLocalizedName(tanks[0].fluid) + " - " + tanks[0].fluid.amount + " / " + tanks[0].capacity);
}
else {
data.add("Fluid Tank: Empty - 0 / " + tanks[0].capacity);
}
}
else {
for (int i = 0; i < tanks.length; ++i) {
if (tanks[i].fluid != null && tanks[i].fluid.amount > 0) {
data.add("Fluid Tank " + i + ": " + tanks[i].fluid.getFluid().getLocalizedName(tanks[i].fluid) + " - " + tanks[i].fluid.amount + " / " + tanks[i].capacity);
}
else {
data.add("Fluid Tank " + i + ": Empty - 0 / " + tanks[i].capacity);
}
}
}
}
}
示例2: detectInventories
import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
public void detectInventories() {
this.inventoryMask = 0;
this.fluidMask = 0;
this.upgrades = new boolean[16];
for (int i = 0; i < 6; ++i) {
final int x = this.xCoord + Facing.offsetsXForSide[i];
final int y = this.yCoord + Facing.offsetsYForSide[i];
final int z = this.zCoord + Facing.offsetsZForSide[i];
final TileEntity tile = this.worldObj.getTileEntity(x, y, z);
if (tile instanceof IInventory) {
this.inventoryMask |= 1 << i;
}
if (tile instanceof IFluidHandler) {
this.fluidMask |= 1 << i;
}
if (this.worldObj.getBlock(x, y, z) == ExtraUtils.enderQuarryUpgrade) {
this.upgrades[this.worldObj.getBlockMetadata(x, y, z)] = true;
}
}
}
示例3: isValidTileEntity
import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
public static boolean isValidTileEntity(final TileEntity inv, final int side) {
if (inv == null) {
return false;
}
final ForgeDirection forgeSide = ForgeDirection.getOrientation(side);
final String classname = inv.getClass().toString();
if (classname.contains("thermalexpansion") && classname.contains("conduit")) {
return false;
}
if (inv instanceof IFluidHandler) {
final FluidTankInfo[] t = ((IFluidHandler)inv).getTankInfo(forgeSide);
if (t != null && t.length != 0) {
return true;
}
}
if (inv instanceof IInventory && ((IInventory)inv).getSizeInventory() > 0) {
if (!(inv instanceof ISidedInventory)) {
return true;
}
final int[] t2 = ((ISidedInventory)inv).getAccessibleSlotsFromSide(side);
if (t2 != null && t2.length != 0) {
return true;
}
}
return isRFEnergy(inv, forgeSide);
}
示例4: transferTo
import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
@Override
public boolean transferTo(final INodeBuffer receptor, final int no) {
if (this.getBuffer() == null || !this.getBufferType().equals(receptor.getBufferType())) {
return false;
}
if (!(receptor.getNode() instanceof IFluidHandler)) {
return false;
}
final ForgeDirection dir = receptor.getNode().getNodeDir();
final IFluidHandler dest = (IFluidHandler)receptor.getNode();
final int k = dest.fill(dir, this.tank.drain(200 * no, false), false);
if (k <= 0) {
return false;
}
dest.fill(dir, this.tank.drain(k, true), true);
receptor.setBuffer(dest);
receptor.markDirty();
return true;
}
示例5: onBlockActivated
import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
public boolean onBlockActivated(final World worldObj, final int x, final int y, final int z, final EntityPlayer player, final int side, final float dx, final float dy, final float dz) {
if (worldObj.isRemote) {
return true;
}
final TileEntity tile = worldObj.getTileEntity(x, y, z);
if (player.getCurrentEquippedItem() != null && tile instanceof IFluidHandler) {
final ItemStack item = player.getCurrentEquippedItem();
final FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(item);
if (fluid != null && ((IFluidHandler)tile).fill(ForgeDirection.getOrientation(side), fluid, false) == fluid.amount) {
((IFluidHandler)tile).fill(ForgeDirection.getOrientation(side), fluid, true);
if (!player.capabilities.isCreativeMode) {
player.setCurrentItemOrArmor(0, item.getItem().getContainerItem(item));
}
return true;
}
}
player.openGui((Object)ExtraUtilsMod.instance, 0, worldObj, x, y, z);
return true;
}
示例6: fillTankWithContainer
import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
public static boolean fillTankWithContainer(IFluidHandler tank, EntityPlayer player)
{
ItemStack stack = player.getCurrentEquippedItem();
FluidStack liquid = FluidContainerRegistry.getFluidForFilledItem(stack);
if(liquid == null)
return false;
if(tank.fill(ForgeDirection.UNKNOWN, liquid, false) != liquid.amount && !player.capabilities.isCreativeMode)
return false;
tank.fill(ForgeDirection.UNKNOWN, liquid, true);
if(!player.capabilities.isCreativeMode)
InventoryUtils.consumeItem(player.inventory, player.inventory.currentItem);
player.inventoryContainer.detectAndSendChanges();
return true;
}
示例7: relievePressure
import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
public boolean relievePressure(World world, BlockPos pos, BlockPos up) {
IBlockState stateAbove = world.getBlockState(up);
Block blockAbove = stateAbove.getBlock();
if (blockAbove.hasTileEntity(stateAbove)) {
TileEntity te = world.getTileEntity(up);
if (te instanceof IFluidHandler) {
IFluidHandler tank = (IFluidHandler) te;
FluidStack steam = TileEntitySolarBoiler.getSteamStack().copy();
steam.amount = getAmount(world, pos);
return tank.fill(EnumFacing.DOWN, steam, true) > 0;
}
}
if (!blockAbove.isPassable(world, up)) {
return false;
}
if (world.getClosestPlayer(pos.getX(), pos.getY(), pos.getZ(), 16 * 3) != null) {
// Could also check ForgeChunkManager to see if this chunk is force-loaded.
// I think I won't though.
EntitySteamGeyser geyser = new EntitySteamGeyser(world);
geyser.setPosition(pos.getX() + 0.5, pos.getY() + 1, pos.getZ() + 0.5);
world.spawnEntityInWorld(geyser);
}
return true;
}
示例8: 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;
}
示例9: 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;
}
示例10: pushUp
import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
public int pushUp(FluidStack fluid, boolean doFill)
{
Coord4D up = Coord4D.get(this).getFromSide(ForgeDirection.UP);
if(up.getTileEntity(worldObj) instanceof TileEntityPortableTank)
{
IFluidHandler handler = (IFluidHandler)up.getTileEntity(worldObj);
if(handler.canFill(ForgeDirection.DOWN, fluid.getFluid()))
{
return handler.fill(ForgeDirection.DOWN, fluid, doFill);
}
}
return 0;
}
示例11: 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;
}
示例12: getConnectedAcceptors
import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
/**
* Gets all the acceptors around a tile entity.
* @param tileEntity - center tile entity
* @return array of IFluidHandlers
*/
public static IFluidHandler[] getConnectedAcceptors(TileEntity tileEntity)
{
IFluidHandler[] acceptors = new IFluidHandler[] {null, null, null, null, null, null};
for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity acceptor = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj());
if(acceptor instanceof IFluidHandler && !(acceptor instanceof ITransmitterTile))
{
acceptors[orientation.ordinal()] = (IFluidHandler)acceptor;
}
}
return acceptors;
}
示例13: absorbBuffer
import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
@Override
public void absorbBuffer(IGridTransmitter<IFluidHandler, FluidNetwork> transmitter)
{
Object b = transmitter.getBuffer();
if(!(b instanceof FluidStack) || ((FluidStack)b).getFluid() == null || ((FluidStack)b).amount == 0)
{
return;
}
FluidStack fluid = (FluidStack)b;
if(buffer == null || buffer.getFluid() == null || buffer.amount == 0)
{
buffer = fluid.copy();
return;
}
if(!fluid.isFluidEqual(buffer)) Mekanism.logger.warn("Fluid type " + fluid.getFluid().getName() + " of buffer doesn't match type " + buffer.getFluid().getName() + " of absorbing network");
buffer.amount += fluid.amount;
fluid.amount = 0;
}
示例14: getTypes
import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
private ArrayList<String> getTypes(RelativePos pos) throws Exception {
TileEntity tile = worldObj.getTileEntity(xCoord + pos.x, yCoord + pos.y, zCoord + pos.z);
if (tile == null) {
throw new Exception("Not a valid target!");
}
ArrayList<String> types = new ArrayList<String>();
if (tile instanceof IInventory) {
types.add("item");
}
if (tile instanceof IFluidHandler) {
types.add("fluid");
}
if (tile instanceof IEnergyProvider) {
types.add("energy-provider");
}
if (tile instanceof IEnergyReceiver) {
types.add("energy-receiver");
}
return types;
}
示例15: fill
import net.minecraftforge.fluids.IFluidHandler; //导入依赖的package包/类
@Override
public int fill(ForgeDirection from, FluidStack resource, boolean doFill) {
IFluidHandler handler = this.getFluidTankInDirection(ForgeDirection.DOWN);
int amt = 0;
if(handler != null) {
amt = handler.fill(from, resource, doFill);
}
//Copy to avoid modifiying the passed one
FluidStack resource2 = resource.copy();
resource2.amount -= amt;
if(resource2.amount > 0)
amt += super.fill(from, resource2, doFill);
if(amt > 0 && doFill)
fluidChanged = true;
checkForUpdate();
return amt;
}