-
Notifications
You must be signed in to change notification settings - Fork 497
/
PipeModelCacheAll.java
82 lines (65 loc) · 3.42 KB
/
PipeModelCacheAll.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package buildcraft.transport.client.model;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import buildcraft.core.lib.client.model.IModelCache;
import buildcraft.core.lib.client.model.ModelCacheJoiner;
import buildcraft.core.lib.client.model.ModelCacheJoiner.ModelKeyWrapper;
import buildcraft.transport.Pipe;
import buildcraft.transport.PipePluggableState;
import buildcraft.transport.PipeRenderState;
import buildcraft.transport.client.model.PipeModelCacheBase.PipeBaseCutoutKey;
import buildcraft.transport.client.model.PipeModelCacheBase.PipeBaseTransclucentKey;
import buildcraft.transport.client.model.PipeModelCacheWire.PipeWireKey;
public class PipeModelCacheAll {
private static final IModelCache<PipeAllCutoutKey> cacheCutout;
private static final IModelCache<PipeAllTranslucentKey> cacheTranslucent;
static {
List<ModelKeyWrapper<PipeAllCutoutKey, ?>> cutout = new ArrayList<>();
cutout.add(new ModelKeyWrapper<>(PipeAllCutoutKey::getBaseCutout, PipeModelCacheBase.cacheCutout));
// Remove when wires are fully moved to the TESR
cutout.add(new ModelKeyWrapper<>(PipeAllCutoutKey::getWire, PipeModelCacheWire.cacheAll));
// TODO: Pluggables!
cacheCutout = new ModelCacheJoiner<>("pipe.all.cutout", cutout);
List<ModelKeyWrapper<PipeAllTranslucentKey, ?>> translucent = new ArrayList<>();
translucent.add(new ModelKeyWrapper<>(PipeAllTranslucentKey::getBaseTranslucent, PipeModelCacheBase.cacheTranslucent));
cacheTranslucent = new ModelCacheJoiner<>("pipe.all.transclucent", translucent);
}
public static ImmutableList<BakedQuad> getCutoutModel(Pipe<?> pipe, PipeRenderState render, PipePluggableState pluggable) {
PipeAllCutoutKey key = new PipeAllCutoutKey(pipe, render, pluggable);
return cacheCutout.bake(key, DefaultVertexFormats.BLOCK);
}
public static ImmutableList<BakedQuad> getTranslucentModel(Pipe<?> pipe, PipeRenderState render, PipePluggableState pluggable) {
PipeAllTranslucentKey key = new PipeAllTranslucentKey(pipe, render, pluggable);
return cacheTranslucent.bake(key, DefaultVertexFormats.BLOCK);
}
public static class PipeAllCutoutKey {
private final PipeBaseCutoutKey cutout;
private final PipeWireKey wire;
// TODO: Pluggable key!
public PipeAllCutoutKey(Pipe<?> pipe, PipeRenderState render, PipePluggableState pluggable) {
cutout = new PipeBaseCutoutKey(pipe, render);
wire = new PipeWireKey(render);
// TODO: Pluggable key!
}
public static PipeBaseCutoutKey getBaseCutout(PipeAllCutoutKey key) {
return key.cutout;
}
public static PipeWireKey getWire(PipeAllCutoutKey key) {
return key.wire;
}
}
public static class PipeAllTranslucentKey {
private final PipeBaseTransclucentKey translucent;
// TODO: Pluggable key!
public PipeAllTranslucentKey(Pipe<?> pipe, PipeRenderState render, PipePluggableState pluggable) {
translucent = new PipeBaseTransclucentKey(render);
// TODO: Pluggable key!
}
public static PipeBaseTransclucentKey getBaseTranslucent(PipeAllTranslucentKey key) {
return key.translucent;
}
}
}