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
}
}
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);
}
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));
}
}
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;
}
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;
}
Aggregations