use of org.spongepowered.common.interfaces.IMixinChunk in project SpongeCommon by SpongePowered.
the class MixinWorld_Tracker method setCreator.
@Override
public void setCreator(int x, int y, int z, @Nullable UUID uuid) {
final Chunk chunk = ((IMixinChunkProviderServer) this.chunkProvider).getLoadedChunkWithoutMarkingActive(x >> 4, z >> 4);
if (chunk == null) {
return;
}
BlockPos pos = new BlockPos(x, y, z);
((IMixinChunk) chunk).setBlockCreator(pos, uuid);
}
use of org.spongepowered.common.interfaces.IMixinChunk in project SpongeCommon by SpongePowered.
the class MixinWorld_Tracker method getCreator.
@Override
public Optional<UUID> getCreator(int x, int y, int z) {
final Chunk chunk = ((IMixinChunkProviderServer) this.chunkProvider).getLoadedChunkWithoutMarkingActive(x >> 4, z >> 4);
if (chunk == null) {
return Optional.empty();
}
BlockPos pos = new BlockPos(x, y, z);
// blocks changing with potentially n block notifiers and n block owners.
return ((IMixinChunk) chunk).getBlockOwnerUUID(pos);
}
use of org.spongepowered.common.interfaces.IMixinChunk in project SpongeCommon by SpongePowered.
the class MixinWorld_Tracker method getNotifier.
@Override
public Optional<UUID> getNotifier(int x, int y, int z) {
final Chunk chunk = ((IMixinChunkProviderServer) this.chunkProvider).getLoadedChunkWithoutMarkingActive(x >> 4, z >> 4);
if (chunk == null) {
return Optional.empty();
}
BlockPos pos = new BlockPos(x, y, z);
// blocks changing with potentially n block notifiers and n block owners.
return ((IMixinChunk) chunk).getBlockNotifierUUID(pos);
}
use of org.spongepowered.common.interfaces.IMixinChunk in project SpongeCommon by SpongePowered.
the class SpongeMessageHandler method handleRequest.
public static void handleRequest(MessageTrackerDataRequest message, RemoteConnection connection, Platform.Type side) {
if (!(connection instanceof PlayerConnection)) {
return;
}
Player player = ((PlayerConnection) connection).getPlayer();
if (!player.hasPermission("sponge.debug.block-tracking")) {
return;
}
EntityPlayerMP sender = (EntityPlayerMP) player;
BlockPos pos = new BlockPos(message.x, message.y, message.z);
if (!sender.world.isBlockLoaded(pos)) {
return;
}
String ownerName;
String notifierName;
Optional<User> owner = Optional.empty();
Optional<User> notifier = Optional.empty();
if (message.type == 0) {
// block
IMixinChunk spongeChunk = (IMixinChunk) sender.world.getChunkFromBlockCoords(pos);
owner = spongeChunk.getBlockOwner(pos);
notifier = spongeChunk.getBlockNotifier(pos);
} else if (message.type == 1) {
// entity
Entity entity = sender.world.getEntityByID(message.entityId);
if (entity != null) {
IMixinEntity spongeEntity = (IMixinEntity) entity;
owner = spongeEntity.getCreatorUser();
notifier = spongeEntity.getNotifierUser();
}
}
ownerName = owner.map(User::getName).orElse("");
notifierName = notifier.map(User::getName).orElse("");
channel.sendTo(player, new MessageTrackerDataResponse(ownerName, notifierName));
}
use of org.spongepowered.common.interfaces.IMixinChunk in project SpongeCommon by SpongePowered.
the class MixinWorld method getIntersectingEntities.
private Set<EntityHit> getIntersectingEntities(Vector3d start, double yDirection, double distance, Predicate<EntityHit> filter) {
final Set<EntityHit> intersecting = new HashSet<>();
// Current chunk
final Vector3d direction = yDirection < 0 ? Vector3d.UNIT_Y.negate() : Vector3d.UNIT_Y;
final double endY = start.getY() + yDirection * distance;
final Vector3i chunkPos = SpongeChunkLayout.instance.forceToChunk(start.toInt());
((IMixinChunk) getChunk(chunkPos).get()).getIntersectingEntities(start, direction, distance, filter, start.getY(), endY, intersecting);
// Check adjacent chunks if near them
final int nearDistance = 2;
// Neighbour -x chunk
final Vector3i chunkBlockPos = SpongeChunkLayout.instance.forceToWorld(chunkPos);
if (start.getX() - chunkBlockPos.getX() <= nearDistance) {
((IMixinChunk) getChunk(chunkPos.add(-1, 0, 0)).get()).getIntersectingEntities(start, direction, distance, filter, start.getY(), endY, intersecting);
}
// Neighbour -z chunk
if (start.getZ() - chunkBlockPos.getZ() <= nearDistance) {
((IMixinChunk) getChunk(chunkPos.add(0, 0, -1)).get()).getIntersectingEntities(start, direction, distance, filter, start.getY(), endY, intersecting);
}
// Neighbour +x chunk
final int chunkWidth = SpongeChunkLayout.CHUNK_SIZE.getX();
if (chunkBlockPos.getX() + chunkWidth - start.getX() <= nearDistance) {
((IMixinChunk) getChunk(chunkPos.add(1, 0, 0)).get()).getIntersectingEntities(start, direction, distance, filter, start.getY(), endY, intersecting);
}
// Neighbour +z chunk
if (chunkBlockPos.getZ() + chunkWidth - start.getZ() <= nearDistance) {
((IMixinChunk) getChunk(chunkPos.add(0, 0, 1)).get()).getIntersectingEntities(start, direction, distance, filter, start.getY(), endY, intersecting);
}
return intersecting;
}
Aggregations