mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-02 11:26:42 +00:00
Remove all raw usages of BSH, improve API generics
This commit is contained in:
committed by
IronApollo
parent
1d87642b52
commit
590b7e23a9
@ -12,10 +12,15 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
@Deprecated
|
||||
public class BlockPattern implements Pattern {
|
||||
|
||||
private BlockStateHolder block;
|
||||
private BaseBlock block;
|
||||
|
||||
public BlockPattern(BlockStateHolder block) {
|
||||
this.block = block;
|
||||
/**
|
||||
* Create a new pattern with the given block.
|
||||
*
|
||||
* @param block the block
|
||||
*/
|
||||
public BlockPattern(BlockStateHolder<?> block) {
|
||||
setBlock(block);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -23,7 +28,7 @@ public class BlockPattern implements Pattern {
|
||||
*
|
||||
* @return the block that is always returned
|
||||
*/
|
||||
public BlockStateHolder getBlock() {
|
||||
public BaseBlock getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
@ -32,13 +37,13 @@ public class BlockPattern implements Pattern {
|
||||
*
|
||||
* @param block the block
|
||||
*/
|
||||
public void setBlock(BlockStateHolder block) {
|
||||
public void setBlock(BlockStateHolder<?> block) {
|
||||
checkNotNull(block);
|
||||
this.block = block;
|
||||
this.block = block.toBaseBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateHolder apply(BlockVector3 position) {
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
return block;
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -37,23 +37,14 @@ public class ClipboardPattern extends AbstractPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
//<<<<<<< HEAD
|
||||
public BlockStateHolder apply(BlockVector3 position) {
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
int xp = position.getBlockX() % sx;
|
||||
int yp = position.getBlockY() % sy;
|
||||
int zp = position.getBlockZ() % sz;
|
||||
if (xp < 0) xp += sx;
|
||||
if (yp < 0) yp += sy;
|
||||
if (zp < 0) zp += sz;
|
||||
return clipboard.getBlock(BlockVector3.at(min.getX() + xp, min.getY() + yp, min.getZ() + zp));
|
||||
//=======
|
||||
// public BlockStateHolder apply(BlockVector3 position) {
|
||||
// int xp = Math.abs(position.getBlockX()) % size.getBlockX();
|
||||
// int yp = Math.abs(position.getBlockY()) % size.getBlockY();
|
||||
// int zp = Math.abs(position.getBlockZ()) % size.getBlockZ();
|
||||
//
|
||||
// return clipboard.getFullBlock(clipboard.getMinimumPoint().add(xp, yp, zp));
|
||||
//>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
return clipboard.getFullBlock(BlockVector3.at(min.getX() + xp, min.getY() + yp, min.getZ() + zp));
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,6 +7,7 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.NullExtent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
/**
|
||||
@ -17,7 +18,7 @@ import com.sk89q.worldedit.world.block.BlockState;
|
||||
public interface FawePattern extends Pattern {
|
||||
|
||||
@Deprecated
|
||||
default BlockStateHolder apply(BlockVector3 position) {
|
||||
default BaseBlock apply(BlockVector3 position) {
|
||||
throw new UnsupportedOperationException("Please use apply(extent, get, set)");
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.NullExtent;
|
||||
import com.sk89q.worldedit.internal.expression.runtime.Return;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
|
||||
@ -55,7 +56,7 @@ public interface Pattern{
|
||||
* @param position the position
|
||||
* @return a block
|
||||
*/
|
||||
BlockStateHolder apply(BlockVector3 position);
|
||||
BaseBlock apply(BlockVector3 position);
|
||||
|
||||
default boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
return extent.setBlock(set, apply(get));
|
||||
|
@ -10,7 +10,7 @@ import com.sk89q.worldedit.extent.Extent;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
@ -56,24 +56,8 @@ public class RandomPattern extends AbstractPattern {
|
||||
this.patterns.add(pattern);
|
||||
}
|
||||
|
||||
//<<<<<<< HEAD
|
||||
public Set<Pattern> getPatterns() {
|
||||
return patterns;
|
||||
//=======
|
||||
// @Override
|
||||
// public BlockStateHolder apply(BlockVector3 position) {
|
||||
// double r = random.nextDouble();
|
||||
// double offset = 0;
|
||||
//
|
||||
// for (Chance chance : patterns) {
|
||||
// if (r <= (offset + chance.getChance()) / max) {
|
||||
// return chance.getPattern().apply(position);
|
||||
// }
|
||||
// offset += chance.getChance();
|
||||
// }
|
||||
//
|
||||
// throw new RuntimeException("ProportionalFillPattern");
|
||||
//>>>>>>> 399e0ad5... Refactor vector system to be cleaner
|
||||
}
|
||||
|
||||
public RandomCollection<Pattern> getCollection() {
|
||||
@ -81,7 +65,7 @@ public class RandomPattern extends AbstractPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateHolder apply(BlockVector3 get) {
|
||||
public BaseBlock apply(BlockVector3 get) {
|
||||
return collection.next(get.getBlockX(), get.getBlockY(), get.getBlockZ()).apply(get);
|
||||
}
|
||||
|
||||
|
@ -23,11 +23,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
/**
|
||||
* Returns the blocks from {@link Extent}, repeating when out of bounds.
|
||||
@ -87,7 +83,7 @@ public class RepeatingExtentPattern extends AbstractPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockStateHolder apply(BlockVector3 position) {
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
BlockVector3 base = position.add(offset);
|
||||
BlockVector3 size = extent.getMaximumPoint().subtract(extent.getMinimumPoint()).add(1, 1, 1);
|
||||
int x = base.getBlockX() % size.getBlockX();
|
||||
|
Reference in New Issue
Block a user