diff --git a/codechicken/microblock/CornerMicroblock.scala b/codechicken/microblock/CornerMicroblock.scala index 20d3776..b124501 100644 --- a/codechicken/microblock/CornerMicroblock.scala +++ b/codechicken/microblock/CornerMicroblock.scala @@ -23,7 +23,7 @@ object CornerMicroClass extends MicroblockClass val rx = if((s&4) != 0) -1 else 1 val ry = if((s&1) != 0) -1 else 1 val rz = if((s&2) != 0) -1 else 1 - val transform = new Scale(new Vector3(rx, ry, rz), Vector3.center) + val transform = new Scale(new Vector3(rx, ry, rz)).at(Vector3.center) for(t <- 1 until 8) { diff --git a/codechicken/microblock/EdgeMicroblock.scala b/codechicken/microblock/EdgeMicroblock.scala index 73fe0ef..9436b9d 100644 --- a/codechicken/microblock/EdgeMicroblock.scala +++ b/codechicken/microblock/EdgeMicroblock.scala @@ -73,13 +73,13 @@ object EdgeMicroClass extends MicroblockClass { val rx = if((s&2) != 0) -1 else 1 val rz = if((s&1) != 0) -1 else 1 - val transform = new TransformationList(new Scale(new Vector3(rx, 1, rz)), AxisCycle.cycles(s>>2)) + val transform = new TransformationList(new Scale(new Vector3(rx, 1, rz)), AxisCycle.cycles(s>>2)).at(Vector3.center) for(t <- 1 until 8) { val d = t/8D aBounds(t<<4|s) = new SelectionBox(new Cuboid6(0, 0, 0, d, 1, d)) - .transform(transform, Vector3.center).bound + .transform(transform).bound } } @@ -133,12 +133,13 @@ object PostMicroClass for(s <- 0 until 3) { + val transform = Rotation.sideRotations(s<<1).at(Vector3.center) for(t <- 2 until 8 by 2) { val d1 = 0.5-t/16D val d2 = 0.5+t/16D aBounds(t<<4|s) = new SelectionBox(new Cuboid6(d1, 0, d1, d2, 1, d2)) - .transform(Rotation.sideRotations(s<<1), Vector3.center).bound + .transform(transform).bound } } diff --git a/codechicken/microblock/FaceMicroblock.scala b/codechicken/microblock/FaceMicroblock.scala index bd3c6c0..9eee5a1 100644 --- a/codechicken/microblock/FaceMicroblock.scala +++ b/codechicken/microblock/FaceMicroblock.scala @@ -45,12 +45,15 @@ object FaceMicroClass extends MicroblockClass var aBounds:Array[Cuboid6] = new Array(256); for(s <- 0 until 6) + { + val transform = Rotation.sideRotations(s).at(Vector3.center) for(t <- 1 until 8) { val d = t/8D aBounds(t<<4|s) = new SelectionBox(new Cuboid6(0, 0, 0, 1, d, 1)) - .transform(Rotation.sideRotations(s), Vector3.center).bound + .transform(transform).bound } + } def getName = "mcr_face" diff --git a/codechicken/microblock/HolloMicroblock.scala b/codechicken/microblock/HolloMicroblock.scala index b11cef2..a8eb527 100644 --- a/codechicken/microblock/HolloMicroblock.scala +++ b/codechicken/microblock/HolloMicroblock.scala @@ -37,6 +37,8 @@ object HollowMicroClass extends MicroblockClass var pBoxes:Array[Seq[Cuboid6]] = new Array(256) var occBounds:Array[Cuboid6] = new Array(256) for(s <- 0 until 6) + { + val transform = Rotation.sideRotations(s).at(Vector3.center) for(t <- 1 until 8) { val d = t/8D @@ -47,10 +49,11 @@ object HollowMicroClass extends MicroblockClass new SelectionBox(new Cuboid6(1-w1, 0, 0, 1, d, 1)), new SelectionBox(new Cuboid6(w1, 0, 0, 1-w1, d, w1)), new SelectionBox(new Cuboid6(w1, 0, 1-w1, 1-w1, d, 1))) - .map(_.transform(Rotation.sideRotations(s), Vector3.center).bound) + .map(_.transform(transform).bound) occBounds(t<<4|s) = new SelectionBox(new Cuboid6(1/8D, 0, 1/8D, 7/8D, d, 7/8D)) - .transform(Rotation.sideRotations(s), Vector3.center).bound + .transform(transform).bound } + } def getName = "mcr_hllw" diff --git a/codechicken/microblock/ItemMicroPart.scala b/codechicken/microblock/ItemMicroPart.scala index f6e5ae6..ee87707 100644 --- a/codechicken/microblock/ItemMicroPart.scala +++ b/codechicken/microblock/ItemMicroPart.scala @@ -142,10 +142,11 @@ object ItemMicroPartRenderer extends IItemRenderer def renderItem(t:ItemRenderType, item:ItemStack, data:Object*) { + GL11.glPushMatrix() if(t == ItemRenderType.ENTITY) - GL11.glScaled(0.5, 0.5, 0.5); + GL11.glScaled(0.5, 0.5, 0.5) if(t == ItemRenderType.INVENTORY || t == ItemRenderType.ENTITY) - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F) val material = getMaterial(item) val mcrClass = MicroblockClassRegistry.getMicroClass(item.getItemDamage) @@ -162,6 +163,7 @@ object ItemMicroPartRenderer extends IItemRenderer val part = mcrClass.create(size, mcrClass.itemSlot, 0, true).asInstanceOf[MicroblockClient] part.render(new Vector3(0.5, 0.5, 0.5).subtract(part.getBounds.center), null, material, part.getBounds, 0) CCRenderState.draw() + GL11.glPopMatrix() } def renderHighlight(world:World, player:EntityPlayer, stack:ItemStack, hit:MovingObjectPosition):Boolean = diff --git a/codechicken/microblock/PlacementGrids.scala b/codechicken/microblock/PlacementGrids.scala index ace3ff4..4bf656b 100644 --- a/codechicken/microblock/PlacementGrids.scala +++ b/codechicken/microblock/PlacementGrids.scala @@ -16,7 +16,7 @@ trait PlacementGrid val pos = new BlockCoord(hit) GL11.glPushMatrix() GL11.glTranslated(pos.x+0.5, pos.y+0.5, pos.z+0.5) - Rotation.sideRotationsG(side).glRotate() + Rotation.sideRotations(side).glApply() val rhit = new Vector3(pos.x+0.5, pos.y+0.5, pos.z+0.5).subtract(hit).rotate(Rotation.sideQuatsR(side^1)) GL11.glTranslated(0, rhit.y-0.002, 0) } diff --git a/codechicken/multipart/IRedstonePart.scala b/codechicken/multipart/IRedstonePart.scala index 427b8bc..8a8a512 100644 --- a/codechicken/multipart/IRedstonePart.scala +++ b/codechicken/multipart/IRedstonePart.scala @@ -6,6 +6,7 @@ import net.minecraft.block.BlockRedstoneWire import net.minecraft.world.IBlockAccess import net.minecraft.util.Direction import PartMap._ +import codechicken.core.vec.Rotation._ trait IRedstonePart { diff --git a/codechicken/multipart/PartMap.java b/codechicken/multipart/PartMap.java index 52ddeb0..06f49e0 100644 --- a/codechicken/multipart/PartMap.java +++ b/codechicken/multipart/PartMap.java @@ -101,35 +101,4 @@ public enum PartMap throw new IllegalArgumentException("Faces "+s1+" and "+s2+" are opposites"); return 15+edgeBetweenMap[s1*6+s2]; } - - private static int[] sideRotMap = new int[]{ - 3,5,2,4, - 3,4,2,5, - 1,5,0,4, - 1,4,0,5, - 1,2,0,3, - 1,3,0,2}; - - public static int rotateSide(int s, int r) - { - return sideRotMap[s<<2|r]; - } - - private static int[] rotSideMap = new int[]{ - -1,-1, 2, 0, 3, 1, - -1,-1, 2, 0, 1, 3, - 2, 0,-1,-1, 3, 1, - 2, 0,-1,-1, 1, 3, - 2, 0, 1, 3,-1,-1, - 2, 0, 3, 1,-1,-1}; - - /** - * Reverse of rotateSide - */ - public static int rotationTo(int s1, int s2) - { - if((s1&6) == (s2&6)) - throw new IllegalArgumentException("Faces "+s1+" and "+s2+" are opposites"); - return rotSideMap[s1*6+s2]; - } } diff --git a/codechicken/multipart/minecraft/McMetaPart.java b/codechicken/multipart/minecraft/McMetaPart.java index de26741..cff2b46 100644 --- a/codechicken/multipart/minecraft/McMetaPart.java +++ b/codechicken/multipart/minecraft/McMetaPart.java @@ -79,6 +79,7 @@ public abstract class McMetaPart extends McBlockPart implements IPartMeta @Override public void renderStatic(Vector3 pos, LazyLightMatrix olm, int pass) { - new RenderBlocks(new PartMetaAccess(this)).renderBlockByRenderType(getBlock(), x(), y(), z()); + if(pass == 0) + new RenderBlocks(new PartMetaAccess(this)).renderBlockByRenderType(getBlock(), x(), y(), z()); } }