mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
Merge remote-tracking branch 'upstream/master' into merge
This commit is contained in:
@ -59,23 +59,23 @@ public class ForestGenerator implements RegionFunction {
|
||||
case BlockID.DIRT:
|
||||
case BlockID.PODZOL:
|
||||
case BlockID.COARSE_DIRT:
|
||||
return treeType.generate(editSession, position.add(0, 1, 0));
|
||||
return treeType.generate(editSession, position.add(0, 1, 0));
|
||||
default:
|
||||
if (t.getMaterial().isReplacedDuringPlacement()) {
|
||||
// since the implementation's tree generators generally don't generate in non-air spots,
|
||||
// we trick editsession history here in the first call
|
||||
editSession.setBlock(position, BlockTypes.AIR.getDefaultState());
|
||||
// and then trick the generator here by directly setting into the world
|
||||
editSession.getWorld().setBlock(position, BlockTypes.AIR.getDefaultState());
|
||||
// so that now the generator can generate the tree
|
||||
boolean success = treeType.generate(editSession, position);
|
||||
if (!success) {
|
||||
editSession.setBlock(position, block); // restore on failure
|
||||
}
|
||||
return success;
|
||||
} else { // Trees won't grow on this!
|
||||
return false;
|
||||
if (t.getMaterial().isReplacedDuringPlacement()) {
|
||||
// since the implementation's tree generators generally don't generate in non-air spots,
|
||||
// we trick editsession history here in the first call
|
||||
editSession.setBlock(position, BlockTypes.AIR.getDefaultState());
|
||||
// and then trick the generator here by directly setting into the world
|
||||
editSession.getWorld().setBlock(position, BlockTypes.AIR.getDefaultState());
|
||||
// so that now the generator can generate the tree
|
||||
boolean success = treeType.generate(editSession, position);
|
||||
if (!success) {
|
||||
editSession.setBlock(position, block); // restore on failure
|
||||
}
|
||||
return success;
|
||||
} else { // Trees won't grow on this!
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.util.Random;
|
||||
@ -39,6 +38,7 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
private final Random random = new Random();
|
||||
private final EditSession editSession;
|
||||
private Pattern plant = getPumpkinPattern();
|
||||
private Pattern leafPattern = BlockTypes.OAK_LEAVES.getDefaultState().with(BlockTypes.OAK_LEAVES.getProperty("persistent"), true);
|
||||
private int affected;
|
||||
|
||||
/**
|
||||
@ -96,7 +96,7 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
}
|
||||
}
|
||||
|
||||
setBlockIfAir(editSession, pos, BlockTypes.OAK_LEAVES.getDefaultState());
|
||||
setBlockIfAir(editSession, pos, leafPattern);
|
||||
affected++;
|
||||
|
||||
int t = random.nextInt(4);
|
||||
@ -166,10 +166,9 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockState leavesBlock = BlockTypes.OAK_LEAVES.getDefaultState();
|
||||
|
||||
if (editSession.getBlock(position).getBlockType().getMaterial().isAir()) {
|
||||
editSession.setBlock(position, leavesBlock);
|
||||
editSession.setBlock(position, leafPattern);
|
||||
}
|
||||
|
||||
placeVine(position, position.add(0, 0, 1));
|
||||
@ -193,12 +192,12 @@ public class GardenPatchGenerator implements RegionFunction {
|
||||
* Set a block only if there's no block already there.
|
||||
*
|
||||
* @param position the position
|
||||
* @param block the block to set
|
||||
* @param pattern the pattern to set
|
||||
* @return if block was changed
|
||||
* @throws MaxChangedBlocksException thrown if too many blocks are changed
|
||||
*/
|
||||
private static <B extends BlockStateHolder<B>> boolean setBlockIfAir(EditSession session, BlockVector3 position, B block) throws MaxChangedBlocksException {
|
||||
return session.getBlock(position).getBlockType().getMaterial().isAir() && session.setBlock(position, block);
|
||||
private static boolean setBlockIfAir(EditSession session, BlockVector3 position, Pattern pattern) throws MaxChangedBlocksException {
|
||||
return session.getBlock(position).getBlockType().getMaterial().isAir() && session.setBlock(position, pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,8 +22,8 @@ package com.sk89q.worldedit.function.mask;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.EvaluationException;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||
|
||||
|
@ -22,8 +22,8 @@ package com.sk89q.worldedit.function.mask;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.internal.expression.Expression;
|
||||
import com.sk89q.worldedit.internal.expression.EvaluationException;
|
||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
||||
import com.sk89q.worldedit.math.BlockVector2;
|
||||
import java.util.function.IntSupplier;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -36,16 +36,21 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.function.CombinedRegionFunction;
|
||||
import com.sk89q.worldedit.function.FlatRegionFunction;
|
||||
import com.sk89q.worldedit.function.FlatRegionMaskingFilter;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.RegionMaskTestFunction;
|
||||
import com.sk89q.worldedit.function.biome.ExtentBiomeCopy;
|
||||
import com.sk89q.worldedit.function.RegionMaskingFilter;
|
||||
import com.sk89q.worldedit.function.entity.ExtentEntityCopy;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||
import com.sk89q.worldedit.function.visitor.EntityVisitor;
|
||||
import com.sk89q.worldedit.function.visitor.IntersectRegionFunction;
|
||||
import com.sk89q.worldedit.function.visitor.RegionVisitor;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.function.visitor.FlatRegionVisitor;
|
||||
import com.sk89q.worldedit.math.transform.AffineTransform;
|
||||
import com.sk89q.worldedit.math.transform.Identity;
|
||||
import com.sk89q.worldedit.math.transform.Transform;
|
||||
@ -78,7 +83,7 @@ public class ForwardExtentCopy implements Operation {
|
||||
private RegionFunction sourceFunction = null;
|
||||
private Transform transform = new Identity();
|
||||
private Transform currentTransform = null;
|
||||
private int affected;
|
||||
private int affectedBlocks;
|
||||
private RegionFunction filterFunction;
|
||||
|
||||
/**
|
||||
@ -94,6 +99,10 @@ public class ForwardExtentCopy implements Operation {
|
||||
public ForwardExtentCopy(Extent source, Region region, Extent destination, BlockVector3 to) {
|
||||
this(source, region, region.getMinimumPoint(), destination, to);
|
||||
}
|
||||
private FlatRegionVisitor lastBiomeVisitor;
|
||||
private EntityVisitor lastEntityVisitor;
|
||||
private int affectedBiomeCols;
|
||||
private int affectedEntities;
|
||||
|
||||
/**
|
||||
* Create a new copy.
|
||||
@ -267,7 +276,7 @@ public class ForwardExtentCopy implements Operation {
|
||||
* @return the number of affected
|
||||
*/
|
||||
public int getAffected() {
|
||||
return affected;
|
||||
return affectedBlocks + affectedBiomeCols + affectedEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -275,6 +284,14 @@ public class ForwardExtentCopy implements Operation {
|
||||
if (currentTransform == null) {
|
||||
currentTransform = transform;
|
||||
}
|
||||
if (lastBiomeVisitor != null) {
|
||||
affectedBiomeCols += lastBiomeVisitor.getAffected();
|
||||
lastBiomeVisitor = null;
|
||||
}
|
||||
if (lastEntityVisitor != null) {
|
||||
affectedEntities += lastEntityVisitor.getAffected();
|
||||
lastEntityVisitor = null;
|
||||
}
|
||||
|
||||
Extent finalDest = destination;
|
||||
BlockVector3 translation = to.subtract(from);
|
||||
@ -405,7 +422,21 @@ public class ForwardExtentCopy implements Operation {
|
||||
@Override
|
||||
public void addStatusMessages(List<String> messages) {
|
||||
StringBuilder msg = new StringBuilder();
|
||||
msg.append(affected).append(" objects(s)");
|
||||
msg.append(affectedBlocks).append(" block(s)");
|
||||
if (affectedBiomeCols > 0) {
|
||||
if (affectedEntities > 0) {
|
||||
msg.append(", ");
|
||||
} else {
|
||||
msg.append(" and ");
|
||||
}
|
||||
msg.append(affectedBiomeCols).append(" biome(s)");
|
||||
}
|
||||
if (affectedEntities > 0) {
|
||||
if (affectedBiomeCols > 0) {
|
||||
msg.append(",");
|
||||
}
|
||||
msg.append(" and ").append(affectedEntities).append(" entities(s)");
|
||||
}
|
||||
msg.append(" affected.");
|
||||
messages.add(msg.toString());
|
||||
}
|
||||
|
Reference in New Issue
Block a user