diff --git a/src/main/java/appeng/block/storage/SkyChestBlock.java b/src/main/java/appeng/block/storage/SkyChestBlock.java index 7c3d1ebab..4a0bdf94a 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()) { + AxisAlignedBB aabb = computeAABB(up); + SHAPES.put(up, VoxelShapes.create(aabb)); + } + } public enum SkyChestType { STONE, BLOCK @@ -87,37 +101,30 @@ public class SkyChestBlock extends AEBaseTileBlock { @Override public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { - // TODO Cache this! It can't be that hard! - AxisAlignedBB aabb = computeAABB(worldIn, pos); - return VoxelShapes.create(aabb); + final SkyChestTileEntity sk = this.getTileEntity(worldIn, pos); + Direction up = sk != null ? sk.getUp() : Direction.UP; + return SHAPES.get(up); } - private AxisAlignedBB computeAABB(final IBlockReader w, final BlockPos pos) { - final SkyChestTileEntity sk = this.getTileEntity(w, pos); - Direction o = Direction.UP; - - 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; + private static AxisAlignedBB computeAABB(Direction up) { + final double offsetX = up.getXOffset() == 0 ? AABB_OFFSET_SIDES : 0.0; + final double offsetY = up.getYOffset() == 0 ? AABB_OFFSET_SIDES : 0.0; + final double offsetZ = up.getZOffset() == 0 ? AABB_OFFSET_SIDES : 0.0; // for x/z top and bottom is swapped 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, - 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, - 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, - 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, - 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, - 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); } diff --git a/src/main/java/appeng/client/render/tesr/SkyChestTESR.java b/src/main/java/appeng/client/render/tesr/SkyChestTESR.java index da7ca30bc..6f7aab0f7 100644 --- a/src/main/java/appeng/client/render/tesr/SkyChestTESR.java +++ b/src/main/java/appeng/client/render/tesr/SkyChestTESR.java @@ -60,11 +60,11 @@ public class SkyChestTESR extends TileEntityRenderer { 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.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.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.rotationPointY = 8.0F; + this.singleLatch.rotationPointY = 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