Fix forge multiworld
Add NMS setLight (sky/block)
Fix clipboard on disk start index
Fix cmd block data
This commit is contained in:
Jesse Boyd 2016-07-25 08:25:07 +10:00
parent d562b6cf66
commit 4bde477206
30 changed files with 470 additions and 90 deletions

View File

@ -30,9 +30,9 @@ import org.bukkit.event.world.WorldInitEvent;
public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMappedFaweQueue<World, CHUNK, CHUNKSECTIONS, SECTION> implements Listener {
public Object adapter;
public Method methodToNative;
public Method methodFromNative;
public static Object adapter;
public static Method methodToNative;
public static Method methodFromNative;
public BukkitQueue_0(final String world) {
super(world);
@ -51,16 +51,6 @@ public abstract class BukkitQueue_0<CHUNK, CHUNKSECTIONS, SECTION> extends NMSMa
return false;
}
@Override
public int getEmmittedLight(CHUNKSECTIONS sections, int x, int y, int z) {
return 0;
}
@Override
public int getSkyLight(CHUNKSECTIONS sections, int x, int y, int z) {
return 15;
}
@Override
public void relight(int x, int y, int z) {}

View File

@ -5,6 +5,7 @@ import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.util.TaskManager;
import com.sk89q.jnbt.CompoundTag;
import org.bukkit.Chunk;
import org.bukkit.World;
@ -23,6 +24,16 @@ public class BukkitQueue_All extends BukkitQueue_0<Chunk, Chunk, Chunk> {
}
}
@Override
public void setSkyLight(int x, int y, int z, int value) {
}
@Override
public void setBlockLight(int x, int y, int z, int value) {
}
public int getCombinedId4Data(Chunk section, int x, int y, int z) {
Block block = ((Chunk) section).getBlock(x & 15, y, z & 15);
int combined = block.getTypeId() << 4;
@ -32,6 +43,45 @@ public class BukkitQueue_All extends BukkitQueue_0<Chunk, Chunk, Chunk> {
return combined;
}
@Override
public int getEmmittedLight(final Chunk chunk, int x, int y, int z) {
if (!chunk.isLoaded()) {
TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override
public void run(Object value) {
chunk.load(true);
}
});
}
return chunk.getBlock(x, y, z).getLightFromBlocks();
}
@Override
public int getSkyLight(final Chunk chunk, int x, int y, int z) {
if (!chunk.isLoaded()) {
TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override
public void run(Object value) {
chunk.load(true);
}
});
}
return chunk.getBlock(x, y, z).getLightFromSky();
}
@Override
public int getLight(final Chunk chunk, int x, int y, int z) {
if (!chunk.isLoaded()) {
TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override
public void run(Object value) {
chunk.load(true);
}
});
}
return chunk.getBlock(x, y, z).getLightLevel();
}
@Override
public boolean fixLighting(FaweChunk<?> fc, RelightMode mode) {
return false;

View File

@ -36,6 +36,7 @@ import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Blocks;
import net.minecraft.server.v1_10_R1.ChunkCoordIntPair;
import net.minecraft.server.v1_10_R1.ChunkSection;
import net.minecraft.server.v1_10_R1.DataBits;
import net.minecraft.server.v1_10_R1.DataPaletteBlock;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityHuman;
@ -77,25 +78,78 @@ import org.bukkit.generator.ChunkGenerator;
public class BukkitQueue_1_10 extends BukkitQueue_0<Chunk, ChunkSection[], DataPaletteBlock> {
private IBlockData air;
private static IBlockData air;
private static Field fieldBits;
public BukkitQueue_1_10(final String world) {
super(world);
checkVersion("v1_10_R1");
try {
Field fieldAir = DataPaletteBlock.class.getDeclaredField("a");
fieldAir.setAccessible(true);
air = (IBlockData) fieldAir.get(null);
if (adapter == null) {
setupAdapter(new com.boydti.fawe.bukkit.v1_10.FaweAdapter_1_10());
Fawe.debug("Using adapter: " + adapter);
Fawe.debug("=========================================");
if (adapter == null) {
try {
Field fieldAir = DataPaletteBlock.class.getDeclaredField("a");
fieldAir.setAccessible(true);
air = (IBlockData) fieldAir.get(null);
fieldBits = DataPaletteBlock.class.getDeclaredField("b");
fieldBits.setAccessible(true);
if (adapter == null) {
setupAdapter(new com.boydti.fawe.bukkit.v1_10.FaweAdapter_1_10());
Fawe.debug("Using adapter: " + adapter);
Fawe.debug("=========================================");
}
} catch (Throwable e) {
throw new RuntimeException(e);
}
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
@Override
public void setSkyLight(int x, int y, int z, int value) {
int cx = x >> 4;
int cz = z >> 4;
if (!ensureChunkLoaded(cx, cz)) {
return;
}
ChunkSection[] sections = getCachedSections(getWorld(), cx, cz);
ChunkSection section = sections[y >> 4];
if (section == null) {
return;
}
section.getSkyLightArray().a(x & 15, y & 15, z & 15, value);
}
@Override
public void setBlockLight(int x, int y, int z, int value) {
int cx = x >> 4;
int cz = z >> 4;
if (!ensureChunkLoaded(cx, cz)) {
return;
}
ChunkSection[] sections = getCachedSections(getWorld(), cx, cz);
ChunkSection section = sections[y >> 4];
if (section == null) {
return;
}
section.getEmittedLightArray().a(x & 15, y & 15, z & 15, value);
}
private DataBits lastBits;
private DataPaletteBlock lastBlocks;
@Override
public boolean hasBlock(DataPaletteBlock dataPaletteBlock, int x, int y, int z) {
try {
if (lastBlocks != dataPaletteBlock) {
lastBits = (DataBits) fieldBits.get(dataPaletteBlock);
lastBlocks = dataPaletteBlock;
}
int i = FaweCache.CACHE_J[y][x & 15][z & 15];
return lastBits.a(i) != 0;
} catch (IllegalAccessException e) {
e.printStackTrace();
}
return false;
}
@Override
public World createWorld(final WorldCreator creator) {
final String name = creator.name();

View File

@ -673,4 +673,34 @@ public class BukkitQueue17 extends BukkitQueue_0<Chunk, ChunkSection[], ChunkSec
}
};
}
@Override
public void setSkyLight(int x, int y, int z, int value) {
int cx = x >> 4;
int cz = z >> 4;
if (!ensureChunkLoaded(cx, cz)) {
return;
}
ChunkSection[] sections = getCachedSections(getWorld(), cx, cz);
ChunkSection section = sections[y >> 4];
if (section == null) {
return;
}
section.getSkyLightArray().a(x & 15, y & 15, z & 15, value);
}
@Override
public void setBlockLight(int x, int y, int z, int value) {
int cx = x >> 4;
int cz = z >> 4;
if (!ensureChunkLoaded(cx, cz)) {
return;
}
ChunkSection[] sections = getCachedSections(getWorld(), cx, cz);
ChunkSection section = sections[y >> 4];
if (section == null) {
return;
}
section.getEmittedLightArray().a(x & 15, y & 15, z & 15, value);
}
}

View File

@ -659,4 +659,34 @@ public class BukkitQueue18R3 extends BukkitQueue_0<Chunk, ChunkSection[], char[]
}
};
}
@Override
public void setSkyLight(int x, int y, int z, int value) {
int cx = x >> 4;
int cz = z >> 4;
if (!ensureChunkLoaded(cx, cz)) {
return;
}
ChunkSection[] sections = getCachedSections(getWorld(), cx, cz);
ChunkSection section = sections[y >> 4];
if (section == null) {
return;
}
section.getSkyLightArray().a(x & 15, y & 15, z & 15, value);
}
@Override
public void setBlockLight(int x, int y, int z, int value) {
int cx = x >> 4;
int cz = z >> 4;
if (!ensureChunkLoaded(cx, cz)) {
return;
}
ChunkSection[] sections = getCachedSections(getWorld(), cx, cz);
ChunkSection section = sections[y >> 4];
if (section == null) {
return;
}
section.getEmittedLightArray().a(x & 15, y & 15, z & 15, value);
}
}

View File

@ -791,4 +791,34 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0<Chunk, ChunkSection[], Dat
public FaweChunk getFaweChunk(int x, int z) {
return new BukkitChunk_1_9(this, x, z);
}
@Override
public void setSkyLight(int x, int y, int z, int value) {
int cx = x >> 4;
int cz = z >> 4;
if (!ensureChunkLoaded(cx, cz)) {
return;
}
ChunkSection[] sections = getCachedSections(getWorld(), cx, cz);
ChunkSection section = sections[y >> 4];
if (section == null) {
return;
}
section.getSkyLightArray().a(x & 15, y & 15, z & 15, value);
}
@Override
public void setBlockLight(int x, int y, int z, int value) {
int cx = x >> 4;
int cz = z >> 4;
if (!ensureChunkLoaded(cx, cz)) {
return;
}
ChunkSection[] sections = getCachedSections(getWorld(), cx, cz);
ChunkSection section = sections[y >> 4];
if (section == null) {
return;
}
section.getEmittedLightArray().a(x & 15, y & 15, z & 15, value);
}
}

View File

@ -114,11 +114,17 @@ public class FaweAPI {
}
public static World getWorld(String worldName) {
for (World current : WorldEdit.getInstance().getServer().getWorlds()) {
List<? extends World> worlds = WorldEdit.getInstance().getServer().getWorlds();
for (World current : worlds) {
if (Fawe.imp().getWorldName(current).equals(worldName)) {
return WorldWrapper.wrap((AbstractWorld) current);
}
}
for (World current : worlds) {
if (current.getName().equals(worldName)) {
return WorldWrapper.wrap((AbstractWorld) current);
}
}
return null;
}

View File

@ -439,7 +439,6 @@ public class FaweCache {
case 129:
case 133:
case 138:
case 137:
case 140:
case 165:
case 166:

View File

@ -102,8 +102,8 @@ public enum BBC {
VISITOR_ENTITY("%s0 entities affected", "WorldEdit.Visitor"),
VISITOR_FLAT("%s0 columns affected", "WorldEdit.Visitor"),
SELECTOR_CUBOID_POS1("First position set to %s0 %s1.", "WorldEdit.Selector"),
SELECTOR_CUBOID_POS2("Second position set to %s0 %s1.", "WorldEdit.Selector"),
SELECTOR_CUBOID_POS1("pos1 set to %s0 %s1.", "WorldEdit.Selector"),
SELECTOR_CUBOID_POS2("pos2 set to %s0 %s1.", "WorldEdit.Selector"),
SELECTOR_INVALID_COORDINATES("Invalid coordinates %s0", "WorldEdit.Selector"),
SELECTOR_ALREADY_SET("Position already set.", "WorldEdit.Selector"),

View File

@ -135,7 +135,7 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
long pair = (long) (cx) << 32 | (cz) & 0xFFFFFFFFL;
lastWrappedChunk = this.blocks.get(pair);
if (lastWrappedChunk == null) {
lastWrappedChunk = this.getFaweChunk(x >> 4, z >> 4);
lastWrappedChunk = this.getFaweChunk(cx, cz);
lastWrappedChunk.setBlock(x & 15, y, z & 15, id, data);
FaweChunk previous = this.blocks.put(pair, lastWrappedChunk);
if (previous == null) {
@ -386,31 +386,64 @@ public abstract class MappedFaweQueue<WORLD, CHUNK, SECTION> extends FaweQueue {
long average = 0;
@Override
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
if (y < 0 || y > 255) {
return 0;
public boolean ensureChunkLoaded(int cx, int cz) throws FaweException.FaweChunkLoadException {
if (!isChunkLoaded(cx, cz)) {
boolean sync = Thread.currentThread() == Fawe.get().getMainThread();
if (sync) {
loadChunk(getWorld(), cx, cz, true);
} else if (Settings.HISTORY.CHUNK_WAIT_MS > 0) {
loadChunk.value = new IntegerPair(cx, cz);
TaskManager.IMP.sync(loadChunk, Settings.HISTORY.CHUNK_WAIT_MS);
if (!isChunkLoaded(cx, cz)) {
throw new FaweException.FaweChunkLoadException();
}
} else {
return false;
}
}
return true;
}
@Override
public boolean hasBlock(int x, int y, int z) throws FaweException.FaweChunkLoadException {
int cx = x >> 4;
int cz = z >> 4;
int cy = y >> 4;
if (cx != lastChunkX || cz != lastChunkZ) {
lastChunkX = cx;
lastChunkZ = cz;
if (!isChunkLoaded(cx, cz)) {
long start = System.currentTimeMillis();
boolean sync = Thread.currentThread() == Fawe.get().getMainThread();
if (sync) {
loadChunk(getWorld(), cx, cz, true);
} else if (Settings.HISTORY.CHUNK_WAIT_MS > 0) {
loadChunk.value = new IntegerPair(cx, cz);
TaskManager.IMP.sync(loadChunk, Settings.HISTORY.CHUNK_WAIT_MS);
if (!isChunkLoaded(cx, cz)) {
throw new FaweException.FaweChunkLoadException();
}
} else {
return 0;
}
if (!ensureChunkLoaded(cx, cz)) {
return false;
}
lastChunkSections = getCachedSections(getWorld(), cx, cz);
lastSection = getCachedSection(lastChunkSections, cy);
} else if (cy != lastChunkY) {
if (lastChunkSections == null) {
return false;
}
lastSection = getCachedSection(lastChunkSections, cy);
}
if (lastSection == null) {
return false;
}
return hasBlock(lastSection, x, y, z);
}
public boolean hasBlock(SECTION section, int x, int y, int z) {
return getCombinedId4Data(lastSection, x, y, z) != 0;
}
@Override
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
int cx = x >> 4;
int cz = z >> 4;
int cy = y >> 4;
if (cx != lastChunkX || cz != lastChunkZ) {
lastChunkX = cx;
lastChunkZ = cz;
if (!ensureChunkLoaded(cx, cz)) {
return 0;
}
lastChunkSections = getCachedSections(getWorld(), cx, cz);
lastSection = getCachedSection(lastChunkSections, cy);

View File

@ -97,6 +97,10 @@ public abstract class NMSMappedFaweQueue<WORLD, CHUNK, CHUNKSECTION, SECTION> ex
public abstract void relight(int x, int y, int z);
public abstract void setSkyLight(int x, int y, int z, int value);
public abstract void setBlockLight(int x, int y, int z, int value);
public abstract int getSkyLight(CHUNKSECTION sections, int x, int y, int z);
public abstract int getEmmittedLight(CHUNKSECTION sections, int x, int y, int z);

View File

@ -39,6 +39,11 @@ public class FaweLocation {
return FaweAPI.getWorld(world);
}
@Override
public String toString() {
return world + "," + x + "," + y + "," + z;
}
@Override
public int hashCode() {
return this.x << (8 + this.z) << (4 + this.y);

View File

@ -115,7 +115,7 @@ public abstract class FawePlayer<T> {
String currentWorldName = getLocation().world;
World world = getWorld();
if (world != null) {
if (world.getName().equals(currentWorldName)) {
if (Fawe.imp().getWorldName(world).equals(currentWorldName)) {
getSession().clearHistory();
loadSessionsFromDisk(world);
}
@ -176,7 +176,7 @@ public abstract class FawePlayer<T> {
final long start = System.currentTimeMillis();
final UUID uuid = getUUID();
final List<Integer> editIds = new ArrayList<>();
final File folder = new File(Fawe.imp().getDirectory(), "history" + File.separator + world.getName() + File.separator + uuid);
final File folder = new File(Fawe.imp().getDirectory(), "history" + File.separator + Fawe.imp().getWorldName(world) + File.separator + uuid);
if (folder.isDirectory()) {
for (File file : folder.listFiles()) {
if (file.getName().endsWith(".bd")) {

View File

@ -202,6 +202,10 @@ public abstract class FaweQueue {
public abstract void addNotifyTask(Runnable runnable);
public boolean hasBlock(int x, int y, int z) throws FaweException.FaweChunkLoadException {
return getCombinedId4Data(x, y, z) != 0;
}
public abstract int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException;
public abstract CompoundTag getTileEntity(int x, int y, int z) throws FaweException.FaweChunkLoadException;

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.object.brush;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper;
import com.boydti.fawe.wrappers.PlayerWrapper;
@ -33,7 +34,7 @@ public class CommandBrush implements Brush {
String replaced = command.replace("{x}", position.getBlockX() + "")
.replace("{y}", position.getBlockY() + "")
.replace("{z}", position.getBlockZ() + "")
.replace("{world}", editSession.getWorld().getName() + "")
.replace("{world}", Fawe.imp().getWorldName(editSession.getWorld()) + "")
.replace("{size}", radius + "");
WorldVectorFace face = player.getBlockTraceFace(256, true);

View File

@ -73,7 +73,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
public DiskStorageHistory(World world, UUID uuid) {
super(world);
String base = "history" + File.separator + world.getName() + File.separator + uuid;
String base = "history" + File.separator + Fawe.imp().getWorldName(world) + File.separator + uuid;
File folder = new File(Fawe.imp().getDirectory(), base);
int max = 0;
if (folder.exists()) {
@ -97,7 +97,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
private void init(UUID uuid, int i) {
this.uuid = uuid;
String base = "history" + File.separator + getWorld().getName() + File.separator + uuid;
String base = "history" + File.separator + Fawe.imp().getWorldName(getWorld()) + File.separator + uuid;
base += File.separator + i;
nbtfFile = new File(Fawe.imp().getDirectory(), base + ".nbtf");
nbttFile = new File(Fawe.imp().getDirectory(), base + ".nbtt");

View File

@ -112,7 +112,10 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet {
@Override
public InputStream getBlockIS() throws IOException {
FaweInputStream result = ids == null ? null : MainUtil.getCompressedIS(new ByteArrayInputStream(ids));
if (ids == null) {
return null;
}
FaweInputStream result = MainUtil.getCompressedIS(new ByteArrayInputStream(ids));
result.skip(FaweStreamChangeSet.HEADER_SIZE);
return result;
}

View File

@ -54,7 +54,7 @@ public class SchematicWriter implements ClipboardWriter {
int x = -1;
int y = 0;
int z = 0;
int index = 0;
int index = -1;
public int[] yarea;
public int[] zwidth;

View File

@ -111,7 +111,12 @@ public class FaweForge implements IFawe {
if (world instanceof WorldWrapper) {
world = ((WorldWrapper) world).getParent();
}
return ((ForgeWorld) world).getWorld().getWorldInfo().getWorldName();
return getWorldName(((ForgeWorld) world).getWorld());
}
public String getWorldName(net.minecraft.world.World w) {
return w.getWorldInfo().getWorldName() + ";" + w.provider.getDimension();
}
@Override

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.forge;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLocation;
@ -66,7 +67,7 @@ public class ForgePlayer extends FawePlayer<EntityPlayerMP> {
public FaweLocation getLocation() {
World world = parent.worldObj;
BlockPos pos = parent.getPosition();
return new FaweLocation(world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ());
return new FaweLocation(Fawe.<FaweForge>imp().getWorldName(world), pos.getX(), pos.getY(), pos.getZ());
}
@Override

View File

@ -55,7 +55,7 @@ import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import net.minecraft.world.gen.ChunkProviderServer;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.common.DimensionManager;
public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlockStorage[], BlockStateContainer> {
@ -687,12 +687,42 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override
public World getImpWorld() {
WorldServer[] worlds = FMLCommonHandler.instance().getMinecraftServerInstance().worldServers;
for (WorldServer ws : worlds) {
if (ws.getWorldInfo().getWorldName().equals(getWorldName())) {
return nmsWorld = ws;
}
if (nmsWorld != null) {
return nmsWorld;
}
return null;
String[] split = getWorldName().split(";");
int id = Integer.parseInt(split[split.length - 1]);
nmsWorld = DimensionManager.getWorld(id);
return nmsWorld;
}
@Override
public void setSkyLight(int x, int y, int z, int value) {
int cx = x >> 4;
int cz = z >> 4;
if (!ensureChunkLoaded(cx, cz)) {
return;
}
ExtendedBlockStorage[] sections = getCachedSections(getWorld(), cx, cz);
ExtendedBlockStorage section = sections[y >> 4];
if (section == null) {
return;
}
section.getSkylightArray().set(x & 15, y & 15, z & 15, value);
}
@Override
public void setBlockLight(int x, int y, int z, int value) {
int cx = x >> 4;
int cz = z >> 4;
if (!ensureChunkLoaded(cx, cz)) {
return;
}
ExtendedBlockStorage[] sections = getCachedSections(getWorld(), cx, cz);
ExtendedBlockStorage section = sections[y >> 4];
if (section == null) {
return;
}
section.getBlocklightArray().set(x & 15, y & 15, z & 15, value);
}
}

View File

@ -108,7 +108,12 @@ public class FaweForge implements IFawe {
if (world instanceof WorldWrapper) {
world = ((WorldWrapper) world).getParent();
}
return ((ForgeWorld) world).getWorld().provider.getDimensionName();
return getWorldName(((ForgeWorld) world).getWorld());
}
public String getWorldName(net.minecraft.world.World w) {
return w.getWorldInfo().getWorldName() + ";" + w.provider.dimensionId;
}
@Override

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.forge;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLocation;
@ -68,7 +69,7 @@ public class ForgePlayer extends FawePlayer<EntityPlayerMP> {
public FaweLocation getLocation() {
World world = parent.worldObj;
ChunkCoordinates pos = parent.getPlayerCoordinates();
return new FaweLocation(world.provider.getDimensionName(), pos.posX, pos.posY, pos.posZ);
return new FaweLocation(Fawe.<FaweForge>imp().getWorldName(world), pos.posX, pos.posY, pos.posZ);
}
@Override

View File

@ -37,7 +37,6 @@ import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.S13PacketDestroyEntities;
import net.minecraft.network.play.server.S21PacketChunkData;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.management.PlayerManager;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IntHashMap;
@ -51,6 +50,7 @@ import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import net.minecraft.world.gen.ChunkProviderServer;
import net.minecraftforge.common.DimensionManager;
public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlockStorage[], ExtendedBlockStorage> {
@ -680,12 +680,41 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override
public World getImpWorld() {
WorldServer[] worlds = MinecraftServer.getServer().worldServers;
for (WorldServer ws : worlds) {
if (ws.provider.getDimensionName().equals(getWorldName())) {
return nmsWorld = ws;
}
if (nmsWorld != null) {
return nmsWorld;
}
return null;
String[] split = getWorldName().split(";");
int id = Integer.parseInt(split[split.length - 1]);
return nmsWorld = DimensionManager.getWorld(id);
}
@Override
public void setSkyLight(int x, int y, int z, int value) {
int cx = x >> 4;
int cz = z >> 4;
if (!ensureChunkLoaded(cx, cz)) {
return;
}
ExtendedBlockStorage[] sections = getCachedSections(getWorld(), cx, cz);
ExtendedBlockStorage section = sections[y >> 4];
if (section == null) {
return;
}
section.getSkylightArray().set(x & 15, y & 15, z & 15, value);
}
@Override
public void setBlockLight(int x, int y, int z, int value) {
int cx = x >> 4;
int cz = z >> 4;
if (!ensureChunkLoaded(cx, cz)) {
return;
}
ExtendedBlockStorage[] sections = getCachedSections(getWorld(), cx, cz);
ExtendedBlockStorage section = sections[y >> 4];
if (section == null) {
return;
}
section.getBlocklightArray().set(x & 15, y & 15, z & 15, value);
}
}

View File

@ -111,7 +111,12 @@ public class FaweForge implements IFawe {
if (world instanceof WorldWrapper) {
world = ((WorldWrapper) world).getParent();
}
return ((ForgeWorld) world).getWorld().provider.getDimensionName();
return getWorldName(((ForgeWorld) world).getWorld());
}
public String getWorldName(net.minecraft.world.World w) {
return w.getWorldInfo().getWorldName() + ";" + w.provider.getDimensionId();
}
@Override

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.forge;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLocation;
@ -69,7 +70,7 @@ public class ForgePlayer extends FawePlayer<EntityPlayerMP> {
public FaweLocation getLocation() {
World world = parent.worldObj;
BlockPos pos = parent.getPosition();
return new FaweLocation(world.provider.getDimensionName(), pos.getX(), pos.getY(), pos.getZ());
return new FaweLocation(Fawe.<FaweForge>imp().getWorldName(world), pos.getX(), pos.getY(), pos.getZ());
}
@Override

View File

@ -35,7 +35,6 @@ import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.play.server.S13PacketDestroyEntities;
import net.minecraft.network.play.server.S21PacketChunkData;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.management.PlayerManager;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockPos;
@ -49,6 +48,7 @@ import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import net.minecraft.world.gen.ChunkProviderServer;
import net.minecraftforge.common.DimensionManager;
public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlockStorage[], char[]> {
@ -643,12 +643,41 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override
public World getImpWorld() {
WorldServer[] worlds = MinecraftServer.getServer().worldServers;
for (WorldServer ws : worlds) {
if (ws.provider.getDimensionName().equals(getWorldName())) {
return nmsWorld = ws;
}
if (nmsWorld != null) {
return nmsWorld;
}
return null;
String[] split = getWorldName().split(";");
int id = Integer.parseInt(split[split.length - 1]);
return nmsWorld = DimensionManager.getWorld(id);
}
@Override
public void setSkyLight(int x, int y, int z, int value) {
int cx = x >> 4;
int cz = z >> 4;
if (!ensureChunkLoaded(cx, cz)) {
return;
}
ExtendedBlockStorage[] sections = getCachedSections(getWorld(), cx, cz);
ExtendedBlockStorage section = sections[y >> 4];
if (section == null) {
return;
}
section.getSkylightArray().set(x & 15, y & 15, z & 15, value);
}
@Override
public void setBlockLight(int x, int y, int z, int value) {
int cx = x >> 4;
int cz = z >> 4;
if (!ensureChunkLoaded(cx, cz)) {
return;
}
ExtendedBlockStorage[] sections = getCachedSections(getWorld(), cx, cz);
ExtendedBlockStorage section = sections[y >> 4];
if (section == null) {
return;
}
section.getBlocklightArray().set(x & 15, y & 15, z & 15, value);
}
}

View File

@ -111,7 +111,12 @@ public class FaweForge implements IFawe {
if (world instanceof WorldWrapper) {
world = ((WorldWrapper) world).getParent();
}
return ((ForgeWorld) world).getWorld().getWorldInfo().getWorldName();
return getWorldName(((ForgeWorld) world).getWorld());
}
public String getWorldName(net.minecraft.world.World w) {
return w.getWorldInfo().getWorldName() + ";" + w.provider.getDimension();
}
@Override

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.forge;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FaweLocation;
@ -68,7 +69,7 @@ public class ForgePlayer extends FawePlayer<EntityPlayerMP> {
public FaweLocation getLocation() {
World world = parent.worldObj;
BlockPos pos = parent.getPosition();
return new FaweLocation(world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ());
return new FaweLocation(Fawe.<FaweForge>imp().getWorldName(world), pos.getX(), pos.getY(), pos.getZ());
}
@Override

View File

@ -55,7 +55,7 @@ import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.chunk.NibbleArray;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import net.minecraft.world.gen.ChunkProviderServer;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.common.DimensionManager;
public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlockStorage[], BlockStateContainer> {
@ -687,12 +687,41 @@ public class ForgeQueue_All extends NMSMappedFaweQueue<World, Chunk, ExtendedBlo
@Override
public World getImpWorld() {
WorldServer[] worlds = FMLCommonHandler.instance().getMinecraftServerInstance().worldServers;
for (WorldServer ws : worlds) {
if (ws.getWorldInfo().getWorldName().equals(getWorldName())) {
return nmsWorld = ws;
}
if (nmsWorld != null) {
return nmsWorld;
}
return null;
String[] split = getWorldName().split(";");
int id = Integer.parseInt(split[split.length - 1]);
return nmsWorld = DimensionManager.getWorld(id);
}
@Override
public void setSkyLight(int x, int y, int z, int value) {
int cx = x >> 4;
int cz = z >> 4;
if (!ensureChunkLoaded(cx, cz)) {
return;
}
ExtendedBlockStorage[] sections = getCachedSections(getWorld(), cx, cz);
ExtendedBlockStorage section = sections[y >> 4];
if (section == null) {
return;
}
section.getSkylightArray().set(x & 15, y & 15, z & 15, value);
}
@Override
public void setBlockLight(int x, int y, int z, int value) {
int cx = x >> 4;
int cz = z >> 4;
if (!ensureChunkLoaded(cx, cz)) {
return;
}
ExtendedBlockStorage[] sections = getCachedSections(getWorld(), cx, cz);
ExtendedBlockStorage section = sections[y >> 4];
if (section == null) {
return;
}
section.getBlocklightArray().set(x & 15, y & 15, z & 15, value);
}
}