Fix SkyStone chest model issues that I had introduced back in 1.8. (#4542)

This makes the chest 1 pixel higher to restore the look it had in 1.7.
Since the skystone chest's texture is a grungy mess, only the most
obvious texture problems were fixed, while for the skystone block chest,
the look should be close to what it was now.
Also introduces caching for the skystone chest's block shape.
This commit is contained in:
shartte
2020-08-03 14:46:23 +02:00
committed by GitHub
parent a85ffec9f9
commit 1801302d8f
5 changed files with 67 additions and 83 deletions
@@ -18,6 +18,9 @@
package appeng.block.storage; package appeng.block.storage;
import java.util.EnumMap;
import java.util.Map;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import net.minecraft.block.BlockRenderType; import net.minecraft.block.BlockRenderType;
@@ -47,7 +50,18 @@ public class SkyChestBlock extends AEBaseTileBlock<SkyChestTileEntity> {
private static final double AABB_OFFSET_BOTTOM = 0.00; private static final double AABB_OFFSET_BOTTOM = 0.00;
private static final double AABB_OFFSET_SIDES = 0.06; private static final double AABB_OFFSET_SIDES = 0.06;
private static final double AABB_OFFSET_TOP = 0.125; private static final double AABB_OFFSET_TOP = 0.0625;
// Precomputed bounding boxes of the chest, sorted into the map by the UP
// direction
private static final Map<Direction, VoxelShape> SHAPES = new EnumMap<>(Direction.class);
static {
for (Direction up : Direction.values()) {
AxisAlignedBB aabb = computeAABB(up);
SHAPES.put(up, VoxelShapes.create(aabb));
}
}
public enum SkyChestType { public enum SkyChestType {
STONE, BLOCK STONE, BLOCK
@@ -87,37 +101,30 @@ public class SkyChestBlock extends AEBaseTileBlock<SkyChestTileEntity> {
@Override @Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
// TODO Cache this! It can't be that hard! final SkyChestTileEntity sk = this.getTileEntity(worldIn, pos);
AxisAlignedBB aabb = computeAABB(worldIn, pos); Direction up = sk != null ? sk.getUp() : Direction.UP;
return VoxelShapes.create(aabb); return SHAPES.get(up);
} }
private AxisAlignedBB computeAABB(final IBlockReader w, final BlockPos pos) { private static AxisAlignedBB computeAABB(Direction up) {
final SkyChestTileEntity sk = this.getTileEntity(w, pos); final double offsetX = up.getXOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
Direction o = Direction.UP; final double offsetY = up.getYOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
final double offsetZ = up.getZOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
if (sk != null) {
o = sk.getUp();
}
final double offsetX = o.getXOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
final double offsetY = o.getYOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
final double offsetZ = o.getZOffset() == 0 ? AABB_OFFSET_SIDES : 0.0;
// for x/z top and bottom is swapped // for x/z top and bottom is swapped
final double minX = Math.max(0.0, final double minX = Math.max(0.0,
offsetX + (o.getXOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getXOffset() * AABB_OFFSET_TOP))); offsetX + (up.getXOffset() < 0 ? AABB_OFFSET_BOTTOM : (up.getXOffset() * AABB_OFFSET_TOP)));
final double minY = Math.max(0.0, final double minY = Math.max(0.0,
offsetY + (o.getYOffset() < 0 ? AABB_OFFSET_TOP : (o.getYOffset() * AABB_OFFSET_BOTTOM))); offsetY + (up.getYOffset() < 0 ? AABB_OFFSET_TOP : (up.getYOffset() * AABB_OFFSET_BOTTOM)));
final double minZ = Math.max(0.0, final double minZ = Math.max(0.0,
offsetZ + (o.getZOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getZOffset() * AABB_OFFSET_TOP))); offsetZ + (up.getZOffset() < 0 ? AABB_OFFSET_BOTTOM : (up.getZOffset() * AABB_OFFSET_TOP)));
final double maxX = Math.min(1.0, final double maxX = Math.min(1.0,
1.0 - offsetX - (o.getXOffset() < 0 ? AABB_OFFSET_TOP : (o.getXOffset() * AABB_OFFSET_BOTTOM))); 1.0 - offsetX - (up.getXOffset() < 0 ? AABB_OFFSET_TOP : (up.getXOffset() * AABB_OFFSET_BOTTOM)));
final double maxY = Math.min(1.0, final double maxY = Math.min(1.0,
1.0 - offsetY - (o.getYOffset() < 0 ? AABB_OFFSET_BOTTOM : (o.getYOffset() * AABB_OFFSET_TOP))); 1.0 - offsetY - (up.getYOffset() < 0 ? AABB_OFFSET_BOTTOM : (up.getYOffset() * AABB_OFFSET_TOP)));
final double maxZ = Math.min(1.0, final double maxZ = Math.min(1.0,
1.0 - offsetZ - (o.getZOffset() < 0 ? AABB_OFFSET_TOP : (o.getZOffset() * AABB_OFFSET_BOTTOM))); 1.0 - offsetZ - (up.getZOffset() < 0 ? AABB_OFFSET_TOP : (up.getZOffset() * AABB_OFFSET_BOTTOM)));
return new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ); return new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
} }
@@ -60,11 +60,11 @@ public class SkyChestTESR extends TileEntityRenderer<SkyChestTileEntity> {
this.singleBottom.addBox(1.0F, 0.0F, 1.0F, 14.0F, 10.0F, 14.0F, 0.0F); this.singleBottom.addBox(1.0F, 0.0F, 1.0F, 14.0F, 10.0F, 14.0F, 0.0F);
this.singleLid = new ModelRenderer(64, 64, 0, 0); this.singleLid = new ModelRenderer(64, 64, 0, 0);
this.singleLid.addBox(1.0F, 0.0F, 0.0F, 14.0F, 5.0F, 14.0F, 0.0F); this.singleLid.addBox(1.0F, 0.0F, 0.0F, 14.0F, 5.0F, 14.0F, 0.0F);
this.singleLid.rotationPointY = 9.0F; this.singleLid.rotationPointY = 10.0F;
this.singleLid.rotationPointZ = 1.0F; this.singleLid.rotationPointZ = 1.0F;
this.singleLatch = new ModelRenderer(64, 64, 0, 0); this.singleLatch = new ModelRenderer(64, 64, 0, 0);
this.singleLatch.addBox(7.0F, -1.0F, 15.0F, 2.0F, 4.0F, 1.0F, 0.0F); this.singleLatch.addBox(7.0F, -1.0F, 15.0F, 2.0F, 4.0F, 1.0F, 0.0F);
this.singleLatch.rotationPointY = 8.0F; this.singleLatch.rotationPointY = 9.0F;
} }
@Override @Override
@@ -7,94 +7,71 @@
"elements": [ "elements": [
{ {
"name": "Base", "name": "Base",
"from": [1.0, 0.0, 1.0], "from": [1, 0, 1],
"to": [15.0, 10.0, 15.0], "to": [15, 10, 15],
"shade": false, "shade": false,
"faces": { "faces": {
"north": { "north": {
"texture": "#0", "uv": [3.5, 8.25, 7, 10.75],
"uv": [3.5, 8.25, 7, 10.75] "rotation": 180,
"texture": "#0"
}, },
"east": { "east": {
"texture": "#0", "uv": [0, 8.25, 3.5, 10.75],
"uv": [0.0, 8.25, 3.5, 10.75] "rotation": 180,
"texture": "#0"
}, },
"south": { "south": {
"texture": "#0", "uv": [10.5, 8.25, 14, 10.75],
"uv": [10.5, 8.25, 14, 10.75] "rotation": 180,
"texture": "#0"
}, },
"west": { "west": {
"texture": "#0", "uv": [7, 8.25, 10.5, 10.75],
"uv": [7, 8.25, 10.5, 10.75] "rotation": 180,
"texture": "#0"
}, },
"up": { "up": { "uv": [3.5, 0, 7, 3.5], "texture": "#0" },
"texture": "#0", "down": { "uv": [7, 0, 10.5, 3.5], "texture": "#0" }
"uv": [3.5, 0.0, 7, 3.5]
},
"down": {
"texture": "#0",
"uv": [7, 0.0, 10.5, 3.5]
}
} }
}, },
{ {
"name": "Lid", "name": "Lid",
"from": [1.0, 10.0, 1.0], "from": [1, 10, 1],
"to": [15.0, 15.0, 15.0], "to": [15, 15, 15],
"shade": false, "shade": false,
"faces": { "faces": {
"north": { "north": {
"texture": "#0", "uv": [3.5, 3.5, 7, 4.75],
"uv": [3.5, 3.5, 7, 4.75] "rotation": 180,
}, "texture": "#0"
"east": {
"texture": "#0",
"uv": [0.0, 3.5, 3.5, 4.75]
}, },
"east": { "uv": [0, 3.5, 3.5, 4.75], "rotation": 180, "texture": "#0" },
"south": { "south": {
"texture": "#0", "uv": [10.5, 3.5, 14, 4.75],
"uv": [10.5, 3.5, 14, 4.75] "rotation": 180,
"texture": "#0"
}, },
"west": { "west": {
"texture": "#0", "uv": [7, 3.5, 10.5, 4.75],
"uv": [7, 3.5, 10.5, 4.75] "rotation": 180,
"texture": "#0"
}, },
"up": { "up": { "uv": [7, 0, 10.5, 3.5], "rotation": 270, "texture": "#0" },
"texture": "#0", "down": { "uv": [7, 0, 10.5, 3.5], "texture": "#0" }
"uv": [3.5, 0.0, 7, 3.5]
},
"down": {
"texture": "#0",
"uv": [7, 0.0, 10.5, 3.5]
}
} }
}, },
{ {
"name": "Knob", "name": "Knob",
"from": [7.0, 7.0, 0.0], "from": [7, 7, 0],
"to": [9.0, 11.0, 1.0], "to": [9, 11, 1],
"shade": false, "shade": false,
"faces": { "faces": {
"north": { "north": { "uv": [0.25, 0.25, 0.75, 1.25], "texture": "#0" },
"texture": "#0", "east": { "uv": [0, 0.25, 0.25, 1.25], "texture": "#0" },
"uv": [0.25, 0.25, 0.75, 1.25] "west": { "uv": [0.75, 0.25, 1.5, 1.25], "texture": "#0" },
}, "up": { "uv": [0.25, 0, 0.75, 0.25], "texture": "#0" },
"east": { "down": { "uv": [0.75, 0, 1.5, 0.25], "texture": "#0" }
"texture": "#0",
"uv": [0, 0.25, 0.25, 1.25]
},
"west": {
"texture": "#0",
"uv": [0.75, 0.25, 1.5, 1.25]
},
"up": {
"texture": "#0",
"uv": [0.25, 0.0, 0.75, 0.25]
},
"down": {
"texture": "#0",
"uv": [0.75, 0.0, 1.5, 0.25]
}
} }
} }
] ]
Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB