use of net.minecraft.server.level.ServerLevel in project SpongeCommon by SpongePowered.
the class NotifyClientEffect method processSideEffect.
@Override
public EffectResult processSideEffect(final BlockPipeline pipeline, final PipelineCursor oldState, final BlockState newState, final SpongeBlockChangeFlag flag, final int limit) {
final LevelChunk chunk = pipeline.getAffectedChunk();
final ServerLevel world = pipeline.getServerWorld();
// if ((flags & 2) != 0 && (!this.isClientSide || (flags & 4) == 0) && (this.isClientSide || chunk.getLocationType() != null && chunk.getLocationType().isAtLeast(ChunkHolder.LocationType.TICKING))) {
if (flag.notifyClients() && (chunk.getFullStatus().isOrAfter(ChunkHolder.FullChunkStatus.TICKING))) {
// this.notifyBlockUpdate(pos, blockstate, newWorldState, flags);
world.sendBlockUpdated(oldState.pos, oldState.state, newState, flag.getRawFlag());
}
return EffectResult.NULL_PASS;
}
use of net.minecraft.server.level.ServerLevel in project SpongeCommon by SpongePowered.
the class UpdateConnectingBlocksEffect method processSideEffect.
@Override
public EffectResult processSideEffect(final BlockPipeline pipeline, final PipelineCursor oldState, final BlockState newState, final SpongeBlockChangeFlag flag, final int limit) {
final ServerLevel world = pipeline.getServerWorld();
final BlockPos pos = oldState.pos;
if (flag.updateNeighboringShapes() && limit > 0) {
// int i = p_241211_3_ & -34; // Vanilla negates 34 to flip neighbor notification and and "state drops"
final int withoutNeighborDropsAndNestedNeighborUpdates = flag.asNestedNeighborUpdates().getRawFlag();
// blockstate.updateIndirectNeighbourShapes(this, p_241211_1_, i, p_241211_4_ - 1);
oldState.state.updateIndirectNeighbourShapes(world, pos, withoutNeighborDropsAndNestedNeighborUpdates, limit - 1);
// p_241211_2_.updateNeighbourShapes(this, p_241211_1_, i, p_241211_4_ - 1);
newState.updateNeighbourShapes(world, pos, withoutNeighborDropsAndNestedNeighborUpdates, limit - 1);
// p_241211_2_.updateIndirectNeighbourShapes(this, p_241211_1_, i, p_241211_4_ - 1);
newState.updateIndirectNeighbourShapes(world, pos, withoutNeighborDropsAndNestedNeighborUpdates, limit - 1);
}
return EffectResult.NULL_PASS;
}
use of net.minecraft.server.level.ServerLevel in project SpongeCommon by SpongePowered.
the class SpawnDestructBlocksEffect method processSideEffect.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public EffectResult processSideEffect(final BlockPipeline pipeline, final PipelineCursor oldState, final BlockState newState, final SpongeBlockChangeFlag flag, final int limit) {
final ServerLevel world = pipeline.getServerWorld();
final BlockPos pos = oldState.pos;
final List<ItemStack> drops = oldState.drops;
drops.forEach(drop -> Block.popResource(world, pos, drop));
return EffectResult.NULL_PASS;
}
use of net.minecraft.server.level.ServerLevel in project SpongeCommon by SpongePowered.
the class SpongeMapStorage method mapInfo.
@Override
public Optional<MapInfo> mapInfo(final UUID uuid) {
this.ensureHasMapUUIDIndex();
final MapInfo mapInfo = this.loadedMapUUIDs.get(uuid);
if (mapInfo != null) {
return Optional.of(mapInfo);
}
final Integer mapId = this.mapIdUUIDIndex.inverse().get(uuid);
if (mapId == null) {
return Optional.empty();
}
final ServerLevel defaultWorld = (ServerLevel) Sponge.server().worldManager().defaultWorld();
final MapInfo loadedMapInfo = (MapInfo) defaultWorld.getMapData(Constants.Map.MAP_PREFIX + mapId);
return Optional.ofNullable(loadedMapInfo);
}
use of net.minecraft.server.level.ServerLevel in project SpongeCommon by SpongePowered.
the class SpongeMapStorage method allMapInfos.
@Override
public Collection<MapInfo> allMapInfos() {
final Set<MapInfo> mapInfos = new HashSet<>();
final ServerLevel defaultWorld = (ServerLevel) Sponge.server().worldManager().defaultWorld();
final int highestId = ((MapIdTrackerBridge) defaultWorld.getDataStorage().computeIfAbsent(MapIndex::new, Constants.Map.MAP_INDEX_DATA_NAME)).bridge$getHighestMapId().orElse(-1);
for (int i = 0; i <= highestId; i++) {
@Nullable final MapInfo mapInfo = (MapInfo) defaultWorld.getMapData(Constants.Map.MAP_PREFIX + i);
if (mapInfo == null) {
SpongeCommon.logger().warn("Missing map with id: " + i);
continue;
}
this.addMapInfo(mapInfo);
mapInfos.add(mapInfo);
}
return mapInfos;
}
Aggregations