Search in sources :

Example 31 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.

the class CommandVEButcher method handleConsoleCommand.

@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
    long time = System.nanoTime();
    // TODO add ability to set location and range
    int dim = 0;
    if (args != null && args.length > 0) {
        if (args[0].startsWith("dim")) {
            try {
                dim = Integer.parseInt(args[0].replace("dim", ""));
            } catch (NumberFormatException e) {
                sender.addChatMessage(new ChatComponentText("Dim id needs to be an int"));
                return true;
            }
        } else {
            sender.addChatMessage(new ChatComponentText("Right now only /ve butcher dim[#] is supported, ex /ve butcher dim0"));
            return true;
        }
    }
    WorldServer world = DimensionManager.getWorld(dim);
    if (world != null) {
        int entitiesKilled = 0;
        int chunksSearched = 0;
        ChunkProviderServer provider = world.theChunkProviderServer;
        for (Object object : provider.loadedChunks) {
            if (object instanceof Chunk) {
                chunksSearched++;
                for (Object l : ((Chunk) object).entityLists) {
                    if (l instanceof Collection) {
                        for (Object e : (Collection) l) {
                            if (e instanceof Entity && e instanceof IMob) {
                                if (((Entity) e).isEntityAlive()) {
                                    ((Entity) e).setDead();
                                    entitiesKilled++;
                                }
                            }
                        }
                    }
                }
            }
        }
        time = System.nanoTime() - time;
        sender.addChatMessage(new ChatComponentText("Removed " + entitiesKilled + "mobs over " + chunksSearched + " chunks in " + StringHelpers.formatNanoTime(time)));
    } else {
        sender.addChatMessage(new ChatComponentText("World doesn't exist, this means it unloaded or the wrong id was provided."));
    }
    return true;
}
Also used : Entity(net.minecraft.entity.Entity) IMob(net.minecraft.entity.monster.IMob) ChunkProviderServer(net.minecraft.world.gen.ChunkProviderServer) Collection(java.util.Collection) WorldServer(net.minecraft.world.WorldServer) Chunk(net.minecraft.world.chunk.Chunk) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 32 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.

the class CommandVERemove method handleConsoleCommand.

@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
    long time = System.nanoTime();
    // TODO add ability to set location and range
    int dim = 0;
    EntitySelector selector = getSelector(args[0]);
    if (selector == null) {
        // TODO return error
        return false;
    }
    if (args != null && args.length > 1) {
        if (args[1].startsWith("dim")) {
            try {
                dim = Integer.parseInt(args[1].replace("dim", ""));
            } catch (NumberFormatException e) {
                sender.addChatMessage(new ChatComponentText("Dim id needs to be an int"));
                return true;
            }
        } else {
            sender.addChatMessage(new ChatComponentText("Right now only /ve butcher dim[#] is supported, ex /ve butcher dim0"));
            return true;
        }
    }
    WorldServer world = DimensionManager.getWorld(dim);
    if (world != null) {
        int entitiesKilled = 0;
        int chunksSearched = 0;
        ChunkProviderServer provider = world.theChunkProviderServer;
        for (Object object : provider.loadedChunks) {
            if (object instanceof Chunk) {
                chunksSearched++;
                for (Object l : ((Chunk) object).entityLists) {
                    if (l instanceof Collection) {
                        for (Object e : (Collection) l) {
                            if (e instanceof Entity && ((Entity) e).isEntityAlive() && selector.isEntityApplicable((Entity) e)) {
                                ((Entity) e).setDead();
                                entitiesKilled++;
                            }
                        }
                    }
                }
            }
        }
        time = System.nanoTime() - time;
        sender.addChatMessage(new ChatComponentText("Removed " + entitiesKilled + " entities over " + chunksSearched + " chunks in " + StringHelpers.formatNanoTime(time)));
    } else {
        sender.addChatMessage(new ChatComponentText("World doesn't exist, this means it unloaded or the wrong id was provided."));
    }
    return true;
}
Also used : Entity(net.minecraft.entity.Entity) EntitySelector(com.builtbroken.mc.prefab.entity.selector.EntitySelector) ChunkProviderServer(net.minecraft.world.gen.ChunkProviderServer) Collection(java.util.Collection) WorldServer(net.minecraft.world.WorldServer) Chunk(net.minecraft.world.chunk.Chunk) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 33 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.

the class CommandVERemove method handleEntityPlayerCommand.

@Override
public boolean handleEntityPlayerCommand(EntityPlayer entityPlayer, String[] args) {
    if (args.length > 0) {
        int radius = 100;
        EntitySelector selector = getSelector(args[0]);
        if (selector == null) {
            // TODO return error
            return false;
        }
        // Get radius from player
        if (args.length > 1 && args[1] != null) {
            try {
                radius = Integer.parseInt(args[1]);
                if (radius > 1000) {
                    entityPlayer.addChatMessage(new ChatComponentText("To prevent lag/crashes radius is limited to 1000"));
                    return true;
                } else if (radius < 1) {
                    entityPlayer.addChatMessage(new ChatComponentText("Radius needs to be positive"));
                    return true;
                }
            } catch (NumberFormatException e) {
                entityPlayer.addChatMessage(new ChatComponentText("Radius needs to be an integer"));
                return true;
            }
        }
        if (selector != null) {
            List<Entity> list = selector.getEntities(entityPlayer, radius);
            for (Entity entity : list) {
                entity.setDead();
            }
            entityPlayer.addChatMessage(new ChatComponentText("Removed " + list.size() + " " + args[0] + " entities within " + radius + " block radius"));
        } else {
            entityPlayer.addChatMessage(new ChatComponentText("Error unknown selector"));
        }
        return true;
    }
    return false;
}
Also used : Entity(net.minecraft.entity.Entity) EntitySelector(com.builtbroken.mc.prefab.entity.selector.EntitySelector) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 34 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.

the class CommandNewGroup method handleConsoleCommand.

@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
    if (args.length > 0) {
        String name = args[0];
        if (GroupProfileHandler.GLOBAL.getAccessProfile().getGroup(name) == null) {
            AccessGroup toExtend = null;
            if (args.length > 1 && args[1].equalsIgnoreCase("extend")) {
                if (args.length > 2) {
                    String extendName = args[2];
                    toExtend = GroupProfileHandler.GLOBAL.getAccessProfile().getGroup(extendName);
                }
                if (toExtend == null) {
                    sender.addChatMessage(new ChatComponentText("Error: Unknown group to extend"));
                    return true;
                }
            }
            AccessGroup group = new AccessGroup(name);
            if (toExtend != null) {
                group.setToExtend(toExtend);
            }
            if (GroupProfileHandler.GLOBAL.getAccessProfile().addGroup(group)) {
                sender.addChatMessage(new ChatComponentText("Group added"));
            } else {
                sender.addChatMessage(new ChatComponentText("Error adding group"));
            }
        } else {
            sender.addChatMessage(new ChatComponentText("A Group by that name already exists"));
        }
    } else {
        sender.addChatMessage(new ChatComponentText("Missing group name"));
    }
    return true;
}
Also used : AccessGroup(com.builtbroken.mc.lib.access.AccessGroup) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 35 with ChatComponentText

use of v1_8_9.net.minecraft.util.ChatComponentText in project Engine by VoltzEngine-Project.

the class GSCPerm method handle.

@Override
public boolean handle(ICommandSender sender, AccessGroup group, String node, String[] args) {
    if (!remove && group.hasNode(node) || remove && group.hasExactNode(node)) {
        if (remove) {
            group.removeNode(node);
        } else {
            sender.addChatMessage(new ChatComponentText("Group already contains the node or super version of the node"));
        }
    } else {
        if (!remove) {
            group.addNode(node);
            sender.addChatMessage(new ChatComponentText("Node added to the group"));
        } else if (group.hasNode(node)) {
            sender.addChatMessage(new ChatComponentText("Group contains a super version of that node, but not an exact match"));
        } else if (group.getExtendGroup() != null && group.getExtendGroup().hasNode(node)) {
            sender.addChatMessage(new ChatComponentText("Super group contains the node, but the node is not contained in this group"));
        } else {
            sender.addChatMessage(new ChatComponentText("Group does not contain the node"));
        }
    }
    return true;
}
Also used : ChatComponentText(net.minecraft.util.ChatComponentText)

Aggregations

ChatComponentText (net.minecraft.util.ChatComponentText)383 IChatComponent (net.minecraft.util.IChatComponent)55 EntityPlayer (net.minecraft.entity.player.EntityPlayer)43 ChatStyle (net.minecraft.util.ChatStyle)39 ItemStack (net.minecraft.item.ItemStack)36 ClickEvent (net.minecraft.event.ClickEvent)31 World (net.minecraft.world.World)28 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)26 TileEntity (net.minecraft.tileentity.TileEntity)25 ChatComponentTranslation (net.minecraft.util.ChatComponentTranslation)25 HoverEvent (net.minecraft.event.HoverEvent)23 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)21 ArrayList (java.util.ArrayList)17 RfToolsDimensionManager (mcjty.rftools.dimension.RfToolsDimensionManager)16 Block (net.minecraft.block.Block)15 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)15 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)14 Entity (net.minecraft.entity.Entity)14 DimensionInformation (mcjty.rftools.dimension.DimensionInformation)13 File (java.io.File)12