Search in sources :

Example 1 with BlockWire

use of club.nsdn.nyasamaelectricity.tileblock.wire.BlockWire in project NyaSamaRailway by NSDN.

the class NSPCT6W method onUpdate.

@Override
public void onUpdate() {
    if (!worldObj.isRemote) {
        int px = MathHelper.floor_double(this.prevPosX);
        int py = MathHelper.floor_double(this.prevPosY);
        int pz = MathHelper.floor_double(this.prevPosZ);
        Block pBlock = worldObj.getBlock(px, py, pz);
        int x = MathHelper.floor_double(this.posX);
        int y = MathHelper.floor_double(this.posY);
        int z = MathHelper.floor_double(this.posZ);
        Block block = worldObj.getBlock(x, y, z);
        ForgeDirection dir = ForgeDirection.UNKNOWN;
        if (worldObj.getTileEntity(x, y, z) instanceof ConvWireMono.Conv) {
            dir = ((ConvWireMono.Conv) worldObj.getTileEntity(x, y, z)).direction;
        }
        ForgeDirection toDir = ForgeDirection.UNKNOWN;
        int yaw = MathHelper.floor_double((double) (this.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
        switch(yaw) {
            case 0:
                toDir = ForgeDirection.SOUTH;
                break;
            case 1:
                toDir = ForgeDirection.WEST;
                break;
            case 2:
                toDir = ForgeDirection.NORTH;
                break;
            case 3:
                toDir = ForgeDirection.EAST;
                break;
        }
        if (block instanceof ConvWireMono && pBlock != block) {
            switch(dir) {
                case // drop to North
                SOUTH:
                    if (toDir == ForgeDirection.NORTH)
                        shiftY = MONO;
                    else if (toDir == ForgeDirection.SOUTH)
                        shiftY = WIRE;
                    break;
                case // drop to East
                WEST:
                    if (toDir == ForgeDirection.EAST)
                        shiftY = MONO;
                    else if (toDir == ForgeDirection.WEST)
                        shiftY = WIRE;
                    break;
                case // drop to South
                NORTH:
                    if (toDir == ForgeDirection.NORTH)
                        shiftY = WIRE;
                    else if (toDir == ForgeDirection.SOUTH)
                        shiftY = MONO;
                    break;
                case // drop to West
                EAST:
                    if (toDir == ForgeDirection.EAST)
                        shiftY = WIRE;
                    else if (toDir == ForgeDirection.WEST)
                        shiftY = MONO;
                    break;
            }
        } else if (block instanceof RailMonoMagnetBase) {
            shiftY = MONO;
        } else if (block instanceof BlockWire) {
            shiftY = WIRE;
        }
        double v = Math.sqrt(motionX * motionX + motionZ * motionZ);
        if (v > 1.0)
            shiftYCnt = shiftY;
        else if (!(block instanceof ConvWireMono) && v == 0)
            shiftYCnt = shiftY;
        else {
            if (shiftYCnt + v < shiftY)
                shiftYCnt += v;
            else if (shiftYCnt - v > shiftY)
                shiftYCnt -= v;
            else
                shiftYCnt = shiftY;
        }
        setShiftYCnt(shiftYCnt);
        setShiftY(shiftY);
    }
    super.onUpdate();
}
Also used : BlockWire(club.nsdn.nyasamaelectricity.tileblock.wire.BlockWire) RailMonoMagnetBase(club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Block(net.minecraft.block.Block) ConvWireMono(club.nsdn.nyasamarailway.tileblock.rail.ConvWireMono)

Example 2 with BlockWire

use of club.nsdn.nyasamaelectricity.tileblock.wire.BlockWire in project NyaSamaRailway by NSDN.

the class NSPCT8W method onUpdate.

@Override
public void onUpdate() {
    if (!worldObj.isRemote) {
        int px = MathHelper.floor_double(this.prevPosX);
        int py = MathHelper.floor_double(this.prevPosY);
        int pz = MathHelper.floor_double(this.prevPosZ);
        Block pBlock = worldObj.getBlock(px, py, pz);
        int x = MathHelper.floor_double(this.posX);
        int y = MathHelper.floor_double(this.posY);
        int z = MathHelper.floor_double(this.posZ);
        Block block = worldObj.getBlock(x, y, z);
        ForgeDirection dir = ForgeDirection.UNKNOWN;
        if (worldObj.getTileEntity(x, y, z) instanceof ConvWireMono.Conv) {
            dir = ((ConvWireMono.Conv) worldObj.getTileEntity(x, y, z)).direction;
        }
        ForgeDirection toDir = ForgeDirection.UNKNOWN;
        int yaw = MathHelper.floor_double((double) (this.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
        switch(yaw) {
            case 0:
                toDir = ForgeDirection.SOUTH;
                break;
            case 1:
                toDir = ForgeDirection.WEST;
                break;
            case 2:
                toDir = ForgeDirection.NORTH;
                break;
            case 3:
                toDir = ForgeDirection.EAST;
                break;
        }
        if (block instanceof ConvWireMono && pBlock != block) {
            switch(dir) {
                case // drop to North
                SOUTH:
                    if (toDir == ForgeDirection.NORTH)
                        shiftY = MONO;
                    else if (toDir == ForgeDirection.SOUTH)
                        shiftY = WIRE;
                    break;
                case // drop to East
                WEST:
                    if (toDir == ForgeDirection.EAST)
                        shiftY = MONO;
                    else if (toDir == ForgeDirection.WEST)
                        shiftY = WIRE;
                    break;
                case // drop to South
                NORTH:
                    if (toDir == ForgeDirection.NORTH)
                        shiftY = WIRE;
                    else if (toDir == ForgeDirection.SOUTH)
                        shiftY = MONO;
                    break;
                case // drop to West
                EAST:
                    if (toDir == ForgeDirection.EAST)
                        shiftY = WIRE;
                    else if (toDir == ForgeDirection.WEST)
                        shiftY = MONO;
                    break;
            }
        } else if (block instanceof RailMonoMagnetBase) {
            shiftY = MONO;
        } else if (block instanceof BlockWire) {
            shiftY = WIRE;
        }
        double v = Math.sqrt(motionX * motionX + motionZ * motionZ);
        if (v > 1.0)
            shiftYCnt = shiftY;
        else if (!(block instanceof ConvWireMono) && v == 0)
            shiftYCnt = shiftY;
        else {
            if (shiftYCnt + v < shiftY)
                shiftYCnt += v;
            else if (shiftYCnt - v > shiftY)
                shiftYCnt -= v;
            else
                shiftYCnt = shiftY;
        }
        setShiftYCnt(shiftYCnt);
        setShiftY(shiftY);
    }
    super.onUpdate();
}
Also used : BlockWire(club.nsdn.nyasamaelectricity.tileblock.wire.BlockWire) RailMonoMagnetBase(club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Block(net.minecraft.block.Block) ConvWireMono(club.nsdn.nyasamarailway.tileblock.rail.ConvWireMono)

Example 3 with BlockWire

use of club.nsdn.nyasamaelectricity.tileblock.wire.BlockWire in project NyaSamaRailway by NSDN.

the class NSPCT6C method onUpdate.

@Override
public void onUpdate() {
    if (!worldObj.isRemote) {
        int px = MathHelper.floor_double(this.prevPosX);
        int py = MathHelper.floor_double(this.prevPosY);
        int pz = MathHelper.floor_double(this.prevPosZ);
        Block pBlock = worldObj.getBlock(px, py, pz);
        int x = MathHelper.floor_double(this.posX);
        int y = MathHelper.floor_double(this.posY);
        int z = MathHelper.floor_double(this.posZ);
        Block block = worldObj.getBlock(x, y, z);
        ForgeDirection dir = ForgeDirection.UNKNOWN;
        if (worldObj.getTileEntity(x, y, z) instanceof ConvWireMono.Conv) {
            dir = ((ConvWireMono.Conv) worldObj.getTileEntity(x, y, z)).direction;
        }
        ForgeDirection toDir = ForgeDirection.UNKNOWN;
        int yaw = MathHelper.floor_double((double) (this.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
        switch(yaw) {
            case 0:
                toDir = ForgeDirection.SOUTH;
                break;
            case 1:
                toDir = ForgeDirection.WEST;
                break;
            case 2:
                toDir = ForgeDirection.NORTH;
                break;
            case 3:
                toDir = ForgeDirection.EAST;
                break;
        }
        if (block instanceof ConvWireMono && pBlock != block) {
            switch(dir) {
                case // drop to North
                SOUTH:
                    if (toDir == ForgeDirection.NORTH)
                        shiftY = MONO;
                    else if (toDir == ForgeDirection.SOUTH)
                        shiftY = WIRE;
                    break;
                case // drop to East
                WEST:
                    if (toDir == ForgeDirection.EAST)
                        shiftY = MONO;
                    else if (toDir == ForgeDirection.WEST)
                        shiftY = WIRE;
                    break;
                case // drop to South
                NORTH:
                    if (toDir == ForgeDirection.NORTH)
                        shiftY = WIRE;
                    else if (toDir == ForgeDirection.SOUTH)
                        shiftY = MONO;
                    break;
                case // drop to West
                EAST:
                    if (toDir == ForgeDirection.EAST)
                        shiftY = WIRE;
                    else if (toDir == ForgeDirection.WEST)
                        shiftY = MONO;
                    break;
            }
        } else if (block instanceof RailMonoMagnetBase) {
            shiftY = MONO;
        } else if (block instanceof BlockWire) {
            shiftY = WIRE;
        }
        double v = Math.sqrt(motionX * motionX + motionZ * motionZ);
        if (v > 1.0)
            shiftYCnt = shiftY;
        else if (!(block instanceof ConvWireMono) && v == 0)
            shiftYCnt = shiftY;
        else {
            if (shiftYCnt + v < shiftY)
                shiftYCnt += v;
            else if (shiftYCnt - v > shiftY)
                shiftYCnt -= v;
            else
                shiftYCnt = shiftY;
        }
        setShiftYCnt(shiftYCnt);
        setShiftY(shiftY);
    }
    super.onUpdate();
}
Also used : BlockWire(club.nsdn.nyasamaelectricity.tileblock.wire.BlockWire) RailMonoMagnetBase(club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Block(net.minecraft.block.Block) ConvWireMono(club.nsdn.nyasamarailway.tileblock.rail.ConvWireMono)

Example 4 with BlockWire

use of club.nsdn.nyasamaelectricity.tileblock.wire.BlockWire in project NyaSamaRailway by NSDN.

the class NSPCT8C method onUpdate.

@Override
public void onUpdate() {
    if (!worldObj.isRemote) {
        int px = MathHelper.floor_double(this.prevPosX);
        int py = MathHelper.floor_double(this.prevPosY);
        int pz = MathHelper.floor_double(this.prevPosZ);
        Block pBlock = worldObj.getBlock(px, py, pz);
        int x = MathHelper.floor_double(this.posX);
        int y = MathHelper.floor_double(this.posY);
        int z = MathHelper.floor_double(this.posZ);
        Block block = worldObj.getBlock(x, y, z);
        ForgeDirection dir = ForgeDirection.UNKNOWN;
        if (worldObj.getTileEntity(x, y, z) instanceof ConvWireMono.Conv) {
            dir = ((ConvWireMono.Conv) worldObj.getTileEntity(x, y, z)).direction;
        }
        ForgeDirection toDir = ForgeDirection.UNKNOWN;
        int yaw = MathHelper.floor_double((double) (this.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
        switch(yaw) {
            case 0:
                toDir = ForgeDirection.SOUTH;
                break;
            case 1:
                toDir = ForgeDirection.WEST;
                break;
            case 2:
                toDir = ForgeDirection.NORTH;
                break;
            case 3:
                toDir = ForgeDirection.EAST;
                break;
        }
        if (block instanceof ConvWireMono && pBlock != block) {
            switch(dir) {
                case // drop to North
                SOUTH:
                    if (toDir == ForgeDirection.NORTH)
                        shiftY = MONO;
                    else if (toDir == ForgeDirection.SOUTH)
                        shiftY = WIRE;
                    break;
                case // drop to East
                WEST:
                    if (toDir == ForgeDirection.EAST)
                        shiftY = MONO;
                    else if (toDir == ForgeDirection.WEST)
                        shiftY = WIRE;
                    break;
                case // drop to South
                NORTH:
                    if (toDir == ForgeDirection.NORTH)
                        shiftY = WIRE;
                    else if (toDir == ForgeDirection.SOUTH)
                        shiftY = MONO;
                    break;
                case // drop to West
                EAST:
                    if (toDir == ForgeDirection.EAST)
                        shiftY = WIRE;
                    else if (toDir == ForgeDirection.WEST)
                        shiftY = MONO;
                    break;
            }
        } else if (block instanceof RailMonoMagnetBase) {
            shiftY = MONO;
        } else if (block instanceof BlockWire) {
            shiftY = WIRE;
        }
        double v = Math.sqrt(motionX * motionX + motionZ * motionZ);
        if (v > 1.0)
            shiftYCnt = shiftY;
        else if (!(block instanceof ConvWireMono) && v == 0)
            shiftYCnt = shiftY;
        else {
            if (shiftYCnt + v < shiftY)
                shiftYCnt += v;
            else if (shiftYCnt - v > shiftY)
                shiftYCnt -= v;
            else
                shiftYCnt = shiftY;
        }
        setShiftYCnt(shiftYCnt);
        setShiftY(shiftY);
    }
    super.onUpdate();
}
Also used : BlockWire(club.nsdn.nyasamaelectricity.tileblock.wire.BlockWire) RailMonoMagnetBase(club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Block(net.minecraft.block.Block) ConvWireMono(club.nsdn.nyasamarailway.tileblock.rail.ConvWireMono)

Aggregations

BlockWire (club.nsdn.nyasamaelectricity.tileblock.wire.BlockWire)4 ConvWireMono (club.nsdn.nyasamarailway.tileblock.rail.ConvWireMono)4 RailMonoMagnetBase (club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase)4 Block (net.minecraft.block.Block)4 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4