mirror of
https://github.com/architectury/architectury-api.git
synced 2026-03-28 03:56:59 -05:00
Implement Forge's new Fluid API (#280)
* (Untested) fixes for the new Forge Fluid API * Migrate ArchitecturyFlowingFluid to FluidTypes * Add overlay textures, fix compile issues * Fix Supplier import * Add FluidState variant of get texture and color methods * Deprecate combined render properties getter in favour of separate stack- and state-aware getters * Add overlay texture override to SimpleArchitecturyFluidAttributes * Update common/src/main/java/dev/architectury/core/fluid/ArchitecturyFluidAttributes.java Co-authored-by: shedaniel <daniel@shedaniel.me> Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com> [norelease]
This commit is contained in:
@@ -30,6 +30,7 @@ import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.LiquidBlock;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
@@ -197,9 +198,26 @@ public interface ArchitecturyFluidAttributes {
|
||||
* @param level the level, can be {@code null}
|
||||
* @param pos the position, can be {@code null}
|
||||
* @return the texture location
|
||||
* @deprecated Please use and override {@link #getSourceTexture(FluidState, BlockAndTintGetter, BlockPos)}
|
||||
* or {@link #getSourceTexture(FluidStack)} instead, this method will be removed in a future version.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
ResourceLocation getSourceTexture(@Nullable FluidStack stack, @Nullable BlockAndTintGetter level, @Nullable BlockPos pos);
|
||||
|
||||
/**
|
||||
* Returns the texture location of this fluid in its source form.
|
||||
* <p>
|
||||
* The vanilla water location is {@code "block/water_still"}.
|
||||
*
|
||||
* @param state the fluid state, can be {@code null}
|
||||
* @param level the level, can be {@code null}
|
||||
* @param pos the position, can be {@code null}
|
||||
* @return the texture location
|
||||
*/
|
||||
default ResourceLocation getSourceTexture(@Nullable FluidState state, @Nullable BlockAndTintGetter level, @Nullable BlockPos pos) {
|
||||
return getSourceTexture(state == null ? null : FluidStack.create(state.getType(), FluidStack.bucketAmount()), level, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the texture location of this fluid in its source form.
|
||||
* <p>
|
||||
@@ -232,9 +250,26 @@ public interface ArchitecturyFluidAttributes {
|
||||
* @param level the level, can be {@code null}
|
||||
* @param pos the position, can be {@code null}
|
||||
* @return the texture location
|
||||
* @deprecated Please use and override {@link #getFlowingTexture(FluidState, BlockAndTintGetter, BlockPos)}
|
||||
* or {@link #getFlowingTexture(FluidStack)} instead, this method will be removed in a future version.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
ResourceLocation getFlowingTexture(@Nullable FluidStack stack, @Nullable BlockAndTintGetter level, @Nullable BlockPos pos);
|
||||
|
||||
/**
|
||||
* Returns the texture location of this fluid in its flowing form.
|
||||
* <p>
|
||||
* The vanilla water location is {@code "block/water_flow"}.
|
||||
*
|
||||
* @param state the fluid state, can be {@code null}
|
||||
* @param level the level, can be {@code null}
|
||||
* @param pos the position, can be {@code null}
|
||||
* @return the texture location
|
||||
*/
|
||||
default ResourceLocation getFlowingTexture(@Nullable FluidState state, @Nullable BlockAndTintGetter level, @Nullable BlockPos pos) {
|
||||
return getFlowingTexture(state == null ? null : FluidStack.create(state.getType(), FluidStack.bucketAmount()), level, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the texture location of this fluid in its flowing form.
|
||||
* <p>
|
||||
@@ -258,6 +293,46 @@ public interface ArchitecturyFluidAttributes {
|
||||
return getFlowingTexture(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the overlay texture location of this fluid behind transparent blocks.
|
||||
* <p>
|
||||
* The vanilla water location is {@code "block/water_overlay"}.
|
||||
*
|
||||
* @param state the fluid state, can be {@code null}
|
||||
* @param level the level, can be {@code null}
|
||||
* @param pos the position, can be {@code null}
|
||||
* @return the texture location, can be {@code null}
|
||||
*/
|
||||
@Nullable
|
||||
default ResourceLocation getOverlayTexture(@Nullable FluidState state, @Nullable BlockAndTintGetter level, @Nullable BlockPos pos) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the overlay texture location of this fluid behind transparent blocks.
|
||||
* <p>
|
||||
* The vanilla water location is {@code "block/water_overlay"}.
|
||||
*
|
||||
* @param stack the fluid stack, can be {@code null}
|
||||
* @return the texture location, can be {@code null}
|
||||
*/
|
||||
@Nullable
|
||||
default ResourceLocation getOverlayTexture(@Nullable FluidStack stack) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the overlay texture location of this fluid behind transparent blocks.
|
||||
* <p>
|
||||
* The vanilla water location is {@code "block/water_overlay"}.
|
||||
*
|
||||
* @return the texture location, can be {@code null}
|
||||
*/
|
||||
@Nullable
|
||||
default ResourceLocation getOverlayTexture() {
|
||||
return getOverlayTexture(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color of the fluid.
|
||||
*
|
||||
@@ -265,9 +340,24 @@ public interface ArchitecturyFluidAttributes {
|
||||
* @param level the level, can be {@code null}
|
||||
* @param pos the position, can be {@code null}
|
||||
* @return the color
|
||||
* @deprecated Please use and override {@link #getColor(FluidState, BlockAndTintGetter, BlockPos)}
|
||||
* or {@link #getColor(FluidStack)} instead, this method will be removed in a future version.
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
int getColor(@Nullable FluidStack stack, @Nullable BlockAndTintGetter level, @Nullable BlockPos pos);
|
||||
|
||||
/**
|
||||
* Returns the color of the fluid.
|
||||
*
|
||||
* @param state the fluid state, can be {@code null}
|
||||
* @param level the level, can be {@code null}
|
||||
* @param pos the position, can be {@code null}
|
||||
* @return the color
|
||||
*/
|
||||
default int getColor(@Nullable FluidState state, @Nullable BlockAndTintGetter level, @Nullable BlockPos pos) {
|
||||
return getColor(state == null ? null : FluidStack.create(state.getType(), FluidStack.bucketAmount()), level, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the color of the fluid.
|
||||
*
|
||||
|
||||
@@ -35,6 +35,7 @@ import net.minecraft.world.level.BlockAndTintGetter;
|
||||
import net.minecraft.world.level.LevelReader;
|
||||
import net.minecraft.world.level.block.LiquidBlock;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Objects;
|
||||
@@ -55,6 +56,8 @@ public class SimpleArchitecturyFluidAttributes implements ArchitecturyFluidAttri
|
||||
private ResourceLocation sourceTexture;
|
||||
@Nullable
|
||||
private ResourceLocation flowingTexture;
|
||||
@Nullable
|
||||
private ResourceLocation overlayTexture;
|
||||
private int color = 0xffffff;
|
||||
private int luminosity = 0;
|
||||
private int density = 1000;
|
||||
@@ -167,7 +170,7 @@ public class SimpleArchitecturyFluidAttributes implements ArchitecturyFluidAttri
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ArchitecturyFluidAttributes#getSourceTexture(FluidStack, BlockAndTintGetter, BlockPos)
|
||||
* @see ArchitecturyFluidAttributes#getSourceTexture(FluidState, BlockAndTintGetter, BlockPos)
|
||||
*/
|
||||
public SimpleArchitecturyFluidAttributes sourceTexture(ResourceLocation sourceTexture) {
|
||||
this.sourceTexture = sourceTexture;
|
||||
@@ -175,7 +178,7 @@ public class SimpleArchitecturyFluidAttributes implements ArchitecturyFluidAttri
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ArchitecturyFluidAttributes#getFlowingTexture(FluidStack, BlockAndTintGetter, BlockPos)
|
||||
* @see ArchitecturyFluidAttributes#getFlowingTexture(FluidState, BlockAndTintGetter, BlockPos)
|
||||
*/
|
||||
public SimpleArchitecturyFluidAttributes flowingTexture(ResourceLocation flowingTexture) {
|
||||
this.flowingTexture = flowingTexture;
|
||||
@@ -183,7 +186,15 @@ public class SimpleArchitecturyFluidAttributes implements ArchitecturyFluidAttri
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ArchitecturyFluidAttributes#getColor(FluidStack, BlockAndTintGetter, BlockPos)
|
||||
* @see ArchitecturyFluidAttributes#getFlowingTexture(FluidState, BlockAndTintGetter, BlockPos)
|
||||
*/
|
||||
public SimpleArchitecturyFluidAttributes overlayTexture(ResourceLocation overlayTexture) {
|
||||
this.overlayTexture = overlayTexture;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ArchitecturyFluidAttributes#getColor(FluidState, BlockAndTintGetter, BlockPos)
|
||||
*/
|
||||
public SimpleArchitecturyFluidAttributes color(int color) {
|
||||
this.color = color;
|
||||
@@ -317,6 +328,11 @@ public class SimpleArchitecturyFluidAttributes implements ArchitecturyFluidAttri
|
||||
return flowingTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResourceLocation getOverlayTexture(@Nullable FluidState state, @Nullable BlockAndTintGetter level, @Nullable BlockPos pos) {
|
||||
return overlayTexture;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor(@Nullable FluidStack stack, @Nullable BlockAndTintGetter level, @Nullable BlockPos pos) {
|
||||
return color;
|
||||
|
||||
Reference in New Issue
Block a user