mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-05 04:26:42 +00:00
Remove hardcoding of world limits (#1199)
* Remove hardcoding of world limits - seems to be working fine without the datapack for world height changing - particular attention should be given to LocalBlockVectorSet and MathMan changes * update adapters * Override getMinY in various classes and ensure selections have a world attached to them * no message * Address comments - Fix for lighting mode 1 * A few more changes * Fix LocalBlockVectorSet * Fix range statement * Various fixes/comment-addressing - There's not much point in having a different file name now for history. We've broken it before... - Fix history read/write - Fix range on for loops in CharBlocks * undo bad CharBlocks change * Fix history y level * Fix biome history * Fix lighting * Fix /up * Make regen fail not because of these changes * Fixes for y < 0 * Fix isEmpty where only the uppermost chunksection is edited * Fix javadocs/FAWE annotations * Better explain why BiomeMath is removed * If history task throws an error, it should only be caught and printed if not completing now. * Min|max world heights for new patterns * Load biomes from NMS instead of bukkit (#1200) * Update adapters * Update adapters * Don't initialise BlockTypes when biomes aren't set up yet so all BiomeTypes.BIOME are no longer null thanks. * Address some comments. * rename layer -> sectionIndex to imply inclusivity * Javadoctored. Co-authored-by: NotMyFault <mc.cache@web.de> Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
This commit is contained in:
@ -457,6 +457,7 @@ public class BrushCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.stencil")
|
||||
public void stencilBrush(
|
||||
Player player,
|
||||
LocalSession session, InjectedValueAccess context,
|
||||
@Arg(desc = "Pattern")
|
||||
Pattern fill,
|
||||
@ -478,13 +479,15 @@ public class BrushCommands {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
InputStream stream = getHeightmapStream(image);
|
||||
HeightBrush brush;
|
||||
int minY = player.getWorld().getMinY();
|
||||
int maxY = player.getWorld().getMaxY();
|
||||
try {
|
||||
brush = new StencilBrush(stream, rotation, yscale, onlyWhite,
|
||||
"#clipboard".equalsIgnoreCase(image)
|
||||
? session.getClipboard().getClipboard() : null
|
||||
? session.getClipboard().getClipboard() : null, minY, maxY
|
||||
);
|
||||
} catch (EmptyClipboardException ignored) {
|
||||
brush = new StencilBrush(stream, rotation, yscale, onlyWhite, null);
|
||||
brush = new StencilBrush(stream, rotation, yscale, onlyWhite, null, minY, maxY);
|
||||
}
|
||||
if (randomRotate) {
|
||||
brush.setRandomRotate(true);
|
||||
@ -710,6 +713,7 @@ public class BrushCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.height")
|
||||
public void heightBrush(
|
||||
Player player,
|
||||
LocalSession session,
|
||||
@Arg(desc = "Expression", def = "5")
|
||||
Expression radius,
|
||||
@ -728,7 +732,7 @@ public class BrushCommands {
|
||||
boolean dontSmooth, InjectedValueAccess context
|
||||
)
|
||||
throws WorldEditException, FileNotFoundException {
|
||||
terrainBrush(session, radius, image, rotation, yscale, false, randomRotate, layers,
|
||||
terrainBrush(player, session, radius, image, rotation, yscale, false, randomRotate, layers,
|
||||
!dontSmooth, ScalableHeightMap.Shape.CONE, context
|
||||
);
|
||||
}
|
||||
@ -741,6 +745,7 @@ public class BrushCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.height")
|
||||
public void cliffBrush(
|
||||
Player player,
|
||||
LocalSession session,
|
||||
@Arg(desc = "Expression", def = "5")
|
||||
Expression radius,
|
||||
@ -760,7 +765,7 @@ public class BrushCommands {
|
||||
boolean dontSmooth, InjectedValueAccess context
|
||||
)
|
||||
throws WorldEditException, FileNotFoundException {
|
||||
terrainBrush(session, radius, image, rotation, yscale, true, randomRotate, layers,
|
||||
terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers,
|
||||
!dontSmooth, ScalableHeightMap.Shape.CYLINDER, context
|
||||
);
|
||||
}
|
||||
@ -775,6 +780,7 @@ public class BrushCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.height")
|
||||
public void flattenBrush(
|
||||
Player player,
|
||||
LocalSession session,
|
||||
@Arg(desc = "Expression", def = "5")
|
||||
Expression radius,
|
||||
@ -794,12 +800,13 @@ public class BrushCommands {
|
||||
boolean dontSmooth, InjectedValueAccess context
|
||||
)
|
||||
throws WorldEditException, FileNotFoundException {
|
||||
terrainBrush(session, radius, image, rotation, yscale, true, randomRotate, layers,
|
||||
terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers,
|
||||
!dontSmooth, ScalableHeightMap.Shape.CONE, context
|
||||
);
|
||||
}
|
||||
|
||||
private void terrainBrush(
|
||||
Player player,
|
||||
LocalSession session,
|
||||
Expression radius,
|
||||
String image,
|
||||
@ -816,23 +823,25 @@ public class BrushCommands {
|
||||
worldEdit.checkMaxBrushRadius(radius);
|
||||
InputStream stream = getHeightmapStream(image);
|
||||
HeightBrush brush;
|
||||
int minY = player.getWorld().getMinY();
|
||||
int maxY = player.getWorld().getMaxY();
|
||||
if (flat) {
|
||||
try {
|
||||
brush = new FlattenBrush(stream, rotation, yscale, layers, smooth,
|
||||
"#clipboard".equalsIgnoreCase(image)
|
||||
? session.getClipboard().getClipboard() : null, shape
|
||||
? session.getClipboard().getClipboard() : null, shape, minY, maxY
|
||||
);
|
||||
} catch (EmptyClipboardException ignored) {
|
||||
brush = new FlattenBrush(stream, rotation, yscale, layers, smooth, null, shape);
|
||||
brush = new FlattenBrush(stream, rotation, yscale, layers, smooth, null, shape, minY, maxY);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
brush = new HeightBrush(stream, rotation, yscale, layers, smooth,
|
||||
"#clipboard".equalsIgnoreCase(image)
|
||||
? session.getClipboard().getClipboard() : null
|
||||
? session.getClipboard().getClipboard() : null, minY, maxY
|
||||
);
|
||||
} catch (EmptyClipboardException ignored) {
|
||||
brush = new HeightBrush(stream, rotation, yscale, layers, smooth, null);
|
||||
brush = new HeightBrush(stream, rotation, yscale, layers, smooth, null, minY, maxY);
|
||||
}
|
||||
}
|
||||
if (randomRotate) {
|
||||
|
@ -635,12 +635,18 @@ public class GenerationCommands {
|
||||
@Arg(desc = "Ore vein size") @Range(from = 0, to = Integer.MAX_VALUE) int size,
|
||||
@Arg(desc = "Ore vein frequency (number of times to attempt to place ore)", def = "10") @Range(from = 0, to = Integer.MAX_VALUE) int freq,
|
||||
@Arg(desc = "Ore vein rarity (% chance each attempt is placed)", def = "100") @Range(from = 0, to = 100) int rarity,
|
||||
@Arg(desc = "Ore vein min y", def = "0") @Range(from = 0, to = 255) int minY,
|
||||
@Arg(desc = "Ore vein max y", def = "63") @Range(from = 0, to = 255) int maxY
|
||||
@Arg(desc = "Ore vein min y", def = "0") int minY,
|
||||
@Arg(desc = "Ore vein max y", def = "63") int maxY
|
||||
) throws WorldEditException {
|
||||
if (mask instanceof AbstractExtentMask) {
|
||||
((AbstractExtentMask) mask).setExtent(editSession);
|
||||
}
|
||||
checkCommandArgument(minY >= editSession.getMinY(), Caption.of("fawe.error.outside-range-lower", "miny",
|
||||
editSession.getMinY()));
|
||||
checkCommandArgument(maxY <= editSession.getMaxY(), Caption.of("fawe.error.outside-range-upper", "maxy",
|
||||
editSession.getMaxY()));
|
||||
checkCommandArgument(minY < maxY, Caption.of("fawe.error.argument-size-mismatch", "miny",
|
||||
"maxy"));
|
||||
editSession.addOre(region, mask, material, size, freq, rarity, minY, maxY);
|
||||
actor.print(Caption.of("fawe.worldedit.visitor.visitor.block", editSession.getBlockChangeCount()));
|
||||
}
|
||||
|
@ -133,8 +133,8 @@ public class HistorySubCommands {
|
||||
Location origin = player.getLocation();
|
||||
BlockVector3 bot = origin.toBlockPoint().subtract(radius, radius, radius);
|
||||
BlockVector3 top = origin.toBlockPoint().add(radius, radius, radius);
|
||||
bot = bot.clampY(0, world.getMaxY());
|
||||
top = top.clampY(0, world.getMaxY());
|
||||
bot = bot.clampY(world.getMinY(), world.getMaxY());
|
||||
top = top.clampY(world.getMinY(), world.getMaxY());
|
||||
// TODO mask the regions bot / top to the bottom and top coord in the allowedRegions
|
||||
// TODO: then mask the edit to the bot / top
|
||||
// if (allowedRegions.length != 1 || !allowedRegions[0].isGlobal()) {
|
||||
@ -196,9 +196,9 @@ public class HistorySubCommands {
|
||||
.summarize(RegionWrapper.GLOBAL(), false);
|
||||
if (summary != null) {
|
||||
rollback.setDimensions(
|
||||
BlockVector3.at(summary.minX, 0, summary.minZ),
|
||||
BlockVector3.at(summary.minX, world.getMinY(), summary.minZ),
|
||||
BlockVector3
|
||||
.at(summary.maxX, 255, summary.maxZ)
|
||||
.at(summary.maxX, world.getMaxY(), summary.maxZ)
|
||||
);
|
||||
rollback.setTime(historyFile.lastModified());
|
||||
RollbackDatabase db = DBHandler.IMP
|
||||
@ -410,8 +410,8 @@ public class HistorySubCommands {
|
||||
|
||||
BlockVector3 bot = origin.toBlockPoint().subtract(radius, radius, radius);
|
||||
BlockVector3 top = origin.toBlockPoint().add(radius, radius, radius);
|
||||
bot = bot.clampY(0, world.getMaxY());
|
||||
top = top.clampY(0, world.getMaxY());
|
||||
bot = bot.clampY(world.getMinY(), world.getMaxY());
|
||||
top = top.clampY(world.getMinY(), world.getMaxY());
|
||||
|
||||
long minTime = System.currentTimeMillis() - timeDiff;
|
||||
Iterable<Supplier<RollbackOptimizedHistory>> edits = database.getEdits(other, minTime, bot, top, false, false);
|
||||
|
@ -363,17 +363,23 @@ public class RegionCommands {
|
||||
@Selection Region region,
|
||||
@Arg(name = "pattern", desc = "The pattern of blocks to lay") Pattern patternArg
|
||||
) throws WorldEditException {
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
int maxY = max.getBlockY();
|
||||
//FAWE start - world min/maxY
|
||||
int maxY = region.getMaximumY();
|
||||
int minY = region.getMinimumY();
|
||||
//FAWE end
|
||||
Iterable<BlockVector2> flat = Regions.asFlatRegion(region).asFlatRegion();
|
||||
Iterator<BlockVector2> iter = flat.iterator();
|
||||
int y = 0;
|
||||
//FAWE start - world min/maxY
|
||||
int y = minY;
|
||||
//FAWE end
|
||||
int affected = 0;
|
||||
while (iter.hasNext()) {
|
||||
BlockVector2 pos = iter.next();
|
||||
int x = pos.getBlockX();
|
||||
int z = pos.getBlockZ();
|
||||
y = editSession.getNearestSurfaceTerrainBlock(x, z, y, 0, maxY);
|
||||
//FAWE start - world min/maxY
|
||||
y = editSession.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY);
|
||||
//FAWE end
|
||||
editSession.setBlock(x, y, z, patternArg);
|
||||
affected++;
|
||||
}
|
||||
@ -856,6 +862,7 @@ public class RegionCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.region.flora")
|
||||
@Logging(REGION)
|
||||
@Preload(Preload.PreloadCheck.PRELOAD)
|
||||
@Confirm(Confirm.Processor.REGION)
|
||||
public int flora(
|
||||
Actor actor, EditSession editSession, @Selection Region region,
|
||||
@ -867,7 +874,7 @@ public class RegionCommands {
|
||||
FloraGenerator generator = new FloraGenerator(editSession);
|
||||
GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
|
||||
//FAWE start - provide extent for preloading
|
||||
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground, editSession);
|
||||
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
|
||||
//FAWE end
|
||||
visitor.setMask(new NoiseFilter2D(new RandomNoise(), density));
|
||||
Operations.completeLegacy(visitor);
|
||||
|
@ -124,9 +124,9 @@ public class SelectionCommands {
|
||||
Location pos;
|
||||
//FAWE start - clamp
|
||||
if (coordinates != null) {
|
||||
pos = new Location(world, coordinates.toVector3().clampY(0, world.getMaxY()));
|
||||
pos = new Location(world, coordinates.toVector3().clampY(world.getMinY(), world.getMaxY()));
|
||||
} else if (actor instanceof Locatable) {
|
||||
pos = ((Locatable) actor).getBlockLocation().clampY(0, world.getMaxY());
|
||||
pos = ((Locatable) actor).getBlockLocation().clampY(world.getMinY(), world.getMaxY());
|
||||
//FAWE end
|
||||
} else {
|
||||
actor.print(Caption.of("worldedit.pos.console-require-coords"));
|
||||
@ -157,9 +157,9 @@ public class SelectionCommands {
|
||||
Location pos;
|
||||
if (coordinates != null) {
|
||||
//FAWE start - clamp
|
||||
pos = new Location(world, coordinates.toVector3().clampY(0, world.getMaxY()));
|
||||
pos = new Location(world, coordinates.toVector3().clampY(world.getMinY(), world.getMaxY()));
|
||||
} else if (actor instanceof Locatable) {
|
||||
pos = ((Locatable) actor).getBlockLocation().clampY(0, world.getMaxY());
|
||||
pos = ((Locatable) actor).getBlockLocation().clampY(world.getMinY(), world.getMaxY());
|
||||
//Fawe end
|
||||
} else {
|
||||
actor.print(Caption.of("worldedit.pos.console-require-coords"));
|
||||
@ -258,7 +258,7 @@ public class SelectionCommands {
|
||||
.clampY(minChunkY, maxChunkY);
|
||||
|
||||
min = minChunk.shl(CHUNK_SHIFTS, CHUNK_SHIFTS_Y, CHUNK_SHIFTS);
|
||||
max = maxChunk.shl(CHUNK_SHIFTS, CHUNK_SHIFTS_Y, CHUNK_SHIFTS).add(15, world.getMaxY(), 15);
|
||||
max = maxChunk.shl(CHUNK_SHIFTS, CHUNK_SHIFTS_Y, CHUNK_SHIFTS).add(15, 255, 15);
|
||||
|
||||
actor.print(Caption.of(
|
||||
"worldedit.chunk.selected-multiple",
|
||||
@ -286,7 +286,7 @@ public class SelectionCommands {
|
||||
}
|
||||
|
||||
min = minChunk.shl(CHUNK_SHIFTS, CHUNK_SHIFTS_Y, CHUNK_SHIFTS);
|
||||
max = min.add(15, world.getMaxY(), 15);
|
||||
max = min.add(15, 255, 15);
|
||||
|
||||
actor.print(Caption.of(
|
||||
"worldedit.chunk.selected",
|
||||
|
@ -413,8 +413,8 @@ public class UtilityCommands {
|
||||
) throws WorldEditException {
|
||||
size = Math.max(1, size);
|
||||
we.checkMaxRadius(size);
|
||||
height = height != null ? Math.min((world.getMaxY() + 1), height + 1) : (world.getMaxY() + 1);
|
||||
|
||||
height = height != null ? Math.min((world.getMaxY() - world.getMinY() + 1), height + 1) : (world.getMaxY() - world.getMinY() + 1);
|
||||
int affected = editSession.removeAbove(session.getPlacementPosition(actor), size, height);
|
||||
actor.print(Caption.of("worldedit.removeabove.removed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
@ -436,8 +436,8 @@ public class UtilityCommands {
|
||||
) throws WorldEditException {
|
||||
size = Math.max(1, size);
|
||||
we.checkMaxRadius(size);
|
||||
height = height != null ? Math.min((world.getMaxY() + 1), height + 1) : (world.getMaxY() + 1);
|
||||
|
||||
height = height != null ? Math.min((world.getMaxY() - world.getMinY() + 1), height + 1) : (world.getMaxY() - world.getMinY() + 1);
|
||||
int affected = editSession.removeBelow(session.getPlacementPosition(actor), size, height);
|
||||
actor.print(Caption.of("worldedit.removebelow.removed", TextComponent.of(affected)));
|
||||
return affected;
|
||||
|
@ -388,7 +388,7 @@ public class BrushTool
|
||||
final int x = loc.getBlockX();
|
||||
final int z = loc.getBlockZ();
|
||||
int y;
|
||||
for (y = height; y > 0; y--) {
|
||||
for (y = height; y > editSession.getMinY(); y--) {
|
||||
BlockType block = editSession.getBlockType(x, y, z);
|
||||
if (block.getMaterial().isMovementBlocker()) {
|
||||
break;
|
||||
|
@ -87,7 +87,8 @@ public class FloodFillTool implements BlockTool {
|
||||
//FAWE start - Respect masks
|
||||
Mask mask = initialType.toMask(editSession);
|
||||
BlockReplace function = new BlockReplace(editSession, pattern);
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(mask, function, range, editSession);
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(mask, function, range, editSession.getMinY(),
|
||||
editSession.getMaxY(), editSession);
|
||||
visitor.visit(origin);
|
||||
Operations.completeLegacy(visitor);
|
||||
//FAWE end
|
||||
|
@ -86,7 +86,14 @@ public class RecursivePickaxe implements BlockTool {
|
||||
final int radius = (int) range;
|
||||
final BlockReplace replace = new BlockReplace(editSession, (BlockTypes.AIR.getDefaultState()));
|
||||
editSession.setMask(null);
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(new IdMask(editSession), replace, radius, editSession);
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(
|
||||
new IdMask(editSession),
|
||||
replace,
|
||||
radius,
|
||||
editSession.getMinY(),
|
||||
editSession.getMaxY(),
|
||||
editSession
|
||||
);
|
||||
//TODO: Fix below
|
||||
//visitor.visit(pos);
|
||||
//Operations.completeBlindly(visitor);
|
||||
|
@ -39,8 +39,8 @@ public class GravityBrush implements Brush {
|
||||
MaxChangedBlocksException {
|
||||
//FAWE start - Ours operates differently to upstream, but does the same
|
||||
double endY = position.getY() + size;
|
||||
double startPerformY = Math.max(0, position.getY() - size);
|
||||
double startCheckY = fullHeight ? 0 : startPerformY;
|
||||
double startPerformY = Math.max(editSession.getMinY(), position.getY() - size);
|
||||
double startCheckY = fullHeight ? editSession.getMinY() : startPerformY;
|
||||
for (double x = position.getX() + size; x > position.getX() - size; --x) {
|
||||
for (double z = position.getZ() + size; z > position.getZ() - size; --z) {
|
||||
double freeSpot = startCheckY;
|
||||
|
Reference in New Issue
Block a user