Skip to content

Commit b2247fe

Browse files
committed
fix: don't bypass history with //ores
- also add copper and update limits - also restrict ores spawning to region - also fix caves out of region error - fixes #3108
1 parent d68afb5 commit b2247fe

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/FaweRegionExtent.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
public abstract class FaweRegionExtent extends ResettableExtent implements IBatchProcessor {
2828

2929
private final FaweLimit limit;
30+
private final boolean hasLimit;
3031

3132
/**
3233
* Create a new instance.
@@ -36,6 +37,7 @@ public abstract class FaweRegionExtent extends ResettableExtent implements IBatc
3637
public FaweRegionExtent(Extent extent, FaweLimit limit) {
3738
super(extent);
3839
this.limit = limit;
40+
this.hasLimit = limit != null;
3941
}
4042

4143
@Override
@@ -75,7 +77,7 @@ public final boolean contains(BlockVector2 p) {
7577
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block)
7678
throws WorldEditException {
7779
if (!contains(x, y, z)) {
78-
if (!limit.MAX_FAILS()) {
80+
if (hasLimit && !limit.MAX_FAILS()) {
7981
WEManager.weManager().cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
8082
}
8183
return false;
@@ -86,7 +88,7 @@ public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B b
8688
@Override
8789
public boolean setBiome(int x, int y, int z, BiomeType biome) {
8890
if (!contains(x, y, z)) {
89-
if (!limit.MAX_FAILS()) {
91+
if (hasLimit && !limit.MAX_FAILS()) {
9092
WEManager.weManager().cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
9193
}
9294
return false;
@@ -102,7 +104,7 @@ public BiomeType getBiome(BlockVector3 position) {
102104
@Override
103105
public BiomeType getBiomeType(int x, int y, int z) {
104106
if (!contains(x, y, z)) {
105-
if (!limit.MAX_FAILS()) {
107+
if (hasLimit && !limit.MAX_FAILS()) {
106108
WEManager.weManager().cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
107109
}
108110
return null;
@@ -118,7 +120,7 @@ public BaseBlock getFullBlock(BlockVector3 position) {
118120
@Override
119121
public BaseBlock getFullBlock(int x, int y, int z) {
120122
if (!contains(x, y, z)) {
121-
if (!limit.MAX_FAILS()) {
123+
if (hasLimit && !limit.MAX_FAILS()) {
122124
WEManager.weManager().cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
123125
}
124126
return BlockTypes.AIR.getDefaultState().toBaseBlock();
@@ -134,7 +136,7 @@ public BlockState getBlock(BlockVector3 position) {
134136
@Override
135137
public BlockState getBlock(int x, int y, int z) {
136138
if (!contains(x, y, z)) {
137-
if (!limit.MAX_FAILS()) {
139+
if (hasLimit && !limit.MAX_FAILS()) {
138140
WEManager.weManager().cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
139141
}
140142
return BlockTypes.AIR.getDefaultState();
@@ -146,7 +148,7 @@ public BlockState getBlock(int x, int y, int z) {
146148
@Override
147149
public Entity createEntity(Location location, BaseEntity entity) {
148150
if (!contains(location.getBlockX(), location.getBlockY(), location.getBlockZ())) {
149-
if (!limit.MAX_FAILS()) {
151+
if (hasLimit && !limit.MAX_FAILS()) {
150152
WEManager.weManager().cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
151153
}
152154
return null;
@@ -158,7 +160,7 @@ public Entity createEntity(Location location, BaseEntity entity) {
158160
@Override
159161
public Entity createEntity(Location location, BaseEntity entity, UUID uuid) {
160162
if (!contains(location.getBlockX(), location.getBlockY(), location.getBlockZ())) {
161-
if (!limit.MAX_FAILS()) {
163+
if (hasLimit && !limit.MAX_FAILS()) {
162164
WEManager.weManager().cancelEditSafe(this, FaweCache.OUTSIDE_REGION);
163165
}
164166
return null;

worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/PassthroughExtent.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,6 @@ public void addOre(Region region, Mask mask, Pattern material, int size, int fre
126126
getExtent().addOre(region, mask, material, size, frequency, rarity, minY, maxY);
127127
}
128128

129-
@Override
130-
public void addOres(Region region, Mask mask) throws WorldEditException {
131-
getExtent().addOres(region, mask);
132-
}
133-
134129
@Override
135130
public List<Countable<BlockType>> getBlockDistribution(Region region) {
136131
return getExtent().getBlockDistribution(region);

worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4117,7 +4117,7 @@ public void removeEntity(int x, int y, int z, UUID uuid) {
41174117
@Override
41184118
public void generate(Region region, GenBase gen) throws WorldEditException {
41194119
for (BlockVector2 chunkPos : region.getChunks()) {
4120-
gen.generate(chunkPos, new SingleRegionExtent(this, getLimit(), region));
4120+
gen.generate(chunkPos, new SingleRegionExtent(this, null, region));
41214121
}
41224122
}
41234123

worldedit-core/src/main/java/com/sk89q/worldedit/extent/Extent.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
import com.sk89q.worldedit.function.mask.BlockMask;
4848
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
4949
import com.sk89q.worldedit.function.mask.Mask;
50+
import com.sk89q.worldedit.function.mask.MaskIntersection;
51+
import com.sk89q.worldedit.function.mask.RegionMask;
5052
import com.sk89q.worldedit.function.mask.SolidBlockMask;
5153
import com.sk89q.worldedit.function.operation.Operation;
5254
import com.sk89q.worldedit.function.operation.Operations;
@@ -584,18 +586,20 @@ default void addOre(
584586

585587
//TODO: probably update these for 1.18 etc.
586588
default void addOres(Region region, Mask mask) throws WorldEditException {
589+
mask = new MaskIntersection(new RegionMask(region), mask);
587590
addOre(region, mask, BlockTypes.DIRT.getDefaultState(), 33, 10, 100, getMinY(), getMaxY());
588591
addOre(region, mask, BlockTypes.GRAVEL.getDefaultState(), 33, 8, 100, getMinY(), getMaxY());
589592
addOre(region, mask, BlockTypes.ANDESITE.getDefaultState(), 33, 10, 100, getMinY(), 79);
590593
addOre(region, mask, BlockTypes.DIORITE.getDefaultState(), 33, 10, 100, getMinY(), 79);
591594
addOre(region, mask, BlockTypes.GRANITE.getDefaultState(), 33, 10, 100, getMinY(), 79);
592-
addOre(region, mask, BlockTypes.COAL_ORE.getDefaultState(), 17, 20, 100, 0, 127);
593-
addOre(region, mask, BlockTypes.IRON_ORE.getDefaultState(), 9, 20, 100, 0, 63);
594-
addOre(region, mask, BlockTypes.GOLD_ORE.getDefaultState(), 9, 2, 100, 0, 31);
595-
addOre(region, mask, BlockTypes.REDSTONE_ORE.getDefaultState(), 8, 8, 100, 0, 15);
596-
addOre(region, mask, BlockTypes.DIAMOND_ORE.getDefaultState(), 8, 1, 100, 0, 15);
597-
addOre(region, mask, BlockTypes.LAPIS_ORE.getDefaultState(), 7, 1, 100, 0, 15);
598-
addOre(region, mask, BlockTypes.EMERALD_ORE.getDefaultState(), 5, 1, 100, 4, 31);
595+
addOre(region, mask, BlockTypes.COAL_ORE.getDefaultState(), 17, 20, 100, 0, 320);
596+
addOre(region, mask, BlockTypes.COPPER_ORE.getDefaultState(), 13, 20, 100, -16, 112);
597+
addOre(region, mask, BlockTypes.IRON_ORE.getDefaultState(), 9, 20, 100, -64, 320);
598+
addOre(region, mask, BlockTypes.GOLD_ORE.getDefaultState(), 9, 2, 100, -32, 256);
599+
addOre(region, mask, BlockTypes.REDSTONE_ORE.getDefaultState(), 8, 8, 100, -64, 16);
600+
addOre(region, mask, BlockTypes.DIAMOND_ORE.getDefaultState(), 8, 1, 100, -64, 16);
601+
addOre(region, mask, BlockTypes.LAPIS_ORE.getDefaultState(), 7, 1, 100, -64, 64);
602+
addOre(region, mask, BlockTypes.EMERALD_ORE.getDefaultState(), 5, 1, 100, -16, 320);
599603
}
600604

601605
/**

worldedit-core/src/main/java/com/sk89q/worldedit/regions/Region.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ default Extent construct(Extent child) {
502502
if (isGlobal()) {
503503
return child;
504504
}
505-
return new SingleRegionExtent(child, FaweLimit.MAX, this);
505+
return new SingleRegionExtent(child, null, this);
506506
}
507507

508508
@Override

0 commit comments

Comments
 (0)