mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
Make ArchitecturyFlowingFluid use the same Forge FluidType when the s… (#467)
* Make ArchitecturyFlowingFluid use the same Forge FluidType when the same ArchitecturyFluidAttributes object is passed in * Use the same fluid type instead of the same properties for simplity * Fix packages import --------- Co-authored-by: shedaniel <daniel@shedaniel.me>
This commit is contained in:
@@ -42,24 +42,24 @@ import net.minecraftforge.fluids.FluidType;
|
||||
import net.minecraftforge.fluids.ForgeFlowingFluid;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class ArchitecturyFlowingFluid extends ForgeFlowingFluid {
|
||||
private static final Map<ArchitecturyFluidAttributes, FluidType> FLUID_TYPE_MAP = new IdentityHashMap<>();
|
||||
private final ArchitecturyFluidAttributes attributes;
|
||||
private final Supplier<FluidType> forgeType;
|
||||
|
||||
ArchitecturyFlowingFluid(ArchitecturyFluidAttributes attributes) {
|
||||
super(toForgeProperties(attributes));
|
||||
this.attributes = attributes;
|
||||
this.forgeType = Suppliers.memoize(() -> {
|
||||
return new ArchitecturyFluidAttributesForge(FluidType.Properties.create(), this, attributes);
|
||||
});
|
||||
}
|
||||
|
||||
private static Properties toForgeProperties(ArchitecturyFluidAttributes attributes) {
|
||||
Properties forge = new Properties(Suppliers.memoize(() -> {
|
||||
return new ArchitecturyFluidAttributesForge(FluidType.Properties.create(), attributes.getSourceFluid(), attributes);
|
||||
return FLUID_TYPE_MAP.computeIfAbsent(attributes, attr -> {
|
||||
return new ArchitecturyFluidAttributesForge(FluidType.Properties.create(), attr.getSourceFluid(), attr);
|
||||
});
|
||||
}), attributes::getSourceFluid, attributes::getFlowingFluid);
|
||||
forge.slopeFindDistance(attributes.getSlopeFindDistance());
|
||||
forge.levelDecreasePerBlock(attributes.getDropOff());
|
||||
@@ -70,11 +70,6 @@ public abstract class ArchitecturyFlowingFluid extends ForgeFlowingFluid {
|
||||
return forge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidType getFluidType() {
|
||||
return forgeType.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fluid getFlowing() {
|
||||
return attributes.getFlowingFluid();
|
||||
|
||||
Reference in New Issue
Block a user