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.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.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
@@ -18,10 +19,10 @@ import java.util.function.Function;
public class ModelDiskDrive implements IModel {
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_NEAR_CAPACITY = new ResourceLocation(RS.ID + ":block/disk_near_capacity");
private static final ResourceLocation MODEL_DISK_FULL = new ResourceLocation(RS.ID + ":block/disk_full");
private static final ResourceLocation MODEL_DISK_DISCONNECTED = new ResourceLocation(RS.ID + ":block/disk_disconnected");
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/disks/disk_near_capacity");
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/disks/disk_disconnected");
@Override
public Collection<ResourceLocation> getDependencies() {
@@ -56,9 +57,9 @@ public class ModelDiskDrive implements IModel {
return new BakedModelDiskDrive(
baseModel.bake(state, format, bakedTextureGetter),
diskModel.bake(state, format, bakedTextureGetter),
diskModelNearCapacity.bake(state, format, bakedTextureGetter),
diskModelFull.bake(state, format, bakedTextureGetter),
new BakedModelFullbright(diskModel.bake(state, format, bakedTextureGetter), RS.ID + ":blocks/disks/leds").setCacheDisabled(),
new BakedModelFullbright(diskModelNearCapacity.bake(state, format, bakedTextureGetter), RS.ID + ":blocks/disks/leds").setCacheDisabled(),
new BakedModelFullbright(diskModelFull.bake(state, format, bakedTextureGetter), RS.ID + ":blocks/disks/leds").setCacheDisabled(),
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_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_NEAR_CAPACITY = new ResourceLocation(RS.ID + ":block/disk_near_capacity");
private static final ResourceLocation MODEL_DISK_FULL = new ResourceLocation(RS.ID + ":block/disk_full");
private static final ResourceLocation MODEL_DISK_DISCONNECTED = new ResourceLocation(RS.ID + ":block/disk_disconnected");
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/disks/disk_near_capacity");
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/disks/disk_disconnected");
@Override
public Collection<ResourceLocation> getDependencies() {
@@ -69,9 +69,9 @@ public class ModelDiskManipulator implements IModel {
return new BakedModelDiskManipulator(
new BakedModelFullbright(baseModelConnected.bake(state, format, bakedTextureGetter), RS.ID + ":blocks/disk_manipulator/cutouts/connected"),
baseModelDisconnected.bake(state, format, bakedTextureGetter),
diskModel.bake(state, format, bakedTextureGetter),
diskModelNearCapacity.bake(state, format, bakedTextureGetter),
diskModelFull.bake(state, format, bakedTextureGetter),
new BakedModelFullbright(diskModel.bake(state, format, bakedTextureGetter), RS.ID + ":blocks/disks/leds").setCacheDisabled(),
new BakedModelFullbright(diskModelNearCapacity.bake(state, format, bakedTextureGetter), RS.ID + ":blocks/disks/leds").setCacheDisabled(),
new BakedModelFullbright(diskModelFull.bake(state, format, bakedTextureGetter), RS.ID + ":blocks/disks/leds").setCacheDisabled(),
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>>() {
@Override
public List<BakedQuad> load(CacheKey key) throws Exception {
List<BakedQuad> quads = new ArrayList<>(key.base.getQuads(key.state, key.side, 0));
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;
public List<BakedQuad> load(CacheKey key) {
return transformQuads(key.base.getQuads(key.state, key.side, 0), key.textures);
}
});
private Set<String> textures;
private boolean cacheDisabled = false;
public BakedModelFullbright(IBakedModel base, String... textures) {
super(base);
@@ -85,15 +76,39 @@ public class BakedModelFullbright extends BakedModelDelegate {
this.textures = new HashSet<>(Arrays.asList(textures));
}
public BakedModelFullbright setCacheDisabled() {
this.cacheDisabled = true;
return this;
}
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
if (state == null) {
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));
}
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) {
VertexFormat newFormat = RenderUtils.getFormatWithLightMap(quad.getFormat());

View File

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

View File

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

View File

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

View File

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