diff --git a/src/main/java/appeng/block/storage/SkyChestBlock.java b/src/main/java/appeng/block/storage/SkyChestBlock.java index 8e7910606..b4cd8060c 100644 --- a/src/main/java/appeng/block/storage/SkyChestBlock.java +++ b/src/main/java/appeng/block/storage/SkyChestBlock.java @@ -18,6 +18,9 @@ package appeng.block.storage; +import java.util.EnumMap; +import java.util.Map; + import javax.annotation.Nullable; import net.minecraft.block.BlockRenderType; @@ -47,7 +50,18 @@ public class SkyChestBlock extends AEBaseTileBlock { private static final double AABB_OFFSET_BOTTOM = 0.00; 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 SHAPES = new EnumMap<>(Direction.class); + + static { + for (Direction up : Direction.values()) { + Box aabb = computeAABB(up); + SHAPES.put(up, VoxelShapes.cuboid(aabb)); + } + } public enum SkyChestType { STONE, BLOCK @@ -87,37 +101,30 @@ public class SkyChestBlock extends AEBaseTileBlock { @Override public VoxelShape getOutlineShape(BlockState state, BlockView worldIn, BlockPos pos, ShapeContext context) { - // TODO Cache this! It can't be that hard! - Box aabb = computeAABB(worldIn, pos); - return VoxelShapes.cuboid(aabb); + final SkyChestBlockEntity sk = this.getBlockEntity(worldIn, pos); + Direction up = sk != null ? sk.getUp() : Direction.UP; + return SHAPES.get(up); } - private Box computeAABB(final BlockView w, final BlockPos pos) { - final SkyChestBlockEntity sk = this.getBlockEntity(w, pos); - Direction o = Direction.UP; - - if (sk != null) { - o = sk.getUp(); - } - - final double offsetX = o.getOffsetX() == 0 ? AABB_OFFSET_SIDES : 0.0; - final double offsetY = o.getOffsetY() == 0 ? AABB_OFFSET_SIDES : 0.0; - final double offsetZ = o.getOffsetZ() == 0 ? AABB_OFFSET_SIDES : 0.0; + private static Box computeAABB(Direction up) { + final double offsetX = up.getOffsetX() == 0 ? AABB_OFFSET_SIDES : 0.0; + final double offsetY = up.getOffsetY() == 0 ? AABB_OFFSET_SIDES : 0.0; + final double offsetZ = up.getOffsetZ() == 0 ? AABB_OFFSET_SIDES : 0.0; // for x/z top and bottom is swapped final double minX = Math.max(0.0, - offsetX + (o.getOffsetX() < 0 ? AABB_OFFSET_BOTTOM : (o.getOffsetX() * AABB_OFFSET_TOP))); + offsetX + (up.getOffsetX() < 0 ? AABB_OFFSET_BOTTOM : (up.getOffsetX() * AABB_OFFSET_TOP))); final double minY = Math.max(0.0, - offsetY + (o.getOffsetY() < 0 ? AABB_OFFSET_TOP : (o.getOffsetY() * AABB_OFFSET_BOTTOM))); + offsetY + (up.getOffsetY() < 0 ? AABB_OFFSET_TOP : (up.getOffsetY() * AABB_OFFSET_BOTTOM))); final double minZ = Math.max(0.0, - offsetZ + (o.getOffsetZ() < 0 ? AABB_OFFSET_BOTTOM : (o.getOffsetZ() * AABB_OFFSET_TOP))); + offsetZ + (up.getOffsetZ() < 0 ? AABB_OFFSET_BOTTOM : (up.getOffsetZ() * AABB_OFFSET_TOP))); final double maxX = Math.min(1.0, - 1.0 - offsetX - (o.getOffsetX() < 0 ? AABB_OFFSET_TOP : (o.getOffsetX() * AABB_OFFSET_BOTTOM))); + 1.0 - offsetX - (up.getOffsetX() < 0 ? AABB_OFFSET_TOP : (up.getOffsetX() * AABB_OFFSET_BOTTOM))); final double maxY = Math.min(1.0, - 1.0 - offsetY - (o.getOffsetY() < 0 ? AABB_OFFSET_BOTTOM : (o.getOffsetY() * AABB_OFFSET_TOP))); + 1.0 - offsetY - (up.getOffsetY() < 0 ? AABB_OFFSET_BOTTOM : (up.getOffsetY() * AABB_OFFSET_TOP))); final double maxZ = Math.min(1.0, - 1.0 - offsetZ - (o.getOffsetZ() < 0 ? AABB_OFFSET_TOP : (o.getOffsetZ() * AABB_OFFSET_BOTTOM))); + 1.0 - offsetZ - (up.getOffsetZ() < 0 ? AABB_OFFSET_TOP : (up.getOffsetZ() * AABB_OFFSET_BOTTOM))); return new Box(minX, minY, minZ, maxX, maxY, maxZ); } diff --git a/src/main/java/appeng/client/render/tesr/SkyChestTESR.java b/src/main/java/appeng/client/render/tesr/SkyChestTESR.java index 68b51db72..64855a6df 100644 --- a/src/main/java/appeng/client/render/tesr/SkyChestTESR.java +++ b/src/main/java/appeng/client/render/tesr/SkyChestTESR.java @@ -63,11 +63,11 @@ public class SkyChestTESR extends BlockEntityRenderer { this.singleBottom.addCuboid(1.0F, 0.0F, 1.0F, 14.0F, 10.0F, 14.0F, 0.0F); this.singleLid = new ModelPart(64, 64, 0, 0); this.singleLid.addCuboid(1.0F, 0.0F, 0.0F, 14.0F, 5.0F, 14.0F, 0.0F); - this.singleLid.pivotY = 9.0F; + this.singleLid.pivotY = 10.0F; this.singleLid.pivotZ = 1.0F; this.singleLatch = new ModelPart(64, 64, 0, 0); this.singleLatch.addCuboid(7.0F, -1.0F, 15.0F, 2.0F, 4.0F, 1.0F, 0.0F); - this.singleLatch.pivotY = 8.0F; + this.singleLatch.pivotY = 9.0F; } @Override diff --git a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_chest.json b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_chest.json index 119e44f92..e5f75d516 100644 --- a/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_chest.json +++ b/src/main/resources/assets/appliedenergistics2/models/item/sky_stone_chest.json @@ -7,94 +7,71 @@ "elements": [ { "name": "Base", - "from": [1.0, 0.0, 1.0], - "to": [15.0, 10.0, 15.0], + "from": [1, 0, 1], + "to": [15, 10, 15], "shade": false, "faces": { "north": { - "texture": "#0", - "uv": [3.5, 8.25, 7, 10.75] + "uv": [3.5, 8.25, 7, 10.75], + "rotation": 180, + "texture": "#0" }, "east": { - "texture": "#0", - "uv": [0.0, 8.25, 3.5, 10.75] + "uv": [0, 8.25, 3.5, 10.75], + "rotation": 180, + "texture": "#0" }, "south": { - "texture": "#0", - "uv": [10.5, 8.25, 14, 10.75] + "uv": [10.5, 8.25, 14, 10.75], + "rotation": 180, + "texture": "#0" }, "west": { - "texture": "#0", - "uv": [7, 8.25, 10.5, 10.75] + "uv": [7, 8.25, 10.5, 10.75], + "rotation": 180, + "texture": "#0" }, - "up": { - "texture": "#0", - "uv": [3.5, 0.0, 7, 3.5] - }, - "down": { - "texture": "#0", - "uv": [7, 0.0, 10.5, 3.5] - } + "up": { "uv": [3.5, 0, 7, 3.5], "texture": "#0" }, + "down": { "uv": [7, 0, 10.5, 3.5], "texture": "#0" } } }, { "name": "Lid", - "from": [1.0, 10.0, 1.0], - "to": [15.0, 15.0, 15.0], + "from": [1, 10, 1], + "to": [15, 15, 15], "shade": false, "faces": { "north": { - "texture": "#0", - "uv": [3.5, 3.5, 7, 4.75] - }, - "east": { - "texture": "#0", - "uv": [0.0, 3.5, 3.5, 4.75] + "uv": [3.5, 3.5, 7, 4.75], + "rotation": 180, + "texture": "#0" }, + "east": { "uv": [0, 3.5, 3.5, 4.75], "rotation": 180, "texture": "#0" }, "south": { - "texture": "#0", - "uv": [10.5, 3.5, 14, 4.75] + "uv": [10.5, 3.5, 14, 4.75], + "rotation": 180, + "texture": "#0" }, "west": { - "texture": "#0", - "uv": [7, 3.5, 10.5, 4.75] + "uv": [7, 3.5, 10.5, 4.75], + "rotation": 180, + "texture": "#0" }, - "up": { - "texture": "#0", - "uv": [3.5, 0.0, 7, 3.5] - }, - "down": { - "texture": "#0", - "uv": [7, 0.0, 10.5, 3.5] - } + "up": { "uv": [7, 0, 10.5, 3.5], "rotation": 270, "texture": "#0" }, + "down": { "uv": [7, 0, 10.5, 3.5], "texture": "#0" } } }, { "name": "Knob", - "from": [7.0, 7.0, 0.0], - "to": [9.0, 11.0, 1.0], + "from": [7, 7, 0], + "to": [9, 11, 1], "shade": false, "faces": { - "north": { - "texture": "#0", - "uv": [0.25, 0.25, 0.75, 1.25] - }, - "east": { - "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] - } + "north": { "uv": [0.25, 0.25, 0.75, 1.25], "texture": "#0" }, + "east": { "uv": [0, 0.25, 0.25, 1.25], "texture": "#0" }, + "west": { "uv": [0.75, 0.25, 1.5, 1.25], "texture": "#0" }, + "up": { "uv": [0.25, 0, 0.75, 0.25], "texture": "#0" }, + "down": { "uv": [0.75, 0, 1.5, 0.25], "texture": "#0" } } } ] diff --git a/src/main/resources/assets/appliedenergistics2/textures/models/skyblockchest.png b/src/main/resources/assets/appliedenergistics2/textures/models/skyblockchest.png index e6b7f80e7..1bc65a687 100644 Binary files a/src/main/resources/assets/appliedenergistics2/textures/models/skyblockchest.png and b/src/main/resources/assets/appliedenergistics2/textures/models/skyblockchest.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/models/skychest.png b/src/main/resources/assets/appliedenergistics2/textures/models/skychest.png index cad859328..50253b6eb 100644 Binary files a/src/main/resources/assets/appliedenergistics2/textures/models/skychest.png and b/src/main/resources/assets/appliedenergistics2/textures/models/skychest.png differ