Fullbright disk drive and disk manipulator disks. #1860

This commit is contained in:
raoulvdberge
2018-07-12 14:27:04 +02:00
parent f928facb24
commit cca8f6752b
13 changed files with 188 additions and 168 deletions

View File

@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.render.model;
import com.raoulvdberge.refinedstorage.RS; import com.raoulvdberge.refinedstorage.RS;
import com.raoulvdberge.refinedstorage.render.model.baked.BakedModelDiskDrive; import com.raoulvdberge.refinedstorage.render.model.baked.BakedModelDiskDrive;
import com.raoulvdberge.refinedstorage.render.model.baked.BakedModelFullbright;
import net.minecraft.client.renderer.block.model.IBakedModel; import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat; import net.minecraft.client.renderer.vertex.VertexFormat;
@@ -18,10 +19,10 @@ import java.util.function.Function;
public class ModelDiskDrive implements IModel { public class ModelDiskDrive implements IModel {
private static final ResourceLocation MODEL_BASE = new ResourceLocation(RS.ID + ":block/disk_drive"); private static final ResourceLocation MODEL_BASE = new ResourceLocation(RS.ID + ":block/disk_drive");
private static final ResourceLocation MODEL_DISK = new ResourceLocation(RS.ID + ":block/disk"); private static final ResourceLocation MODEL_DISK = new ResourceLocation(RS.ID + ":block/disks/disk");
private static final ResourceLocation MODEL_DISK_NEAR_CAPACITY = new ResourceLocation(RS.ID + ":block/disk_near_capacity"); private static final ResourceLocation MODEL_DISK_NEAR_CAPACITY = new ResourceLocation(RS.ID + ":block/disks/disk_near_capacity");
private static final ResourceLocation MODEL_DISK_FULL = new ResourceLocation(RS.ID + ":block/disk_full"); private static final ResourceLocation MODEL_DISK_FULL = new ResourceLocation(RS.ID + ":block/disks/disk_full");
private static final ResourceLocation MODEL_DISK_DISCONNECTED = new ResourceLocation(RS.ID + ":block/disk_disconnected"); private static final ResourceLocation MODEL_DISK_DISCONNECTED = new ResourceLocation(RS.ID + ":block/disks/disk_disconnected");
@Override @Override
public Collection<ResourceLocation> getDependencies() { public Collection<ResourceLocation> getDependencies() {
@@ -56,9 +57,9 @@ public class ModelDiskDrive implements IModel {
return new BakedModelDiskDrive( return new BakedModelDiskDrive(
baseModel.bake(state, format, bakedTextureGetter), baseModel.bake(state, format, bakedTextureGetter),
diskModel.bake(state, format, bakedTextureGetter), new BakedModelFullbright(diskModel.bake(state, format, bakedTextureGetter), RS.ID + ":blocks/disks/leds").setCacheDisabled(),
diskModelNearCapacity.bake(state, format, bakedTextureGetter), new BakedModelFullbright(diskModelNearCapacity.bake(state, format, bakedTextureGetter), RS.ID + ":blocks/disks/leds").setCacheDisabled(),
diskModelFull.bake(state, format, bakedTextureGetter), new BakedModelFullbright(diskModelFull.bake(state, format, bakedTextureGetter), RS.ID + ":blocks/disks/leds").setCacheDisabled(),
diskModelDisconnected.bake(state, format, bakedTextureGetter) diskModelDisconnected.bake(state, format, bakedTextureGetter)
); );
} }

View File

@@ -22,10 +22,10 @@ public class ModelDiskManipulator implements IModel {
private static final ResourceLocation MODEL_BASE_CONNECTED = new ResourceLocation(RS.ID + ":block/disk_manipulator_connected"); private static final ResourceLocation MODEL_BASE_CONNECTED = new ResourceLocation(RS.ID + ":block/disk_manipulator_connected");
private static final ResourceLocation MODEL_BASE_DISCONNECTED = new ResourceLocation(RS.ID + ":block/disk_manipulator_disconnected"); private static final ResourceLocation MODEL_BASE_DISCONNECTED = new ResourceLocation(RS.ID + ":block/disk_manipulator_disconnected");
private static final ResourceLocation MODEL_DISK = new ResourceLocation(RS.ID + ":block/disk"); private static final ResourceLocation MODEL_DISK = new ResourceLocation(RS.ID + ":block/disks/disk");
private static final ResourceLocation MODEL_DISK_NEAR_CAPACITY = new ResourceLocation(RS.ID + ":block/disk_near_capacity"); private static final ResourceLocation MODEL_DISK_NEAR_CAPACITY = new ResourceLocation(RS.ID + ":block/disks/disk_near_capacity");
private static final ResourceLocation MODEL_DISK_FULL = new ResourceLocation(RS.ID + ":block/disk_full"); private static final ResourceLocation MODEL_DISK_FULL = new ResourceLocation(RS.ID + ":block/disks/disk_full");
private static final ResourceLocation MODEL_DISK_DISCONNECTED = new ResourceLocation(RS.ID + ":block/disk_disconnected"); private static final ResourceLocation MODEL_DISK_DISCONNECTED = new ResourceLocation(RS.ID + ":block/disks/disk_disconnected");
@Override @Override
public Collection<ResourceLocation> getDependencies() { public Collection<ResourceLocation> getDependencies() {
@@ -69,9 +69,9 @@ public class ModelDiskManipulator implements IModel {
return new BakedModelDiskManipulator( return new BakedModelDiskManipulator(
new BakedModelFullbright(baseModelConnected.bake(state, format, bakedTextureGetter), RS.ID + ":blocks/disk_manipulator/cutouts/connected"), new BakedModelFullbright(baseModelConnected.bake(state, format, bakedTextureGetter), RS.ID + ":blocks/disk_manipulator/cutouts/connected"),
baseModelDisconnected.bake(state, format, bakedTextureGetter), baseModelDisconnected.bake(state, format, bakedTextureGetter),
diskModel.bake(state, format, bakedTextureGetter), new BakedModelFullbright(diskModel.bake(state, format, bakedTextureGetter), RS.ID + ":blocks/disks/leds").setCacheDisabled(),
diskModelNearCapacity.bake(state, format, bakedTextureGetter), new BakedModelFullbright(diskModelNearCapacity.bake(state, format, bakedTextureGetter), RS.ID + ":blocks/disks/leds").setCacheDisabled(),
diskModelFull.bake(state, format, bakedTextureGetter), new BakedModelFullbright(diskModelFull.bake(state, format, bakedTextureGetter), RS.ID + ":blocks/disks/leds").setCacheDisabled(),
diskModelDisconnected.bake(state, format, bakedTextureGetter) diskModelDisconnected.bake(state, format, bakedTextureGetter)
); );
} }

View File

@@ -62,22 +62,13 @@ public class BakedModelFullbright extends BakedModelDelegate {
private static final LoadingCache<CacheKey, List<BakedQuad>> CACHE = CacheBuilder.newBuilder().build(new CacheLoader<CacheKey, List<BakedQuad>>() { private static final LoadingCache<CacheKey, List<BakedQuad>> CACHE = CacheBuilder.newBuilder().build(new CacheLoader<CacheKey, List<BakedQuad>>() {
@Override @Override
public List<BakedQuad> load(CacheKey key) throws Exception { public List<BakedQuad> load(CacheKey key) {
List<BakedQuad> quads = new ArrayList<>(key.base.getQuads(key.state, key.side, 0)); return transformQuads(key.base.getQuads(key.state, key.side, 0), key.textures);
for (int i = 0; i < quads.size(); ++i) {
BakedQuad quad = quads.get(i);
if (key.textures.contains(quad.getSprite().getIconName())) {
quads.set(i, transformQuad(quad, 0.007F));
}
}
return quads;
} }
}); });
private Set<String> textures; private Set<String> textures;
private boolean cacheDisabled = false;
public BakedModelFullbright(IBakedModel base, String... textures) { public BakedModelFullbright(IBakedModel base, String... textures) {
super(base); super(base);
@@ -85,15 +76,39 @@ public class BakedModelFullbright extends BakedModelDelegate {
this.textures = new HashSet<>(Arrays.asList(textures)); this.textures = new HashSet<>(Arrays.asList(textures));
} }
public BakedModelFullbright setCacheDisabled() {
this.cacheDisabled = true;
return this;
}
@Override @Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) { public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
if (state == null) { if (state == null) {
return base.getQuads(state, side, rand); return base.getQuads(state, side, rand);
} }
if (cacheDisabled) {
return transformQuads(base.getQuads(state, side, 0), textures);
}
return CACHE.getUnchecked(new CacheKey(base, textures, state instanceof IExtendedBlockState ? ((IExtendedBlockState) state).getClean() : state, side)); return CACHE.getUnchecked(new CacheKey(base, textures, state instanceof IExtendedBlockState ? ((IExtendedBlockState) state).getClean() : state, side));
} }
private static List<BakedQuad> transformQuads(List<BakedQuad> oldQuads, Set<String> textures) {
List<BakedQuad> quads = new ArrayList<>(oldQuads);
for (int i = 0; i < quads.size(); ++i) {
BakedQuad quad = quads.get(i);
if (textures.contains(quad.getSprite().getIconName())) {
quads.set(i, transformQuad(quad, 0.007F));
}
}
return quads;
}
private static BakedQuad transformQuad(BakedQuad quad, float light) { private static BakedQuad transformQuad(BakedQuad quad, float light) {
VertexFormat newFormat = RenderUtils.getFormatWithLightMap(quad.getFormat()); VertexFormat newFormat = RenderUtils.getFormatWithLightMap(quad.getFormat());

View File

@@ -1,7 +1,8 @@
{ {
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)", "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
"textures": { "textures": {
"0": "refinedstorage:blocks/disk" "base": "refinedstorage:blocks/disks/disk",
"led": "refinedstorage:blocks/disks/leds"
}, },
"elements": [ "elements": [
{ {
@@ -18,7 +19,7 @@
], ],
"faces": { "faces": {
"north": { "north": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
3.0, 3.0,
0.0, 0.0,
@@ -27,7 +28,7 @@
] ]
}, },
"east": { "east": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
2.0, 2.0,
0.0, 0.0,
@@ -36,7 +37,7 @@
] ]
}, },
"south": { "south": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
9.0, 9.0,
0.0, 0.0,
@@ -45,7 +46,7 @@
] ]
}, },
"west": { "west": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
8.0, 8.0,
0.0, 0.0,
@@ -54,7 +55,7 @@
] ]
}, },
"up": { "up": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
3.0, 3.0,
2.0, 2.0,
@@ -63,7 +64,7 @@
] ]
}, },
"down": { "down": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
3.0, 3.0,
3.0, 3.0,
@@ -87,57 +88,57 @@
], ],
"faces": { "faces": {
"north": { "north": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0, 2.0,
1.0, 0.0,
15.0, 2.0,
2.0 0.0
] ]
}, },
"east": { "east": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0, 2.0,
1.0, 0.0,
15.0, 2.0,
2.0 0.0
] ]
}, },
"south": { "south": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0, 2.0,
1.0, 0.0,
15.0, 2.0,
2.0 0.0
] ]
}, },
"west": { "west": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0, 2.0,
1.0, 0.0,
15.0, 2.0,
2.0 0.0
] ]
}, },
"up": { "up": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0, 2.0,
1.0, 0.0,
15.0, 2.0,
2.0 0.0
] ]
}, },
"down": { "down": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0, 2.0,
1.0, 0.0,
15.0, 2.0,
2.0 0.0
] ]
} }
} }

View File

@@ -1,7 +1,8 @@
{ {
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)", "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
"textures": { "textures": {
"0": "refinedstorage:blocks/disk_disconnected" "base": "refinedstorage:blocks/disks/disk",
"led": "refinedstorage:blocks/disks/leds"
}, },
"elements": [ "elements": [
{ {
@@ -18,7 +19,7 @@
], ],
"faces": { "faces": {
"north": { "north": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
3.0, 3.0,
0.0, 0.0,
@@ -27,7 +28,7 @@
] ]
}, },
"east": { "east": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
2.0, 2.0,
0.0, 0.0,
@@ -36,7 +37,7 @@
] ]
}, },
"south": { "south": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
9.0, 9.0,
0.0, 0.0,
@@ -45,7 +46,7 @@
] ]
}, },
"west": { "west": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
8.0, 8.0,
0.0, 0.0,
@@ -54,7 +55,7 @@
] ]
}, },
"up": { "up": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
3.0, 3.0,
2.0, 2.0,
@@ -63,7 +64,7 @@
] ]
}, },
"down": { "down": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
3.0, 3.0,
3.0, 3.0,
@@ -87,57 +88,57 @@
], ],
"faces": { "faces": {
"north": { "north": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0, 3.0,
1.0, 0.0,
15.0, 3.0,
2.0 0.0
] ]
}, },
"east": { "east": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0, 3.0,
1.0, 0.0,
15.0, 3.0,
2.0 0.0
] ]
}, },
"south": { "south": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0, 3.0,
1.0, 0.0,
15.0, 3.0,
2.0 0.0
] ]
}, },
"west": { "west": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0, 3.0,
1.0, 0.0,
15.0, 3.0,
2.0 0.0
] ]
}, },
"up": { "up": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0, 3.0,
1.0, 0.0,
15.0, 3.0,
2.0 0.0
] ]
}, },
"down": { "down": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0, 3.0,
1.0, 0.0,
15.0, 3.0,
2.0 0.0
] ]
} }
} }

View File

@@ -1,7 +1,8 @@
{ {
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)", "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
"textures": { "textures": {
"0": "refinedstorage:blocks/disk_full" "base": "refinedstorage:blocks/disks/disk",
"led": "refinedstorage:blocks/disks/leds"
}, },
"elements": [ "elements": [
{ {
@@ -18,7 +19,7 @@
], ],
"faces": { "faces": {
"north": { "north": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
3.0, 3.0,
0.0, 0.0,
@@ -27,7 +28,7 @@
] ]
}, },
"east": { "east": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
2.0, 2.0,
0.0, 0.0,
@@ -36,7 +37,7 @@
] ]
}, },
"south": { "south": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
9.0, 9.0,
0.0, 0.0,
@@ -45,7 +46,7 @@
] ]
}, },
"west": { "west": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
8.0, 8.0,
0.0, 0.0,
@@ -54,7 +55,7 @@
] ]
}, },
"up": { "up": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
3.0, 3.0,
2.0, 2.0,
@@ -63,7 +64,7 @@
] ]
}, },
"down": { "down": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
3.0, 3.0,
3.0, 3.0,
@@ -87,57 +88,57 @@
], ],
"faces": { "faces": {
"north": { "north": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0,
1.0, 1.0,
15.0, 0.0,
2.0 1.0,
0.0
] ]
}, },
"east": { "east": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0,
1.0, 1.0,
15.0, 0.0,
2.0 1.0,
0.0
] ]
}, },
"south": { "south": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0,
1.0, 1.0,
15.0, 0.0,
2.0 1.0,
0.0
] ]
}, },
"west": { "west": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0,
1.0, 1.0,
15.0, 0.0,
2.0 1.0,
0.0
] ]
}, },
"up": { "up": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0,
1.0, 1.0,
15.0, 0.0,
2.0 1.0,
0.0
] ]
}, },
"down": { "down": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0,
1.0, 1.0,
15.0, 0.0,
2.0 1.0,
0.0
] ]
} }
} }

View File

@@ -1,7 +1,8 @@
{ {
"__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)", "__comment": "Model generated using MrCrayfish's Model Creator (http://mrcrayfish.com/modelcreator/)",
"textures": { "textures": {
"0": "refinedstorage:blocks/disk_near_capacity" "base": "refinedstorage:blocks/disks/disk",
"led": "refinedstorage:blocks/disks/leds"
}, },
"elements": [ "elements": [
{ {
@@ -18,7 +19,7 @@
], ],
"faces": { "faces": {
"north": { "north": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
3.0, 3.0,
0.0, 0.0,
@@ -27,7 +28,7 @@
] ]
}, },
"east": { "east": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
2.0, 2.0,
0.0, 0.0,
@@ -36,7 +37,7 @@
] ]
}, },
"south": { "south": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
9.0, 9.0,
0.0, 0.0,
@@ -45,7 +46,7 @@
] ]
}, },
"west": { "west": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
8.0, 8.0,
0.0, 0.0,
@@ -54,7 +55,7 @@
] ]
}, },
"up": { "up": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
3.0, 3.0,
2.0, 2.0,
@@ -63,7 +64,7 @@
] ]
}, },
"down": { "down": {
"texture": "#0", "texture": "#base",
"uv": [ "uv": [
3.0, 3.0,
3.0, 3.0,
@@ -87,57 +88,57 @@
], ],
"faces": { "faces": {
"north": { "north": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0, 0.0,
1.0, 0.0,
15.0, 0.0,
2.0 0.0
] ]
}, },
"east": { "east": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0, 0.0,
1.0, 0.0,
15.0, 0.0,
2.0 0.0
] ]
}, },
"south": { "south": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0, 0.0,
1.0, 0.0,
15.0, 0.0,
2.0 0.0
] ]
}, },
"west": { "west": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0, 0.0,
1.0, 0.0,
15.0, 0.0,
2.0 0.0
] ]
}, },
"up": { "up": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0, 0.0,
1.0, 0.0,
15.0, 0.0,
2.0 0.0
] ]
}, },
"down": { "down": {
"texture": "#0", "texture": "#led",
"uv": [ "uv": [
14.0, 0.0,
1.0, 0.0,
15.0, 0.0,
2.0 0.0
] ]
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 217 B