本文整理汇总了Java中net.minecraftforge.fluids.FluidStack类的典型用法代码示例。如果您正苦于以下问题:Java FluidStack类的具体用法?Java FluidStack怎么用?Java FluidStack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FluidStack类属于net.minecraftforge.fluids包,在下文中一共展示了FluidStack类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: finishWithMekanismHandling
import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@Optional.Method(modid = "mekanism")
private boolean finishWithMekanismHandling(HybridTank handler, ResultChance chance) {
if(this.required instanceof HybridFluidGas && handler instanceof HybridGasTank) {
GasStack gasOut = ((HybridFluidGas) this.required).asGasStack();
HybridGasTank gasTankHandler = (HybridGasTank) handler;
int fillableGas = gasTankHandler.receiveGas(EnumFacing.UP, gasOut, false);
if(chance.canProduce(this.chance)) {
return fillableGas >= gasOut.amount;
}
return fillableGas >= gasOut.amount && gasTankHandler.receiveGas(EnumFacing.UP, gasOut, true) >= gasOut.amount;
} else {
FluidStack outStack = this.required.asFluidStack();
if(outStack != null) {
int fillableAmount = handler.fillInternal(outStack.copy(), false);
if(chance.canProduce(this.chance)) {
return fillableAmount >= outStack.amount;
}
FluidStack copyOut = outStack.copy();
if(this.tagDisplay != null ){
copyOut.tag = this.tagDisplay.copy();
}
return fillableAmount >= outStack.amount && handler.fillInternal(copyOut.copy(), true) >= copyOut.amount;
}
}
return false;
}
示例2: drain
import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@Nullable
@Override
public FluidStack drain(FluidStack resource, boolean doDrain) {
FluidStack drained = null;
if(tile != null)
for (EnumFacing facing : EnumFacing.HORIZONTALS) {
if(tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,facing))
{
IFluidHandler capability = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY,facing);
drained = capability.drain(resource,doDrain);
if(drained != null)
break;
}
}
return drained;
}
示例3: addTooltip
import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@Override
public void addTooltip(int mouseX, int mouseY, List<String> curTip, boolean shift) {
Fluid fluid = null;
int amt = 0;
int capacity = 0;
if (tank.getFluid() != null) {
fluid = tank.getFluid().getFluid();
amt = tank.getFluidAmount();
}
capacity = tank.getCapacity();
if (fluid == null || amt == 0 || capacity == 0) {
curTip.add(amt + "/" + capacity + " mb");
curTip.add(TextFormatting.GRAY + I18n.format("gui.liquid.empty"));
} else {
curTip.add(amt + "/" + capacity + " mb");
curTip.add(TextFormatting.GRAY + fluid.getLocalizedName(new FluidStack(fluid, amt)));
}
}
示例4: drain
import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@Nullable
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
if (container.stackSize != 1 || maxDrain < Fluid.BUCKET_VOLUME)
{
return null;
}
FluidStack fluidStack = getFluid();
if (fluidStack != null)
{
if (doDrain)
{
setFluid(null);
}
return fluidStack;
}
return null;
}
示例5: matchFluidStack
import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
private T matchFluidStack(Iterable<T> ingredients, T ingredientToMatch) {
if(Iterables.isEmpty(ingredients)) {
return null;
}
FluidStack stack = ingredientToMatch.asFluidStack();
if(stack == null) {
return null;
}
Fluid fluidMatch = stack.getFluid();
for (T hybridFluid : ingredients) {
FluidStack hybridFluidStack = hybridFluid.asFluidStack();
if(hybridFluidStack == null) {
continue;
}
if(hybridFluidStack.getFluid() == fluidMatch) {
return hybridFluid;
}
}
return null;
}
示例6: renderItem
import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@Override
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
RenderBlocks renderblocks = (RenderBlocks) data[0];
Block block = Block.getBlockFromItem(item.getItem());
if (item.hasTagCompound()) {
NBTTagCompound tag = item.stackTagCompound;
if (tag.hasKey("Fluid")) {
FluidStack liquid = FluidStack.loadFluidStackFromNBT(item.getTagCompound().getCompoundTag("Fluid"));
if (liquid != null) {
GL11.glEnable(GL11.GL_BLEND);
float height = ((float) liquid.amount / (float) 8000 * (float) 0.99);
renderblocks.setRenderBounds(0.01, 0.01, 0.01, 0.99, height, 0.99);
Utils.renderInventoryBlock(renderblocks, GrandFluidTank.renderblocks, liquid.getFluid());
GL11.glDisable(GL11.GL_BLEND);
}
}
GL11.glEnable(GL11.GL_ALPHA_TEST);
renderblocks.setRenderBounds(0, 0, 0, 1, 1, 1);
Utils.renderInventoryBlock(renderblocks, block, GrandFluidTank.glassfluidtank.getIcon(0, 0));
GL11.glDisable(GL11.GL_ALPHA_TEST);
}
}
示例7: equals
import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@Override
public boolean equals(Object obj) {
if (obj instanceof RecipeOutputFluid) {
RecipeOutputFluid ro = (RecipeOutputFluid) obj;
if (outputs.size() == ro.outputs.size() &&
(metadata == null && ro.metadata == null || metadata != null && ro.metadata != null && metadata.equals(ro.metadata))) {
Iterator<FluidStack> itA = outputs.iterator();
Iterator<FluidStack> itB = ro.outputs.iterator();
while (itA.hasNext() && itB.hasNext()) {
FluidStack stackA = itA.next();
FluidStack stackB = itB.next();
if (stackA.isFluidStackIdentical(stackB)) return false;
}
return true;
}
}
return false;
}
示例8: drawFluid
import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
private void drawFluid(Minecraft minecraft, final int xPosition, final int yPosition, @Nullable FluidStack fluidStack) {
if (fluidStack == null) {
return;
}
Fluid fluid = fluidStack.getFluid();
if (fluid == null) {
return;
}
TextureAtlasSprite fluidStillSprite = getStillFluidSprite(minecraft, fluid);
int fluidColor = fluid.getColor(fluidStack);
int scaledAmount = (fluidStack.amount * height) / capacityMb;
if (fluidStack.amount > 0 && scaledAmount < MIN_FLUID_HEIGHT) {
scaledAmount = MIN_FLUID_HEIGHT;
}
if (scaledAmount > height) {
scaledAmount = height;
}
drawTiledSprite(minecraft, xPosition, yPosition, width, height, fluidColor, scaledAmount, fluidStillSprite);
}
示例9: getStack
import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@Nullable
private FluidStack getStack(IBlockState blockState)
{
Material material = blockState.getMaterial();
if (material == Material.WATER && blockState.getValue(BlockLiquid.LEVEL) == 0)
{
return new FluidStack(FluidRegistry.WATER, Fluid.BUCKET_VOLUME);
}
else if (material == Material.LAVA && blockState.getValue(BlockLiquid.LEVEL) == 0)
{
return new FluidStack(FluidRegistry.LAVA, Fluid.BUCKET_VOLUME);
}
else
{
return null;
}
}
示例10: addTooltip
import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
public static void addTooltip(ItemStack stack, World world, List<String> curInfo, boolean sneaking) {
if (stack.getTagCompound() != null && stack.getItem() instanceof ItemSemiBlockBase) {
if (stack.getTagCompound().getBoolean("invisible")) curInfo.add(I18n.format("gui.logisticFrame.invisible"));
if (stack.getTagCompound().hasKey("filters") && stack.getTagCompound().getTagList("filters", 10).tagCount() > 0 || stack.getTagCompound().hasKey("fluidFilters") && stack.getTagCompound().getTagList("fluidFilters", 10).tagCount() > 0) {
String key = SemiBlockManager.getKeyForSemiBlock(SemiBlockManager.getSemiBlockForItem((ItemSemiBlockBase) stack.getItem()));
if (sneaking) {
curInfo.add(I18n.format(String.format("gui.%s.filters", key)));
SemiBlockRequester requester = new SemiBlockRequester();
requester.onPlaced(PneumaticCraftRepressurized.proxy.getPlayer(), stack, null);
ItemStack[] stacks = new ItemStack[requester.getFilters().getSlots()];
for (int i = 0; i < stacks.length; i++) {
stacks[i] = requester.getFilters().getStackInSlot(i);
}
PneumaticCraftUtils.sortCombineItemStacksAndToString(curInfo, stacks);
for (int i = 0; i < 9; i++) {
FluidStack fluid = requester.getTankFilter(i).getFluid();
if (fluid != null) {
curInfo.add("-" + fluid.amount / 1000 + "B " + fluid.getLocalizedName());
}
}
} else {
curInfo.add(I18n.format(String.format("gui.%s.hasFilters", key)));
}
}
}
}
示例11: amountRequested
import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@Override
public int amountRequested(FluidStack stack) {
int totalRequestingAmount = getTotalRequestedAmount(stack);
if (totalRequestingAmount > 0) {
TileEntity te = getTileEntity();
int count = 0;
for (EnumFacing facing : EnumFacing.VALUES) {
if (te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing)) {
IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, facing);
for (IFluidTankProperties properties : handler.getTankProperties()) {
FluidStack contents = properties.getContents();
if (contents != null && contents.getFluid() == stack.getFluid()) {
count += contents.amount;
}
}
if (count > 0) break;
}
}
if (count == 0) return 0;
count += getIncomingFluid(stack.getFluid());
return Math.max(0, Math.min(stack.amount, totalRequestingAmount - count));
}
return 0;
}
示例12: suckLiquid
import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
private boolean suckLiquid() {
Block block = world.getBlockState(getPos().offset(EnumFacing.DOWN, currentDepth + 1)).getBlock();
Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
if (fluid == null) {
pumpingLake = null;
return false;
}
FluidStack fluidStack = new FluidStack(fluid, 1000);
if (tank.fill(fluidStack, false) == 1000) {
if (pumpingLake == null) {
findLake(block);
}
BlockPos curPos = null;
boolean foundSource = false;
while (pumpingLake.size() > 0) {
curPos = pumpingLake.get(0);
if (getWorld().getBlockState(curPos).getBlock() == block && FluidUtils.isSourceBlock(getWorld(), curPos)) {
foundSource = true;
break;
}
pumpingLake.remove(0);
}
if (pumpingLake.size() == 0) {
pumpingLake = null;
} else if (foundSource) {
getWorld().setBlockToAir(curPos);
tank.fill(fluidStack, true);
addAir(-100);
status = Status.PUMPING;
}
}
return true;
}
示例13: registerGeoBurnables
import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@SubscribeEvent
public static void registerGeoBurnables(RegistryEvent.Register<IGeoburnable> event){
IForgeRegistry<IGeoburnable> reg = event.getRegistry();
reg.register(new BlockGeoburnable(Blocks.MAGMA, 40, 1));
reg.register(new BlockGeoburnable(Blocks.FIRE, 80, 2){
@Override
public ItemStack getJEIIcon() {
return new ItemStack(Items.FLINT_AND_STEEL);
}
});
reg.register(new BlockGeoburnable(Blocks.LAVA, 160, 3){
@Override
public ItemStack getJEIIcon() {
return FluidUtil.getFilledBucket(new FluidStack(FluidRegistry.LAVA, Fluid.BUCKET_VOLUME));
}
});
}
示例14: fill
import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
@Override
public int fill(FluidStack resource, boolean doFill)
{
if (resource == null || resource.amount <= 0)
return 0;
resource = resource.copy();
int totalFillAmount = 0;
for (IFluidHandler handler : subHandlers)
{
int fillAmount = handler.fill(resource, doFill);
totalFillAmount += fillAmount;
resource.amount -= fillAmount;
if (resource.amount <= 0)
break;
}
return totalFillAmount;
}
示例15: getLiquidXPText
import net.minecraftforge.fluids.FluidStack; //导入依赖的package包/类
private List<String> getLiquidXPText() {
List<String> liquidXpText = new ArrayList<String>();
liquidXpText.add("gui.tab.info.aerialInterface.liquidXp.info");
for (Fluid fluid : PneumaticCraftAPIHandler.getInstance().liquidXPs.keySet()) {
liquidXpText.add(TextFormatting.DARK_AQUA + new FluidStack(fluid, 1).getLocalizedName() + " (" + fluid.getName() + ")");
}
return liquidXpText;
}