// System.out.println("Yaw = " + MathHelper.floor_double(rotationYaw));
int x;
int y = MathHelper.floor_double(posY);
int z;
EnumTrackMeta dir = EnumTrackMeta.NORTH_SOUTH;
if (getFacing() == ForgeDirection.WEST || getFacing() == ForgeDirection.EAST)
dir = EnumTrackMeta.EAST_WEST;
if (getDelay() == 0) {
float offset = 1.5f;
x = MathHelper.floor_double(getXAhead(posX, offset));
z = MathHelper.floor_double(getZAhead(posZ, offset));
if (placeBallast) {
boolean placed = placeBallast(x, y - 1, z);
if (placed)
setDelay(STANDARD_DELAY);
else {
setDelay(FAIL_DELAY);
setActive(false);
}
placeBallast = false;
} else if (!worldObj.isSideSolid(x, y - 1, z, ForgeDirection.UP)) {
placeBallast = true;
setDelay(BALLAST_DELAY);
}
}
if (getDelay() == 0) {
float offset = 0.8f;
x = MathHelper.floor_double(getXAhead(posX, offset));
z = MathHelper.floor_double(getZAhead(posZ, offset));
if (placeRail) {
boolean placed = placeTrack(x, y, z, dir);
if (placed)
setDelay(STANDARD_DELAY);
else {
setDelay(FAIL_DELAY);
setActive(false);
}
placeRail = false;
} else if (TrackTools.isRailBlockAt(worldObj, x, y, z)) {
if (!dir.isEqual(TrackTools.getTrackMeta(worldObj, this, x, y, z))) {
worldObj.setBlockMetadataWithNotify(x, y, z, dir.ordinal(), 3);
setDelay(STANDARD_DELAY);
}
} else if (worldObj.isAirBlock(x, y, z) || replaceableBlocks.contains(worldObj.getBlock(x, y, z))) {
placeRail = true;
setDelay(STANDARD_DELAY);