Search in sources :

Example 6 with Cube

use of com.builtbroken.mc.lib.transform.region.Cube in project Engine by VoltzEngine-Project.

the class AbstractTileTest method testGetCollisionBounds.

@Test
public void testGetCollisionBounds() {
    FakeWorld world = FakeWorld.newWorld("TestGetCollisionBounds");
    world.setBlock(0, 0, 0, block);
    Tile tile = ((Tile) world.getTileEntity(0, 0, 0));
    Cube cube = tile.getCollisionBounds();
    if (cube != null) {
    // TODO test too see if cube is valid
    }
}
Also used : Cube(com.builtbroken.mc.lib.transform.region.Cube) FakeWorld(com.builtbroken.mc.testing.junit.world.FakeWorld) PacketTile(com.builtbroken.mc.core.network.packet.PacketTile) BlockTile(com.builtbroken.mc.prefab.tile.BlockTile) Tile(com.builtbroken.mc.prefab.tile.Tile) Test(org.junit.Test)

Example 7 with Cube

use of com.builtbroken.mc.lib.transform.region.Cube 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 8 with Cube

use of com.builtbroken.mc.lib.transform.region.Cube in project Engine by VoltzEngine-Project.

the class PacketSelectionData method decodeInto.

@Override
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) {
    RenderSelection.cube_render_list.clear();
    RenderSelection.region_render_list.clear();
    // Read selection
    RenderSelection.selection = new Cube(buffer);
    // Read other player's selections to render
    int count = buffer.readInt();
    if (count > 0)
        for (int i = 0; i < count; i++) {
            RenderSelection.cube_render_list.add(new Cube(buffer));
        }
    // Read region bounds
    count = buffer.readInt();
    if (count > 0)
        for (int i = 0; i < count; i++) {
            RenderSelection.region_render_list.add(new Cube(buffer));
        }
}
Also used : Cube(com.builtbroken.mc.lib.transform.region.Cube)

Example 9 with Cube

use of com.builtbroken.mc.lib.transform.region.Cube 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 10 with Cube

use of com.builtbroken.mc.lib.transform.region.Cube in project Engine by VoltzEngine-Project.

the class Region method save.

@Override
public NBTTagCompound save(NBTTagCompound nbt) {
    if (segments.size() > 0) {
        NBTTagList list = new NBTTagList();
        for (Cube cube : segments) {
            list.appendTag(cube.toNBT());
        }
        nbt.setTag("segments", list);
    }
    NBTTagCompound tag = new NBTTagCompound();
    profile.save(tag);
    nbt.setTag("profile", tag);
    return nbt;
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) Cube(com.builtbroken.mc.lib.transform.region.Cube) NBTTagCompound(net.minecraft.nbt.NBTTagCompound)

Aggregations

Cube (com.builtbroken.mc.lib.transform.region.Cube)21 Pos (com.builtbroken.mc.lib.transform.vector.Pos)6 IRadioWaveReceiver (com.builtbroken.mc.api.map.radio.IRadioWaveReceiver)4 PacketTile (com.builtbroken.mc.core.network.packet.PacketTile)3 BlockTile (com.builtbroken.mc.prefab.tile.BlockTile)3 Tile (com.builtbroken.mc.prefab.tile.Tile)3 FakeWorld (com.builtbroken.mc.testing.junit.world.FakeWorld)3 ArrayList (java.util.ArrayList)3 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)3 Test (org.junit.Test)3 Region (com.builtbroken.mc.lib.modflags.Region)2 TileEntity (net.minecraft.tileentity.TileEntity)2 IRadioWaveSender (com.builtbroken.mc.api.map.radio.IRadioWaveSender)1 IMultiTileHost (com.builtbroken.mc.api.tile.multiblock.IMultiTileHost)1 PacketSelectionData (com.builtbroken.mc.core.network.packet.PacketSelectionData)1 RadioMap (com.builtbroken.mc.lib.world.radio.RadioMap)1 Entity (net.minecraft.entity.Entity)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 NBTTagList (net.minecraft.nbt.NBTTagList)1 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)1