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:
Max
2022-06-16 11:59:08 +02:00
committed by GitHub
parent a997cd44c1
commit 7d86eba267
7 changed files with 304 additions and 126 deletions

View File

@@ -42,8 +42,8 @@ import java.util.function.Function;
@Environment(EnvType.CLIENT)
class ArchitecturyFluidRenderingFabric implements FluidVariantRenderHandler, FluidRenderHandler {
private final ArchitecturyFluidAttributes attributes;
private final TextureAtlasSprite[] sprites = new TextureAtlasSprite[2];
private final TextureAtlasSprite[] spritesOther = new TextureAtlasSprite[2];
private final TextureAtlasSprite[] sprites = new TextureAtlasSprite[3];
private final TextureAtlasSprite[] spritesOther = new TextureAtlasSprite[3];
public ArchitecturyFluidRenderingFabric(ArchitecturyFluidAttributes attributes) {
this.attributes = attributes;
@@ -56,6 +56,8 @@ class ArchitecturyFluidRenderingFabric implements FluidVariantRenderHandler, Flu
Function<ResourceLocation, TextureAtlasSprite> atlas = Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS);
sprites[0] = atlas.apply(attributes.getSourceTexture(stack));
sprites[1] = atlas.apply(attributes.getFlowingTexture(stack));
ResourceLocation overlayTexture = attributes.getOverlayTexture(stack);
sprites[2] = overlayTexture == null ? null : atlas.apply(overlayTexture);
return sprites;
}
@@ -66,15 +68,16 @@ class ArchitecturyFluidRenderingFabric implements FluidVariantRenderHandler, Flu
@Override
public TextureAtlasSprite[] getFluidSprites(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, FluidState state) {
FluidStack stack = FluidStack.create(state.getType(), FluidStack.bucketAmount());
Function<ResourceLocation, TextureAtlasSprite> atlas = Minecraft.getInstance().getTextureAtlas(TextureAtlas.LOCATION_BLOCKS);
spritesOther[0] = atlas.apply(attributes.getSourceTexture(stack, view, pos));
spritesOther[1] = atlas.apply(attributes.getFlowingTexture(stack, view, pos));
spritesOther[0] = atlas.apply(attributes.getSourceTexture(state, view, pos));
spritesOther[1] = atlas.apply(attributes.getFlowingTexture(state, view, pos));
ResourceLocation overlayTexture = attributes.getOverlayTexture(state, view, pos);
spritesOther[2] = overlayTexture == null ? null : atlas.apply(overlayTexture);
return spritesOther;
}
@Override
public int getFluidColor(@Nullable BlockAndTintGetter view, @Nullable BlockPos pos, FluidState state) {
return attributes.getColor(FluidStack.create(state.getType(), FluidStack.bucketAmount()), view, pos);
return attributes.getColor(state, view, pos);
}
}