2020-10-19 22:07:05 +02:00
|
|
|
package com.simibubi.create;
|
|
|
|
|
2022-11-17 22:50:15 +01:00
|
|
|
import static com.simibubi.create.Create.REGISTRATE;
|
|
|
|
|
2022-08-01 22:37:39 +02:00
|
|
|
import java.util.function.Consumer;
|
|
|
|
|
2020-12-03 20:41:55 +01:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2021-06-26 09:30:01 +02:00
|
|
|
import com.simibubi.create.AllTags.AllFluidTags;
|
2020-12-03 20:41:55 +01:00
|
|
|
import com.simibubi.create.content.contraptions.fluids.VirtualFluid;
|
2020-10-19 22:07:05 +02:00
|
|
|
import com.simibubi.create.content.contraptions.fluids.potion.PotionFluid;
|
2022-08-01 22:37:39 +02:00
|
|
|
import com.simibubi.create.content.contraptions.fluids.potion.PotionFluid.PotionFluidType;
|
2021-12-04 04:17:42 +01:00
|
|
|
import com.simibubi.create.content.palettes.AllPaletteStoneTypes;
|
2021-05-23 03:00:10 +02:00
|
|
|
import com.tterrag.registrate.util.entry.FluidEntry;
|
2020-10-19 22:07:05 +02:00
|
|
|
|
2021-11-02 00:08:20 +01:00
|
|
|
import net.minecraft.core.BlockPos;
|
2022-08-01 22:37:39 +02:00
|
|
|
import net.minecraft.resources.ResourceLocation;
|
2021-11-02 00:08:20 +01:00
|
|
|
import net.minecraft.world.level.BlockAndTintGetter;
|
2021-11-02 06:18:30 +01:00
|
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
|
|
import net.minecraft.world.level.material.Fluid;
|
|
|
|
import net.minecraft.world.level.material.FluidState;
|
2022-08-01 22:37:39 +02:00
|
|
|
import net.minecraftforge.client.extensions.common.IClientFluidTypeExtensions;
|
|
|
|
import net.minecraftforge.fluids.FluidStack;
|
|
|
|
import net.minecraftforge.fluids.FluidType;
|
2020-12-03 20:41:55 +01:00
|
|
|
import net.minecraftforge.fluids.ForgeFlowingFluid;
|
|
|
|
|
2020-10-19 22:07:05 +02:00
|
|
|
public class AllFluids {
|
|
|
|
|
2021-06-26 09:30:01 +02:00
|
|
|
public static final FluidEntry<PotionFluid> POTION =
|
2022-08-01 22:37:39 +02:00
|
|
|
REGISTRATE.virtualFluid("potion", PotionFluidType::new, PotionFluid::new)
|
2022-08-06 02:45:46 +02:00
|
|
|
.lang("Potion")
|
2022-08-01 22:37:39 +02:00
|
|
|
.register();
|
2020-12-03 20:41:55 +01:00
|
|
|
|
2021-06-26 09:30:01 +02:00
|
|
|
public static final FluidEntry<VirtualFluid> TEA = REGISTRATE.virtualFluid("tea")
|
2022-08-06 02:45:46 +02:00
|
|
|
.lang("Builder's Tea")
|
2022-08-01 22:37:39 +02:00
|
|
|
.tag(AllTags.forgeFluidTag("tea"))
|
|
|
|
.register();
|
2020-12-03 20:41:55 +01:00
|
|
|
|
2021-06-26 09:30:01 +02:00
|
|
|
public static final FluidEntry<ForgeFlowingFluid.Flowing> HONEY =
|
2022-08-01 22:37:39 +02:00
|
|
|
REGISTRATE.standardFluid("honey", NoColorFluidAttributes::new)
|
2022-08-06 02:45:46 +02:00
|
|
|
.lang("Honey")
|
2022-08-01 22:37:39 +02:00
|
|
|
.properties(b -> b.viscosity(2000)
|
|
|
|
.density(1400))
|
|
|
|
.fluidProperties(p -> p.levelDecreasePerBlock(2)
|
|
|
|
.tickRate(25)
|
|
|
|
.slopeFindDistance(3)
|
|
|
|
.explosionResistance(100f))
|
|
|
|
.tag(AllFluidTags.HONEY.tag)
|
|
|
|
.source(ForgeFlowingFluid.Source::new) // TODO: remove when Registrate fixes FluidBuilder
|
|
|
|
.bucket()
|
|
|
|
.tag(AllTags.forgeItemTag("buckets/honey"))
|
|
|
|
.build()
|
|
|
|
.register();
|
2020-10-19 22:07:05 +02:00
|
|
|
|
2021-06-26 09:30:01 +02:00
|
|
|
public static final FluidEntry<ForgeFlowingFluid.Flowing> CHOCOLATE =
|
2022-08-01 22:37:39 +02:00
|
|
|
REGISTRATE.standardFluid("chocolate", NoColorFluidAttributes::new)
|
2022-08-06 02:45:46 +02:00
|
|
|
.lang("Chocolate")
|
2022-08-01 22:37:39 +02:00
|
|
|
.tag(AllTags.forgeFluidTag("chocolate"))
|
|
|
|
.properties(b -> b.viscosity(1500)
|
|
|
|
.density(1400))
|
|
|
|
.fluidProperties(p -> p.levelDecreasePerBlock(2)
|
|
|
|
.tickRate(25)
|
|
|
|
.slopeFindDistance(3)
|
|
|
|
.explosionResistance(100f))
|
|
|
|
.register();
|
2020-10-19 22:07:05 +02:00
|
|
|
|
|
|
|
// Load this class
|
|
|
|
|
|
|
|
public static void register() {}
|
|
|
|
|
2020-12-03 20:41:55 +01:00
|
|
|
@Nullable
|
2020-12-05 11:42:14 +01:00
|
|
|
public static BlockState getLavaInteraction(FluidState fluidState) {
|
2021-07-15 11:32:03 +02:00
|
|
|
Fluid fluid = fluidState.getType();
|
2021-12-04 04:17:42 +01:00
|
|
|
if (fluid.isSame(HONEY.get()))
|
|
|
|
return AllPaletteStoneTypes.LIMESTONE.getBaseBlock()
|
|
|
|
.get()
|
|
|
|
.defaultBlockState();
|
|
|
|
if (fluid.isSame(CHOCOLATE.get()))
|
|
|
|
return AllPaletteStoneTypes.SCORIA.getBaseBlock()
|
|
|
|
.get()
|
|
|
|
.defaultBlockState();
|
2020-12-03 20:41:55 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-08-01 22:37:39 +02:00
|
|
|
public static abstract class TintedFluidType extends FluidType {
|
|
|
|
|
|
|
|
protected static final int NO_TINT = 0xffffffff;
|
|
|
|
private ResourceLocation stillTexture;
|
|
|
|
private ResourceLocation flowingTexture;
|
|
|
|
|
|
|
|
public TintedFluidType(Properties properties, ResourceLocation stillTexture, ResourceLocation flowingTexture) {
|
|
|
|
super(properties);
|
2022-08-07 21:21:41 +02:00
|
|
|
this.stillTexture = stillTexture;
|
|
|
|
this.flowingTexture = flowingTexture;
|
2022-08-01 22:37:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void initializeClient(Consumer<IClientFluidTypeExtensions> consumer) {
|
|
|
|
consumer.accept(new IClientFluidTypeExtensions() {
|
|
|
|
|
|
|
|
@Override
|
2022-08-07 21:21:41 +02:00
|
|
|
public ResourceLocation getStillTexture() {
|
|
|
|
return stillTexture;
|
2022-08-01 22:37:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2022-08-07 21:21:41 +02:00
|
|
|
public ResourceLocation getFlowingTexture() {
|
|
|
|
return flowingTexture;
|
2022-08-01 22:37:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getTintColor(FluidStack stack) {
|
2022-08-07 21:21:41 +02:00
|
|
|
return TintedFluidType.this.getTintColor(stack);
|
2022-08-01 22:37:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getTintColor(FluidState state, BlockAndTintGetter getter, BlockPos pos) {
|
2022-08-07 21:21:41 +02:00
|
|
|
return TintedFluidType.this.getTintColor(state, getter, pos);
|
2022-08-01 22:37:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
protected abstract int getTintColor(FluidStack stack);
|
|
|
|
|
|
|
|
protected abstract int getTintColor(FluidState state, BlockAndTintGetter getter, BlockPos pos);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-12-04 23:31:12 +01:00
|
|
|
/**
|
|
|
|
* Removing alpha from tint prevents optifine from forcibly applying biome
|
|
|
|
* colors to modded fluids (Makes translucent fluids disappear)
|
|
|
|
*/
|
2022-08-01 22:37:39 +02:00
|
|
|
private static class NoColorFluidAttributes extends TintedFluidType {
|
2020-12-04 23:31:12 +01:00
|
|
|
|
2022-08-01 22:37:39 +02:00
|
|
|
public NoColorFluidAttributes(Properties properties, ResourceLocation stillTexture,
|
|
|
|
ResourceLocation flowingTexture) {
|
|
|
|
super(properties, stillTexture, flowingTexture);
|
2020-12-04 23:31:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2022-08-07 21:21:41 +02:00
|
|
|
protected int getTintColor(FluidStack stack) {
|
|
|
|
return NO_TINT;
|
2020-12-04 23:31:12 +01:00
|
|
|
}
|
|
|
|
|
2022-08-01 22:37:39 +02:00
|
|
|
@Override
|
2022-08-07 21:21:41 +02:00
|
|
|
public int getTintColor(FluidState state, BlockAndTintGetter world, BlockPos pos) {
|
|
|
|
return 0x00ffffff;
|
2022-08-01 22:37:39 +02:00
|
|
|
}
|
|
|
|
|
2020-12-04 23:31:12 +01:00
|
|
|
}
|
2022-08-01 22:37:39 +02:00
|
|
|
|
2020-10-19 22:07:05 +02:00
|
|
|
}
|