当前位置: 首页>>代码示例>>Java>>正文


Java IFluidTank类代码示例

本文整理汇总了Java中net.minecraftforge.fluids.IFluidTank的典型用法代码示例。如果您正苦于以下问题:Java IFluidTank类的具体用法?Java IFluidTank怎么用?Java IFluidTank使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IFluidTank类属于net.minecraftforge.fluids包,在下文中一共展示了IFluidTank类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: render

import net.minecraftforge.fluids.IFluidTank; //导入依赖的package包/类
@Override
public void render(TileEntityPlasticMixer te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
    IFluidTank tank = te.getTank();
    if (tank.getFluidAmount() == 0) return;

    GlStateManager.pushMatrix();
    GlStateManager.translate(x, y, z);
    GlStateManager.enableBlend();
    GlStateManager.disableAlpha();
    GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);

    AxisAlignedBB bounds = getRenderBounds(tank);
    PneumaticCraftUtils.renderFluid(tank.getFluid().getFluid(), bounds);

    GlStateManager.disableBlend();
    GlStateManager.enableAlpha();
    GlStateManager.popMatrix();
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:21,代码来源:RenderPlasticMixer.java

示例2: readCapabilities

import net.minecraftforge.fluids.IFluidTank; //导入依赖的package包/类
protected void readCapabilities(NBTTagCompound nbt, @Nullable EnumFacing side){
    IItemHandler inventory = this.getInventory(side);
    if(inventory != null && inventory instanceof IItemHandlerModifiable && nbt.hasKey("Inventory")){
        for(int i = 0; i < inventory.getSlots(); i++){ // clear the inventory, otherwise empty stacks doesn't get overriden while syncing. Forge Bug?
            ((IItemHandlerModifiable) inventory).setStackInSlot(i, ItemStack.EMPTY);
        }
        CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.readNBT(inventory, side, nbt.getTag("Inventory"));
    }
    IFluidHandler tank = getTank(side);
    if(tank != null && tank instanceof IFluidTank && nbt.hasKey("FluidTank")){
        CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.readNBT(tank, side, nbt.getCompoundTag("FluidTank"));
    }
    IEnergyStorage energy = getEnergy(side);
    if(energy != null && energy instanceof EnergyStorage && nbt.hasKey("Energy")){
        CapabilityEnergy.ENERGY.readNBT(energy, side, nbt.getTag("Energy"));
    }
}
 
开发者ID:canitzp,项目名称:Metalworks,代码行数:18,代码来源:TileBase.java

示例3: extractFluidsFromTanks

import net.minecraftforge.fluids.IFluidTank; //导入依赖的package包/类
public static void extractFluidsFromTanks(List<IFluidTank> tanks, List<FluidStack> fluids)
{
    LinkedList<IFluidTank> remaining = Lists.newLinkedList(tanks);

    for (FluidStack stack : fluids)
    {
        for (Iterator<IFluidTank> iterator = remaining.iterator(); iterator.hasNext(); )
        {
            IFluidTank tank = iterator.next();
            if (tank.getFluid() != null && tank.getFluid().getFluid().getName().equals(stack.getFluid().getName()))
            {
                FluidStack drained = tank.drain(stack.amount, false);
                if (drained != null && drained.amount == stack.amount)
                {
                    tank.drain(stack.amount, true);
                    iterator.remove();
                    break;
                }
            }
        }
    }
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:23,代码来源:ItemHelper.java

示例4: getFluidTank

import net.minecraftforge.fluids.IFluidTank; //导入依赖的package包/类
@Nullable
@Override
public IFluidTank getFluidTank(String name)
{
    String moduleName;
    String sourceName;
    TileEntityModule module;

    if (name.contains(":"))
    {
        String[] split = name.split(":");
        moduleName = split[0];
        sourceName = split[1];
    } else
    {
        moduleName = name;
        sourceName = name;
    }

    module = modules.get(moduleName);
    if (module instanceof FluidSource)
        return ((FluidSource) module).getFluidTank(sourceName);

    return null;
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:26,代码来源:TileEntitySimple.java

示例5: getPickBlock

import net.minecraftforge.fluids.IFluidTank; //导入依赖的package包/类
@Override
@Nonnull
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
	ItemStack result = new ItemStack(this);
	TileEntityTank tile = getTileEntity(world, pos, TileEntityTank.class);
	if (tile != null) {
		IFluidTank tank = tile.getTank();
		if (tank.getFluidAmount() > 0) {
			NBTTagCompound tankTag = tile.getItemNBT();
			if (tankTag.hasKey("Amount")) tankTag.setInteger("Amount", tank.getCapacity());

			NBTTagCompound nbt = ItemUtils.getItemTag(result);
			nbt.setTag("tank", tankTag);
		}
	}
	return result;
}
 
开发者ID:OpenMods,项目名称:OpenBlocks,代码行数:18,代码来源:BlockTank.java

示例6: getRenderBounds

import net.minecraftforge.fluids.IFluidTank; //导入依赖的package包/类
static AxisAlignedBB getRenderBounds(IFluidTank tank, AxisAlignedBB tankBounds) {
    float percent = (float) tank.getFluidAmount() / (float) tank.getCapacity();

    double tankHeight = tankBounds.maxY - tankBounds.minY;
    double y1 = tankBounds.minY, y2 = (tankBounds.minY + (tankHeight * percent));
    if (tank.getFluid().getFluid().getDensity() < 0) {
        double yOff = tankBounds.maxY - y2;  // lighter than air fluids move to the top of the tank
        y1 += yOff; y2 += yOff;
    }
    return new AxisAlignedBB(tankBounds.minX, y1, tankBounds.minZ, tankBounds.maxX, y2, tankBounds.maxZ);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:12,代码来源:TankRenderHelper.java

示例7: actionPerformed

import net.minecraftforge.fluids.IFluidTank; //导入依赖的package包/类
@Override
public void actionPerformed(IGuiWidget widget) {
    super.actionPerformed(widget);
    if (widget instanceof WidgetFluidStack) {
        boolean leftClick = Mouse.isButtonDown(0);
        boolean middleClick = Mouse.isButtonDown(2);
        boolean shift = PneumaticCraftRepressurized.proxy.isSneakingInGui();
        IFluidTank tank = logistics.getTankFilter(widget.getID());
        if (tank.getFluidAmount() > 0) {
            if (middleClick) {
                logistics.setFilter(widget.getID(), null);
            } else if (leftClick) {
                tank.drain(shift ? tank.getFluidAmount() / 2 : 1000, true);
                if (tank.getFluidAmount() < 1000) {
                    tank.drain(1000, true);
                }
            } else {
                tank.fill(new FluidStack(tank.getFluid().getFluid(), shift ? tank.getFluidAmount() : 1000), true);
            }
            NetworkHandler.sendToServer(new PacketSetLogisticsFluidFilterStack(logistics, tank.getFluid(), widget.getID()));
        } else {
            fluidSearchGui = new GuiLogisticsLiquidFilter(this);
            editingSlot = widget.getID();
            mc.displayGuiScreen(fluidSearchGui);
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:28,代码来源:GuiLogisticsBase.java

示例8: writeCapabilities

import net.minecraftforge.fluids.IFluidTank; //导入依赖的package包/类
protected void writeCapabilities(NBTTagCompound nbt, @Nullable EnumFacing side){
    IItemHandler inventory = this.getInventory(side);
    if(inventory != null && inventory instanceof IItemHandlerModifiable){
        nbt.setTag("Inventory", CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.writeNBT(inventory, side));
    }
    IFluidHandler tank = getTank(side);
    if(tank != null && tank instanceof IFluidTank){
        nbt.setTag("FluidTank", CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY.writeNBT(tank, side));
    }
    IEnergyStorage energy = getEnergy(side);
    if(energy != null && energy instanceof EnergyStorage){
        nbt.setTag("Energy", CapabilityEnergy.ENERGY.writeNBT(energy, side));
    }
}
 
开发者ID:canitzp,项目名称:Metalworks,代码行数:15,代码来源:TileBase.java

示例9: extractInputFluids

import net.minecraftforge.fluids.IFluidTank; //导入依赖的package包/类
private void extractInputFluids(MachineRecipe recipe)
{
    List<IFluidTank> remaining = Arrays.stream(supplier.inputTanks)
                                       .map(fluidSource::getFluidTank)
                                       .collect(Collectors.toCollection(LinkedList::new));

    ItemHelper.extractFluidsFromTanks(remaining, recipe.getFluidRecipeInput());
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:9,代码来源:TileEntityModuleMachine.java

示例10: getActiveRecipe

import net.minecraftforge.fluids.IFluidTank; //导入依赖的package包/类
private MachineRecipe getActiveRecipe()
{
    NonNullList<ItemStack> input = invHandler.getInputStacks();
    List<FluidStack> inputFluid = Arrays.stream(supplier.inputTanks)
                                        .map(fluidSource::getFluidTank)
                                        .map(IFluidTank::getFluid)
                                        .collect(Collectors.toList());

    return MachineManager.findMatchingRecipe(supplier.recipeList, input, inputFluid, tile.getWorld());
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:11,代码来源:TileEntityModuleMachine.java

示例11: detectAndSendChanges

import net.minecraftforge.fluids.IFluidTank; //导入依赖的package包/类
@Override
public void detectAndSendChanges()
{
    super.detectAndSendChanges();

    for (int i = 0; i < tanks.size(); i++)
    {
        IFluidTank tank = tanks.get(i);

        FluidStack prev = fluidStacks.get(i);
        FluidStack current = tank.getFluid();

        if (!ItemHelper.fluidStackEqual(prev, current))
        {
            PacketSyncContainerFluid packet = new PacketSyncContainerFluid(windowId, i, current);
            for (IContainerListener listener : listeners)
            {
                if (listener instanceof EntityPlayerMP)
                {
                    EntityPlayerMP player = (EntityPlayerMP) listener;
                    CustomStuff4.network.sendTo(packet, player);
                }
            }

            fluidStacks.set(i, current == null ? null : current.copy());
        }
    }
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:29,代码来源:ContainerCS4.java

示例12: update

import net.minecraftforge.fluids.IFluidTank; //导入依赖的package包/类
@Override
public void update() {
    if (hasFuel()) {
        ItemStack melt = inventory.getStackInSlot(0);
        MeltingRecipe recipe = MelteryHandler.getMelteryRecipe(melt);

        if (recipe != null) {
            if (progress > recipe.getUsableTemperature()) {
                FluidStack fluidStack = recipe.getResult();
                if ((tank.getCapacity() - tank.getFluidAmount()) >= tank.fill(fluidStack, false)) {
                    tank.fill(fluidStack, true);
                    world.playSound(null, pos, SoundEvents.ITEM_BUCKET_FILL_LAVA, SoundCategory.BLOCKS, 1.0f, 0.75f);
                    melt.shrink(1);
                } else {
                    world.playSound(null, pos, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 1.0f, 0.75f);
                }
                setProgress(0);
            }
            incrementProcress();
        }
    }
    if(tank.getFluidAmount() > 0) {
        for (EnumFacing facing : EnumFacing.HORIZONTALS) {
            BlockPos side = pos.offset(facing);
            if (!world.isAirBlock(side)) {
                if (world.getTileEntity(side) != null) {
                    TileEntity tile = world.getTileEntity(side);
                    if (!(tile instanceof TileMeltery) && tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite())) {
                        IFluidHandler fluidHandler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing.getOpposite());
                        if (fluidHandler instanceof IFluidTank) {
                            FluidUtil.tryFluidTransfer(fluidHandler, tank, 140, true);
                        }
                    }

                }
            }
        }
    }
}
 
开发者ID:primetoxinz,项目名称:Meltery,代码行数:40,代码来源:TileMeltery.java

示例13: drawFluidTank

import net.minecraftforge.fluids.IFluidTank; //导入依赖的package包/类
public void drawFluidTank(IFluidTank tank, int x, int y) {
	FluidStack fluid = tank.getFluid();
	TextureManager manager = Minecraft.getMinecraft().renderEngine;
	if (fluid != null) {
		manager.bindTexture(manager.getResourceLocation(0));
		float amount = fluid.amount;
		float capacity = tank.getCapacity();
		float scale = amount / capacity;
		int fluidTankHeight = 60;
		int fluidAmount = (int) (scale * fluidTankHeight);
		drawFluid(x, y + fluidTankHeight - fluidAmount, fluid.getFluid().getIcon(fluid), 16, fluidAmount);
	}
}
 
开发者ID:austinv11,项目名称:DartCraft2,代码行数:14,代码来源:GuiInfuser.java

示例14: updateConnections

import net.minecraftforge.fluids.IFluidTank; //导入依赖的package包/类
public void updateConnections() {
	ticksSinceLastConnectionUpdate = 0;
	connectedNorth = false;
	connectedSouth = false;
	connectedEast = false;
	connectedWest = false;
	connectedDown = false;
	connectedUp = false;
	for (EnumFacing e : EnumFacing.VALUES) {
		if (this.world.getTileEntity(this.pos.offset(e)) instanceof IFluidTank) {
			// LogHelper.info("Connection point found to the : " + e.toString());
			switch (e) {
			case NORTH:
				connectedNorth = true;
				break;
			case SOUTH:
				connectedSouth = true;
				break;
			case EAST:
				connectedEast = true;
				break;
			case WEST:
				connectedWest = true;
				break;
			case UP:
				connectedUp = true;
				break;
			case DOWN:
				connectedDown = true;
				break;
			}

		}
	}
}
 
开发者ID:TechStack,项目名称:TechStack-s-HeavyMachineryMod,代码行数:36,代码来源:TileEntityLiquidPipe.java

示例15: getFluidTankInfo

import net.minecraftforge.fluids.IFluidTank; //导入依赖的package包/类
public FluidTankInfo[] getFluidTankInfo(ITankManager manager)
{
	Object[] tanks = manager.getTanks();
	List<FluidTankInfo> infos = new ArrayList<FluidTankInfo>();
	
	for(int slot : availableSlots)
	{
		if(slot <= tanks.length-1 && tanks[slot] instanceof IFluidTank)
		{
			infos.add(((IFluidTank)tanks[slot]).getInfo());
		}
	}
	
	return infos.toArray(new FluidTankInfo[] {});
}
 
开发者ID:Microsoft,项目名称:vsminecraft,代码行数:16,代码来源:SideData.java


注:本文中的net.minecraftforge.fluids.IFluidTank类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。