use of net.minecraft.block.BlockRailBase in project Railcraft by Railcraft.
the class RenderCart method getPos.
public Vec3d getPos(EntityMinecart cart, double p_70489_1_, double p_70489_3_, double p_70489_5_) {
int i = MathHelper.floor_double(p_70489_1_);
int j = MathHelper.floor_double(p_70489_3_);
int k = MathHelper.floor_double(p_70489_5_);
if (BlockRailBase.isRailBlock(cart.worldObj, new BlockPos(i, j - 1, k))) {
--j;
}
IBlockState iblockstate = cart.worldObj.getBlockState(new BlockPos(i, j, k));
if (BlockRailBase.isRailBlock(iblockstate)) {
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = ((BlockRailBase) iblockstate.getBlock()).getRailDirection(cart.worldObj, new BlockPos(i, j, k), iblockstate, cart);
int[][] aint = MATRIX[blockrailbase$enumraildirection.getMetadata()];
double d0 = (double) i + 0.5D + (double) aint[0][0] * 0.5D;
double d1 = (double) j + 0.0625D + (double) aint[0][1] * 0.5D;
double d2 = (double) k + 0.5D + (double) aint[0][2] * 0.5D;
double d3 = (double) i + 0.5D + (double) aint[1][0] * 0.5D;
double d4 = (double) j + 0.0625D + (double) aint[1][1] * 0.5D;
double d5 = (double) k + 0.5D + (double) aint[1][2] * 0.5D;
double d6 = d3 - d0;
double d7 = (d4 - d1) * 2.0D;
double d8 = d5 - d2;
double d9;
if (d6 == 0.0D) {
d9 = p_70489_5_ - (double) k;
} else if (d8 == 0.0D) {
d9 = p_70489_1_ - (double) i;
} else {
double d10 = p_70489_1_ - d0;
double d11 = p_70489_5_ - d2;
d9 = (d10 * d6 + d11 * d8) * 2.0D;
}
p_70489_1_ = d0 + d6 * d9;
p_70489_3_ = d1 + d7 * d9;
p_70489_5_ = d2 + d8 * d9;
if (d7 < 0.0D) {
++p_70489_3_;
}
if (d7 > 0.0D) {
p_70489_3_ += 0.5D;
}
return new Vec3d(p_70489_1_, p_70489_3_, p_70489_5_);
} else {
return null;
}
}
use of net.minecraft.block.BlockRailBase in project NyaSamaRailway by NSDN.
the class NSPCT6C method updateRiderPosition.
@Override
public void updateRiderPosition() {
if (this.riddenByEntity != null) {
double x = this.posX, y = this.posY, z = this.posZ;
int bx = MathHelper.floor_double(x);
int by = MathHelper.floor_double(y);
int bz = MathHelper.floor_double(z);
Block block = worldObj.getBlock(bx, by, bz);
int meta = worldObj.getBlockMetadata(bx, by, bz);
double len = -1.0 + getShiftYCnt();
Vec3 mod = Vec3.createVectorHelper(0, len, 0);
mod.rotateAroundX(this.rotationPitch);
mod.rotateAroundY(this.rotationYaw);
x += mod.xCoord;
y += mod.yCoord;
z += mod.zCoord;
this.riddenByEntity.setPositionAndRotation(x, y + this.getMountedYOffset(), z, this.rotationYaw, 0.0F);
if (this.riddenByEntity instanceof Container && worldObj.isRemote) {
Container container = (Container) this.riddenByEntity;
container.setPositionAndRotation2(x, y + this.getMountedYOffset(), z, this.rotationYaw, 0.0F, -2);
boolean fix = true;
if (block instanceof BlockRailBase) {
fix = ((BlockRailBase) block).isPowered() || meta < 6 || meta > 9;
}
if ((((int) container.rotationYaw) % 90) != 0 && fix) {
container.prevRotationYaw = container.rotationYaw = (float) (MathHelper.floor_double((double) (this.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) * 90.0F;
}
}
}
}
use of net.minecraft.block.BlockRailBase in project NyaSamaRailway by NSDN.
the class LocoBase method func_70489_a.
@Override
public Vec3 func_70489_a(double doubleX, double doubleY, double doubleZ) {
int x = MathHelper.floor_double(doubleX);
int y = MathHelper.floor_double(doubleY);
int z = MathHelper.floor_double(doubleZ);
if (!BlockRailBase.func_150049_b_(this.worldObj, x, y, z) && BlockRailBase.func_150049_b_(this.worldObj, x, y - 1, z)) {
--y;
}
Block block = this.worldObj.getBlock(x, y, z);
if (BlockRailBase.func_150051_a(block)) {
int l = ((BlockRailBase) block).getBasicRailMetadata(worldObj, this, x, y, z);
doubleY = (double) y;
if (l >= 2 && l <= 5) {
doubleY = (double) (y + 1);
}
int[][] aint = matrix[l];
double d3 = 0.0D;
double d4 = (double) x + 0.5D + (double) aint[0][0] * 0.5D;
double d5 = (double) y + 0.5D + (double) aint[0][1] * 0.5D;
double d6 = (double) z + 0.5D + (double) aint[0][2] * 0.5D;
double d7 = (double) x + 0.5D + (double) aint[1][0] * 0.5D;
double d8 = (double) y + 0.5D + (double) aint[1][1] * 0.5D;
double d9 = (double) z + 0.5D + (double) aint[1][2] * 0.5D;
double d10 = d7 - d4;
double d11 = (d8 - d5) * 2.0D;
double d12 = d9 - d6;
if (d10 == 0.0D) {
doubleX = (double) x + 0.5D;
d3 = doubleZ - (double) z;
} else if (d12 == 0.0D) {
doubleZ = (double) z + 0.5D;
d3 = doubleX - (double) x;
} else {
double d13 = doubleX - d4;
double d14 = doubleZ - d6;
d3 = (d13 * d10 + d14 * d12) * 2.0D;
}
doubleX = d4 + d10 * d3;
doubleY = d5 + d11 * d3;
doubleZ = d6 + d12 * d3;
if (d11 < 0.0D) {
++doubleY;
}
if (d11 > 0.0D) {
doubleY += 0.5D;
}
return Vec3.createVectorHelper(doubleX, doubleY, doubleZ);
} else {
return null;
}
}
use of net.minecraft.block.BlockRailBase in project NyaSamaRailway by NSDN.
the class MinecartBase method func_70495_a.
@Override
@SideOnly(Side.CLIENT)
public Vec3 func_70495_a(double doubleX, double doubleY, double doubleZ, double v) {
int x = MathHelper.floor_double(doubleX);
int y = MathHelper.floor_double(doubleY);
int z = MathHelper.floor_double(doubleZ);
if (!BlockRailBase.func_150049_b_(this.worldObj, x, y, z) && BlockRailBase.func_150049_b_(this.worldObj, x, y - 1, z)) {
--y;
}
Block block = this.worldObj.getBlock(x, y, z);
if (!BlockRailBase.func_150051_a(block)) {
return null;
} else {
int l = ((BlockRailBase) block).getBasicRailMetadata(worldObj, this, x, y, z);
doubleY = (double) y;
if (l >= 2 && l <= 5) {
doubleY = (double) (y + 1);
}
int[][] aint = matrix[l];
double d4 = (double) (aint[1][0] - aint[0][0]);
double d5 = (double) (aint[1][2] - aint[0][2]);
double d6 = Math.sqrt(d4 * d4 + d5 * d5);
d4 /= d6;
d5 /= d6;
doubleX += d4 * v;
doubleZ += d5 * v;
if (aint[0][1] != 0 && MathHelper.floor_double(doubleX) - x == aint[0][0] && MathHelper.floor_double(doubleZ) - z == aint[0][2]) {
doubleY += (double) aint[0][1];
} else if (aint[1][1] != 0 && MathHelper.floor_double(doubleX) - x == aint[1][0] && MathHelper.floor_double(doubleZ) - z == aint[1][2]) {
doubleY += (double) aint[1][1];
}
return this.func_70489_a(doubleX, doubleY, doubleZ);
}
}
use of net.minecraft.block.BlockRailBase in project NyaSamaRailway by NSDN.
the class NSPCT6W method updateRiderPosition.
@Override
public void updateRiderPosition() {
if (this.riddenByEntity != null) {
double x = this.posX, y = this.posY, z = this.posZ;
int bx = MathHelper.floor_double(x);
int by = MathHelper.floor_double(y);
int bz = MathHelper.floor_double(z);
Block block = worldObj.getBlock(bx, by, bz);
int meta = worldObj.getBlockMetadata(bx, by, bz);
double len = -1.0 + getShiftYCnt();
Vec3 mod = Vec3.createVectorHelper(0, len, 0);
mod.rotateAroundX(this.rotationPitch);
mod.rotateAroundY(this.rotationYaw);
x += mod.xCoord;
y += mod.yCoord;
z += mod.zCoord;
this.riddenByEntity.setPositionAndRotation(x, y + this.getMountedYOffset(), z, this.rotationYaw, 0.0F);
if (this.riddenByEntity instanceof Container && worldObj.isRemote) {
Container container = (Container) this.riddenByEntity;
container.setPositionAndRotation2(x, y + this.getMountedYOffset(), z, this.rotationYaw, 0.0F, -2);
boolean fix = true;
if (block instanceof BlockRailBase) {
fix = ((BlockRailBase) block).isPowered() || meta < 6 || meta > 9;
}
if ((((int) container.rotationYaw) % 90) != 0 && fix) {
container.prevRotationYaw = container.rotationYaw = (float) (MathHelper.floor_double((double) (this.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3) * 90.0F;
}
}
}
}
Aggregations