mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Infinite water source simulator 2024
- Don't update block states when a pipe is removing a fluid that would be an infinite source - Add accessor mixin for FlowingFluid#getNewLiquid to test
This commit is contained in:
parent
1d03915225
commit
9c1e0d5886
3 changed files with 36 additions and 3 deletions
|
@ -13,6 +13,7 @@ import com.simibubi.create.content.fluids.potion.PotionFluidHandler;
|
|||
import com.simibubi.create.foundation.advancement.AdvancementBehaviour;
|
||||
import com.simibubi.create.foundation.advancement.AllAdvancements;
|
||||
import com.simibubi.create.foundation.fluid.FluidHelper;
|
||||
import com.simibubi.create.foundation.mixin.accessor.FlowingFluidAccessor;
|
||||
import com.simibubi.create.infrastructure.config.AllConfigs;
|
||||
|
||||
import net.createmod.catnip.utility.BlockFace;
|
||||
|
@ -166,10 +167,25 @@ public class OpenEndedPipe extends FlowSource {
|
|||
if (waterlog) {
|
||||
world.setBlock(outputPos, state.setValue(WATERLOGGED, false), 3);
|
||||
world.scheduleTick(outputPos, Fluids.WATER, 1);
|
||||
return stack;
|
||||
} else {
|
||||
var newState = fluidState.createLegacyBlock()
|
||||
.setValue(LiquidBlock.LEVEL, 14);
|
||||
|
||||
var newFluidState = newState.getFluidState();
|
||||
|
||||
if (newFluidState.getType() instanceof FlowingFluidAccessor flowing) {
|
||||
var potentiallyFilled = flowing.create$getNewLiquid(world, outputPos, newState);
|
||||
|
||||
// Check if we'd immediately become the same fluid again.
|
||||
if (potentiallyFilled.equals(fluidState)) {
|
||||
// If so, no need to update the block state.
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
world.setBlock(outputPos, newState, 3);
|
||||
}
|
||||
world.setBlock(outputPos, fluidState.createLegacyBlock()
|
||||
.setValue(LiquidBlock.LEVEL, 14), 3);
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.simibubi.create.foundation.mixin.accessor;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.FlowingFluid;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
|
||||
@Mixin(FlowingFluid.class)
|
||||
public interface FlowingFluidAccessor {
|
||||
@Invoker("getNewLiquid")
|
||||
FluidState create$getNewLiquid(Level pLevel, BlockPos pPos, BlockState pBlockState);
|
||||
}
|
|
@ -20,6 +20,7 @@
|
|||
"accessor.AbstractProjectileDispenseBehaviorAccessor",
|
||||
"accessor.DispenserBlockAccessor",
|
||||
"accessor.FallingBlockEntityAccessor",
|
||||
"accessor.FlowingFluidAccessor",
|
||||
"accessor.FluidInteractionRegistryAccessor",
|
||||
"accessor.GameTestHelperAccessor",
|
||||
"accessor.LivingEntityAccessor",
|
||||
|
|
Loading…
Add table
Reference in a new issue