Bug fixes
- Fixed spout creating potions from any fluid - Fixed pipes not actually transferring the type of fluid selected by layer II flow propagation - Fixed some fluid handlers erasing nbt data of extracted fluidstacks - Fix sidedness issues in Config packets
This commit is contained in:
parent
f8b3a77f26
commit
64b2c61389
4 changed files with 73 additions and 32 deletions
|
@ -13,6 +13,7 @@ import java.util.function.Supplier;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import com.simibubi.create.content.contraptions.fluids.PipeConnection.Flow;
|
||||
import com.simibubi.create.foundation.fluid.FluidHelper;
|
||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
import com.simibubi.create.foundation.utility.BlockFace;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
|
@ -41,6 +42,7 @@ public class FluidNetwork {
|
|||
List<BlockFace> queued;
|
||||
Set<Pair<BlockFace, PipeConnection>> frontier;
|
||||
Set<BlockPos> visited;
|
||||
FluidStack fluid;
|
||||
List<Pair<BlockFace, LazyOptional<IFluidHandler>>> targets;
|
||||
Map<BlockPos, WeakReference<FluidTransportBehaviour>> cache;
|
||||
|
||||
|
@ -49,6 +51,7 @@ public class FluidNetwork {
|
|||
this.start = location;
|
||||
this.sourceSupplier = sourceSupplier;
|
||||
this.source = LazyOptional.empty();
|
||||
this.fluid = FluidStack.EMPTY;
|
||||
this.frontier = new HashSet<>();
|
||||
this.visited = new HashSet<>();
|
||||
this.targets = new ArrayList<>();
|
||||
|
@ -87,7 +90,12 @@ public class FluidNetwork {
|
|||
|
||||
if (!pipeConnection.hasFlow())
|
||||
continue;
|
||||
|
||||
Flow flow = pipeConnection.flow.get();
|
||||
if (!fluid.isEmpty() && !flow.fluid.isFluidEqual(fluid)) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
if (!flow.inbound) {
|
||||
if (pipeConnection.comparePressure() >= 0)
|
||||
iterator.remove();
|
||||
|
@ -96,6 +104,9 @@ public class FluidNetwork {
|
|||
if (!flow.complete)
|
||||
continue;
|
||||
|
||||
if (fluid.isEmpty())
|
||||
fluid = flow.fluid;
|
||||
|
||||
boolean canRemove = true;
|
||||
for (Direction side : Iterate.directions) {
|
||||
if (side == blockFace.getFace())
|
||||
|
@ -168,7 +179,18 @@ public class FluidNetwork {
|
|||
IFluidHandler handler = source.orElse(null);
|
||||
if (handler == null)
|
||||
return;
|
||||
FluidStack transfer = handler.drain(flowSpeed, action);
|
||||
|
||||
FluidStack transfer = FluidStack.EMPTY;
|
||||
for (int i = 0; i < handler.getTanks(); i++) {
|
||||
FluidStack contained = handler.getFluidInTank(i);
|
||||
if (contained.isEmpty())
|
||||
continue;
|
||||
if (!contained.isFluidEqual(fluid))
|
||||
continue;
|
||||
FluidStack toExtract = FluidHelper.copyStackWithAmount(contained, flowSpeed);
|
||||
transfer = handler.drain(toExtract, action);
|
||||
}
|
||||
|
||||
if (transfer.isEmpty())
|
||||
return;
|
||||
|
||||
|
@ -229,6 +251,7 @@ public class FluidNetwork {
|
|||
visited.clear();
|
||||
targets.clear();
|
||||
queued.clear();
|
||||
fluid = FluidStack.EMPTY;
|
||||
queued.add(start);
|
||||
pauseBeforePropagation = 2;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.simibubi.create.content.contraptions.fluids.actors;
|
||||
|
||||
import com.simibubi.create.AllFluids;
|
||||
import com.simibubi.create.content.contraptions.fluids.potion.PotionFluidHandler;
|
||||
import com.simibubi.create.foundation.fluid.FluidHelper;
|
||||
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
|
@ -36,7 +38,7 @@ public class GenericItemFilling {
|
|||
}
|
||||
|
||||
public static int getRequiredAmountForItem(World world, ItemStack stack, FluidStack availableFluid) {
|
||||
if (stack.getItem() == Items.GLASS_BOTTLE)
|
||||
if (stack.getItem() == Items.GLASS_BOTTLE && canFillGlassBottleInternally(availableFluid))
|
||||
return PotionFluidHandler.getRequiredAmountForFilledBottle(stack, availableFluid);
|
||||
|
||||
LazyOptional<IFluidHandlerItem> capability =
|
||||
|
@ -45,7 +47,8 @@ public class GenericItemFilling {
|
|||
if (tank == null)
|
||||
return -1;
|
||||
if (tank instanceof FluidBucketWrapper) {
|
||||
Item filledBucket = availableFluid.getFluid().getFilledBucket();
|
||||
Item filledBucket = availableFluid.getFluid()
|
||||
.getFilledBucket();
|
||||
if (filledBucket == null || filledBucket == Items.AIR)
|
||||
return -1;
|
||||
return 1000;
|
||||
|
@ -55,12 +58,19 @@ public class GenericItemFilling {
|
|||
return filled == 0 ? -1 : filled;
|
||||
}
|
||||
|
||||
private static boolean canFillGlassBottleInternally(FluidStack availableFluid) {
|
||||
return availableFluid.getFluid()
|
||||
.isEquivalentTo(Fluids.WATER)
|
||||
|| availableFluid.getFluid()
|
||||
.isEquivalentTo(AllFluids.POTION.get());
|
||||
}
|
||||
|
||||
public static ItemStack fillItem(World world, int requiredAmount, ItemStack stack, FluidStack availableFluid) {
|
||||
FluidStack toFill = availableFluid.copy();
|
||||
toFill.setAmount(requiredAmount);
|
||||
availableFluid.shrink(requiredAmount);
|
||||
|
||||
if (stack.getItem() == Items.GLASS_BOTTLE) {
|
||||
if (stack.getItem() == Items.GLASS_BOTTLE && canFillGlassBottleInternally(availableFluid)) {
|
||||
ItemStack fillBottle = ItemStack.EMPTY;
|
||||
if (FluidHelper.isWater(toFill.getFluid()))
|
||||
fillBottle = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTION), Potions.WATER);
|
||||
|
|
|
@ -57,35 +57,42 @@ public class ConfigureConfigPacket extends SimplePacketBase {
|
|||
}
|
||||
|
||||
enum Actions {
|
||||
rainbowDebug((value) -> {
|
||||
AllConfigs.CLIENT.rainbowDebug.set(Boolean.parseBoolean(value));
|
||||
}),
|
||||
overlayScreen(Actions::overlayScreenAction),
|
||||
fixLighting(Actions::experimentalLightingAction),
|
||||
overlayReset((value) -> {
|
||||
AllConfigs.CLIENT.overlayOffsetX.set(0);
|
||||
AllConfigs.CLIENT.overlayOffsetY.set(0);
|
||||
}),
|
||||
rainbowDebug(() -> Actions::rainbowDebug),
|
||||
overlayScreen(() -> Actions::overlayScreen),
|
||||
fixLighting(() -> Actions::experimentalLighting),
|
||||
overlayReset(() -> Actions::overlayReset),
|
||||
|
||||
;
|
||||
|
||||
private final Consumer<String> consumer;
|
||||
private final Supplier<Consumer<String>> consumer;
|
||||
|
||||
Actions(Consumer<String> action) {
|
||||
Actions(Supplier<Consumer<String>> action) {
|
||||
this.consumer = action;
|
||||
}
|
||||
|
||||
void performAction(String value) {
|
||||
consumer.accept(value);
|
||||
consumer.get()
|
||||
.accept(value);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static void overlayScreenAction(String value) {
|
||||
private static void rainbowDebug(String value) {
|
||||
AllConfigs.CLIENT.rainbowDebug.set(Boolean.parseBoolean(value));
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static void overlayReset(String value) {
|
||||
AllConfigs.CLIENT.overlayOffsetX.set(0);
|
||||
AllConfigs.CLIENT.overlayOffsetY.set(0);
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static void overlayScreen(String value) {
|
||||
ScreenOpener.open(new GoggleConfigScreen());
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
private static void experimentalLightingAction(String value) {
|
||||
private static void experimentalLighting(String value) {
|
||||
ForgeConfig.CLIENT.experimentalForgeLightPipelineEnabled.set(true);
|
||||
Minecraft.getInstance().worldRenderer.loadRenderers();
|
||||
}
|
||||
|
|
|
@ -108,7 +108,8 @@ public class CombinedTankWrapper implements IFluidHandler {
|
|||
resource.shrink(amount);
|
||||
|
||||
if (!drainedFromCurrent.isEmpty() && (drained.isEmpty() || drainedFromCurrent.isFluidEqual(drained)))
|
||||
drained = new FluidStack(drainedFromCurrent.getFluid(), amount + drained.getAmount(), drained.getTag());
|
||||
drained = new FluidStack(drainedFromCurrent.getFluid(), amount + drained.getAmount(),
|
||||
drainedFromCurrent.getTag());
|
||||
if (resource.isEmpty())
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue