Skip to content

Commit

Permalink
Hopefully fixed a couple of conveyors issues, closes #554 and closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Buuz135 committed Apr 16, 2019
1 parent 5c351a0 commit 9e53f53
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ public void render(TileEntityConveyor te, double x, double y, double z, float pa
double posY = 2 / 16f - 1 / 32f;
double right = 1 / 16f;
double left = 15 / 16f;
BlockConveyor.EnumSides sides = te.getWorld().getBlockState(te.getPos()).getBlock().getActualState(te.getWorld().getBlockState(te.getPos()), te.getWorld(), te.getPos()).getValue(BlockConveyor.SIDES);
BlockConveyor.EnumSides sides = BlockConveyor.EnumSides.NONE;
if (te.getWorld().getBlockState(te.getPos()).getBlock() instanceof BlockConveyor)
sides = te.getWorld().getBlockState(te.getPos()).getBlock().getActualState(te.getWorld().getBlockState(te.getPos()), te.getWorld(), te.getPos()).getValue(BlockConveyor.SIDES);
if (sides == BlockConveyor.EnumSides.BOTH || sides == BlockConveyor.EnumSides.RIGHT) right = 0;
if (sides == BlockConveyor.EnumSides.BOTH || sides == BlockConveyor.EnumSides.LEFT) left = 1;
Color color = new Color(fluid.getColor(te.getTank().getFluid()));
Expand Down
66 changes: 31 additions & 35 deletions src/main/java/com/buuz135/industrial/utils/MovementUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,46 +36,42 @@ public class MovementUtils {
public static void handleConveyorMovement(Entity entity, EnumFacing direction, BlockPos pos, BlockConveyor.EnumType type) {
if (entity instanceof EntityPlayer && entity.isSneaking()) return;
if (entity.posY - pos.getY() > 0.3 && !type.isVertical()) return;
try {
AxisAlignedBB collision = entity.world.getBlockState(pos).getBlock().getCollisionBoundingBox(entity.world.getBlockState(pos), entity.world, pos).offset(pos);
if (!type.isVertical() && !collision.grow(0.01).intersects(entity.getEntityBoundingBox())) return;

AxisAlignedBB collision = entity.world.getBlockState(pos).getBlock().getCollisionBoundingBox(entity.world.getBlockState(pos), entity.world, pos).offset(pos);
// if (direction == EnumFacing.NORTH || direction == EnumFacing.SOUTH){
// collision = collision.contract(-0.1,0,0);
// collision = collision.contract(0.1,0,0);
// }
// if (direction == EnumFacing.EAST || direction == EnumFacing.WEST) {
// collision = collision.contract(0,0,-0.1);
// collision = collision.contract(0,0,0.1);
// }
if (!type.isVertical() && !collision.grow(0.01).intersects(entity.getEntityBoundingBox())) return;

//DIRECTION MOVEMENT
double speed = 0.2;
if (type.isFast()) speed *= 2;
Vec3d vec3d = new Vec3d(speed * direction.getDirectionVec().getX(), speed * direction.getDirectionVec().getY(), speed * direction.getDirectionVec().getZ());
if (type.isVertical()) {
vec3d = vec3d.add(0, type.isUp() ? 0.258 : -0.05, 0);
entity.onGround = false;
}
//DIRECTION MOVEMENT
double speed = 0.2;
if (type.isFast()) speed *= 2;
Vec3d vec3d = new Vec3d(speed * direction.getDirectionVec().getX(), speed * direction.getDirectionVec().getY(), speed * direction.getDirectionVec().getZ());
if (type.isVertical()) {
vec3d = vec3d.add(0, type.isUp() ? 0.258 : -0.05, 0);
entity.onGround = false;
}

//CENTER
if (direction == EnumFacing.NORTH || direction == EnumFacing.SOUTH) {
if (entity.posX - pos.getX() < 0.45) {
vec3d = vec3d.add(0.08, 0, 0);
} else if (entity.posX - pos.getX() > 0.55) {
vec3d = vec3d.add(-0.08, 0, 0);
//CENTER
if (direction == EnumFacing.NORTH || direction == EnumFacing.SOUTH) {
if (entity.posX - pos.getX() < 0.45) {
vec3d = vec3d.add(0.08, 0, 0);
} else if (entity.posX - pos.getX() > 0.55) {
vec3d = vec3d.add(-0.08, 0, 0);
}
}
}
if (direction == EnumFacing.EAST || direction == EnumFacing.WEST) {
if (entity.posZ - pos.getZ() < 0.45) {
vec3d = vec3d.add(0, 0, 0.08);
} else if (entity.posZ - pos.getZ() > 0.55) {
vec3d = vec3d.add(0, 0, -0.08);
if (direction == EnumFacing.EAST || direction == EnumFacing.WEST) {
if (entity.posZ - pos.getZ() < 0.45) {
vec3d = vec3d.add(0, 0, 0.08);
} else if (entity.posZ - pos.getZ() > 0.55) {
vec3d = vec3d.add(0, 0, -0.08);
}
}
}

entity.motionX = vec3d.x;
if (vec3d.y != 0) entity.motionY = vec3d.y;
entity.motionZ = vec3d.z;
entity.motionX = vec3d.x;
if (vec3d.y != 0) entity.motionY = vec3d.y;
entity.motionZ = vec3d.z;
} catch (Exception e) {
System.out.println("Found error while trying to move " + entity.toString() + " at position " + pos.toString());
e.printStackTrace();
}
}

public static void handleConveyorMovement(Entity entity, EnumFacing direction, BlockPos pos, BlockConveyor.EnumType type, List<Entity> filter) {
Expand Down

0 comments on commit 9e53f53

Please sign in to comment.