本文整理匯總了Java中net.minecraftforge.fluids.FluidStack.copy方法的典型用法代碼示例。如果您正苦於以下問題:Java FluidStack.copy方法的具體用法?Java FluidStack.copy怎麽用?Java FluidStack.copy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.fluids.FluidStack
的用法示例。
在下文中一共展示了FluidStack.copy方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRequestedAmount
import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
public static int getRequestedAmount(SemiBlockLogistics requester, FluidStack providingStack) {
int requestedAmount = requester instanceof ISpecificRequester ? ((ISpecificRequester) requester).amountRequested(providingStack) : providingStack.amount;
if (requestedAmount == 0) return 0;
providingStack = providingStack.copy();
providingStack.amount = requestedAmount;
FluidStack remainder = providingStack.copy();
remainder.amount += requester.getIncomingFluid(remainder.getFluid());
TileEntity te = requester.getTileEntity();
if (te == null) return 0;
for (EnumFacing d : EnumFacing.VALUES) {
if (te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, d)) {
IFluidHandler handler = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, d);
int fluidFilled = handler.fill(remainder, false);
if (fluidFilled > 0) {
remainder.amount -= fluidFilled;
break;
}
}
}
providingStack.amount -= remainder.amount;
if (providingStack.amount <= 0) return 0;
return providingStack.amount;
}
示例2: 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;
}
示例3: fill
import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public int fill(FluidStack resource, boolean doFill)
{
if (container.stackSize != 1 || resource == null || resource.amount <= 0 || !canFillFluidType(resource))
{
return 0;
}
FluidStack contained = getFluid();
if (contained == null)
{
int fillAmount = Math.min(capacity, resource.amount);
if (fillAmount == capacity) {
if (doFill) {
FluidStack filled = resource.copy();
filled.amount = fillAmount;
setFluid(filled);
}
return fillAmount;
}
}
return 0;
}
示例4: 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;
}
示例5: SmeltingRecipeWrapper
import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
public SmeltingRecipeWrapper(MeltingRecipe recipe) {
this.inputs = recipe.input.getInputs();
this.outputs = ImmutableList.of(recipe.getResult());
this.temperature = recipe.getTemperature();
ImmutableList.Builder<FluidStack> builder = ImmutableList.builder();
for(FluidStack fs : TinkerRegistry.getSmelteryFuels()) {
if(fs.getFluid().getTemperature(fs) >= temperature) {
fs = fs.copy();
fs.amount = 1000;
builder.add(fs);
}
}
fuels = builder.build();
}
示例6: getContents
import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Nullable
@Override
public FluidStack getContents()
{
FluidStack contents = tank.getFluid();
return contents == null ? null : contents.copy();
}
示例7: drain
import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public FluidStack drain(int maxDrain, boolean doDrain)
{
if (container.stackSize != 1 || maxDrain <= 0)
{
return null;
}
FluidStack contained = getFluid();
if (contained == null || contained.amount <= 0 || !canDrainFluidType(contained))
{
return null;
}
final int drainAmount = Math.min(contained.amount, maxDrain);
if (drainAmount == capacity) {
FluidStack drained = contained.copy();
if (doDrain) {
setContainerToEmpty();
}
return drained;
}
return null;
}
示例8: fill
import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public int fill(FluidStack resource, boolean doFill)
{
if (resource == null || !resource.getFluid().equals(WATER) || resource.amount <= 0)
{
return 0;
}
FluidStack contents = this.getContents();
int max = this.getCapacity();
int current = contents != null ? contents.amount : 0;
int lacking = max - current;
int filled = Math.min(lacking, resource.amount);
if (doFill)
{
if (contents != null)
{
contents.amount += filled;
}
else
{
contents = resource.copy();
contents.amount = filled;
}
this.setFluidStack(contents);
}
return filled;
}
示例9: finishCrafting
import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
public boolean finishCrafting(MachineComponent component, RecipeCraftingContext context, ResultChance chance) {
if(component.getComponentType() != MachineComponent.ComponentType.FLUID ||
!(component instanceof MachineComponent.FluidHatch) ||
component.getIOType() != getActionType()) return false;
HybridTank handler = context.getFluidHandler(component);
switch (getActionType()) {
case OUTPUT:
if(ModularMachinery.isMekanismLoaded) {
return finishWithMekanismHandling(handler, chance);
} 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;
}
示例10: copyWhenNecessary
import net.minecraftforge.fluids.FluidStack; //導入方法依賴的package包/類
@Override
protected FluidStack copyWhenNecessary(FluidStack oldValue) {
return oldValue.copy();
}