Implement fluid overlay texture rendering for custom fluids.

This commit is contained in:
David Quintana 2019-12-19 17:51:07 +01:00
parent d86f58a0df
commit a901d80dd5
4 changed files with 39 additions and 7 deletions

View file

@ -8,9 +8,12 @@ buildscript {
name 'maven_central'
url 'https://repo.maven.apache.org/maven2/'
}
maven {
url 'http://dogforce-games.com/maven'
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:3.+'
classpath 'net.minecraftforge.gradle:ForgeGradle:3.0.165-run-configs-rework'
classpath 'org.ow2.asm:asm:7.2'
classpath 'org.ow2.asm:asm-tree:7.2'
}
@ -183,6 +186,12 @@ project(':forge') {
srcDirs = ["$rootDir/src/userdev/resources"]
}
}
userdev_test {
compileClasspath += sourceSets.userdev.runtimeClasspath
runtimeClasspath += sourceSets.userdev.runtimeClasspath
compileClasspath += sourceSets.test.runtimeClasspath
runtimeClasspath += sourceSets.test.runtimeClasspath
}
}
//Eclipse adds the sourcesets twice, once where we tell it to, once in the projects folder. No idea why. So delete them
eclipse.classpath.file.whenMerged { cls -> cls.entries.removeIf { e -> e instanceof SourceFolder && e.path.startsWith('src/') && !e.path.startsWith('src/main/') } }
@ -266,6 +275,8 @@ project(':forge') {
environment 'MOD_CLASSES', 'dummy' // Needed to work around FG limitation, FG will replace this!
ideaModule "${rootProject.name}.${project.name}.userdev_test"
mods {
TestMods { sources sourceSets.test }
}
@ -298,6 +309,8 @@ project(':forge') {
environment 'MOD_CLASSES', 'dummy' // Needed to work around FG limitation, FG will replace this!
ideaModule "${rootProject.name}.${project.name}.userdev_test"
mods {
TestMods { sources sourceSets.test }
}
@ -333,6 +346,8 @@ project(':forge') {
environment 'MOD_CLASSES', 'dummy' // Needed to work around FG limitation, FG will replace this!
ideaModule "${rootProject.name}.${project.name}.userdev_test"
mods {
tests { sources sourceSets.test }
}

View file

@ -51,6 +51,19 @@
flag7 = true;
}
@@ -222,10 +223,10 @@
flag7 = true;
BlockPos blockpos = p_228796_2_.func_177972_a(direction);
TextureAtlasSprite textureatlassprite2 = atextureatlassprite[1];
- if (!flag) {
+ if (atextureatlassprite[2] != null) {
Block block = p_228796_1_.func_180495_p(blockpos).func_177230_c();
if (block == Blocks.field_150359_w || block instanceof StainedGlassBlock) {
- textureatlassprite2 = this.field_187501_d;
+ textureatlassprite2 = atextureatlassprite[2];
}
}
@@ -239,15 +240,15 @@
float f31 = 1.0F * f30 * f;
float f32 = 1.0F * f30 * f1;
@ -59,15 +72,16 @@
- this.func_228797_a_(p_228796_3_, d5, d1 + (double)f38, d6, f31, f32, f33, f49, f28, k);
- this.func_228797_a_(p_228796_3_, d5, d1 + (double)f12, d6, f31, f32, f33, f49, f29, k);
- this.func_228797_a_(p_228796_3_, d3, d1 + (double)f12, d4, f31, f32, f33, f48, f29, k);
+ this.func_228797_a_(p_228796_3_, d3, d1 + (double)f36, d4, f31, f32, f33, alpha, f48, f50, k);
+ this.func_228797_a_(p_228796_3_, d5, d1 + (double)f38, d6, f31, f32, f33, alpha, f49, f28, k);
+ this.func_228797_a_(p_228796_3_, d5, d1 + (double)f12, d6, f31, f32, f33, alpha, f49, f29, k);
+ this.func_228797_a_(p_228796_3_, d3, d1 + (double)f12, d4, f31, f32, f33, alpha, f48, f29, k);
if (textureatlassprite2 != this.field_187501_d) {
- if (textureatlassprite2 != this.field_187501_d) {
- this.func_228797_a_(p_228796_3_, d3, d1 + (double)f12, d4, f31, f32, f33, f48, f29, k);
- this.func_228797_a_(p_228796_3_, d5, d1 + (double)f12, d6, f31, f32, f33, f49, f29, k);
- this.func_228797_a_(p_228796_3_, d5, d1 + (double)f38, d6, f31, f32, f33, f49, f28, k);
- this.func_228797_a_(p_228796_3_, d3, d1 + (double)f36, d4, f31, f32, f33, f48, f50, k);
+ this.func_228797_a_(p_228796_3_, d3, d1 + (double)f36, d4, f31, f32, f33, alpha, f48, f50, k);
+ this.func_228797_a_(p_228796_3_, d5, d1 + (double)f38, d6, f31, f32, f33, alpha, f49, f28, k);
+ this.func_228797_a_(p_228796_3_, d5, d1 + (double)f12, d6, f31, f32, f33, alpha, f49, f29, k);
+ this.func_228797_a_(p_228796_3_, d3, d1 + (double)f12, d4, f31, f32, f33, alpha, f48, f29, k);
+ if (textureatlassprite2 != atextureatlassprite[2]) {
+ this.func_228797_a_(p_228796_3_, d3, d1 + (double)f12, d4, f31, f32, f33, alpha, f48, f29, k);
+ this.func_228797_a_(p_228796_3_, d5, d1 + (double)f12, d6, f31, f32, f33, alpha, f49, f29, k);
+ this.func_228797_a_(p_228796_3_, d5, d1 + (double)f38, d6, f31, f32, f33, alpha, f49, f28, k);

View file

@ -525,9 +525,11 @@ public class ForgeHooksClient
@SuppressWarnings("deprecation")
public static TextureAtlasSprite[] getFluidSprites(ILightReader world, BlockPos pos, IFluidState fluidStateIn)
{
ResourceLocation overlayTexture = fluidStateIn.getFluid().getAttributes().getOverlayTexture();
return new TextureAtlasSprite[] {
Minecraft.getInstance().func_228015_a_(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(fluidStateIn.getFluid().getAttributes().getStillTexture(world, pos)),
Minecraft.getInstance().func_228015_a_(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(fluidStateIn.getFluid().getAttributes().getFlowingTexture(world, pos)),
overlayTexture == null ? null : Minecraft.getInstance().func_228015_a_(AtlasTexture.LOCATION_BLOCKS_TEXTURE).apply(overlayTexture),
};
}

View file

@ -52,6 +52,7 @@ public class NewFluidTest
public static final ResourceLocation FLUID_STILL = new ResourceLocation("minecraft:block/brown_mushroom_block");
public static final ResourceLocation FLUID_FLOWING = new ResourceLocation("minecraft:block/mushroom_stem");
public static final ResourceLocation FLUID_OVERLAY = new ResourceLocation("minecraft:block/obsidian");
public static final DeferredRegister<Block> BLOCKS = new DeferredRegister<>(ForgeRegistries.BLOCKS, MODID);
public static final DeferredRegister<Item> ITEMS = new DeferredRegister<>(ForgeRegistries.ITEMS, MODID);
@ -72,7 +73,7 @@ public class NewFluidTest
);
public static final ForgeFlowingFluid.Properties test_fluid_properties =
new ForgeFlowingFluid.Properties(test_fluid, test_fluid_flowing, FluidAttributes.builder(FLUID_STILL, FLUID_FLOWING).color(0x3F1080FF))
new ForgeFlowingFluid.Properties(test_fluid, test_fluid_flowing, FluidAttributes.builder(FLUID_STILL, FLUID_FLOWING).overlay(FLUID_OVERLAY).color(0x3F1080FF))
.bucket(test_fluid_bucket).block(test_fluid_block);
public NewFluidTest()