use of org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer in project SpongeCommon by SpongePowered.
the class SpongeTeleportHelper method getSafeLocation.
@Override
public Optional<Location<World>> getSafeLocation(Location<World> location, int height, int width, int distanceToDrop, TeleportHelperFilter filter, TeleportHelperFilter... additionalFilters) {
final World world = location.getExtent();
final Set<TeleportHelperFilter> filters = Sets.newHashSet(additionalFilters);
filters.add(filter);
if (SpongeImpl.getGlobalConfig().getConfig().getTeleportHelper().isForceBlacklistOn()) {
// Always force this into the set if the user has requested it.
filters.add(TeleportHelperFilters.CONFIG);
}
IMixinChunkProviderServer chunkProviderServer = (IMixinChunkProviderServer) ((net.minecraft.world.WorldServer) world).getChunkProvider();
chunkProviderServer.setForceChunkRequests(true);
try {
// Get the vectors to check, and get the block types with them.
// The vectors should be sorted by distance from the centre of the checking region, so
// this makes it easier to try to get close, because we can just iterate and get progressively further out.
Optional<Vector3i> result = getSafeLocation(world, getBlockLocations(location, height, width), distanceToDrop, filters);
return result.map(vector3i -> new Location<>(world, vector3i.toDouble().add(0.5, 0, 0.5)));
} finally {
// Just in case some exception occurs, we want this to disable again.
chunkProviderServer.setForceChunkRequests(false);
}
}
use of org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer in project SpongeCommon by SpongePowered.
the class MixinChunk_Async_Lighting method onRelightChecksGetBlockState.
@Redirect(method = "enqueueRelightChecks", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlockState(Lnet/minecraft/util/math/BlockPos;)Lnet/minecraft/block/state/IBlockState;"))
private IBlockState onRelightChecksGetBlockState(World world, BlockPos pos) {
Chunk chunk = ((IMixinChunkProviderServer) world.getChunkProvider()).getLoadedChunkWithoutMarkingActive(pos.getX() >> 4, pos.getZ() >> 4);
final IMixinChunk spongeChunk = (IMixinChunk) chunk;
if (chunk == null || chunk.unloadQueued || !spongeChunk.areNeighborsLoaded()) {
return Blocks.AIR.getDefaultState();
}
return chunk.getBlockState(pos);
}
use of org.spongepowered.common.interfaces.world.gen.IMixinChunkProviderServer 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.world.gen.IMixinChunkProviderServer 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.world.gen.IMixinChunkProviderServer 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);
}
Aggregations