use of com.builtbroken.mc.imp.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class Vector3Test method testAddition.
/** Simple addition test for Vector3 */
public void testAddition() throws Exception {
Pos vec = new Pos(0, 1, 0);
vec = vec.add(1, 1, 1);
Assert.assertEquals(2.0, vec.y(), 0);
Assert.assertEquals(1.0, vec.x(), 0);
Assert.assertEquals(1.0, vec.z(), 0);
}
use of com.builtbroken.mc.imp.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class Vector3Test method testSubtraction.
/** Simple addition test for Vector3 */
public void testSubtraction() throws Exception {
Pos vec = new Pos(0, 1, 0);
vec = vec.subtract(1, 1, 1);
Assert.assertEquals(0.0, vec.y(), 0);
Assert.assertEquals(-1.0, vec.x(), 0);
Assert.assertEquals(-1.0, vec.z(), 0);
}
use of com.builtbroken.mc.imp.transform.vector.Pos 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.imp.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class MultiBlockHelper method destroyMultiBlockStructure.
/**
* Breaks down the multiblock stucture linked to the host
*
* @param host - host providing the layour of the structure
* @param doDrops - attempt to drop blocks?
* @param offset - offset the layout by the location of the host?
* @param killHost - destroy the host block as well?
*/
public static void destroyMultiBlockStructure(IMultiTileHost host, boolean doDrops, boolean offset, boolean killHost) {
if (host != null) {
HashMap<IPos3D, String> map = host.getLayoutOfMultiBlock();
if (map != null && !map.isEmpty()) {
IWorldPosition center;
if (host instanceof TileEntity) {
center = new Location((TileEntity) host);
} else if (host instanceof IWorldPosition) {
center = (IWorldPosition) host;
} else {
logger.error("MultiBlockHelper >> Tile[" + host + "]'s is not a TileEntity or IWorldPosition instance, thus we can not get a position to break down the structure.");
return;
}
for (Map.Entry<IPos3D, String> entry : map.entrySet()) {
Pos pos = entry.getKey() instanceof Pos ? (Pos) entry.getKey() : new Pos(entry.getKey());
if (offset) {
pos = pos.add(center);
}
TileEntity tile = pos.getTileEntity(center.world());
if (tile instanceof IMultiTile) {
((IMultiTile) tile).setHost(null);
pos.setBlockToAir(center.world());
}
}
if (doDrops) {
InventoryUtility.dropBlockAsItem(center, killHost);
} else if (killHost) {
center.world().setBlockToAir(center.xi(), center.yi(), center.zi());
}
} else {
logger.error("MultiBlockHelper >> Tile[" + host + "]'s structure map is empty");
}
}
}
use of com.builtbroken.mc.imp.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class MultiBlockHelper method updateStructure.
/**
* Runs a world update on all members of the structure
*
* @param world
* @param host
* @param offset - off set the location data by the center of the host
*/
public static void updateStructure(World world, IMultiTileHost host, boolean offset) {
//TODO junit test
if (!(host instanceof TileEntity)) {
Engine.error("Tile host is not an instance of TileEntity");
}
if (world == null) {
Engine.error("Tile host is not an instance of TileEntity");
}
HashMap<IPos3D, String> map = host.getLayoutOfMultiBlock();
if (map != null && !map.isEmpty()) {
int x = ((TileEntity) host).xCoord;
int y = ((TileEntity) host).yCoord;
int z = ((TileEntity) host).zCoord;
Pos center = new Pos(x, y, z);
for (Map.Entry<IPos3D, String> entry : map.entrySet()) {
Location pos = new Location(world, entry.getKey());
if (offset) {
pos = pos.add(center);
}
pos.markForUpdate();
}
center.markForUpdate(world);
} else {
logger.error("Tile[" + host + "]'s structure map is empty");
}
}
Aggregations