use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class PacketSpawnStream method handleClientSide.
@Override
public void handleClientSide(EntityPlayer player) {
if (player.worldObj.provider.dimensionId == dim) {
if (type == 0) {
short short1 = 128;
final Random rand = player.worldObj.rand;
for (int l = 0; l < short1; ++l) {
double d6 = (double) l / ((double) short1 - 1.0D);
float f = (rand.nextFloat() - 0.5F) * 0.2F;
float f1 = (rand.nextFloat() - 0.5F) * 0.2F;
float f2 = (rand.nextFloat() - 0.5F) * 0.2F;
double d7 = vx + (x - vx) * d6 + (rand.nextDouble() - 0.5D) * 5.0D;
double d8 = vy + (y - vy) * d6 + (rand.nextDouble() - 0.5D) * 5.0D;
double d9 = vz + (z - vz) * d6 + (rand.nextDouble() - 0.5D) * 5.0D;
Engine.proxy.spawnParticle("portal", player.worldObj, d7, d8, d9, (double) f, (double) f1, (double) f2);
}
} else if (type == 1) {
Engine.proxy.spawnBeamFx(SharedAssets.GREY_TEXTURE, player.worldObj, new Pos(x, y, z), new Pos(vx, vy, vz), Color.RED, 5);
} else if (type == 2) {
Engine.proxy.spawnBeamFx(SharedAssets.GREY_TEXTURE, player.worldObj, new Pos(x, y, z), new Pos(vx, vy, vz), new Color(red, green, blue), 5);
}
}
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class SchematicMap method getBlocksToPlace.
/**
* Gets all blocks needed to build the schematic at the given location
*
* @param spot - center point of the schematic
* @param blockMap - map of blocks from the schematic file
* @param checkWorld - check if blocks are already placed
* @param checkIfWorldIsLoaded - check if the area is loaded, make sure this is true if
* checkWorld boolean is true as it effects the results if the chunk is unloaded. Setting this
* true will not load the area and is designed to prevent wasting blocks when generating
* buildings using actual blocks
*/
public void getBlocksToPlace(Location spot, List<IWorldEdit> blockMap, boolean checkWorld, boolean checkIfWorldIsLoaded) {
if (this.block_map != null) {
for (Entry<Pos, Pair<Block, Integer>> entry : this.block_map.entrySet()) {
Block block = entry.getValue().left();
int meta = entry.getValue().right();
if (block == null || block != Blocks.sponge) {
if (meta > 15) {
meta = 15;
} else if (meta < 0) {
meta = 0;
}
Pos setPos = spot.toPos().subtract(this.schematicCenter).add(entry.getKey());
if (checkWorld) {
if (checkIfWorldIsLoaded) {
Chunk chunk = spot.world.getChunkFromBlockCoords(setPos.xi(), setPos.zi());
if (!chunk.isChunkLoaded) {
continue;
}
}
Block checkID = setPos.getBlock(spot.world);
int checkMeta = setPos.getBlockMetadata(spot.world);
if (checkID == block && checkMeta == meta) {
continue;
}
}
blockMap.add(new BlockEdit(spot.world, setPos).set(block, meta));
}
}
}
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class SchematicMap method loadWorldSelection.
public SchematicMap loadWorldSelection(World world, IPos3D pos, IPos3D pos2) {
int deltaX, deltaY, deltaZ;
Pos start = new Pos(pos.x() > pos2.x() ? pos2.x() : pos.x(), pos.y() > pos2.y() ? pos2.y() : pos.y(), pos.z() > pos2.z() ? pos2.z() : pos.z());
SchematicMap sch = new SchematicMap();
if (pos.x() < pos2.x()) {
deltaX = (int) (pos2.x() - pos.x() + 1);
} else {
deltaX = (int) (pos.x() - pos2.x() + 1);
}
if (pos.y() < pos2.y()) {
deltaY = (int) (pos2.y() - pos.y() + 1);
} else {
deltaY = (int) (pos.y() - pos2.y() + 1);
}
if (pos.z() < pos2.z()) {
deltaZ = (int) (pos2.z() - pos.z() + 1);
} else {
deltaZ = (int) (pos.z() - pos2.z() + 1);
}
sch.schematicSize = new Pos(deltaX, deltaY, deltaZ);
for (int x = 0; x < deltaX; ++x) {
for (int y = 0; y < deltaY; ++y) {
for (int z = 0; z < deltaZ; ++z) {
Block block = world.getBlock((int) start.x() + x, (int) start.y() + y, (int) start.z() + z);
int blockMeta = world.getBlockMetadata((int) start.x() + x, (int) start.y() + y, (int) start.z() + z);
sch.block_map.put(new Pos(x, y, z), new Pair<>(block, blockMeta));
}
}
}
return sch;
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class SchematicMap method save.
@Override
public NBTTagCompound save(NBTTagCompound nbt) {
if (!init) {
this.init();
}
NBTTagCompound blockNBT = nbt.getCompoundTag(BLOCK_LIST_SAVE_NAME);
if (this.schematicSize != null) {
nbt.setInteger("sizeX", (int) this.schematicSize.x());
nbt.setInteger("sizeY", (int) this.schematicSize.y());
nbt.setInteger("sizeZ", (int) this.schematicSize.z());
}
if (this.schematicCenter != null) {
nbt.setInteger("centerX", (int) this.schematicCenter.x());
nbt.setInteger("centerY", (int) this.schematicCenter.y());
nbt.setInteger("centerZ", (int) this.schematicCenter.z());
}
int i = 0;
for (Entry<Pos, Pair<Block, Integer>> entry : block_map.entrySet()) {
String output = "";
Block block = entry.getValue().left();
if (block != null && SchematicMap.BLOCK_SAVE_MAP_REV.containsKey(block)) {
output += SchematicMap.BLOCK_SAVE_MAP_REV.get(block);
} else {
output += entry.getValue().left();
}
output += ":" + entry.getValue().right();
output += ":" + (entry.getKey().x()) + ":" + ((int) entry.getKey().y()) + ":" + ((int) entry.getKey().z());
blockNBT.setString("Block" + i, output);
i++;
}
blockNBT.setInteger("count", i);
nbt.setTag(BLOCK_LIST_SAVE_NAME, blockNBT);
return nbt;
}
use of com.builtbroken.mc.lib.transform.vector.Pos in project Engine by VoltzEngine-Project.
the class EntityAbstractCart method onUpdate.
@Override
public void onUpdate() {
this.prevDistanceWalkedModified = this.distanceWalkedModified;
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
this.prevRotationPitch = this.rotationPitch;
this.prevRotationYaw = this.rotationYaw;
// Updates the collision box
if (invalidBox || boundingBox == null) {
validateBoundBox();
}
// Grab rail side if null
if (railSide == null) {
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
Pos pos = new Pos((Entity) this).add(side);
Block block = pos.getBlock(worldObj);
final TileEntity tile = pos.getTileEntity(worldObj);
if (!(block instanceof ITransportRailBlock || tile instanceof ITransportRail)) {
railSide = side;
break;
}
}
}
Pos pos = new Pos(Math.floor(posX), Math.floor(posY), Math.floor(posZ)).floor();
Block block = pos.getBlock(world());
if (block == Blocks.air) {
pos = pos.add(railSide);
block = pos.getBlock(worldObj);
}
final TileEntity tile = pos.getTileEntity(worldObj);
if (!worldObj.isRemote) {
// Kills entity if it falls out of the world, should never happen
if (this.posY < -64.0D) {
this.kill();
return;
} else // Breaks entity if its not on a track
if (!(block instanceof ITransportRailBlock || tile instanceof ITransportRail)) {
destroyCart();
return;
}
// Moves the entity
if (motionX != 0 || motionY != 0 || motionZ != 0) {
moveEntity(motionX, motionY, motionZ);
recenterCartOnRail();
}
}
if (isAirBorne) {
motionY -= (9.8 / 20);
motionY = Math.max(-2, motionY);
}
// Handles pushing entities out of the way
doCollisionLogic();
// Updates the rail and cart position
if (tile instanceof ITransportRail) {
((ITransportRail) tile).tickRailFromCart(this);
} else if (block instanceof ITransportRailBlock) {
((ITransportRailBlock) block).tickRailFromCart(this, world(), pos.xi(), pos.yi(), pos.zi(), worldObj.getBlockMetadata(pos.xi(), pos.yi(), pos.zi()));
}
if (!worldObj.isRemote && updateClient) {
sentDescriptionPacket();
}
}
Aggregations