Search in sources :

Example 1 with TileEntityRailReception

use of club.nsdn.nyasamarailway.tileblock.signal.TileEntityRailReception in project NyaSamaRailway by NSDN.

the class RailMonoMagnetReception method onRailPowered.

@Override
public void onRailPowered(World world, int x, int y, int z, int meta, boolean hasCart) {
    boolean playerDetectable = false;
    if (!checkNearbySameRail(world, x, y, z))
        playerDetectable = true;
    EntityMinecart cart = getMinecart(world, x, y, z);
    TileEntityRailReception rail = null;
    if (world.getTileEntity(x, y, z) instanceof TileEntityRailReception) {
        rail = (TileEntityRailReception) world.getTileEntity(x, y, z);
    }
    TileEntityRailReception.powered(!isForward(), cart, rail, playerDetectable);
}
Also used : TileEntityRailReception(club.nsdn.nyasamarailway.tileblock.signal.TileEntityRailReception) EntityMinecart(net.minecraft.entity.item.EntityMinecart)

Example 2 with TileEntityRailReception

use of club.nsdn.nyasamarailway.tileblock.signal.TileEntityRailReception in project NyaSamaRailway by NSDN.

the class RailMonoMagnetReceptionAnti method updateTick.

@Override
public void updateTick(World world, int x, int y, int z, Random random) {
    if (!world.isRemote) {
        float bBoxSize = 0.125F;
        List bBox = world.getEntitiesWithinAABB(EntityMinecart.class, AxisAlignedBB.getBoundingBox((double) ((float) x + bBoxSize), (double) y, (double) ((float) z + bBoxSize), (double) ((float) (x + 1) - bBoxSize), (double) ((float) (y + 1) - bBoxSize), (double) ((float) (z + 1) - bBoxSize)));
        TileEntityRailReception rail = null;
        if (world.getTileEntity(x, y, z) instanceof TileEntityRailReception) {
            rail = (TileEntityRailReception) world.getTileEntity(x, y, z);
        }
        boolean playerDetectable = false;
        if (!checkNearbySameRail(world, x, y, z))
            playerDetectable = true;
        if (rail != null) {
            TileEntityRailReception.tick(!isForward(), bBox, rail, playerDetectable);
        }
        world.scheduleBlockUpdate(x, y, z, this, 1);
    }
    super.updateTick(world, x, y, z, random);
}
Also used : TileEntityRailReception(club.nsdn.nyasamarailway.tileblock.signal.TileEntityRailReception) List(java.util.List)

Example 3 with TileEntityRailReception

use of club.nsdn.nyasamarailway.tileblock.signal.TileEntityRailReception in project NyaSamaRailway by NSDN.

the class RailMonoMagnetReceptionAnti method onRailPowered.

@Override
public void onRailPowered(World world, int x, int y, int z, int meta, boolean hasCart) {
    boolean playerDetectable = false;
    if (!checkNearbySameRail(world, x, y, z))
        playerDetectable = true;
    EntityMinecart cart = getMinecart(world, x, y, z);
    TileEntityRailReception rail = null;
    if (world.getTileEntity(x, y, z) instanceof TileEntityRailReception) {
        rail = (TileEntityRailReception) world.getTileEntity(x, y, z);
    }
    TileEntityRailReception.powered(!isForward(), cart, rail, playerDetectable);
}
Also used : TileEntityRailReception(club.nsdn.nyasamarailway.tileblock.signal.TileEntityRailReception) EntityMinecart(net.minecraft.entity.item.EntityMinecart)

Example 4 with TileEntityRailReception

use of club.nsdn.nyasamarailway.tileblock.signal.TileEntityRailReception in project NyaSamaRailway by NSDN.

the class RailMonoMagnetReception method updateTick.

@Override
public void updateTick(World world, int x, int y, int z, Random random) {
    if (!world.isRemote) {
        float bBoxSize = 0.125F;
        List bBox = world.getEntitiesWithinAABB(EntityMinecart.class, AxisAlignedBB.getBoundingBox((double) ((float) x + bBoxSize), (double) y, (double) ((float) z + bBoxSize), (double) ((float) (x + 1) - bBoxSize), (double) ((float) (y + 1) - bBoxSize), (double) ((float) (z + 1) - bBoxSize)));
        TileEntityRailReception rail = null;
        if (world.getTileEntity(x, y, z) instanceof TileEntityRailReception) {
            rail = (TileEntityRailReception) world.getTileEntity(x, y, z);
        }
        boolean playerDetectable = false;
        if (!checkNearbySameRail(world, x, y, z))
            playerDetectable = true;
        if (rail != null) {
            TileEntityRailReception.tick(!isForward(), bBox, rail, playerDetectable);
        }
        world.scheduleBlockUpdate(x, y, z, this, 1);
    }
    super.updateTick(world, x, y, z, random);
}
Also used : TileEntityRailReception(club.nsdn.nyasamarailway.tileblock.signal.TileEntityRailReception) List(java.util.List)

Example 5 with TileEntityRailReception

use of club.nsdn.nyasamarailway.tileblock.signal.TileEntityRailReception in project NyaSamaRailway by NSDN.

the class RailMonoMagnetReception method onMinecartPass.

@Override
public void onMinecartPass(World world, EntityMinecart cart, int x, int y, int z) {
    boolean playerDetectable = false;
    EntityPlayer player = null;
    if (!checkNearbySameRail(world, x, y, z))
        playerDetectable = true;
    if (cart.riddenByEntity instanceof EntityPlayer) {
        player = (EntityPlayer) cart.riddenByEntity;
        ItemStack stack = ((EntityPlayer) cart.riddenByEntity).getCurrentEquippedItem();
        if (stack != null) {
            if (stack.getItem() instanceof ItemNTP8Bit || stack.getItem() instanceof ItemNTP32Bit) {
                return;
            }
        }
    } else if (cart.riddenByEntity instanceof EntityMinecart) {
        EntityMinecart ncart = (EntityMinecart) cart.riddenByEntity;
        if (ncart.riddenByEntity instanceof EntityPlayer) {
            player = (EntityPlayer) ncart.riddenByEntity;
            ItemStack stack = ((EntityPlayer) ncart.riddenByEntity).getCurrentEquippedItem();
            if (stack != null) {
                if (stack.getItem() instanceof ItemNTP8Bit || stack.getItem() instanceof ItemNTP32Bit) {
                    return;
                }
            }
        }
    }
    if (world.getTileEntity(x, y, z) instanceof TileEntityRailReception) {
        TileEntityRailReception rail = (TileEntityRailReception) world.getTileEntity(x, y, z);
        TileEntityRailReception.cart(!isForward(), cart, rail, player, playerDetectable);
    }
}
Also used : ItemNTP32Bit(club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit) ItemNTP8Bit(club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit) TileEntityRailReception(club.nsdn.nyasamarailway.tileblock.signal.TileEntityRailReception) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) EntityMinecart(net.minecraft.entity.item.EntityMinecart)

Aggregations

TileEntityRailReception (club.nsdn.nyasamarailway.tileblock.signal.TileEntityRailReception)10 EntityMinecart (net.minecraft.entity.item.EntityMinecart)6 ItemNTP32Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit)3 ItemNTP8Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit)3 List (java.util.List)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 ItemStack (net.minecraft.item.ItemStack)3 BlockRailReception (club.nsdn.nyasamarailway.block.rail.special.BlockRailReception)1 BlockRailReceptionAnti (club.nsdn.nyasamarailway.block.rail.special.BlockRailReceptionAnti)1 BlockCoinBlock (club.nsdn.nyasamarailway.tileblock.functional.BlockCoinBlock)1 BlockTicketBlockOnce (club.nsdn.nyasamarailway.tileblock.functional.BlockTicketBlockOnce)1 TileEntityTrackSideReception (club.nsdn.nyasamarailway.tileblock.signal.TileEntityTrackSideReception)1 BlockSignalBox (club.nsdn.nyasamarailway.tileblock.signal.core.BlockSignalBox)1 BlockTriStateSignalBox (club.nsdn.nyasamarailway.tileblock.signal.core.BlockTriStateSignalBox)1 BlockGateFront (club.nsdn.nyasamarailway.tileblock.signal.deco.BlockGateFront)1 TileEntityTransceiver (club.nsdn.nyasamatelecom.api.tileentity.TileEntityTransceiver)1 UUID (java.util.UUID)1 Block (net.minecraft.block.Block)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 TileEntity (net.minecraft.tileentity.TileEntity)1