Search in sources :

Example 96 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project RFToolsControl by McJty.

the class VectorArtScreenModule method mouseClick.

@Override
public void mouseClick(World world, int x, int y, boolean clicked, EntityPlayer player) {
    int xoffset = 0;
    if (x >= xoffset) {
        if (coordinate.getY() != -1) {
            if (!WorldTools.chunkLoaded(world, coordinate)) {
                return;
            }
            Block block = world.getBlockState(coordinate).getBlock();
            if (block != ModBlocks.processorBlock) {
                return;
            }
            if (clicked) {
                TileEntity te = world.getTileEntity(coordinate);
                if (te instanceof ProcessorTileEntity) {
                    ProcessorTileEntity processor = (ProcessorTileEntity) te;
                    processor.signal(new Tuple(x, y + 7));
                }
            }
        } else if (player != null) {
            player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "Module is not linked to a processor!"), false);
        }
    }
}
Also used : ProcessorTileEntity(mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) ProcessorTileEntity(mcjty.rftoolscontrol.blocks.processor.ProcessorTileEntity) Block(net.minecraft.block.Block) Tuple(mcjty.rftoolscontrol.api.parameters.Tuple) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 97 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project Random-Things by lumien231.

the class RTCommand method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (args.length == 0) {
        return;
    }
    if (args[0].equals("setBiomeCrystal")) {
        if (args.length == 2 && sender instanceof EntityPlayer) {
            String biomeName = args[1];
            EntityPlayer player = (EntityPlayer) sender;
            ItemStack equipped = player.getHeldItemMainhand();
            if (equipped != null && equipped.getItem() instanceof ItemBiomeCrystal) {
                if (equipped.getTagCompound() == null) {
                    equipped.setTagCompound(new NBTTagCompound());
                }
                equipped.getTagCompound().setString("biomeName", args[1]);
            }
        }
    } else if (args[0].equals("generateBiomeCrystalChests")) {
        if (sender instanceof EntityPlayer) {
            List<ResourceLocation> biomeIds = new ArrayList<>(Biome.REGISTRY.getKeys());
            int modX = 0;
            while (!biomeIds.isEmpty()) {
                sender.getEntityWorld().setBlockState(sender.getPosition().add(modX, 0, 0), Blocks.CHEST.getDefaultState());
                IInventory inventory = (IInventory) sender.getEntityWorld().getTileEntity(sender.getPosition().add(modX, 0, 0));
                for (int i = 0; i < 27; i++) {
                    if (!biomeIds.isEmpty()) {
                        ResourceLocation next = biomeIds.remove(biomeIds.size() - 1);
                        ItemStack crystal = new ItemStack(ModItems.biomeCrystal);
                        crystal.setTagCompound(new NBTTagCompound());
                        crystal.getTagCompound().setString("biomeName", next.toString());
                        inventory.setInventorySlotContents(i, crystal);
                    }
                }
                modX += 2;
            }
        }
    } else if (args[0].equals("tpFilter")) {
        if (sender instanceof EntityPlayerMP) {
            EntityPlayerMP player = (EntityPlayerMP) sender;
            ItemStack held;
            if ((held = player.getHeldItemMainhand()) != null && held.getItem() == ModItems.positionFilter) {
                BlockPos pos = ItemPositionFilter.getPosition(held);
                player.connection.setPlayerLocation(pos.getX(), pos.getY() + 150, pos.getZ(), player.rotationYaw, player.rotationPitch);
            }
        }
    } else if (args[0].equals("testSlimeSpawn")) {
        BlockPos pos = sender.getPosition();
        World world = sender.getEntityWorld();
        if (pos != null && world != null) {
            EntitySlime slime = new EntitySlime(world);
            slime.setLocationAndAngles(pos.getX(), pos.getY(), pos.getZ(), 0F, 0F);
            sender.sendMessage(new TextComponentString(slime.getCanSpawnHere() + ""));
        }
    } else if (args[0].equals("notify") && args.length == 5) {
        String title = args[1];
        String body = args[2];
        String itemName = args[3];
        String player = args[4];
        EntityPlayerMP playerEntity = server.getPlayerList().getPlayerByUsername(player);
        ItemStack itemStack = new ItemStack(ForgeRegistries.ITEMS.getValue(new ResourceLocation(itemName)));
        MessageNotification message = new MessageNotification(title, body, itemStack);
        PacketHandler.INSTANCE.sendTo(message, playerEntity);
    } else if (args[0].equals("fireplaces")) {
        FlooNetworkHandler handler = FlooNetworkHandler.get(sender.getEntityWorld());
        List<FlooFireplace> firePlaces = handler.getFirePlaces();
        sender.sendMessage(new TextComponentString("Floo Fireplaces in Dimension " + sender.getEntityWorld().provider.getDimension()).setStyle(new Style().setUnderlined(true)));
        sender.sendMessage(new TextComponentString(""));
        for (FlooFireplace firePlace : firePlaces) {
            String name = firePlace.getName();
            UUID creator = firePlace.getCreatorUUID();
            String ownerName = null;
            if (creator != null) {
                GameProfile profile = server.getPlayerProfileCache().getProfileByUUID(creator);
                if (profile != null) {
                    ownerName = profile.getName();
                }
            }
            BlockPos pos = firePlace.getLastKnownPosition();
            sender.sendMessage(new TextComponentString((name == null ? "<Unnamed>" : name) + " | " + String.format("%d %d %d", pos.getX(), pos.getY(), pos.getZ()) + (ownerName != null ? " | " + ownerName : "")));
        }
    } else if (args[0].equals("festival")) {
        FestivalHandler handler = FestivalHandler.get(sender.getEntityWorld());
        List<EntityVillager> villagerList = sender.getEntityWorld().getEntitiesWithinAABB(EntityVillager.class, new AxisAlignedBB(sender.getPosition()).grow(50));
        if (!villagerList.isEmpty()) {
            EntityVillager villager = villagerList.get(0);
            int success = handler.addFestival(villager);
            if (success == 2) {
                sender.sendMessage(new TextComponentTranslation("command.festival.scheduled"));
            } else {
                sender.sendMessage(new TextComponentTranslation("command.festival.failed"));
            }
        } else {
            sender.sendMessage(new TextComponentTranslation("command.festival.novillager"));
        }
    } else if (args[0].equals("ancientFurnace")) {
        WorldGenAncientFurnace.pattern.place(sender.getEntityWorld(), sender.getPosition(), 3);
    }
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) TextComponentString(net.minecraft.util.text.TextComponentString) MessageNotification(lumien.randomthings.network.messages.MessageNotification) World(net.minecraft.world.World) ResourceLocation(net.minecraft.util.ResourceLocation) FlooNetworkHandler(lumien.randomthings.handler.floo.FlooNetworkHandler) EntityVillager(net.minecraft.entity.passive.EntityVillager) Style(net.minecraft.util.text.Style) ArrayList(java.util.ArrayList) List(java.util.List) BlockPos(net.minecraft.util.math.BlockPos) UUID(java.util.UUID) IInventory(net.minecraft.inventory.IInventory) FestivalHandler(lumien.randomthings.handler.festival.FestivalHandler) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) EntitySlime(net.minecraft.entity.monster.EntitySlime) ItemBiomeCrystal(lumien.randomthings.item.ItemBiomeCrystal) TextComponentString(net.minecraft.util.text.TextComponentString) GameProfile(com.mojang.authlib.GameProfile) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) FlooFireplace(lumien.randomthings.handler.floo.FlooFireplace)

Example 98 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project FoamFix by asiekierka.

the class CommandGhostBuster method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    if (args.length >= 1) {
        if ("on".equals(args[0])) {
            ChunkProviderServerWrapped.debugChunkProviding = true;
            sender.sendMessage(new TextComponentString("Ghost chunkload logging ON!"));
            return;
        } else if ("off".equals(args[0])) {
            ChunkProviderServerWrapped.debugChunkProviding = false;
            sender.sendMessage(new TextComponentString("Ghost chunkload logging OFF!"));
            return;
        }
    }
    sender.sendMessage(new TextComponentString("Ghost chunkload logging status: " + (ChunkProviderServerWrapped.debugChunkProviding ? "ON" : "OFF")));
    return;
}
Also used : TextComponentString(net.minecraft.util.text.TextComponentString)

Example 99 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project RFTools by McJty.

the class ButtonScreenModule method mouseClick.

@Override
public void mouseClick(World world, int x, int y, boolean clicked, EntityPlayer player) {
    int xoffset;
    if (!line.isEmpty()) {
        xoffset = 80;
    } else {
        xoffset = 5;
    }
    if (x >= xoffset) {
        if (channel != -1) {
            if (toggle) {
                if (clicked) {
                    RedstoneChannels channels = RedstoneChannels.getChannels(world);
                    RedstoneChannels.RedstoneChannel ch = channels.getOrCreateChannel(channel);
                    ch.setValue((ch.getValue() == 0) ? 15 : 0);
                    channels.save(world);
                }
            } else {
                RedstoneChannels channels = RedstoneChannels.getChannels(world);
                RedstoneChannels.RedstoneChannel ch = channels.getOrCreateChannel(channel);
                ch.setValue(clicked ? 15 : 0);
                channels.save(world);
            }
        } else {
            if (player != null) {
                player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "Module is not linked to redstone channel!"), false);
            }
        }
    }
}
Also used : RedstoneChannels(mcjty.rftools.blocks.logic.wireless.RedstoneChannels) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 100 with TextComponentString

use of net.minecraft.util.text.TextComponentString in project RFTools by McJty.

the class DumpScreenModule method mouseClick.

@Override
public void mouseClick(World world, int x, int y, boolean clicked, EntityPlayer player) {
    if ((!clicked) || player == null) {
        return;
    }
    if (BlockPosTools.INVALID.equals(coordinate)) {
        player.sendStatusMessage(new TextComponentString(TextFormatting.RED + "Module is not linked to storage scanner!"), false);
        return;
    }
    StorageScannerTileEntity scannerTileEntity = StorageControlScreenModule.getStorageScanner(dim, coordinate);
    if (scannerTileEntity == null) {
        return;
    }
    int xoffset = 5;
    if (x >= xoffset) {
        for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
            if (isShown(player.inventory.getStackInSlot(i))) {
                ItemStack stack = scannerTileEntity.injectStackFromScreen(player.inventory.getStackInSlot(i), player);
                player.inventory.setInventorySlotContents(i, stack);
            }
        }
        player.openContainer.detectAndSendChanges();
        return;
    }
}
Also used : ItemStack(net.minecraft.item.ItemStack) StorageScannerTileEntity(mcjty.rftools.blocks.storagemonitor.StorageScannerTileEntity) TextComponentString(net.minecraft.util.text.TextComponentString)

Aggregations

TextComponentString (net.minecraft.util.text.TextComponentString)343 EntityPlayer (net.minecraft.entity.player.EntityPlayer)79 ItemStack (net.minecraft.item.ItemStack)68 BlockPos (net.minecraft.util.math.BlockPos)60 ITextComponent (net.minecraft.util.text.ITextComponent)48 TileEntity (net.minecraft.tileentity.TileEntity)41 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)35 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)32 Colony (com.minecolonies.coremod.colony.Colony)26 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)26 IBlockState (net.minecraft.block.state.IBlockState)23 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)21 Style (net.minecraft.util.text.Style)21 IColony (com.minecolonies.api.colony.IColony)19 ClickEvent (net.minecraft.util.text.event.ClickEvent)19 Entity (net.minecraft.entity.Entity)18 Block (net.minecraft.block.Block)17 World (net.minecraft.world.World)17 ArrayList (java.util.ArrayList)16 ActionResult (net.minecraft.util.ActionResult)13