Skip to content

Commit cf06126

Browse files
committed
progress
1 parent 192ac89 commit cf06126

24 files changed

Lines changed: 6554 additions & 92 deletions

worldedit-bukkit/adapters/adapter-26.1/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ plugins {
66

77
dependencies {
88
// https://artifactory.papermc.io/ui/native/universe/io/papermc/paper/dev-bundle/
9-
the<PaperweightUserDependenciesExtension>().paperDevBundle("26.1.1.build.14-alpha")
9+
the<PaperweightUserDependenciesExtension>().paperDevBundle("26.1.1.build.20-alpha")
10+
compileOnly(libs.paperLib)
1011
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
package com.sk89q.worldedit.bukkit.adapter.impl.fawe.v26_1;
2+
3+
import com.fastasyncworldedit.core.util.MathMan;
4+
import com.sk89q.worldedit.bukkit.adapter.impl.fawe.v26_1.PaperweightChunkAccessProxy;
5+
import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap;
6+
import net.minecraft.core.BlockPos;
7+
import net.minecraft.core.Direction;
8+
import net.minecraft.core.Holder;
9+
import net.minecraft.core.SectionPos;
10+
import net.minecraft.core.particles.ParticleOptions;
11+
import net.minecraft.server.MinecraftServer;
12+
import net.minecraft.server.level.ServerLevel;
13+
import net.minecraft.sounds.SoundEvent;
14+
import net.minecraft.sounds.SoundSource;
15+
import net.minecraft.util.RandomSource;
16+
import net.minecraft.world.DifficultyInstance;
17+
import net.minecraft.world.entity.Entity;
18+
import net.minecraft.world.entity.player.Player;
19+
import net.minecraft.world.flag.FeatureFlagSet;
20+
import net.minecraft.world.level.biome.Biome;
21+
import net.minecraft.world.level.biome.BiomeManager;
22+
import net.minecraft.world.level.block.state.BlockState;
23+
import net.minecraft.world.level.border.WorldBorder;
24+
import net.minecraft.world.level.chunk.ChunkAccess;
25+
import net.minecraft.world.level.chunk.ChunkSource;
26+
import net.minecraft.world.level.chunk.status.ChunkStatus;
27+
import net.minecraft.world.level.lighting.LevelLightEngine;
28+
import net.minecraft.world.level.material.FluidState;
29+
import org.bukkit.craftbukkit.util.BlockStateListPopulator;
30+
import org.jetbrains.annotations.NotNull;
31+
32+
import javax.annotation.Nonnull;
33+
import javax.annotation.Nullable;
34+
import java.util.List;
35+
36+
public class FaweBlockStateListPopulator extends BlockStateListPopulator {
37+
38+
private final Long2ObjectOpenHashMap<PaperweightChunkAccessProxy> chunkProxies = new Long2ObjectOpenHashMap<>();
39+
private final ServerLevel world;
40+
41+
public FaweBlockStateListPopulator(ServerLevel world) {
42+
super(world);
43+
this.world = world;
44+
}
45+
46+
@Override
47+
public long getSeed() {
48+
return world.getSeed();
49+
}
50+
51+
@Override
52+
@Nonnull
53+
public ServerLevel getLevel() {
54+
return world.getLevel();
55+
}
56+
57+
@Override
58+
@Nonnull
59+
public DifficultyInstance getCurrentDifficultyAt(final BlockPos pos) {
60+
return world.getCurrentDifficultyAt(pos);
61+
}
62+
63+
@Override
64+
public MinecraftServer getServer() {
65+
return world.getServer();
66+
}
67+
68+
@Override
69+
@Nonnull
70+
public ChunkSource getChunkSource() {
71+
return world.getChunkSource();
72+
}
73+
74+
@Override
75+
@Nonnull
76+
public RandomSource getRandom() {
77+
return world.getRandom();
78+
}
79+
80+
@Override
81+
public void playSound(
82+
final Entity source,
83+
final BlockPos pos,
84+
final SoundEvent sound,
85+
final SoundSource category,
86+
final float volume,
87+
final float pitch
88+
) {
89+
// don't for now
90+
}
91+
92+
@Override
93+
public void addParticle(
94+
final ParticleOptions parameters,
95+
final double x,
96+
final double y,
97+
final double z,
98+
final double velocityX,
99+
final double velocityY,
100+
final double velocityZ
101+
) {
102+
// definitely don't
103+
}
104+
105+
@Override
106+
public @NotNull List<? extends Player> players() {
107+
return world.players();
108+
}
109+
110+
@Override
111+
public ChunkAccess getChunk(final int chunkX, final int chunkZ, final ChunkStatus leastStatus, final boolean create) {
112+
ChunkAccess worldChunk = world.getChunk(chunkX, chunkZ, leastStatus, create);
113+
PaperweightChunkAccessProxy proxy = chunkProxies.compute(
114+
MathMan.pairInt(chunkX, chunkZ),
115+
(k, v) -> v == null ? PaperweightChunkAccessProxy.getInstance() : v
116+
);
117+
proxy.parent = worldChunk;
118+
return proxy;
119+
}
120+
121+
@Override
122+
@Nonnull
123+
public BiomeManager getBiomeManager() {
124+
return world.getBiomeManager();
125+
}
126+
127+
@Override
128+
@Nonnull
129+
public Holder<Biome> getUncachedNoiseBiome(final int biomeX, final int biomeY, final int biomeZ) {
130+
return world.getUncachedNoiseBiome(biomeX, biomeY, biomeZ);
131+
}
132+
133+
@Override
134+
public int getSeaLevel() {
135+
return world.getSeaLevel();
136+
}
137+
138+
@Override
139+
public @Nonnull ChunkAccess getChunk(final @Nonnull BlockPos pos) {
140+
ChunkAccess worldChunk = world.getChunk(pos);
141+
PaperweightChunkAccessProxy proxy = chunkProxies.compute(
142+
MathMan.pairInt(SectionPos.blockToSectionCoord(pos.getX()), SectionPos.blockToSectionCoord(pos.getZ())),
143+
(k, v) -> v == null ? PaperweightChunkAccessProxy.getInstance() : v
144+
);
145+
proxy.parent = worldChunk;
146+
return proxy;
147+
}
148+
149+
@Override
150+
public @Nonnull ChunkAccess getChunk(final int chunkX, final int chunkZ) {
151+
ChunkAccess worldChunk = world.getChunk(chunkX, chunkZ);
152+
PaperweightChunkAccessProxy proxy = chunkProxies.compute(
153+
MathMan.pairInt(chunkX, chunkZ),
154+
(k, v) -> v == null ? PaperweightChunkAccessProxy.getInstance() : v
155+
);
156+
proxy.parent = worldChunk;
157+
return proxy;
158+
}
159+
160+
@Override
161+
public @Nonnull ChunkAccess getChunk(final int chunkX, final int chunkZ, final @Nonnull ChunkStatus chunkStatus) {
162+
ChunkAccess worldChunk = world.getChunk(chunkX, chunkZ, chunkStatus);
163+
PaperweightChunkAccessProxy proxy = chunkProxies.compute(
164+
MathMan.pairInt(chunkX, chunkZ),
165+
(k, v) -> v == null ? PaperweightChunkAccessProxy.getInstance() : v
166+
);
167+
proxy.parent = worldChunk;
168+
return proxy;
169+
}
170+
171+
@Override
172+
@Nonnull
173+
public FeatureFlagSet enabledFeatures() {
174+
return world.enabledFeatures();
175+
}
176+
177+
@Override
178+
@Nonnull
179+
public LevelLightEngine getLightEngine() {
180+
return world.getLightEngine();
181+
}
182+
183+
@Nullable
184+
@Override
185+
public ChunkAccess getChunkIfLoadedImmediately(final int x, final int z) {
186+
return world.getChunkIfLoadedImmediately(x, z);
187+
}
188+
189+
@Override
190+
public BlockState getBlockStateIfLoaded(final BlockPos blockposition) {
191+
return world.getBlockStateIfLoaded(blockposition);
192+
}
193+
194+
@Override
195+
public FluidState getFluidIfLoaded(final BlockPos blockposition) {
196+
return world.getFluidIfLoaded(blockposition);
197+
}
198+
199+
@Override
200+
@Nonnull
201+
public WorldBorder getWorldBorder() {
202+
return world.getWorldBorder();
203+
}
204+
205+
@Override
206+
public boolean setBlock(final BlockPos pos, final BlockState state, final int flags, final int maxUpdateDepth) {
207+
return world.setBlock(pos, state, flags, maxUpdateDepth);
208+
}
209+
210+
@Override
211+
public boolean removeBlock(final BlockPos pos, final boolean move) {
212+
return world.removeBlock(pos, move);
213+
}
214+
215+
@Override
216+
public boolean destroyBlock(final BlockPos pos, final boolean drop, final Entity breakingEntity, final int maxUpdateDepth) {
217+
return world.destroyBlock(pos, drop, breakingEntity, maxUpdateDepth);
218+
}
219+
220+
@Override
221+
@Nonnull
222+
public BlockState getBlockState(final BlockPos pos) {
223+
return world.getBlockState(pos);
224+
}
225+
226+
@Override
227+
public boolean setBlock(final BlockPos pos, final BlockState state, final int flags) {
228+
return world.setBlock(pos, state, flags);
229+
}
230+
231+
}

0 commit comments

Comments
 (0)