Search in sources :

Example 16 with RailMonoMagnetBase

use of club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase in project NyaSamaRailway by NSDN.

the class NSC3BM method onUpdate.

@Override
public void onUpdate() {
    int x = MathHelper.floor_double(this.posX);
    int y = MathHelper.floor_double(this.posY);
    int z = MathHelper.floor_double(this.posZ);
    if (worldObj.getBlock(x, y, z) instanceof RailMonoMagnetBase) {
        RailMonoMagnetBase rail = (RailMonoMagnetBase) worldObj.getBlock(x, y, z);
        int meta = worldObj.getBlockMetadata(x, y, z);
        if (rail.isPowered())
            meta &= 0x7;
        if (meta >= 2 && meta <= 5) {
            if (shiftY < -0.5)
                shiftY += 0.05;
        } else if (shiftY > -1.0)
            shiftY -= 0.05;
    } else {
        boolean state;
        state = worldObj.getBlock(x + 1, y, z) instanceof RailMonoMagnetBase;
        state |= worldObj.getBlock(x - 1, y, z) instanceof RailMonoMagnetBase;
        state |= worldObj.getBlock(x, y, z + 1) instanceof RailMonoMagnetBase;
        state |= worldObj.getBlock(x, y, z - 1) instanceof RailMonoMagnetBase;
        if (!state && shiftY < 0)
            shiftY += 0.05;
    }
    super.onUpdate();
}
Also used : RailMonoMagnetBase(club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase)

Example 17 with RailMonoMagnetBase

use of club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase in project NyaSamaRailway by NSDN.

the class ItemNSC3BM method onItemUse.

@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float px, float py, float pz) {
    if (BlockRailBase.func_150051_a(world.getBlock(x, y, z)) && world.getBlock(x, y, z) instanceof RailMonoMagnetBase) {
        if (!world.isRemote) {
            LocoBase entityminecart = new NSC3BM(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
            if (itemStack.hasDisplayName()) {
                entityminecart.setMinecartName(itemStack.getDisplayName());
            }
            world.spawnEntityInWorld(entityminecart);
        }
        --itemStack.stackSize;
        return true;
    } else {
        return false;
    }
}
Also used : RailMonoMagnetBase(club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase) LocoBase(club.nsdn.nyasamarailway.entity.LocoBase) NSC3BM(club.nsdn.nyasamarailway.entity.nsc.NSC3BM)

Example 18 with RailMonoMagnetBase

use of club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase in project NyaSamaRailway by NSDN.

the class ItemNSC3B method onItemUse.

@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float px, float py, float pz) {
    if (BlockRailBase.func_150051_a(world.getBlock(x, y, z)) && world.getBlock(x, y, z) instanceof RailMonoMagnetBase) {
        if (!world.isRemote) {
            MinecartBase entityminecart = new NSC3B(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
            if (itemStack.hasDisplayName()) {
                entityminecart.setMinecartName(itemStack.getDisplayName());
            }
            world.spawnEntityInWorld(entityminecart);
        }
        --itemStack.stackSize;
        return true;
    } else {
        return false;
    }
}
Also used : MinecartBase(club.nsdn.nyasamarailway.entity.MinecartBase) RailMonoMagnetBase(club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase) NSC3B(club.nsdn.nyasamarailway.entity.nsc.NSC3B)

Example 19 with RailMonoMagnetBase

use of club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase in project NyaSamaRailway by NSDN.

the class ItemNSC1B method onItemUse.

@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float px, float py, float pz) {
    if (BlockRailBase.func_150051_a(world.getBlock(x, y, z)) && world.getBlock(x, y, z) instanceof RailMonoMagnetBase) {
        if (!world.isRemote) {
            MinecartBase entityminecart = new NSC1B(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
            if (itemStack.hasDisplayName()) {
                entityminecart.setMinecartName(itemStack.getDisplayName());
            }
            world.spawnEntityInWorld(entityminecart);
        }
        --itemStack.stackSize;
        return true;
    } else {
        return false;
    }
}
Also used : MinecartBase(club.nsdn.nyasamarailway.entity.MinecartBase) RailMonoMagnetBase(club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase) NSC1B(club.nsdn.nyasamarailway.entity.nsc.NSC1B)

Example 20 with RailMonoMagnetBase

use of club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase in project NyaSamaRailway by NSDN.

the class ItemNSPCT4 method onItemUse.

@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World world, int x, int y, int z, int side, float px, float py, float pz) {
    if (BlockRailBase.func_150051_a(world.getBlock(x, y, z)) && world.getBlock(x, y, z) instanceof RailMonoMagnetBase) {
        if (!world.isRemote) {
            MinecartBase entityminecart = new NSPCT4(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
            if (itemStack.hasDisplayName()) {
                entityminecart.setMinecartName(itemStack.getDisplayName());
            }
            world.spawnEntityInWorld(entityminecart);
        }
        --itemStack.stackSize;
        return true;
    } else {
        return false;
    }
}
Also used : MinecartBase(club.nsdn.nyasamarailway.entity.MinecartBase) RailMonoMagnetBase(club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase) NSPCT4(club.nsdn.nyasamarailway.entity.cart.NSPCT4)

Aggregations

RailMonoMagnetBase (club.nsdn.nyasamarailway.tileblock.rail.mono.RailMonoMagnetBase)20 BlockWire (club.nsdn.nyasamaelectricity.tileblock.wire.BlockWire)4 LocoBase (club.nsdn.nyasamarailway.entity.LocoBase)4 MinecartBase (club.nsdn.nyasamarailway.entity.MinecartBase)4 ConvWireMono (club.nsdn.nyasamarailway.tileblock.rail.ConvWireMono)4 Block (net.minecraft.block.Block)4 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4 NSPCT4 (club.nsdn.nyasamarailway.entity.cart.NSPCT4)1 NSPCT4M (club.nsdn.nyasamarailway.entity.loco.NSPCT4M)1 NSC1B (club.nsdn.nyasamarailway.entity.nsc.NSC1B)1 NSC1BM (club.nsdn.nyasamarailway.entity.nsc.NSC1BM)1 NSC2B (club.nsdn.nyasamarailway.entity.nsc.NSC2B)1 NSC2BM (club.nsdn.nyasamarailway.entity.nsc.NSC2BM)1 NSC3B (club.nsdn.nyasamarailway.entity.nsc.NSC3B)1 NSC3BM (club.nsdn.nyasamarailway.entity.nsc.NSC3BM)1