Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-08 04:20:06 +01:00
Removed the regeneration code for the Sponge platform
Dieser Commit ist enthalten in:
Ursprung
de0da7d3e9
Commit
23f2930aad
@ -121,112 +121,6 @@ public class SpongeNMSWorld extends SpongeWorld {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T, K> K getFieldValue(Class<T> clazz, T object, String feildName, Class<K> valueClazz) {
|
|
||||||
try {
|
|
||||||
Field field = clazz.getDeclaredField(feildName); // Found in the MCP Mappings
|
|
||||||
field.setAccessible(true);
|
|
||||||
|
|
||||||
return valueClazz.cast(field.get(object));
|
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
||||||
System.out.println("Exception while modifying inaccessible variable: " + e.getMessage());
|
|
||||||
}
|
|
||||||
throw new IllegalStateException("Invalid variable state");
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
|
||||||
public boolean regenerate(Region region, EditSession editSession) {
|
|
||||||
BaseBlock[] history = new BaseBlock[256 * (getMaxY() + 1)];
|
|
||||||
|
|
||||||
IChunkProvider provider = ((net.minecraft.world.World) getWorld()).getChunkProvider();
|
|
||||||
if (!(provider instanceof ChunkProviderServer)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ChunkProviderServer chunkServer = (ChunkProviderServer) provider;
|
|
||||||
|
|
||||||
IChunkProvider chunkProvider = getFieldValue(
|
|
||||||
ChunkProviderServer.class,
|
|
||||||
chunkServer,
|
|
||||||
"field_73246_d", // serverChunkGenerator
|
|
||||||
IChunkProvider.class
|
|
||||||
);
|
|
||||||
|
|
||||||
Set droppedChunksSet = getFieldValue(
|
|
||||||
ChunkProviderServer.class,
|
|
||||||
chunkServer,
|
|
||||||
"field_73248_b", // droppedChunksSet,
|
|
||||||
Set.class
|
|
||||||
);
|
|
||||||
|
|
||||||
LongHashMap id2ChunkMap = getFieldValue(
|
|
||||||
ChunkProviderServer.class,
|
|
||||||
chunkServer,
|
|
||||||
"field_73244_f", // id2ChunkMap
|
|
||||||
LongHashMap.class
|
|
||||||
);
|
|
||||||
|
|
||||||
List loadedChunks = getFieldValue(
|
|
||||||
ChunkProviderServer.class,
|
|
||||||
chunkServer,
|
|
||||||
"field_73245_g", // loadedChunks
|
|
||||||
List.class
|
|
||||||
);
|
|
||||||
|
|
||||||
for (Vector2D chunk : region.getChunks()) {
|
|
||||||
Vector min = new Vector(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
|
|
||||||
|
|
||||||
for (int x = 0; x < 16; x++) {
|
|
||||||
for (int y = 0; y < getMaxY() + 1; y++) {
|
|
||||||
for (int z = 0; z < 16; z++) {
|
|
||||||
Vector pt = min.add(x, y, z);
|
|
||||||
int index = y * 16 * 16 + z * 16 + x;
|
|
||||||
history[index] = editSession.getBlock(pt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Set<Vector2D> chunks = region.getChunks();
|
|
||||||
for (Vector2D coord : chunks) {
|
|
||||||
long pos = ChunkCoordIntPair.chunkXZ2Int(coord.getBlockX(), coord.getBlockZ());
|
|
||||||
Chunk mcChunk;
|
|
||||||
if (chunkServer.chunkExists(coord.getBlockX(), coord.getBlockZ())) {
|
|
||||||
mcChunk = chunkServer.loadChunk(coord.getBlockX(), coord.getBlockZ());
|
|
||||||
mcChunk.onChunkUnload();
|
|
||||||
}
|
|
||||||
droppedChunksSet.remove(pos);
|
|
||||||
id2ChunkMap.remove(pos);
|
|
||||||
mcChunk = chunkProvider.provideChunk(coord.getBlockX(), coord.getBlockZ());
|
|
||||||
id2ChunkMap.add(pos, mcChunk);
|
|
||||||
loadedChunks.add(mcChunk);
|
|
||||||
if (mcChunk != null) {
|
|
||||||
mcChunk.onChunkLoad();
|
|
||||||
mcChunk.populateChunk(chunkProvider, chunkProvider, coord.getBlockX(), coord.getBlockZ());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Throwable t) {
|
|
||||||
logger.log(Level.WARNING, "Failed to generate chunk", t);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int x = 0; x < 16; x++) {
|
|
||||||
for (int y = 0; y < getMaxY() + 1; y++) {
|
|
||||||
for (int z = 0; z < 16; z++) {
|
|
||||||
Vector pt = min.add(x, y, z);
|
|
||||||
int index = y * 16 * 16 + z * 16 + x;
|
|
||||||
|
|
||||||
if (!region.contains(pt))
|
|
||||||
editSession.smartSetBlock(pt, history[index]);
|
|
||||||
else {
|
|
||||||
editSession.rememberChange(pt, history[index], editSession.rawGetBlock(pt));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static WorldGenerator createWorldGenerator(TreeGenerator.TreeType type) {
|
private static WorldGenerator createWorldGenerator(TreeGenerator.TreeType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -22,6 +22,7 @@ package com.sk89q.worldedit.sponge;
|
|||||||
import com.flowpowered.math.vector.Vector3d;
|
import com.flowpowered.math.vector.Vector3d;
|
||||||
import com.flowpowered.math.vector.Vector3i;
|
import com.flowpowered.math.vector.Vector3i;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.Vector2D;
|
import com.sk89q.worldedit.Vector2D;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
@ -154,6 +155,11 @@ public abstract class SpongeWorld extends AbstractWorld {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean regenerate(Region region, EditSession editSession) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBlockLightLevel(Vector position) {
|
public int getBlockLightLevel(Vector position) {
|
||||||
checkNotNull(position);
|
checkNotNull(position);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren