diff --git a/src/main/java/cactusServer/models/CollisionManager.java b/src/main/java/cactusServer/models/CollisionManager.java index 2de5987..8634441 100644 --- a/src/main/java/cactusServer/models/CollisionManager.java +++ b/src/main/java/cactusServer/models/CollisionManager.java @@ -15,10 +15,11 @@ public class CollisionManager { private static CollisionManager theInstance; private HashMap instances; - private ArrayList resultList = new ArrayList(); + private ArrayList resultList; private CollisionManager() { instances = Instances.getInstance().getInstances(); + resultList = new ArrayList(); } public static CollisionManager getInstance() { @@ -27,7 +28,7 @@ } return theInstance; } - + @JSONHint(ignore = true) public ArrayList getResultList() { return resultList; @@ -55,7 +56,7 @@ CollisionResult result; result = PhysicsUtility.checkCollision(player.getObject(), null, object.getObject(), null); if (result != null) { - objMove(result,object); + objMove(result, object, false); } } @@ -66,16 +67,18 @@ Vector3d vec1 = object1.getVelocity().getVector3d(); Vector3d vec2 = object2.getVelocity().getVector3d(); if (vec1.length() > vec2.length()) { - objMove(result,object1); - }else { - objMove(result,object2); + objMove(result, object1, true); + } else { + objMove(result, object2, true); } } } - - private void objMove(CollisionResult result,Object object) { + + private void objMove(CollisionResult result, Object object, boolean negate) { result.normal.scale(-1); Vector3d vec = object.getPosition().getVector3d(); + if (negate) + result.normal.negate(); vec.add(result.normal); object.setPosition(new Position3D(vec)); }