3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-12-25 10:30:04 +01:00

Lighting and Database changes

Dieser Commit ist enthalten in:
MattBDev 2020-02-18 17:21:09 -05:00
Ursprung 175b3a93ce
Commit 39dfc2444b
22 geänderte Dateien mit 93 neuen und 285 gelöschten Zeilen

Datei anzeigen

@ -7,7 +7,6 @@ import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.changeset.DiskStorageHistory;
import com.boydti.fawe.object.changeset.SimpleChangeSetSummary;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.extent.LightingExtent;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.EditSessionBuilder;
import com.boydti.fawe.util.MainUtil;
@ -113,28 +112,7 @@ public class FaweAPI {
// if (parser != null) parser.register(methods);
// return parser != null;
// }
public static <T> T getParser(Class<T> parserClass) {
try {
Field field = AbstractFactory.class.getDeclaredField("parsers");
field.setAccessible(true);
ArrayList<InputParser> parsers = new ArrayList<>();
parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getMaskFactory()));
parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getBlockFactory()));
parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getItemFactory()));
parsers.addAll((List<InputParser>) field.get(WorldEdit.getInstance().getPatternFactory()));
for (InputParser parser : parsers) {
if (parserClass.isAssignableFrom(parser.getClass())) {
return (T) parser;
}
}
return null;
} catch (Throwable e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
/**
* You can either use a IQueueExtent or an EditSession to change blocks<br>
* - The IQueueExtent skips a bit of overhead so it's marginally faster<br>
@ -399,30 +377,30 @@ public class FaweAPI {
* @return
*/
public static int fixLighting(World world, Region selection, @Nullable IQueueExtent queue) {
final BlockVector3 bot = selection.getMinimumPoint();
final BlockVector3 top = selection.getMaximumPoint();
final int minX = bot.getBlockX() >> 4;
final int minZ = bot.getBlockZ() >> 4;
final int maxX = top.getBlockX() >> 4;
final int maxZ = top.getBlockZ() >> 4;
int count = 0;
if (queue == null) queue = createQueue(world, false);
// Remove existing lighting first
if (queue instanceof LightingExtent) {
LightingExtent relighter = (LightingExtent) queue;
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
relighter.relightChunk(x, z);
count++;
}
}
} else {
throw new UnsupportedOperationException("Queue is not " + LightingExtent.class);
}
return count;
// final BlockVector3 bot = selection.getMinimumPoint();
// final BlockVector3 top = selection.getMaximumPoint();
//
// final int minX = bot.getBlockX() >> 4;
// final int minZ = bot.getBlockZ() >> 4;
//
// final int maxX = top.getBlockX() >> 4;
// final int maxZ = top.getBlockZ() >> 4;
//
// int count = 0;
// if (queue == null) queue = createQueue(world, false);
// // Remove existing lighting first
// if (queue instanceof LightingExtent) {
// LightingExtent relighter = (LightingExtent) queue;
// for (int x = minX; x <= maxX; x++) {
// for (int z = minZ; z <= maxZ; z++) {
// relighter.relightChunk(x, z);
// count++;
// }
// }
// } else {
// throw new UnsupportedOperationException("Queue is not " + LightingExtent.class);
// }
return 0;
}
/**

Datei anzeigen

@ -1,48 +1,25 @@
package com.boydti.fawe.database;
package com.boydti.fawe.database
import com.boydti.fawe.config.Config;
import com.sk89q.worldedit.world.World;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.boydti.fawe.config.Config
import com.sk89q.worldedit.world.World
import org.slf4j.LoggerFactory
import java.util.concurrent.ConcurrentHashMap
public class DBHandler {
private final Logger log = LoggerFactory.getLogger(Config.class);
public final static DBHandler IMP = new DBHandler();
private Map<String, RollbackDatabase> databases = new ConcurrentHashMap<>(8, 0.9f, 1);
public RollbackDatabase getDatabase(World world) {
String worldName = world.getName();
RollbackDatabase database = databases.get(worldName);
if (database != null) {
return database;
}
try {
database = new RollbackDatabase(world);
databases.put(worldName, database);
return database;
} catch (Throwable e) {
log.error("No JDBC driver found!\n TODO: Bundle driver with FAWE (or disable database)", e);
return null;
}
object DBHandler {
private val log = LoggerFactory.getLogger(Config::class.java)
private val databases: MutableMap<String, RollbackDatabase> = ConcurrentHashMap(8, 0.9f, 1)
fun getDatabase(world: World): RollbackDatabase? {
val worldName = world.name
var database = databases[worldName]
return database
?: try {
database = RollbackDatabase(world)
databases[worldName] = database
database
} catch (e: Throwable) {
log.error("No JDBC driver found!\n TODO: Bundle driver with FAWE (or disable database)", e)
null
}
}
public RollbackDatabase getDatabase(String world) {
RollbackDatabase database = databases.get(world);
if (database != null) {
return database;
}
try {
database = new RollbackDatabase(world);
databases.put(world, database);
return database;
} catch (Throwable e) {
e.printStackTrace();
return null;
}
}
}

Datei anzeigen

@ -1,7 +1,6 @@
package com.boydti.fawe.database;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.logging.rollback.RollbackOptimizedHistory;
import com.boydti.fawe.object.collection.YieldIterable;
@ -40,26 +39,22 @@ public class RollbackDatabase extends AsyncNotifyQueue {
private final World world;
private Connection connection;
private @Language("sql") String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS `{0}edits` (`player` BLOB(16) NOT NULL,`id` INT NOT NULL, `time` INT NOT NULL,`x1` INT NOT NULL,`x2` INT NOT NULL,`z1` INT NOT NULL,`z2` INT NOT NULL,`y1` INT NOT NULL, `y2` INT NOT NULL, `size` INT NOT NULL, `command` VARCHAR, PRIMARY KEY (player, id))";
private @Language("sql") String UPDATE_TABLE1 = "ALTER TABLE `{0}edits` ADD COLUMN `command` VARCHAR";
private @Language("sql") String UPDATE_TABLE2 = "alter table `{0}edits` add size int default 0 not null";
private @Language("sql") String INSERT_EDIT = "INSERT OR REPLACE INTO `{0}edits` (`player`,`id`,`time`,`x1`,`x2`,`z1`,`z2`,`y1`,`y2`,`command`,`size`) VALUES(?,?,?,?,?,?,?,?,?,?,?)";
private @Language("sql") String PURGE = "DELETE FROM `{0}edits` WHERE `time`<?";
private @Language("sql") String GET_EDITS_USER = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` DESC, `id` DESC";
private @Language("sql") String GET_EDITS_USER_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` ASC, `id` ASC";
private @Language("sql") String GET_EDITS = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` DESC, `id` DESC";
private @Language("sql") String GET_EDITS_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` , `id` ";
private @Language("sql") String GET_EDIT_USER = "SELECT * FROM `{0}edits` WHERE `player`=? AND `id`=?";
private @Language("SQLite") String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS `{0}edits` (`player` BLOB(16) NOT NULL,`id` INT NOT NULL, `time` INT NOT NULL,`x1` INT NOT NULL,`x2` INT NOT NULL,`z1` INT NOT NULL,`z2` INT NOT NULL,`y1` INT NOT NULL, `y2` INT NOT NULL, `size` INT NOT NULL, `command` VARCHAR, PRIMARY KEY (player, id))";
private @Language("SQLite") String UPDATE_TABLE1 = "ALTER TABLE `{0}edits` ADD COLUMN `command` VARCHAR";
private @Language("SQLite") String UPDATE_TABLE2 = "alter table `{0}edits` add size int default 0 not null";
private @Language("SQLite") String INSERT_EDIT = "INSERT OR REPLACE INTO `{0}edits` (`player`,`id`,`time`,`x1`,`x2`,`z1`,`z2`,`y1`,`y2`,`command`,`size`) VALUES(?,?,?,?,?,?,?,?,?,?,?)";
private @Language("SQLite") String PURGE = "DELETE FROM `{0}edits` WHERE `time`<?";
private @Language("SQLite") String GET_EDITS_USER = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` DESC, `id` DESC";
private @Language("SQLite") String GET_EDITS_USER_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? AND `player`=? ORDER BY `time` ASC, `id` ASC";
private @Language("SQLite") String GET_EDITS = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` DESC, `id` DESC";
private @Language("SQLite") String GET_EDITS_ASC = "SELECT * FROM `{0}edits` WHERE `time`>? AND `x2`>=? AND `x1`<=? AND `z2`>=? AND `z1`<=? AND `y2`>=? AND `y1`<=? ORDER BY `time` , `id` ";
private @Language("SQLite") String GET_EDIT_USER = "SELECT * FROM `{0}edits` WHERE `player`=? AND `id`=?";
private @Language("sql") String DELETE_EDITS_USER = "DELETE FROM `{0}edits` WHERE `player`=? AND `time`>? AND `x2`>=? AND `x1`<=? AND `y2`>=? AND `y1`<=? AND `z2`>=? AND `z1`<=?";
private @Language("sql") String DELETE_EDIT_USER = "DELETE FROM `{0}edits` WHERE `player`=? AND `id`=?";
private @Language("SQLite") String DELETE_EDITS_USER = "DELETE FROM `{0}edits` WHERE `player`=? AND `time`>? AND `x2`>=? AND `x1`<=? AND `y2`>=? AND `y1`<=? AND `z2`>=? AND `z1`<=?";
private @Language("SQLite") String DELETE_EDIT_USER = "DELETE FROM `{0}edits` WHERE `player`=? AND `id`=?";
private ConcurrentLinkedQueue<RollbackOptimizedHistory> historyChanges = new ConcurrentLinkedQueue<>();
public RollbackDatabase(String world) throws SQLException, ClassNotFoundException {
this(FaweAPI.getWorld(world));
}
public RollbackDatabase(World world) throws SQLException, ClassNotFoundException {
super((t, e) -> e.printStackTrace());
this.prefix = "";

Datei anzeigen

@ -96,7 +96,7 @@ public class RollbackOptimizedHistory extends DiskStorageHistory {
public void close() throws IOException {
super.close();
// Save to DB
RollbackDatabase db = DBHandler.IMP.getDatabase(getWorld());
RollbackDatabase db = DBHandler.INSTANCE.getDatabase(getWorld());
if (db != null) {
db.logEdit(this);
}

Datei anzeigen

@ -77,7 +77,7 @@ public class InspectBrush extends BrushTool implements DoubleActionTraceTool {
final int y = target.getBlockY();
final int z = target.getBlockZ();
World world = player.getWorld();
RollbackDatabase db = DBHandler.IMP.getDatabase(world);
RollbackDatabase db = DBHandler.INSTANCE.getDatabase(world);
System.out.println("World " + world.getName());
int count = 0;
for (Supplier<RollbackOptimizedHistory> supplier : db.getEdits(target, false)) {

Datei anzeigen

@ -121,10 +121,9 @@ public class DiskStorageHistory extends FaweStreamChangeSet {
@Override
public void delete() {
// Fawe.debug("Deleting history: " + getWorld().getName() + "/" + uuid + "/" + index);
deleteFiles();
if (Settings.IMP.HISTORY.USE_DATABASE) {
RollbackDatabase db = DBHandler.IMP.getDatabase(getWorld());
RollbackDatabase db = DBHandler.INSTANCE.getDatabase(getWorld());
db.delete(uuid, index);
}
}

Datei anzeigen

@ -133,61 +133,6 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
return super.getBlock(position);
}
@Override
public int getBlockLight(int x, int y, int z) {
if (!contains(x, y, z)) {
if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
}
return 0;
}
return super.getBlockLight(x, y, z);
}
@Override
public int getBrightness(int x, int y, int z) {
if (!contains(x, y, z)) {
if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
}
return 0;
}
return super.getBrightness(x, y, z);
}
@Override
public int getLight(int x, int y, int z) {
if (!contains(x, y, z)) {
if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
}
return 0;
}
return super.getLight(x, y, z);
}
@Override
public int getOpacity(int x, int y, int z) {
if (!contains(x, y, z)) {
if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
}
return 0;
}
return super.getOpacity(x, y, z);
}
@Override
public int getSkyLight(int x, int y, int z) {
if (!contains(x, y, z)) {
if (!limit.MAX_FAILS()) {
WEManager.IMP.cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
}
return 0;
}
return super.getSkyLight(x, y, z);
}
@Nullable
@Override
public Entity createEntity(Location location, BaseEntity entity) {

Datei anzeigen

@ -1,17 +0,0 @@
package com.boydti.fawe.object.extent;
import com.sk89q.worldedit.extent.Extent;
public interface LightingExtent extends Extent {
int getLight(int x, int y, int z);
int getSkyLight(int x, int y, int z);
int getBlockLight(int x, int y, int z);
int getOpacity(int x, int y, int z);
int getBrightness(int x, int y, int z);
public void relightChunk(int chunkX, int chunkZ);
}

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.mask;
import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.math.BlockVector3;
@ -17,10 +16,10 @@ public class BlockLightMask extends AbstractExtentMask {
@Override
public boolean test(Extent extent, BlockVector3 vector) {
if (extent instanceof LightingExtent) {
int light = ((LightingExtent) extent).getBlockLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max;
}
// if (extent instanceof LightingExtent) {
// int light = ((LightingExtent) extent).getBlockLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
// return light >= min && light <= max;
// }
return false;
}

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.mask;
import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.math.BlockVector3;
@ -17,10 +16,10 @@ public class BrightnessMask extends AbstractExtentMask {
@Override
public boolean test(Extent extent, BlockVector3 vector) {
if (extent instanceof LightingExtent) {
int light = ((LightingExtent) extent).getBrightness(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max;
}
// if (extent instanceof LightingExtent) {
// int light = ((LightingExtent) extent).getBrightness(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
// return light >= min && light <= max;
// }
return false;
}

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.mask;
import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.math.BlockVector3;
@ -17,10 +16,10 @@ public class LightMask extends AbstractExtentMask {
@Override
public boolean test(Extent extent, BlockVector3 vector) {
if (extent instanceof LightingExtent) {
int light = ((LightingExtent) extent).getLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max;
}
// if (extent instanceof LightingExtent) {
// int light = ((LightingExtent) extent).getLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
// return light >= min && light <= max;
// }
return false;
}

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.mask;
import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.math.BlockVector3;
@ -17,10 +16,10 @@ public class OpacityMask extends AbstractExtentMask {
@Override
public boolean test(Extent extent, BlockVector3 vector) {
if (extent instanceof LightingExtent) {
int light = ((LightingExtent) extent).getOpacity(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max;
}
// if (extent instanceof LightingExtent) {
// int light = ((LightingExtent) extent).getOpacity(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
// return light >= min && light <= max;
// }
return false;
}

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.mask;
import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.math.BlockVector3;
@ -18,11 +17,11 @@ public class SkyLightMask extends AbstractExtentMask {
@Override
public boolean test(Extent extent, BlockVector3 vector) {
if (extent instanceof LightingExtent) {
int light = ((LightingExtent) extent)
.getSkyLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
return light >= min && light <= max;
}
// if (extent instanceof LightingExtent) {
// int light = ((LightingExtent) extent)
// .getSkyLight(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
// return light >= min && light <= max;
// }
return false;
}

Datei anzeigen

@ -4,9 +4,6 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractMask;
import com.sk89q.worldedit.math.BlockVector3;
/**
* Restricts the
*/
public class XAxisMask extends AbstractMask implements ResettableMask {
private transient int layer = -1;

Datei anzeigen

@ -4,9 +4,6 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractMask;
import com.sk89q.worldedit.math.BlockVector3;
/**
* Restricts the
*/
public class YAxisMask extends AbstractMask implements ResettableMask {
private transient int layer = -1;

Datei anzeigen

@ -4,9 +4,6 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractMask;
import com.sk89q.worldedit.math.BlockVector3;
/**
* Restricts the
*/
public class ZAxisMask extends AbstractMask implements ResettableMask {
private transient int layer = -1;

Datei anzeigen

@ -12,6 +12,6 @@ public class ChatProgressTracker extends DefaultProgressTracker {
@Override
public void sendTile(Component title, Component sub) {
getPlayer().print(TextComponent.builder().append(title).append("\n").append(sub).build());
getPlayer().print(TextComponent.builder().append(title).append(TextComponent.newline()).append(sub).build());
}
}

Datei anzeigen

@ -15,11 +15,12 @@ import com.sk89q.worldedit.regions.AbstractRegion;
import com.sk89q.worldedit.regions.RegionOperationException;
import com.sk89q.worldedit.world.World;
import java.util.Iterator;
import org.jetbrains.annotations.NotNull;
public class FuzzyRegion extends AbstractRegion {
private final Mask mask;
private BlockVectorSet set = new BlockVectorSet();
private final BlockVectorSet set = new BlockVectorSet();
private int minX, minY, minZ, maxX, maxY, maxZ;
private Extent extent;
@ -44,24 +45,22 @@ public class FuzzyRegion extends AbstractRegion {
}
public void select(int x, int y, int z) {
RecursiveVisitor search = new RecursiveVisitor(mask.withExtent(extent), new RegionFunction() {
@Override
public boolean apply(BlockVector3 p) throws WorldEditException {
setMinMax(p.getBlockX(), p.getBlockY(), p.getBlockZ());
return true;
}
RecursiveVisitor search = new RecursiveVisitor(mask.withExtent(extent), p -> {
setMinMax(p.getBlockX(), p.getBlockY(), p.getBlockZ());
return true;
}, 256);
search.setVisited(set);
search.visit(BlockVector3.at(x, y, z));
Operations.completeBlindly(search);
}
@NotNull
@Override
public Iterator<BlockVector3> iterator() {
return set.iterator();
}
private final void setMinMax(int x, int y, int z) {
private void setMinMax(int x, int y, int z) {
if (x > maxX) {
maxX = x;
}

Datei anzeigen

@ -179,7 +179,7 @@ public class HistorySubCommands {
BlockVector3
.at(summary.maxX, 255, summary.maxZ));
rollback.setTime(historyFile.lastModified());
RollbackDatabase db = DBHandler.IMP
RollbackDatabase db = DBHandler.INSTANCE
.getDatabase(world);
db.logEdit(rollback);
actor.print("Logging: " + historyFile);

Datei anzeigen

@ -81,7 +81,7 @@ public class ProvideBindings extends Bindings {
@Binding
public RollbackDatabase database(World world) {
return DBHandler.IMP.getDatabase(world);
return DBHandler.INSTANCE.getDatabase(world);
}
@AllowedRegion(FaweMaskManager.MaskType.OWNER)

Datei anzeigen

@ -26,7 +26,6 @@ import com.boydti.fawe.beta.IBatchProcessor;
import com.boydti.fawe.object.HistoryExtent;
import com.boydti.fawe.object.changeset.AbstractChangeSet;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.object.extent.LightingExtent;
import com.boydti.fawe.util.ExtentTraverser;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEditException;
@ -52,7 +51,7 @@ import org.jetbrains.annotations.Range;
/**
* A base class for {@link Extent}s that merely passes extents onto another.
*/
public class AbstractDelegateExtent implements Extent, LightingExtent {
public class AbstractDelegateExtent implements Extent {
private final Extent extent;
@ -200,55 +199,7 @@ public class AbstractDelegateExtent implements Extent, LightingExtent {
public boolean setBiome(BlockVector2 position, BiomeType biome) {
return extent.setBiome(position.getX(), 0, position.getZ(), biome);
}
@Override
public int getSkyLight(int x, int y, int z) {
if (extent instanceof LightingExtent) {
return ((LightingExtent) extent).getSkyLight(x, y, z);
}
return 0;
}
@Override
public int getBlockLight(int x, int y, int z) {
if (extent instanceof LightingExtent) {
return ((LightingExtent) extent).getBlockLight(x, y, z);
}
return getBrightness(x, y, z);
}
@Override
public int getOpacity(int x, int y, int z) {
if (extent instanceof LightingExtent) {
return ((LightingExtent) extent).getOpacity(x, y, z);
}
return getBlock(x, y, z).getBlockType().getMaterial().getLightOpacity();
}
@Override
public int getLight(int x, int y, int z) {
if (extent instanceof LightingExtent) {
return ((LightingExtent) extent).getLight(x, y, z);
}
return 0;
}
@Override
public int getBrightness(int x, int y, int z) {
if (extent instanceof LightingExtent) {
return ((LightingExtent) extent).getBrightness(x, y, z);
}
return getBlock(x, y, z).getBlockType().getMaterial().getLightValue();
}
@Override
public void relightChunk(int chunkX, int chunkZ) {
if (extent instanceof LightingExtent) {
((LightingExtent) extent).relightChunk(chunkX, chunkZ);
} else {
throw new UnsupportedOperationException("Cannot relight");
}
}
@Override
public String toString() {
return super.toString() + ":" + (extent == this ? "" : extent.toString());

Datei anzeigen

@ -22,7 +22,6 @@ package com.sk89q.worldedit.world;
import com.boydti.fawe.beta.IChunkGet;
import com.boydti.fawe.beta.implementation.packet.ChunkPacket;
import com.boydti.fawe.beta.IChunkCache;
import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEditException;
@ -134,10 +133,6 @@ public interface World extends Extent, Keyed, IChunkCache<IChunkGet> {
* @return the light level (0-15)
*/
default int getBlockLightLevel(BlockVector3 position) {
if (this instanceof LightingExtent) {
LightingExtent extent = (LightingExtent) this;
return extent.getBlockLight(position.getX(), position.getY(), position.getZ());
}
return getBlock(position).getMaterial().getLightValue();
}