Rotational neighbor culling for staircase cases.

This commit is contained in:
Joshua Sigona 2021-11-12 16:03:48 +09:00
parent 928052fbd0
commit ef9d56cdca
4 changed files with 200 additions and 44 deletions

View File

@ -4,6 +4,8 @@ import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import sig.models.Staircase;
public class Block { public class Block {
final static int CLOCKWISE = 1; final static int CLOCKWISE = 1;
final static int COUNTER_CLOCKWISE = -1; final static int COUNTER_CLOCKWISE = -1;
@ -53,6 +55,22 @@ public class Block {
} }
facingDir=facingDir.clockwise(); facingDir=facingDir.clockwise();
} }
if (!(block instanceof Cube)) {
updateFaces();
for (int x=-1;x<=1;x++) {
for (int y=-1;y<=1;y++) {
for (int z=-1;z<=1;z++) {
if (Math.abs(x)+Math.abs(y)+Math.abs(z)==1) {
String key = (pos.x+x)+"_"+(pos.y+y)+"_"+(pos.z+z);
if (SigRenderer.blockGrid.containsKey(key)) {
Block b = SigRenderer.blockGrid.get(key);
b.updateFaces();
}
}
}
}
}
}
} }
public void setFacingDirection(FacingDirection direction) { public void setFacingDirection(FacingDirection direction) {
updateFacingDirection(direction); updateFacingDirection(direction);
@ -67,25 +85,82 @@ public class Block {
updateFacingDirection(facingDir.counterClockwise()); updateFacingDirection(facingDir.counterClockwise());
} }
public void updateFaces() { public void updateFaces() {
if (SigRenderer.blockGrid.containsKey(pos.x+"_"+(pos.y+1)+"_"+pos.z)) { String key = pos.x+"_"+(pos.y+1)+"_"+pos.z;
neighbors.UP=SigRenderer.blockGrid.get(pos.x+"_"+(pos.y+1)+"_"+pos.z).neighbors.DOWN=block.triangles.get(Texture.TOP).tex.hasTransparency==SigRenderer.blockGrid.get(pos.x+"_"+(pos.y+1)+"_"+pos.z).block.triangles.get(Texture.BOTTOM).tex.hasTransparency&&block.triangles.get(Texture.TOP).tex.hasTranslucency==SigRenderer.blockGrid.get(pos.x+"_"+(pos.y+1)+"_"+pos.z).block.triangles.get(Texture.BOTTOM).tex.hasTranslucency; Block b = SigRenderer.blockGrid.get(key);
if (SigRenderer.blockGrid.containsKey(key)) {
if (b.block instanceof Staircase && block instanceof Staircase) {
neighbors.UP=true;
b.neighbors.DOWN=false;
} else {
neighbors.UP=b.neighbors.DOWN=block.triangles.get(Texture.TOP).tex.hasTransparency==b.block.triangles.get(Texture.BOTTOM).tex.hasTransparency&&block.triangles.get(Texture.TOP).tex.hasTranslucency==b.block.triangles.get(Texture.BOTTOM).tex.hasTranslucency;
} }
if (SigRenderer.blockGrid.containsKey(pos.x+"_"+(pos.y-1)+"_"+pos.z)) {
neighbors.DOWN=SigRenderer.blockGrid.get(pos.x+"_"+(pos.y-1)+"_"+pos.z).neighbors.UP=block.triangles.get(Texture.BOTTOM).tex.hasTransparency==SigRenderer.blockGrid.get(pos.x+"_"+(pos.y-1)+"_"+pos.z).block.triangles.get(Texture.TOP).tex.hasTransparency&&block.triangles.get(Texture.BOTTOM).tex.hasTranslucency==SigRenderer.blockGrid.get(pos.x+"_"+(pos.y-1)+"_"+pos.z).block.triangles.get(Texture.TOP).tex.hasTranslucency;
} }
if (SigRenderer.blockGrid.containsKey((pos.x-1)+"_"+(pos.y)+"_"+pos.z)) { key = pos.x+"_"+(pos.y-1)+"_"+pos.z;
neighbors.LEFT=SigRenderer.blockGrid.get((pos.x-1)+"_"+(pos.y)+"_"+pos.z).neighbors.RIGHT=block.triangles.get(Texture.WEST).tex.hasTransparency==SigRenderer.blockGrid.get((pos.x-1)+"_"+(pos.y)+"_"+pos.z).block.triangles.get(Texture.EAST).tex.hasTransparency&&block.triangles.get(Texture.WEST).tex.hasTranslucency==SigRenderer.blockGrid.get((pos.x-1)+"_"+(pos.y)+"_"+pos.z).block.triangles.get(Texture.EAST).tex.hasTranslucency; b = SigRenderer.blockGrid.get(key);
if (SigRenderer.blockGrid.containsKey(key)) {
if (b.block instanceof Staircase && block instanceof Staircase) {
neighbors.DOWN=false;
b.neighbors.UP=true;
} else
if (b.block instanceof Staircase && block instanceof Cube) {
b.neighbors.UP=block.triangles.get(Texture.BOTTOM).tex.hasTransparency==b.block.triangles.get(Texture.TOP).tex.hasTransparency&&block.triangles.get(Texture.BOTTOM).tex.hasTranslucency==b.block.triangles.get(Texture.TOP).tex.hasTranslucency;
} else {
neighbors.DOWN=b.neighbors.UP=block.triangles.get(Texture.BOTTOM).tex.hasTransparency==b.block.triangles.get(Texture.TOP).tex.hasTransparency&&block.triangles.get(Texture.BOTTOM).tex.hasTranslucency==b.block.triangles.get(Texture.TOP).tex.hasTranslucency;
} }
if (SigRenderer.blockGrid.containsKey((pos.x+1)+"_"+(pos.y)+"_"+pos.z)) {
neighbors.RIGHT=SigRenderer.blockGrid.get((pos.x+1)+"_"+(pos.y)+"_"+pos.z).neighbors.LEFT=block.triangles.get(Texture.EAST).tex.hasTransparency==SigRenderer.blockGrid.get((pos.x+1)+"_"+(pos.y)+"_"+pos.z).block.triangles.get(Texture.WEST).tex.hasTransparency&&block.triangles.get(Texture.EAST).tex.hasTranslucency==SigRenderer.blockGrid.get((pos.x+1)+"_"+(pos.y)+"_"+pos.z).block.triangles.get(Texture.WEST).tex.hasTranslucency;
} }
if (SigRenderer.blockGrid.containsKey(pos.x+"_"+(pos.y)+"_"+(pos.z+1))) { key=(pos.x-1)+"_"+(pos.y)+"_"+pos.z;
neighbors.FORWARD=SigRenderer.blockGrid.get(pos.x+"_"+(pos.y)+"_"+(pos.z+1)).neighbors.BACKWARD=block.triangles.get(Texture.SOUTH).tex.hasTransparency==SigRenderer.blockGrid.get(pos.x+"_"+(pos.y)+"_"+(pos.z+1)).block.triangles.get(Texture.NORTH).tex.hasTransparency&&block.triangles.get(Texture.SOUTH).tex.hasTranslucency==SigRenderer.blockGrid.get(pos.x+"_"+(pos.y)+"_"+(pos.z+1)).block.triangles.get(Texture.NORTH).tex.hasTranslucency; b = SigRenderer.blockGrid.get(key);
if (SigRenderer.blockGrid.containsKey(key)) {
if (b.block instanceof Staircase && block instanceof Staircase &&
b.getFacingDirection()!=getFacingDirection()) {
neighbors.LEFT=b.neighbors.RIGHT=false;
} else
if (b.block instanceof Staircase && block instanceof Cube) {
b.neighbors.RIGHT=block.triangles.get(Texture.WEST).tex.hasTransparency==b.block.triangles.get(Texture.EAST).tex.hasTransparency&&block.triangles.get(Texture.WEST).tex.hasTranslucency==b.block.triangles.get(Texture.EAST).tex.hasTranslucency;
} else {
neighbors.LEFT=b.neighbors.RIGHT=block.triangles.get(Texture.WEST).tex.hasTransparency==b.block.triangles.get(Texture.EAST).tex.hasTransparency&&block.triangles.get(Texture.WEST).tex.hasTranslucency==b.block.triangles.get(Texture.EAST).tex.hasTranslucency;
} }
if (SigRenderer.blockGrid.containsKey(pos.x+"_"+(pos.y)+"_"+(pos.z-1))) { }
key=(pos.x+1)+"_"+(pos.y)+"_"+pos.z;
b = SigRenderer.blockGrid.get(key);
if (SigRenderer.blockGrid.containsKey(key)) {
if (b.block instanceof Staircase && block instanceof Staircase &&
b.getFacingDirection()!=getFacingDirection()) {
neighbors.RIGHT=b.neighbors.LEFT=false;
} else
if (b.block instanceof Staircase && block instanceof Cube) {
b.neighbors.LEFT=block.triangles.get(Texture.EAST).tex.hasTransparency==b.block.triangles.get(Texture.WEST).tex.hasTransparency&&block.triangles.get(Texture.EAST).tex.hasTranslucency==b.block.triangles.get(Texture.WEST).tex.hasTranslucency;
} else {
neighbors.RIGHT=b.neighbors.LEFT=block.triangles.get(Texture.EAST).tex.hasTransparency==b.block.triangles.get(Texture.WEST).tex.hasTransparency&&block.triangles.get(Texture.EAST).tex.hasTranslucency==b.block.triangles.get(Texture.WEST).tex.hasTranslucency;
}
}
key=pos.x+"_"+(pos.y)+"_"+(pos.z+1);
b = SigRenderer.blockGrid.get(key);
if (SigRenderer.blockGrid.containsKey(key)) {
if (b.block instanceof Staircase && block instanceof Staircase &&
!b.getFacingDirection().isOpposite(getFacingDirection())) {
neighbors.FORWARD=b.neighbors.BACKWARD=false;
} else
if (b.block instanceof Staircase && block instanceof Cube) {
b.neighbors.BACKWARD=block.triangles.get(Texture.SOUTH).tex.hasTransparency==b.block.triangles.get(Texture.NORTH).tex.hasTransparency&&block.triangles.get(Texture.SOUTH).tex.hasTranslucency==b.block.triangles.get(Texture.NORTH).tex.hasTranslucency;
} else {
neighbors.FORWARD=b.neighbors.BACKWARD=block.triangles.get(Texture.SOUTH).tex.hasTransparency==b.block.triangles.get(Texture.NORTH).tex.hasTransparency&&block.triangles.get(Texture.SOUTH).tex.hasTranslucency==b.block.triangles.get(Texture.NORTH).tex.hasTranslucency;
}
}
key=pos.x+"_"+(pos.y)+"_"+(pos.z-1);
b = SigRenderer.blockGrid.get(key);
if (SigRenderer.blockGrid.containsKey(key)) {
if (b.block instanceof Staircase && block instanceof Staircase &&
!b.getFacingDirection().isOpposite(getFacingDirection())) {
neighbors.BACKWARD=b.neighbors.FORWARD=false;
} else
if (b.block instanceof Staircase && block instanceof Cube) {
SigRenderer.blockGrid.get(pos.x+"_"+(pos.y)+"_"+(pos.z-1)).neighbors.FORWARD=block.triangles.get(Texture.NORTH).tex.hasTransparency==SigRenderer.blockGrid.get(pos.x+"_"+(pos.y)+"_"+(pos.z-1)).block.triangles.get(Texture.SOUTH).tex.hasTransparency&&block.triangles.get(Texture.NORTH).tex.hasTranslucency==SigRenderer.blockGrid.get(pos.x+"_"+(pos.y)+"_"+(pos.z-1)).block.triangles.get(Texture.SOUTH).tex.hasTranslucency;
} else {
neighbors.BACKWARD=SigRenderer.blockGrid.get(pos.x+"_"+(pos.y)+"_"+(pos.z-1)).neighbors.FORWARD=block.triangles.get(Texture.NORTH).tex.hasTransparency==SigRenderer.blockGrid.get(pos.x+"_"+(pos.y)+"_"+(pos.z-1)).block.triangles.get(Texture.SOUTH).tex.hasTransparency&&block.triangles.get(Texture.NORTH).tex.hasTranslucency==SigRenderer.blockGrid.get(pos.x+"_"+(pos.y)+"_"+(pos.z-1)).block.triangles.get(Texture.SOUTH).tex.hasTranslucency; neighbors.BACKWARD=SigRenderer.blockGrid.get(pos.x+"_"+(pos.y)+"_"+(pos.z-1)).neighbors.FORWARD=block.triangles.get(Texture.NORTH).tex.hasTransparency==SigRenderer.blockGrid.get(pos.x+"_"+(pos.y)+"_"+(pos.z-1)).block.triangles.get(Texture.SOUTH).tex.hasTransparency&&block.triangles.get(Texture.NORTH).tex.hasTranslucency==SigRenderer.blockGrid.get(pos.x+"_"+(pos.y)+"_"+(pos.z-1)).block.triangles.get(Texture.SOUTH).tex.hasTranslucency;
} }
} }
}
@Override @Override
public String toString() { public String toString() {
return "Block [pos=" + pos + ", neighbors=" + neighbors + "]"; return "Block [pos=" + pos + ", neighbors=" + neighbors + "]";

View File

@ -13,4 +13,7 @@ public enum FacingDirection {
FacingDirection counterClockwise() { FacingDirection counterClockwise() {
return orderList[Math.floorMod((this.ordinal()-1),orderList.length)]; return orderList[Math.floorMod((this.ordinal()-1),orderList.length)];
} }
boolean isOpposite(FacingDirection dir) {
return this.ordinal()!=dir.ordinal()&&this.ordinal()%2==dir.ordinal()%2;
}
} }

View File

@ -31,7 +31,7 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene
public static boolean WIREFRAME = false; public static boolean WIREFRAME = false;
public static boolean PROFILING = false; public static boolean PROFILING = false;
public static boolean FLYING_MODE = false; public static boolean FLYING_MODE = true;
public static int SCREEN_WIDTH=1280; public static int SCREEN_WIDTH=1280;
public static int SCREEN_HEIGHT=720; public static int SCREEN_HEIGHT=720;
public final static long TIMEPERTICK = 16666667l; public final static long TIMEPERTICK = 16666667l;
@ -194,10 +194,7 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene
if (b4!=null && b4.block instanceof Staircase) {found=true;} if (b4!=null && b4.block instanceof Staircase) {found=true;}
} }
if (!found) { if (!found) {
System.out.println("Not Found");
SigRenderer.currentStaircase=null; SigRenderer.currentStaircase=null;
} else {
System.out.println("Found");
} }
} }
if (checkCollisionSquare(0,fallSpd-gravity,0)&&SigRenderer.currentStaircase==null) { if (checkCollisionSquare(0,fallSpd-gravity,0)&&SigRenderer.currentStaircase==null) {
@ -284,24 +281,41 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene
} }
if (answer!=null) { if (answer!=null) {
if (answer.e.getButton()==MouseEvent.BUTTON1) { if (answer.e.getButton()==MouseEvent.BUTTON1) {
switch (answer.t.dir) { int dirVal=0;
if (answer.t.b.block instanceof Cube) {
dirVal=answer.t.dir;
} else {
int[] directions = new int[]{BlockType.FRONT,BlockType.RIGHT,BlockType.BACK,BlockType.LEFT};
dirVal=answer.t.dir;
if (dirVal!=BlockType.TOP&&dirVal!=BlockType.BOTTOM) {
int index=-1;
for (int i=0;i<directions.length;i++) {
if (dirVal==directions[i]) {
index=i;
break;
}
}
dirVal=directions[(index+answer.t.b.getFacingDirection().ordinal())%4];
}
}
switch (dirVal) {
case BlockType.FRONT:{ case BlockType.FRONT:{
addBlock(Vector.add(answer.t.b.pos,new Vector(0,0,-1)),Cube.class,BlockType.PLANKS,FacingDirection.SOUTH); addBlock(Vector.add(answer.t.b.pos,new Vector(0,0,-1)),Staircase.class,BlockType.PLANKS,FacingDirection.SOUTH);
}break; }break;
case BlockType.BACK:{ case BlockType.BACK:{
addBlock(Vector.add(answer.t.b.pos,new Vector(0,0,1)),Cube.class,BlockType.PLANKS,FacingDirection.SOUTH); addBlock(Vector.add(answer.t.b.pos,new Vector(0,0,1)),Staircase.class,BlockType.PLANKS,FacingDirection.SOUTH);
}break; }break;
case BlockType.LEFT:{ case BlockType.LEFT:{
addBlock(Vector.add(answer.t.b.pos,new Vector(-1,0,0)),Cube.class,BlockType.PLANKS,FacingDirection.SOUTH); addBlock(Vector.add(answer.t.b.pos,new Vector(-1,0,0)),Staircase.class,BlockType.PLANKS,FacingDirection.SOUTH);
}break; }break;
case BlockType.RIGHT:{ case BlockType.RIGHT:{
addBlock(Vector.add(answer.t.b.pos,new Vector(1,0,0)),Cube.class,BlockType.PLANKS,FacingDirection.SOUTH); addBlock(Vector.add(answer.t.b.pos,new Vector(1,0,0)),Staircase.class,BlockType.PLANKS,FacingDirection.SOUTH);
}break; }break;
case BlockType.TOP:{ case BlockType.TOP:{
addBlock(Vector.add(answer.t.b.pos,new Vector(0,1,0)),Cube.class,BlockType.PLANKS,FacingDirection.SOUTH); addBlock(Vector.add(answer.t.b.pos,new Vector(0,1,0)),Staircase.class,BlockType.PLANKS,FacingDirection.SOUTH);
}break; }break;
case BlockType.BOTTOM:{ case BlockType.BOTTOM:{
addBlock(Vector.add(answer.t.b.pos,new Vector(0,-1,0)),Cube.class,BlockType.PLANKS,FacingDirection.SOUTH); addBlock(Vector.add(answer.t.b.pos,new Vector(0,-1,0)),Staircase.class,BlockType.PLANKS,FacingDirection.SOUTH);
}break; }break;
} }
} else } else
@ -383,10 +397,10 @@ public class SigRenderer implements KeyListener,MouseListener,MouseMotionListene
} }
} }
addBlock(new Vector(31,1,31),Staircase.class,BlockType.PLANKS,FacingDirection.NORTH); addBlock(new Vector(31,1,31),Staircase.class,BlockType.PLANKS,FacingDirection.NORTH);
addBlock(new Vector(31,2,32),Staircase.class,BlockType.PLANKS,FacingDirection.EAST); /*addBlock(new Vector(31,2,32),Staircase.class,BlockType.PLANKS,FacingDirection.EAST);
addBlock(new Vector(31,3,33),Staircase.class,BlockType.PLANKS,FacingDirection.WEST); addBlock(new Vector(31,3,33),Staircase.class,BlockType.PLANKS,FacingDirection.WEST);
addBlock(new Vector(31,4,34),Staircase.class,BlockType.PLANKS,FacingDirection.SOUTH); addBlock(new Vector(31,4,34),Staircase.class,BlockType.PLANKS,FacingDirection.SOUTH);
addBlock(new Vector(31,5,35),Staircase.class,BlockType.PLANKS,FacingDirection.SOUTH); addBlock(new Vector(31,5,35),Staircase.class,BlockType.PLANKS,FacingDirection.SOUTH);*/
for (int x=0;x<64;x++) { for (int x=0;x<64;x++) {
for (int y=1;y<5;y++) { for (int y=1;y<5;y++) {

View File

@ -1,10 +1,12 @@
package sig.models; package sig.models;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
import sig.Block; import sig.Block;
import sig.BlockType; import sig.BlockType;
import sig.FacingDirection;
import sig.Mesh; import sig.Mesh;
import sig.SigRenderer; import sig.SigRenderer;
import sig.Triangle; import sig.Triangle;
@ -18,38 +20,57 @@ public class Staircase extends Mesh{
for (Triangle t : triangles) { for (Triangle t : triangles) {
t.tex=type.getTexture(BlockType.FRONT); t.tex=type.getTexture(BlockType.FRONT);
} }
triangles.get(0).dir=BlockType.FRONT;
triangles.get(1).dir=BlockType.FRONT;
triangles.get(2).dir=BlockType.TOP;
triangles.get(3).dir=BlockType.TOP;
triangles.get(4).dir=BlockType.TOP;
triangles.get(5).dir=BlockType.TOP;
triangles.get(6).dir=BlockType.FRONT;
triangles.get(7).dir=BlockType.FRONT;
triangles.get(8).dir=BlockType.BACK;
triangles.get(9).dir=BlockType.BACK;
triangles.get(10).dir=BlockType.BOTTOM;
triangles.get(11).dir=BlockType.BOTTOM;
triangles.get(12).dir=BlockType.LEFT;
triangles.get(13).dir=BlockType.LEFT;
triangles.get(14).dir=BlockType.LEFT;
triangles.get(15).dir=BlockType.LEFT;
triangles.get(16).dir=BlockType.RIGHT;
triangles.get(17).dir=BlockType.RIGHT;
triangles.get(18).dir=BlockType.RIGHT;
triangles.get(19).dir=BlockType.RIGHT;
} }
protected List<Triangle> prepareRender(Block b) { protected List<Triangle> prepareRender(Block b) {
List<Triangle> tris = new ArrayList<Triangle>(); List<Triangle> tris = new ArrayList<Triangle>();
Triangle[][] renderTriangles = new Triangle[][]{
{b.block.triangles.get(0),b.block.triangles.get(1)},
{b.block.triangles.get(12),b.block.triangles.get(13),b.block.triangles.get(14),b.block.triangles.get(15)},
{b.block.triangles.get(8),b.block.triangles.get(9)},
{b.block.triangles.get(16),b.block.triangles.get(17),b.block.triangles.get(18),b.block.triangles.get(19)},
};
if (!b.neighbors.UP) { if (!b.neighbors.UP) {
}
if (!b.neighbors.DOWN) {
}
if (!b.neighbors.LEFT) {
tris.add(b.block.triangles.get(12));
tris.add(b.block.triangles.get(13));
tris.add(b.block.triangles.get(14));
tris.add(b.block.triangles.get(15));
}
if (!b.neighbors.RIGHT) {
tris.add(b.block.triangles.get(16));
tris.add(b.block.triangles.get(17));
tris.add(b.block.triangles.get(18));
tris.add(b.block.triangles.get(19));
}
if (!b.neighbors.FORWARD) {
}
if (!b.neighbors.BACKWARD) {
tris.add(b.block.triangles.get(0));
tris.add(b.block.triangles.get(1));
}
tris.add(b.block.triangles.get(4)); tris.add(b.block.triangles.get(4));
tris.add(b.block.triangles.get(5)); tris.add(b.block.triangles.get(5));
}
if (!b.neighbors.DOWN) {
tris.add(b.block.triangles.get(10)); tris.add(b.block.triangles.get(10));
tris.add(b.block.triangles.get(11)); tris.add(b.block.triangles.get(11));
tris.add(b.block.triangles.get(8)); }
tris.add(b.block.triangles.get(9)); if (!b.neighbors.LEFT) {
tris.addAll(Arrays.asList(renderTriangles[(b.getFacingDirection().ordinal()+FacingDirection.WEST.ordinal())%4]));
}
if (!b.neighbors.RIGHT) {
tris.addAll(Arrays.asList(renderTriangles[(b.getFacingDirection().ordinal()+FacingDirection.EAST.ordinal())%4]));
}
if (!b.neighbors.FORWARD) {
tris.addAll(Arrays.asList(renderTriangles[(b.getFacingDirection().ordinal()+FacingDirection.NORTH.ordinal())%4]));
}
if (!b.neighbors.BACKWARD) {
tris.addAll(Arrays.asList(renderTriangles[(b.getFacingDirection().ordinal()+FacingDirection.SOUTH.ordinal())%4]));
}
tris.add(b.block.triangles.get(2)); tris.add(b.block.triangles.get(2));
tris.add(b.block.triangles.get(3)); tris.add(b.block.triangles.get(3));
tris.add(b.block.triangles.get(6)); tris.add(b.block.triangles.get(6));
@ -58,15 +79,58 @@ public class Staircase extends Mesh{
} }
public boolean handleCollision(Block b) { public boolean handleCollision(Block b) {
if (SigRenderer.currentStaircase!=null) { if (SigRenderer.currentStaircase!=null) {
float diffX=SigRenderer.vCamera.x-b.pos.x;
float diffZ=SigRenderer.vCamera.z-b.pos.z; float diffZ=SigRenderer.vCamera.z-b.pos.z;
switch (b.getFacingDirection()) {
case EAST: {
SigRenderer.vCamera.y=b.pos.y+diffX+0.7f;
}break;
case NORTH: {
SigRenderer.vCamera.y=b.pos.y+(1-diffZ)+0.7f;
}break;
case SOUTH: {
SigRenderer.vCamera.y=b.pos.y+diffZ+0.7f; SigRenderer.vCamera.y=b.pos.y+diffZ+0.7f;
}break;
case WEST: {
SigRenderer.vCamera.y=b.pos.y+(1-diffX)+0.7f;
}break;
}
SigRenderer.fallSpd=0; SigRenderer.fallSpd=0;
return true; return true;
} }
if (SigRenderer.vCamera.y>=b.pos.y) { if (SigRenderer.vCamera.y>=b.pos.y) {
boolean valid=false;
if (SigRenderer.vCamera.y>=b.pos.y+1f) {
valid=true;
} else {
switch (b.getFacingDirection()) {
case EAST: {
if (SigRenderer.vCamera.x<b.pos.x+0.5f) {
valid=true;
}
}break;
case NORTH: {
if (SigRenderer.vCamera.z>b.pos.z+0.5f) {
valid=true;
}
}break;
case SOUTH: {
if (SigRenderer.vCamera.z<b.pos.z+0.5f) {
valid=true;
}
}break;
case WEST: {
if (SigRenderer.vCamera.x>b.pos.x+0.5f) {
valid=true;
}
}break;
}
}
if (valid) {
SigRenderer.currentStaircase=this; SigRenderer.currentStaircase=this;
return true; return true;
} }
}
return false; return false;
} }
} }