Search in sources :

Example 1 with Region

use of com.builtbroken.mc.lib.modflags.Region in project Engine by VoltzEngine-Project.

the class SelectionHandler method updatePlayerRenderData.

public static void updatePlayerRenderData(EntityPlayerMP player) {
    List<Cube> cubes = new ArrayList();
    List<Cube> regions = new ArrayList();
    Cube selection = getSelection(player);
    for (Cube cube : selections.values()) {
        if (cube != selection && cube.distance(new Pos(player)) <= 160) {
            cubes.add(cube);
        }
    }
    for (Region region : RegionManager.getControllerForWorld(player.worldObj).getRegionsNear(player, 160)) {
        for (Cube cube : region.segments) {
            if (cube.isCloseToAnyCorner(new Pos(player), 160)) {
                regions.add(cube);
            }
        }
    }
    Engine.instance.packetHandler.sendToPlayer(new PacketSelectionData(selection, cubes, regions), player);
}
Also used : PacketSelectionData(com.builtbroken.mc.core.network.packet.PacketSelectionData) Cube(com.builtbroken.mc.lib.transform.region.Cube) Pos(com.builtbroken.mc.lib.transform.vector.Pos) ArrayList(java.util.ArrayList) Region(com.builtbroken.mc.lib.modflags.Region)

Example 2 with Region

use of com.builtbroken.mc.lib.modflags.Region in project Engine by VoltzEngine-Project.

the class CommandNewRegion method handleEntityPlayerCommand.

@Override
public boolean handleEntityPlayerCommand(EntityPlayer player, String[] args) {
    if (args.length > 0) {
        String name = args[0];
        if (RegionManager.getControllerForWorld(player.worldObj).getRegion(name) == null) {
            Cube cube = SelectionHandler.getSelection(player);
            if (cube != null && cube.isValid()) {
                Region region = RegionManager.getControllerForWorld(player.worldObj).createNewRegion(name, cube);
                if (region != null) {
                    region.getAccessProfile().getGroup("owner").addMember(player);
                    player.addChatMessage(new ChatComponentText("Region created"));
                } else {
                    player.addChatMessage(new ChatComponentText("Error creating region"));
                }
            } else {
                player.addChatMessage(new ChatComponentText("Invalid selection to create region"));
            }
        } else {
            player.addChatMessage(new ChatComponentText("A region by that name already exists"));
        }
    } else {
        player.addChatMessage(new ChatComponentText("Need a region name"));
    }
    return true;
}
Also used : Cube(com.builtbroken.mc.lib.transform.region.Cube) Region(com.builtbroken.mc.lib.modflags.Region) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 3 with Region

use of com.builtbroken.mc.lib.modflags.Region in project Engine by VoltzEngine-Project.

the class CommandRegion method handleEntityPlayerCommand.

@Override
public boolean handleEntityPlayerCommand(EntityPlayer player, String[] args) {
    if (args.length > 0) {
        String name = args[0];
        Region region = RegionManager.getControllerForWorld(player.worldObj).getRegion(name);
        if (region != null) {
            if (args.length > 1) {
                for (AbstractCommand command : subCommands) {
                    if (command instanceof SubCommandRegion && command.getCommandName().equalsIgnoreCase(args[1])) {
                        if (((SubCommandRegion) command).handle(player, region, removeFront(args, 2))) {
                            return true;
                        }
                    }
                }
            }
            player.addChatMessage(new ChatComponentText("Unknown region sub command"));
        } else {
            player.addChatMessage(new ChatComponentText("Unknown region"));
        }
    } else {
        player.addChatMessage(new ChatComponentText("Missing region name"));
    }
    return true;
}
Also used : SubCommandRegion(com.builtbroken.mc.core.commands.ext.SubCommandRegion) AbstractCommand(com.builtbroken.mc.prefab.commands.AbstractCommand) Region(com.builtbroken.mc.lib.modflags.Region) SubCommandRegion(com.builtbroken.mc.core.commands.ext.SubCommandRegion) ChatComponentText(net.minecraft.util.ChatComponentText)

Aggregations

Region (com.builtbroken.mc.lib.modflags.Region)3 Cube (com.builtbroken.mc.lib.transform.region.Cube)2 ChatComponentText (net.minecraft.util.ChatComponentText)2 SubCommandRegion (com.builtbroken.mc.core.commands.ext.SubCommandRegion)1 PacketSelectionData (com.builtbroken.mc.core.network.packet.PacketSelectionData)1 Pos (com.builtbroken.mc.lib.transform.vector.Pos)1 AbstractCommand (com.builtbroken.mc.prefab.commands.AbstractCommand)1 ArrayList (java.util.ArrayList)1