Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
MinecraftForge
GitHub Repository: MinecraftForge/MinecraftForge
Path: blob/1.21.x/src/main/java/net/minecraftforge/client/model/generators/loaders/DynamicFluidContainerModelBuilder.java
7003 views
1
/*
2
* Copyright (c) Forge Development LLC and contributors
3
* SPDX-License-Identifier: LGPL-2.1-only
4
*/
5
6
package net.minecraftforge.client.model.generators.loaders;
7
8
import com.google.common.base.Preconditions;
9
import com.google.gson.JsonObject;
10
import net.minecraft.world.level.material.Fluid;
11
import net.minecraft.resources.ResourceLocation;
12
import net.minecraftforge.client.model.generators.CustomLoaderBuilder;
13
import net.minecraftforge.client.model.generators.ModelBuilder;
14
import net.minecraftforge.common.data.ExistingFileHelper;
15
import net.minecraftforge.registries.ForgeRegistries;
16
17
/**
18
* In 1.21.4 Mojang exposed their data generators for their models. So it should be feasible to just use theirs.
19
* If you find something lacking feel free to open a PR so that we can extend it.
20
* @deprecated Use Vanilla's providers {@link net.minecraft.client.data.models.ModelProvider}
21
*/
22
public class DynamicFluidContainerModelBuilder<T extends ModelBuilder<T>> extends CustomLoaderBuilder<T>
23
{
24
private static final ResourceLocation NAME = ResourceLocation.fromNamespaceAndPath("forge", "fluid_container");
25
public static <T extends ModelBuilder<T>> DynamicFluidContainerModelBuilder<T> begin(T parent, ExistingFileHelper existingFileHelper)
26
{
27
return new DynamicFluidContainerModelBuilder<>(parent, existingFileHelper);
28
}
29
30
private ResourceLocation fluid;
31
private Boolean flipGas;
32
private Boolean applyTint;
33
private Boolean coverIsMask;
34
private Boolean applyFluidLuminosity;
35
36
protected DynamicFluidContainerModelBuilder(T parent, ExistingFileHelper existingFileHelper)
37
{
38
super(NAME, parent, existingFileHelper);
39
}
40
41
public DynamicFluidContainerModelBuilder<T> fluid(Fluid fluid)
42
{
43
Preconditions.checkNotNull(fluid, "fluid must not be null");
44
this.fluid = ForgeRegistries.FLUIDS.getKey(fluid);
45
return this;
46
}
47
48
public DynamicFluidContainerModelBuilder<T> flipGas(boolean flip)
49
{
50
this.flipGas = flip;
51
return this;
52
}
53
54
public DynamicFluidContainerModelBuilder<T> applyTint(boolean tint)
55
{
56
this.applyTint = tint;
57
return this;
58
}
59
60
public DynamicFluidContainerModelBuilder<T> coverIsMask(boolean coverIsMask)
61
{
62
this.coverIsMask = coverIsMask;
63
return this;
64
}
65
66
public DynamicFluidContainerModelBuilder<T> applyFluidLuminosity(boolean applyFluidLuminosity)
67
{
68
this.applyFluidLuminosity = applyFluidLuminosity;
69
return this;
70
}
71
72
@Override
73
public JsonObject toJson(JsonObject json)
74
{
75
json = super.toJson(json);
76
77
Preconditions.checkNotNull(fluid, "fluid must not be null");
78
79
json.addProperty("fluid", fluid.toString());
80
81
if (flipGas != null)
82
json.addProperty("flip_gas", flipGas);
83
84
if (applyTint != null)
85
json.addProperty("apply_tint", applyTint);
86
87
if (coverIsMask != null)
88
json.addProperty("cover_is_mask", coverIsMask);
89
90
if (applyFluidLuminosity != null)
91
json.addProperty("apply_fluid_luminosity", applyFluidLuminosity);
92
93
return json;
94
}
95
}
96
97