Honey, I'm blue!

- Evade fluid tinting issues with optifine
This commit is contained in:
simibubi 2020-12-04 23:31:12 +01:00
parent 9e4b92babf
commit 3301f8ff01
6 changed files with 41 additions and 17 deletions

View file

@ -753,7 +753,7 @@ a68cd40ffb769b195437107f4a2c2188b222b74a assets/create/models/block/gray_sail.js
17b651233c62b928f0228562a7f6e7a2b7b2d6b7 assets/create/models/block/green_sail.json
1438b8ce54ac5557b8f10dcef94f3525eae19461 assets/create/models/block/green_seat.json
cc7ce9b6bc687ad5027a67c3bf22bdf5bcd71674 assets/create/models/block/green_valve_handle.json
5bbe7e5322020d205d2c60bc14e4b45b317a193c assets/create/models/block/honey.json
5163171ed77af879fa06f290bf24b1bb99735c94 assets/create/models/block/honey.json
9730fcb02f679087e81e24c836751e625be6a298 assets/create/models/block/horizontal_framed_glass.json
d13df8a5920c5778d98081fb0e97f045e2fd46a2 assets/create/models/block/horizontal_framed_glass_pane_noside.json
3e975bec02e2670ce2b1868cebcbd780a5ebf3f8 assets/create/models/block/horizontal_framed_glass_pane_noside_alt.json

View file

@ -1,5 +1,5 @@
{
"textures": {
"particle": "block/honey_block_top"
"particle": "create:fluid/honey_still"
}
}

View file

@ -10,14 +10,15 @@ import com.simibubi.create.foundation.data.CreateRegistrate;
import com.tterrag.registrate.util.entry.RegistryEntry;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.IFluidState;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ILightReader;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.ForgeFlowingFluid;
public class AllFluids {
@ -39,7 +40,7 @@ public class AllFluids {
.register();
public static RegistryEntry<ForgeFlowingFluid.Flowing> HONEY =
REGISTRATE.fluid("honey", new ResourceLocation("block/honey_block_top"), Create.asResource("fluid/honey_flow"))
REGISTRATE.standardFluid("honey", NoColorFluidAttributes::new)
.lang(f -> "fluid.create.honey", "Honey")
.attributes(b -> b.viscosity(500)
.density(1400))
@ -50,24 +51,23 @@ public class AllFluids {
.tag(AllTags.forgeFluidTag("honey"))
.register();
public static RegistryEntry<ForgeFlowingFluid.Flowing> CHOCOLATE = REGISTRATE.standardFluid("chocolate")
.lang(f -> "fluid.create.chocolate", "Chocolate")
.attributes(b -> b.viscosity(500)
.density(1400))
.properties(p -> p.levelDecreasePerBlock(2)
.tickRate(25)
.slopeFindDistance(3)
.explosionResistance(100f))
.register();
public static RegistryEntry<ForgeFlowingFluid.Flowing> CHOCOLATE =
REGISTRATE.standardFluid("chocolate", NoColorFluidAttributes::new)
.lang(f -> "fluid.create.chocolate", "Chocolate")
.attributes(b -> b.viscosity(500)
.density(1400))
.properties(p -> p.levelDecreasePerBlock(2)
.tickRate(25)
.slopeFindDistance(3)
.explosionResistance(100f))
.register();
// Load this class
public static void register() {}
@OnlyIn(Dist.CLIENT)
public static void assignRenderLayers() {
makeTranslucent(HONEY);
}
public static void assignRenderLayers() {}
@OnlyIn(Dist.CLIENT)
private static void makeTranslucent(RegistryEntry<? extends ForgeFlowingFluid> entry) {
@ -90,4 +90,21 @@ public class AllFluids {
return null;
}
/**
* Removing alpha from tint prevents optifine from forcibly applying biome
* colors to modded fluids (Makes translucent fluids disappear)
*/
private static class NoColorFluidAttributes extends FluidAttributes {
protected NoColorFluidAttributes(Builder builder, Fluid fluid) {
super(builder, fluid);
}
@Override
public int getColor(ILightReader world, BlockPos pos) {
return 0x00ffffff;
}
}
}

View file

@ -25,6 +25,7 @@ import com.tterrag.registrate.builders.FluidBuilder;
import com.tterrag.registrate.builders.ItemBuilder;
import com.tterrag.registrate.util.NonNullLazyValue;
import com.tterrag.registrate.util.entry.RegistryEntry;
import com.tterrag.registrate.util.nullness.NonNullBiFunction;
import com.tterrag.registrate.util.nullness.NonNullConsumer;
import com.tterrag.registrate.util.nullness.NonNullFunction;
import com.tterrag.registrate.util.nullness.NonNullSupplier;
@ -143,6 +144,12 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
return fluid(name, Create.asResource("fluid/" + name + "_still"), Create.asResource("fluid/" + name + "_flow"));
}
public FluidBuilder<ForgeFlowingFluid.Flowing, CreateRegistrate> standardFluid(String name,
NonNullBiFunction<FluidAttributes.Builder, Fluid, FluidAttributes> attributesFactory) {
return fluid(name, Create.asResource("fluid/" + name + "_still"), Create.asResource("fluid/" + name + "_flow"),
attributesFactory);
}
/* Util */
public static <T extends Block> NonNullConsumer<? super T> connectedTextures(ConnectedTextureBehaviour behavior) {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B