use of com.bergerkiller.bukkit.common.bases.IntVector3 in project BKCommonLib by bergerhealer.
the class CommonHumanEntity method getSpawnPoint.
/**
* Gets the block location of the respawn point for the human entity.
* If none is available, null is returned instead.
*
* @return spawn point coordinates, or null if none are available
*/
public BlockLocation getSpawnPoint() {
Object handle = getHandle();
String world = EntityHumanHandle.T.spawnWorld.get(handle);
IntVector3 coords = EntityHumanHandle.T.spawnCoord.get(handle);
if (world != null && coords != null && !world.isEmpty()) {
return new BlockLocation(world, coords);
} else {
return null;
}
}
use of com.bergerkiller.bukkit.common.bases.IntVector3 in project BKCommonLib by bergerhealer.
the class CommonHumanEntity method setSpawnPoint.
/**
* Sets the block location of the respawn point for the human entity.
* To clear the respawn point and set it to 'none', set it to null.
*
* @param spawnPoint to set to
*/
public void setSpawnPoint(BlockLocation spawnPoint) {
Object handle = getHandle();
IntVector3 coord = null;
String world = "";
if (spawnPoint != null) {
world = spawnPoint.world;
coord = spawnPoint.getCoordinates();
}
EntityHumanHandle.T.spawnWorld.set(handle, world);
EntityHumanHandle.T.spawnCoord.set(handle, coord);
}
use of com.bergerkiller.bukkit.common.bases.IntVector3 in project BKCommonLib by bergerhealer.
the class BlockDataImpl method ignite.
@Override
public final void ignite(org.bukkit.World world, int x, int y, int z) {
ExplosionHandle ex = ExplosionHandle.createNew(world, null, x, y, z, 4.0f, true, true);
this.block.ignite(world, new IntVector3(x, y, z), ex);
}
use of com.bergerkiller.bukkit.common.bases.IntVector3 in project BKCommonLib by bergerhealer.
the class ItemFrameInfo method recalculateUUID.
void recalculateUUID() {
// Find out the tile information of this item frame
// This is a slow and lengthy procedure; hopefully it does not happen too often
// What we do is: we add all neighbours, then find the most top-left item frame
// Subtracting coordinates will give us the tile x/y of this item frame
IntVector3 itemFramePosition = this.coordinates;
ItemFrameCluster cluster = this.controller.findCluster(itemFrameHandle, itemFramePosition);
// If not fully loaded, 'park' this item frame until surrounding chunks are loaded too
World world = this.getWorld();
boolean fullyLoaded = true;
for (ItemFrameCluster.ChunkDependency dependency : cluster.chunk_dependencies) {
fullyLoaded &= this.controller.checkClusterChunkDependency(world, dependency);
}
if (!fullyLoaded) {
this.requiresFurtherLoading = true;
return;
}
// Calculate UUID of this item frame
this.recalculateUUIDInCluster(cluster);
// as otherwise there is a tick delay until these other item frames initialize.
if (cluster.hasMultipleTiles()) {
for (ItemFrameInfo itemFrame : this.controller.findClusterItemFrames(cluster)) {
if (itemFrame == this) {
continue;
}
if ((itemFrame.lastFrameItemUpdateNeeded && itemFrame.checkItemChanged()) || itemFrame.requiresFurtherLoading) {
itemFrame.recalculateUUIDInCluster(cluster);
}
}
}
}
use of com.bergerkiller.bukkit.common.bases.IntVector3 in project BKCommonLib by bergerhealer.
the class ItemFrameInfo method recalculateUUIDInCluster.
private void recalculateUUIDInCluster(ItemFrameCluster cluster) {
this.requiresFurtherLoading = false;
IntVector3 itemFramePosition = this.coordinates;
UUID mapUUID = this.itemFrameHandle.getItemMapDisplayDynamicOnlyUUID();
if (mapUUID == null) {
return;
}
MapUUID newMapUUID;
if (cluster.hasMultipleTiles()) {
int tileX = 0;
int tileY = 0;
if (cluster.facing.getModY() > 0) {
// We use rotation of the item frame to decide which side is up
switch(cluster.rotation) {
case 90:
tileX = (itemFramePosition.z - cluster.min_coord.z);
tileY = (cluster.max_coord.x - itemFramePosition.x);
break;
case 180:
tileX = (cluster.max_coord.x - itemFramePosition.x);
tileY = (cluster.max_coord.z - itemFramePosition.z);
break;
case 270:
tileX = (cluster.max_coord.z - itemFramePosition.z);
tileY = (itemFramePosition.x - cluster.min_coord.x);
break;
default:
tileX = (itemFramePosition.x - cluster.min_coord.x);
tileY = (itemFramePosition.z - cluster.min_coord.z);
break;
}
} else if (cluster.facing.getModY() < 0) {
// We use rotation of the item frame to decide which side is up
switch(cluster.rotation) {
case 90:
tileX = (cluster.max_coord.z - itemFramePosition.z);
tileY = (cluster.max_coord.x - itemFramePosition.x);
break;
case 180:
tileX = (cluster.max_coord.x - itemFramePosition.x);
tileY = (itemFramePosition.z - cluster.min_coord.z);
break;
case 270:
tileX = (itemFramePosition.z - cluster.min_coord.z);
tileY = (itemFramePosition.x - cluster.min_coord.x);
break;
default:
tileX = (itemFramePosition.x - cluster.min_coord.x);
tileY = (cluster.max_coord.z - itemFramePosition.z);
break;
}
} else {
// On the wall
switch(cluster.facing) {
case NORTH:
tileX = (cluster.max_coord.x - itemFramePosition.x);
break;
case EAST:
tileX = (cluster.max_coord.z - itemFramePosition.z);
break;
case SOUTH:
tileX = (itemFramePosition.x - cluster.min_coord.x);
break;
case WEST:
tileX = (itemFramePosition.z - cluster.min_coord.z);
break;
default:
tileX = 0;
break;
}
tileY = cluster.max_coord.y - itemFramePosition.y;
}
newMapUUID = new MapUUID(mapUUID, tileX, tileY);
} else {
newMapUUID = new MapUUID(mapUUID, 0, 0);
}
if (lastMapUUID == null || !lastMapUUID.getUUID().equals(mapUUID)) {
// Map item UUID changed entirely. Remove the previous and add the new.
remove();
lastMapUUID = newMapUUID;
needsItemRefresh.set(sentMapInfoToPlayers && !newMapUUID.equals(preReloadMapUUID));
preReloadMapUUID = null;
add();
} else if (newMapUUID.equals(lastMapUUID)) {
// No change occurred
} else if (this.displayInfo != null) {
// Tile coordinates of this map were changed
// Ensure the new tile coordinates are added
this.displayInfo.addTileIfMissing(newMapUUID.getTileX(), newMapUUID.getTileY());
// Refresh state now so that removeTileIfMissing works correctly
int oldTileX = lastMapUUID.getTileX();
int oldTileY = lastMapUUID.getTileY();
lastMapUUID = newMapUUID;
needsItemRefresh.set(sentMapInfoToPlayers);
preReloadMapUUID = null;
// If the previous coordinates are now no longer used, remove the tile
this.displayInfo.removeTileIfMissing(oldTileX, oldTileY);
} else {
// Tile coordinates changed, but we had no previous display info
// Strange.
lastMapUUID = newMapUUID;
needsItemRefresh.set(sentMapInfoToPlayers);
preReloadMapUUID = null;
}
}
Aggregations