Add feature patch hook for overrides
This commit is contained in:
@@ -3,6 +3,7 @@ package org.bukkit.craftbukkit;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.mojang.serialization.Codec;
|
||||
import io.papermc.paper.FeatureHooks;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
@@ -56,7 +57,7 @@ public class CraftChunk implements Chunk {
|
||||
private final ServerLevel worldServer;
|
||||
private final int x;
|
||||
private final int z;
|
||||
private static final PalettedContainer<net.minecraft.world.level.block.state.BlockState> emptyBlockIDs = new PalettedContainer<>(net.minecraft.world.level.block.Block.BLOCK_STATE_REGISTRY, Blocks.AIR.defaultBlockState(), PalettedContainer.Strategy.SECTION_STATES);
|
||||
private static final PalettedContainer<net.minecraft.world.level.block.state.BlockState> emptyBlockIDs = FeatureHooks.emptyPalettedBlockContainer();
|
||||
private static final byte[] FULL_LIGHT = new byte[2048];
|
||||
private static final byte[] EMPTY_LIGHT = new byte[2048];
|
||||
|
||||
|
||||
@@ -2718,7 +2718,7 @@ public final class CraftServer implements Server {
|
||||
public ChunkGenerator.ChunkData createChunkData(World world) {
|
||||
Preconditions.checkArgument(world != null, "World cannot be null");
|
||||
ServerLevel handle = ((CraftWorld) world).getHandle();
|
||||
return new OldCraftChunkData(world.getMinHeight(), world.getMaxHeight(), handle.registryAccess().lookupOrThrow(Registries.BIOME));
|
||||
return new OldCraftChunkData(world.getMinHeight(), world.getMaxHeight(), handle.registryAccess().lookupOrThrow(Registries.BIOME), world);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import io.papermc.paper.FeatureHooks;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
|
||||
@@ -511,12 +512,7 @@ public class CraftWorld extends CraftRegionAccessor implements World {
|
||||
List<ServerPlayer> playersInRange = playerChunk.playerProvider.getPlayers(playerChunk.getPos(), false);
|
||||
if (playersInRange.isEmpty()) return;
|
||||
|
||||
ClientboundLevelChunkWithLightPacket refreshPacket = new ClientboundLevelChunkWithLightPacket(chunk, this.world.getLightEngine(), null, null);
|
||||
for (ServerPlayer player : playersInRange) {
|
||||
if (player.connection == null) continue;
|
||||
|
||||
player.connection.send(refreshPacket);
|
||||
}
|
||||
FeatureHooks.sendChunkRefreshPackets(playersInRange, chunk);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.google.common.io.BaseEncoding;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.papermc.paper.FeatureHooks;
|
||||
import it.unimi.dsi.fastutil.shorts.ShortArraySet;
|
||||
import it.unimi.dsi.fastutil.shorts.ShortSet;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
@@ -3489,27 +3490,19 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
||||
@Override
|
||||
public Set<java.lang.Long> getSentChunkKeys() {
|
||||
org.spigotmc.AsyncCatcher.catchOp("accessing sent chunks");
|
||||
final it.unimi.dsi.fastutil.longs.LongOpenHashSet keys = new it.unimi.dsi.fastutil.longs.LongOpenHashSet();
|
||||
this.getHandle().getChunkTrackingView().forEach(pos -> keys.add(pos.longKey));
|
||||
return it.unimi.dsi.fastutil.longs.LongSets.unmodifiable(keys);
|
||||
return FeatureHooks.getSentChunkKeys(this.getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<org.bukkit.Chunk> getSentChunks() {
|
||||
org.spigotmc.AsyncCatcher.catchOp("accessing sent chunks");
|
||||
final it.unimi.dsi.fastutil.objects.ObjectOpenHashSet<org.bukkit.Chunk> chunks = new it.unimi.dsi.fastutil.objects.ObjectOpenHashSet<>();
|
||||
final org.bukkit.World world = this.getWorld();
|
||||
this.getHandle().getChunkTrackingView().forEach(pos -> {
|
||||
final org.bukkit.Chunk chunk = world.getChunkAt(pos.longKey);
|
||||
chunks.add(chunk);
|
||||
});
|
||||
return it.unimi.dsi.fastutil.objects.ObjectSets.unmodifiable(chunks);
|
||||
return FeatureHooks.getSentChunks(this.getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkSent(final long chunkKey) {
|
||||
org.spigotmc.AsyncCatcher.catchOp("accessing sent chunks");
|
||||
return this.getHandle().getChunkTrackingView().contains(new net.minecraft.world.level.ChunkPos(chunkKey));
|
||||
return FeatureHooks.isChunkSent(this.getHandle(), chunkKey);
|
||||
}
|
||||
// Paper end
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.bukkit.craftbukkit.generator;
|
||||
|
||||
import io.papermc.paper.FeatureHooks;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import net.minecraft.core.BlockPos;
|
||||
@@ -27,8 +28,15 @@ public final class OldCraftChunkData implements ChunkGenerator.ChunkData {
|
||||
private final Registry<net.minecraft.world.level.biome.Biome> biomes;
|
||||
private Set<BlockPos> tiles;
|
||||
private final Set<BlockPos> lights = new HashSet<>();
|
||||
private final org.bukkit.World world;
|
||||
|
||||
@Deprecated @io.papermc.paper.annotation.DoNotUse
|
||||
public OldCraftChunkData(int minHeight, int maxHeight, Registry<net.minecraft.world.level.biome.Biome> biomes) {
|
||||
this(minHeight, maxHeight, biomes, null);
|
||||
}
|
||||
|
||||
public OldCraftChunkData(int minHeight, int maxHeight, Registry<net.minecraft.world.level.biome.Biome> biomes, org.bukkit.World world) {
|
||||
this.world = world;
|
||||
this.minHeight = minHeight;
|
||||
this.maxHeight = maxHeight;
|
||||
this.biomes = biomes;
|
||||
@@ -176,7 +184,7 @@ public final class OldCraftChunkData implements ChunkGenerator.ChunkData {
|
||||
int offset = (y - this.minHeight) >> 4;
|
||||
LevelChunkSection section = this.sections[offset];
|
||||
if (create && section == null) {
|
||||
this.sections[offset] = section = new LevelChunkSection(this.biomes);
|
||||
this.sections[offset] = section = FeatureHooks.createSection(this.biomes, this.world instanceof org.bukkit.craftbukkit.CraftWorld ? ((org.bukkit.craftbukkit.CraftWorld) this.world).getHandle() : null, null, offset + (this.minHeight >> 4)); // Paper - Anti-Xray - Add parameters
|
||||
}
|
||||
return section;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.bukkit.map.MapCursor;
|
||||
|
||||
public class RenderData {
|
||||
|
||||
public final byte[] buffer;
|
||||
public byte[] buffer;
|
||||
public final ArrayList<MapCursor> cursors;
|
||||
|
||||
public RenderData() {
|
||||
|
||||
Reference in New Issue
Block a user