Search in sources :

Example 56 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project NyaSamaRailway by NSDN.

the class NSPCT10J method modifyHighSpeedMode.

public void modifyHighSpeedMode(EntityPlayer player) {
    setHighSpeedMode(!getHighSpeedMode());
    player.addChatComponentMessage(new ChatComponentTranslation("info.nspc10j.mode", String.valueOf(getHighSpeedMode()).toUpperCase()));
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation)

Example 57 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project NyaSamaRailway by NSDN.

the class NSPCT10J method interactFirst.

@Override
public boolean interactFirst(EntityPlayer player) {
    if (MinecraftForge.EVENT_BUS.post(new MinecartInteractEvent(this, player))) {
        return true;
    } else if (this.riddenByEntity != null && this.riddenByEntity instanceof EntityPlayer && this.riddenByEntity != player) {
        return true;
    } else if (this.riddenByEntity != null && this.riddenByEntity != player) {
        return false;
    } else {
        if (player != null) {
            ItemStack stack = player.getCurrentEquippedItem();
            if (stack != null) {
                if (stack.getItem() instanceof Item1N4148 || stack.getItem() instanceof ItemNTP8Bit || stack.getItem() instanceof ItemNTP32Bit) {
                    return true;
                }
                if (stack.getItem() instanceof ItemMinecart)
                    return true;
            }
            if (!this.worldObj.isRemote) {
                player.mountEntity(this);
                player.addChatComponentMessage(new ChatComponentTranslation("info.nsr.x"));
            }
        }
        return true;
    }
}
Also used : ItemNTP32Bit(club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit) ItemNTP8Bit(club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit) Item1N4148(club.nsdn.nyasamarailway.item.tool.Item1N4148) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) ItemMinecart(net.minecraft.item.ItemMinecart) MinecartInteractEvent(net.minecraftforge.event.entity.minecart.MinecartInteractEvent) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack)

Example 58 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project NyaSamaRailway by NSDN.

the class Item1N4148 method onItemUseFirst.

@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) {
    Block block = world.getBlock(x, y, z);
    if (block == null)
        return false;
    if (player.isSneaking())
        if (world.getTileEntity(x, y, z) instanceof TileEntityTrackSideReception) {
            TileEntityTrackSideReception reception = (TileEntityTrackSideReception) world.getTileEntity(x, y, z);
            if (reception.cartType.isEmpty()) {
                reception.cartType = "loco";
                say(player, "info.reception.loco");
            } else {
                if (reception.cartType.equals("loco")) {
                    reception.cartType = "";
                    say(player, "info.reception.reset");
                } else {
                    reception.cartType = "";
                    reception.extInfo = "";
                    say(player, "info.reception.cleared");
                }
            }
            return !world.isRemote;
        }
    if (block instanceof IRailDirectional) {
        if (player.isSneaking()) {
            TileEntity rail = world.getTileEntity(x, y, z);
            if (rail == null)
                return false;
            if (rail instanceof TileEntityRailReception) {
                if (((TileEntityRailReception) rail).cartType.isEmpty()) {
                    ((TileEntityRailReception) rail).cartType = "loco";
                    say(player, "info.reception.loco");
                } else {
                    if (((TileEntityRailReception) rail).cartType.equals("loco")) {
                        ((TileEntityRailReception) rail).cartType = "";
                        say(player, "info.reception.reset");
                    } else {
                        ((TileEntityRailReception) rail).cartType = "";
                        ((TileEntityRailReception) rail).extInfo = "";
                        ;
                        say(player, "info.reception.cleared");
                    }
                }
                return !world.isRemote;
            }
        }
        if (((IRailDirectional) block).isForward()) {
            if (block instanceof BlockRailReception)
                world.setBlock(x, y, z, BlockLoader.blockRailReceptionAnti);
            if (block instanceof BlockRailProtectHead) {
                int meta = world.getBlockMetadata(x, y, z);
                world.setBlock(x, y, z, BlockLoader.blockRailProtectHeadAnti);
                world.setBlockMetadataWithNotify(x, y, z, meta, 1);
            }
            if ((block instanceof BlockRailDirectional))
                world.setBlock(x, y, z, BlockLoader.blockRailDirectionalAnti);
            if (block instanceof RailMonoMagnetReception)
                world.setBlock(x, y, z, BlockLoader.railMonoMagnetReceptionAnti);
            if ((block instanceof RailMonoMagnetDirectional))
                world.setBlock(x, y, z, BlockLoader.railMonoMagnetDirectionalAnti);
        } else {
            if (block instanceof BlockRailReceptionAnti)
                world.setBlock(x, y, z, BlockLoader.blockRailReception);
            if (block instanceof BlockRailProtectHeadAnti) {
                int meta = world.getBlockMetadata(x, y, z);
                world.setBlock(x, y, z, BlockLoader.blockRailProtectHead);
                world.setBlockMetadataWithNotify(x, y, z, meta, 1);
            }
            if ((block instanceof BlockRailDirectionalAnti))
                world.setBlock(x, y, z, BlockLoader.blockRailDirectional);
            if (block instanceof RailMonoMagnetReceptionAnti)
                world.setBlock(x, y, z, BlockLoader.railMonoMagnetReception);
            if ((block instanceof RailMonoMagnetDirectionalAnti))
                world.setBlock(x, y, z, BlockLoader.railMonoMagnetDirectional);
        }
        return !world.isRemote;
    } else if (block instanceof BlockRailDetectorBase && !(block instanceof IRailNoDelay)) {
        int nowDelay = ((BlockRailDetectorBase) block).getDelaySecond();
        if (block instanceof BlockRailStoneSleeperDetector) {
            switch(nowDelay) {
                case 0:
                    world.setBlock(x, y, z, BlockLoader.blockRailStoneSleeperDetector5s);
                    break;
                case 5:
                    world.setBlock(x, y, z, BlockLoader.blockRailStoneSleeperDetector15s);
                    break;
                case 15:
                    world.setBlock(x, y, z, BlockLoader.blockRailStoneSleeperDetector30s);
                    break;
                case 30:
                    world.setBlock(x, y, z, BlockLoader.blockRailStoneSleeperDetector);
                    break;
            }
        } else if (block instanceof BlockRailNoSleeperDetector) {
            switch(nowDelay) {
                case 0:
                    world.setBlock(x, y, z, BlockLoader.blockRailNoSleeperDetector5s);
                    break;
                case 5:
                    world.setBlock(x, y, z, BlockLoader.blockRailNoSleeperDetector15s);
                    break;
                case 15:
                    world.setBlock(x, y, z, BlockLoader.blockRailNoSleeperDetector30s);
                    break;
                case 30:
                    world.setBlock(x, y, z, BlockLoader.blockRailNoSleeperDetector);
                    break;
            }
        }
        nowDelay = ((BlockRailDetectorBase) world.getBlock(x, y, z)).getDelaySecond();
        say(player, "info.1N4148.delay", nowDelay);
        return !world.isRemote;
    } else if (block instanceof RailMonoMagnetDetector && !(block instanceof IRailNoDelay)) {
        int nowDelay = ((RailMonoMagnetDetector) block).getDelaySecond();
        switch(nowDelay) {
            case 0:
                world.setBlock(x, y, z, BlockLoader.railMonoMagnetDetector5s);
                break;
            case 5:
                world.setBlock(x, y, z, BlockLoader.railMonoMagnetDetector15s);
                break;
            case 15:
                world.setBlock(x, y, z, BlockLoader.railMonoMagnetDetector30s);
                break;
            case 30:
                world.setBlock(x, y, z, BlockLoader.railMonoMagnetDetector);
                break;
        }
        nowDelay = ((RailMonoMagnetDetector) world.getBlock(x, y, z)).getDelaySecond();
        say(player, "info.1N4148.delay", nowDelay);
        return !world.isRemote;
    }
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    if (tileEntity == null)
        return false;
    if (player.isSneaking()) {
        if (tileEntity instanceof BlockCoinBlock.CoinBlock) {
            BlockCoinBlock.CoinBlock coinBlock = (BlockCoinBlock.CoinBlock) tileEntity;
            if (coinBlock.value <= 0)
                coinBlock.value = 1;
            switch(coinBlock.value) {
                case 1:
                    coinBlock.value = 5;
                    break;
                case 5:
                    coinBlock.value = 10;
                    break;
                case 10:
                    coinBlock.value = 20;
                    break;
                case 20:
                    coinBlock.value = 50;
                    break;
                case 50:
                    coinBlock.value = 1;
                    break;
            }
            if (player instanceof EntityPlayerMP)
                player.addChatComponentMessage(new ChatComponentTranslation("info.coin.value", coinBlock.value));
        } else if (tileEntity instanceof BlockTicketBlockOnce.TicketBlock) {
            BlockTicketBlockOnce.TicketBlock ticketBlock = (BlockTicketBlockOnce.TicketBlock) tileEntity;
            switch(ticketBlock.setOver) {
                case 1:
                    ticketBlock.setOver = 5;
                    break;
                case 5:
                    ticketBlock.setOver = 10;
                    break;
                case 10:
                    ticketBlock.setOver = 20;
                    break;
                case 20:
                    ticketBlock.setOver = 50;
                    break;
                case 50:
                    ticketBlock.setOver = 1;
                    break;
            }
            if (player instanceof EntityPlayerMP)
                player.addChatComponentMessage(new ChatComponentTranslation("info.ticket.over", ticketBlock.setOver));
        } else if (tileEntity instanceof BlockGateFront.GateFront) {
            BlockGateFront.GateFront gateFront = (BlockGateFront.GateFront) tileEntity;
            switch(gateFront.setOver) {
                case 1:
                    gateFront.setOver = 5;
                    break;
                case 5:
                    gateFront.setOver = 10;
                    break;
                case 10:
                    gateFront.setOver = 20;
                    break;
                case 20:
                    gateFront.setOver = 50;
                    break;
                case 50:
                    gateFront.setOver = 1;
                    break;
            }
            if (player instanceof EntityPlayerMP)
                player.addChatComponentMessage(new ChatComponentTranslation("info.gate.over", gateFront.setOver));
        }
    }
    if (tileEntity instanceof TileEntityTransceiver) {
        TileEntityTransceiver thisRail = (TileEntityTransceiver) tileEntity;
        if (player.isSneaking() && !world.isRemote) {
            UUID uuid = player.getUniqueID();
            if (tmpRails.containsKey(uuid)) {
                if (tmpRails.get(uuid) == thisRail) {
                    thisRail.setTransceiver(null);
                    say(player, "info.blocking.abort");
                } else {
                    if (thisRail.getTransceiver() == tmpRails.get(uuid)) {
                        thisRail.getTransceiver().setTransceiver(null);
                        thisRail.setTransceiver(null);
                        say(player, "info.blocking.disconnected");
                    } else {
                        thisRail.setTransceiver(tmpRails.get(uuid));
                        thisRail.getTransceiver().setTransceiver(thisRail);
                        say(player, "info.blocking.connected");
                    }
                }
                tmpRails.remove(uuid);
            } else {
                tmpRails.put(uuid, thisRail);
                say(player, "info.blocking.begin");
            }
            return true;
        }
    } else if (tileEntity instanceof BlockTriStateSignalBox.TileEntityTriStateSignalBox) {
        BlockTriStateSignalBox.TileEntityTriStateSignalBox signalBox = (BlockTriStateSignalBox.TileEntityTriStateSignalBox) tileEntity;
        if (player.isSneaking()) {
            signalBox.prevInverterEnabled = signalBox.inverterEnabled;
            if (signalBox.inverterEnabled) {
                signalBox.inverterEnabled = false;
                say(player, "info.signal.box.inverter.off");
            } else {
                signalBox.inverterEnabled = true;
                say(player, "info.signal.box.inverter.on");
            }
        } else {
            signalBox.prevTriStateIsNeg = signalBox.triStateIsNeg;
            if (signalBox.triStateIsNeg) {
                signalBox.triStateIsNeg = false;
                say(player, "info.signal.box.triState.pos");
            } else {
                signalBox.triStateIsNeg = true;
                say(player, "info.signal.box.triState.neg");
            }
        }
        return !world.isRemote;
    } else if (tileEntity instanceof BlockSignalBox.TileEntitySignalBox) {
        BlockSignalBox.TileEntitySignalBox signalBox = (BlockSignalBox.TileEntitySignalBox) tileEntity;
        if (player.isSneaking()) {
            if (signalBox.inverterEnabled) {
                signalBox.inverterEnabled = false;
                say(player, "info.signal.box.inverter.off");
            } else {
                signalBox.inverterEnabled = true;
                say(player, "info.signal.box.inverter.on");
            }
        }
        return !world.isRemote;
    } else if (tileEntity instanceof club.nsdn.nyasamarailway.tileblock.signal.TileEntitySignalLight) {
        club.nsdn.nyasamarailway.tileblock.signal.TileEntitySignalLight signalLight = (club.nsdn.nyasamarailway.tileblock.signal.TileEntitySignalLight) tileEntity;
        if (player.isSneaking()) {
            signalLight.prevLightType = signalLight.lightType;
            switch(signalLight.lightType) {
                case "none":
                    signalLight.lightType = "red&off";
                    say(player, "info.signal.light.mode.red_off");
                    break;
                case "red&off":
                    signalLight.lightType = "yellow&off";
                    say(player, "info.signal.light.mode.yellow_off");
                    break;
                case "yellow&off":
                    signalLight.lightType = "green&off";
                    say(player, "info.signal.light.mode.green_off");
                    break;
                case "green&off":
                    signalLight.lightType = "white&off";
                    say(player, "info.signal.light.mode.white_off");
                    break;
                case "white&off":
                    signalLight.lightType = "blue&off";
                    say(player, "info.signal.light.mode.blue_off");
                    break;
                case "blue&off":
                    signalLight.lightType = "purple&off";
                    say(player, "info.signal.light.mode.purple_off");
                    break;
                case "purple&off":
                    signalLight.lightType = "red&yellow";
                    say(player, "info.signal.light.mode.red_yellow");
                    break;
                case "red&yellow":
                    signalLight.lightType = "red&green";
                    say(player, "info.signal.light.mode.red_green");
                    break;
                case "red&green":
                    signalLight.lightType = "yellow&green";
                    say(player, "info.signal.light.mode.yellow_green");
                    break;
                case "yellow&green":
                    signalLight.lightType = "white&blue";
                    say(player, "info.signal.light.mode.white_blue");
                    break;
                case "white&blue":
                    signalLight.lightType = "yellow&purple";
                    say(player, "info.signal.light.mode.yellow_purple");
                    break;
                case "yellow&purple":
                    signalLight.lightType = "none";
                    say(player, "info.signal.light.mode.none");
                    break;
                default:
                    break;
            }
        } else {
            if (signalLight.isBlinking) {
                signalLight.isBlinking = false;
                say(player, "info.signal.light.blink.off");
            } else {
                signalLight.isBlinking = true;
                say(player, "info.signal.light.blink.on");
            }
        }
        return !world.isRemote;
    }
    return false;
}
Also used : BlockTriStateSignalBox(club.nsdn.nyasamarailway.tileblock.signal.core.BlockTriStateSignalBox) BlockTicketBlockOnce(club.nsdn.nyasamarailway.tileblock.functional.BlockTicketBlockOnce) TileEntity(net.minecraft.tileentity.TileEntity) BlockGateFront(club.nsdn.nyasamarailway.tileblock.signal.deco.BlockGateFront) BlockRailReception(club.nsdn.nyasamarailway.block.rail.special.BlockRailReception) UUID(java.util.UUID) BlockSignalBox(club.nsdn.nyasamarailway.tileblock.signal.core.BlockSignalBox) TileEntityTrackSideReception(club.nsdn.nyasamarailway.tileblock.signal.TileEntityTrackSideReception) BlockCoinBlock(club.nsdn.nyasamarailway.tileblock.functional.BlockCoinBlock) BlockCoinBlock(club.nsdn.nyasamarailway.tileblock.functional.BlockCoinBlock) TileEntityTransceiver(club.nsdn.nyasamatelecom.api.tileentity.TileEntityTransceiver) BlockRailReceptionAnti(club.nsdn.nyasamarailway.block.rail.special.BlockRailReceptionAnti) TileEntityRailReception(club.nsdn.nyasamarailway.tileblock.signal.TileEntityRailReception) ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) BlockGateFront(club.nsdn.nyasamarailway.tileblock.signal.deco.BlockGateFront) BlockCoinBlock(club.nsdn.nyasamarailway.tileblock.functional.BlockCoinBlock) Block(net.minecraft.block.Block) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP)

Example 59 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project NyaSamaRailway by NSDN.

the class ItemNTP8Bit method addCart.

public void addCart(ItemStack itemStack, EntityPlayer player, Entity entity) {
    int id = entity.getEntityId();
    power.set(itemStack, 0);
    brake.set(itemStack, 5);
    dir.set(itemStack, 0);
    cart.set(itemStack, id);
    if (player instanceof EntityPlayerMP) {
        TrainPacket packet = new TrainPacket();
        packet.fromStack(itemStack);
        NetworkWrapper.instance.sendTo(packet, (EntityPlayerMP) player);
    }
    player.addChatComponentMessage(new ChatComponentTranslation("info.ntp.controlled"));
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) TrainPacket(club.nsdn.nyasamarailway.network.TrainPacket)

Example 60 with ChatComponentTranslation

use of net.minecraft.util.ChatComponentTranslation in project NyaSamaRailway by NSDN.

the class ItemNTP32Bit method addCart.

public void addCart(ItemStack itemStack, EntityPlayer player, Entity entity) {
    if (entity instanceof LocoBase) {
        player.addChatComponentMessage(new ChatComponentTranslation("info.ntp.error"));
        return;
    }
    int[] array = carts.get(itemStack);
    ArrayList<Integer> list = new ArrayList<>();
    for (int i : array) list.add(i);
    int id = entity.getEntityId();
    if (!list.contains(id)) {
        list.add(id);
        player.addChatComponentMessage(new ChatComponentTranslation("info.ntp.controlled"));
    }
    array = new int[list.size()];
    for (int i = 0; i < list.size(); i++) array[i] = list.get(i);
    carts.set(itemStack, array);
}
Also used : ChatComponentTranslation(net.minecraft.util.ChatComponentTranslation) LocoBase(club.nsdn.nyasamarailway.entity.LocoBase) ArrayList(java.util.ArrayList)

Aggregations

ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)89 ItemStack (net.minecraft.item.ItemStack)21 TileEntity (net.minecraft.tileentity.TileEntity)15 EntityPlayer (net.minecraft.entity.player.EntityPlayer)14 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)11 ChatComponentText (net.minecraft.util.ChatComponentText)6 ArrayList (java.util.ArrayList)5 Block (net.minecraft.block.Block)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)4 World (net.minecraft.world.World)4 Item1N4148 (club.nsdn.nyasamarailway.item.tool.Item1N4148)3 ItemNTP32Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP32Bit)3 ItemNTP8Bit (club.nsdn.nyasamarailway.item.tool.ItemNTP8Bit)3 TileEntityActuator (club.nsdn.nyasamatelecom.api.tileentity.TileEntityActuator)3 BufferedImage (java.awt.image.BufferedImage)3 IChatComponent (net.minecraft.util.IChatComponent)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 Int3 (WayofTime.alchemicalWizardry.api.Int3)2 TEReagentConduit (WayofTime.alchemicalWizardry.common.tileEntity.TEReagentConduit)2 TrainPacket (club.nsdn.nyasamarailway.network.TrainPacket)2