Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing voxel height and voxel center commands #350

Open
wants to merge 1 commit into
base: sponge-1.12
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions src/main/java/com/thevoxelbox/voxelsniper/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ public void brushName(String brushName) {
this.snipeData.sendMessage(TextColors.AQUA, "Brush Type: ", TextColors.LIGHT_PURPLE, brushName);
}

/**
* Display Center Parameter.
*/
public void center() {
this.snipeData.sendMessage(TextColors.DARK_BLUE, "Brush Center: ", TextColors.DARK_RED, this.snipeData.getCylinderCenter());
}

/**
* Display custom message.
*
Expand All @@ -81,8 +74,8 @@ public void custom(Object... args) {
/**
* Display voxel height.
*/
public void height() {
this.snipeData.sendMessage(TextColors.DARK_AQUA, "Brush Height: ", TextColors.DARK_RED, this.snipeData.getVoxelHeight());
public void height(int height) {
this.snipeData.sendMessage(TextColors.DARK_AQUA, "Brush Height: ", TextColors.DARK_RED, height);
}

/**
Expand Down
20 changes: 0 additions & 20 deletions src/main/java/com/thevoxelbox/voxelsniper/SnipeData.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ public class SnipeData {
private Key<?> replaceInkKey;
private Object replaceInkValue;

private int voxelHeight;
private int cylinderCenter;
private int range;
private boolean ranged;
private boolean lightning;
Expand All @@ -64,8 +62,6 @@ public SnipeData(Sniper vs) {

this.brushSize = VoxelSniperConfiguration.DEFAULT_BRUSH_SIZE;
this.voxelList = new VoxelList();
this.voxelHeight = VoxelSniperConfiguration.DEFAULT_VOXEL_HEIGHT;
this.cylinderCenter = VoxelSniperConfiguration.DEFAULT_CYLINDER_CENTER;
this.range = 0;

this.ranged = false;
Expand All @@ -85,14 +81,6 @@ public void setBrushSize(double brushSize) {
this.brushSize = brushSize;
}

public int getCylinderCenter() {
return this.cylinderCenter;
}

public void setCylinderCenter(int cCen) {
this.cylinderCenter = cCen;
}

public int getRange() {
return this.range;
}
Expand All @@ -113,14 +101,6 @@ public void setReplaceState(BlockState state) {
this.replaceState = state;
}

public int getVoxelHeight() {
return this.voxelHeight;
}

public void setVoxelHeight(int voxelHeight) {
this.voxelHeight = voxelHeight;
}

public String getVoxelId() {
return voxelState.getId();
}
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/com/thevoxelbox/voxelsniper/VoxelSniper.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@
import com.thevoxelbox.voxelsniper.brush.terrain.SplatterVoxelBrush;
import com.thevoxelbox.voxelsniper.command.VoxelBrushCommand;
import com.thevoxelbox.voxelsniper.command.VoxelBrushToolCommand;
import com.thevoxelbox.voxelsniper.command.VoxelCenterCommand;
import com.thevoxelbox.voxelsniper.command.VoxelDefaultCommand;
import com.thevoxelbox.voxelsniper.command.VoxelHeightCommand;
import com.thevoxelbox.voxelsniper.command.VoxelInkCommand;
import com.thevoxelbox.voxelsniper.command.VoxelInkReplaceCommand;
import com.thevoxelbox.voxelsniper.command.VoxelListCommand;
Expand Down Expand Up @@ -164,9 +162,7 @@ private void registerCommands() {
// @Cleanup auto detect and load these?
VoxelBrushCommand.setup(this);
VoxelBrushToolCommand.setup(this);
VoxelCenterCommand.setup(this);
VoxelDefaultCommand.setup(this);
VoxelHeightCommand.setup(this);
VoxelInkCommand.setup(this);
VoxelInkReplaceCommand.setup(this);
VoxelListCommand.setup(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo;
import com.thevoxelbox.voxelsniper.VoxelSniper;
import com.thevoxelbox.voxelsniper.VoxelSniperConfiguration;
import com.thevoxelbox.voxelsniper.brush.Brush;
import com.thevoxelbox.voxelsniper.brush.PerformBrush;
import org.spongepowered.api.text.format.TextColors;
Expand All @@ -45,12 +47,17 @@
)
public class CylinderBrush extends PerformBrush {

private int height;
private int offset;

public CylinderBrush() {
this.height = VoxelSniperConfiguration.DEFAULT_VOXEL_HEIGHT;
this.offset = VoxelSniperConfiguration.DEFAULT_CYLINDER_CENTER;
}

private void cylinder(SnipeData v, Location<World> targetBlock) {
int yStartingPoint = targetBlock.getBlockY() + v.getCylinderCenter();
int yEndPoint = targetBlock.getBlockY() + v.getVoxelHeight() + v.getCylinderCenter();
int yStartingPoint = targetBlock.getBlockY() + this.offset;
int yEndPoint = yStartingPoint + this.height - 1;

if (yEndPoint < yStartingPoint) {
yEndPoint = yStartingPoint;
Expand Down Expand Up @@ -110,8 +117,8 @@ protected final void powder(final SnipeData v) {
public final void info(final Message vm) {
vm.brushName(this.info.name());
vm.size();
vm.height();
vm.center();
vm.height(this.height);
vm.custom(TextColors.DARK_BLUE, "Brush Offset: ", TextColors.DARK_RED, offset);
}

@Override
Expand All @@ -121,22 +128,24 @@ public final void parameters(final String[] par, final SnipeData v) {

if (parameter.equalsIgnoreCase("info")) {
v.sendMessage(TextColors.GOLD, "Cylinder Brush Parameters:");
v.sendMessage(TextColors.AQUA, "/b c h[number] -- set the cylinder v.voxelHeight. Default is 1.");
v.sendMessage(TextColors.DARK_BLUE
+ "/b c c[number] -- set the origin of the cylinder compared to the target block. Positive numbers will move the cylinder upward, negative will move it downward.");
v.sendMessage(TextColors.AQUA, "/b c h[number] -- set the cylinder height. Default is 1.");
v.sendMessage(TextColors.DARK_BLUE,
"/b c o[number] -- set the vertical offset of the cylinder compared to the target ",
"block. Positive numbers will move the cylinder upward, negative will move it ",
"downward. Default is 0.");
return;
}
if (parameter.startsWith("h")) {
try {
v.setVoxelHeight((int) Double.parseDouble(parameter.replace("h", "")));
v.sendMessage(TextColors.AQUA, "Cylinder v.voxelHeight set to: " + v.getVoxelHeight());
this.height = Integer.parseInt(parameter.substring(1));
v.sendMessage(TextColors.AQUA, "Cylinder height set to: ", this.height);
} catch (NumberFormatException e) {
v.sendMessage(TextColors.RED, "Invalid height given.");
}
} else if (parameter.startsWith("c")) {
} else if (parameter.startsWith("o")) {
try {
v.setCylinderCenter((int) Double.parseDouble(parameter.replace("c", "")));
v.sendMessage(TextColors.AQUA, "Cylinder origin set to: " + v.getCylinderCenter());
this.offset = (int) Double.parseDouble(parameter.substring(1));
v.sendMessage(TextColors.AQUA, "Cylinder origin set to: " + this.offset);
} catch (NumberFormatException e) {
v.sendMessage(TextColors.RED, "Invalid origin given.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo;
import com.thevoxelbox.voxelsniper.VoxelSniperConfiguration;
import com.thevoxelbox.voxelsniper.brush.Brush;
import com.flowpowered.math.GenericMath;
import org.spongepowered.api.block.BlockState;
import org.spongepowered.api.text.format.TextColors;
import org.spongepowered.api.util.Direction;
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
Expand All @@ -45,21 +47,24 @@
)
public class ExtrudeBrush extends Brush {

private int height;

public ExtrudeBrush() {
this.height = VoxelSniperConfiguration.DEFAULT_VOXEL_HEIGHT;
}

private void extrude(final SnipeData v, Location<World> targetBlock, Direction axis) {
double brushSize = v.getBrushSize();
double brushSizeSquared = brushSize * brushSize;
// @Safety there is no bounds checks done here
this.undo = new Undo(GenericMath.floor(Math.PI * (brushSize + 1) * (brushSize + 1) * v.getVoxelHeight()));
this.undo = new Undo(GenericMath.floor(Math.PI * (brushSize + 1) * (brushSize + 1) * this.height));
int size = GenericMath.floor(brushSize) + 1;

for (int x = -size; x <= size; x++) {
for (int z = -size; z <= size; z++) {
if (x * x + z * z < brushSizeSquared) {
if (v.getVoxelList().contains(get(x, z, axis, targetBlock))) {
for (int y = 0; y < v.getVoxelHeight(); y++) {
for (int y = 0; y < this.height; y++) {
set(x, z, axis, targetBlock, v.getVoxelState(), y);
}
}
Expand Down Expand Up @@ -123,7 +128,22 @@ protected final void powder(final SnipeData v) {
public final void info(final Message vm) {
vm.brushName(this.info.name());
vm.size();
vm.height();
vm.height(this.height);
vm.voxelList();
}

@Override
public final void parameters(String[] args, SnipeData v) {
if (args.length == 1 && args[0].toLowerCase().startsWith("h")) {
try {
this.height = Integer.parseInt(args[0].substring(1));
v.sendMessage(TextColors.AQUA, "Extrude height set to: ", this.height);
} catch (NumberFormatException e) {
v.sendMessage(TextColors.RED, "Invalid height given.");
}
} else if (args.length > 0) {
v.sendMessage(TextColors.GOLD, "Extrude Brush Parameters:");
v.sendMessage(TextColors.AQUA, "/b ex h[number] -- set the extrude height. Default is 1.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.thevoxelbox.voxelsniper.Message;
import com.thevoxelbox.voxelsniper.SnipeData;
import com.thevoxelbox.voxelsniper.Undo;
import com.thevoxelbox.voxelsniper.VoxelSniperConfiguration;
import com.thevoxelbox.voxelsniper.brush.Brush;
import com.thevoxelbox.voxelsniper.brush.PerformBrush;
import com.thevoxelbox.voxelsniper.util.BlockHelper;
Expand All @@ -47,8 +48,10 @@ public class FillDownBrush extends PerformBrush {

private boolean fillLiquid = true;
private boolean fromExisting = false;
private int verticalLimit;

public FillDownBrush() {
this.verticalLimit = VoxelSniperConfiguration.DEFAULT_VOXEL_HEIGHT;
}

private void fillDown(SnipeData v, Location<World> targetBlock) {
Expand All @@ -71,7 +74,7 @@ private void fillDown(SnipeData v, Location<World> targetBlock) {
if (xs + zs < brushSizeSquared) {
int y = targetBlock.getBlockY();
if (this.fromExisting) {
for (int y0 = -v.getVoxelHeight(); y0 < v.getVoxelHeight(); y0++) {
for (int y0 = -this.verticalLimit; y0 < this.verticalLimit; y0++) {
if (this.world.getBlock(x, y + y0, z) != v.getReplaceState()) {
y += y0 - 1;
break;
Expand Down Expand Up @@ -117,22 +120,35 @@ public final void info(final Message vm) {

@Override
public final void parameters(final String[] par, final SnipeData v) {
for (int i = 0; i < par.length; i++) {
if (par[i].equalsIgnoreCase("info")) {
for (String parameter : par) {
parameter = parameter.toLowerCase();
if (parameter.equals("info")) {
v.sendMessage(TextColors.GOLD, "Fill Down Parameters:");
v.sendMessage(TextColors.AQUA, "/b fd some -- Fills only into air.");
v.sendMessage(TextColors.AQUA, "/b fd all -- Fills into liquids as well. (Default)");
v.sendMessage(TextColors.AQUA, "/b fd -e -- Fills only own from existing blocks. (Toggle)");
v.sendMessage(TextColors.AQUA, "/b fd -e -- Fills down only from existing blocks. (Toggle)");
v.sendMessage(TextColors.AQUA, "/b fd r[number] -- Vertical range for checking where to fill down when using -e. Default 5.");
return;
} else if (par[i].equalsIgnoreCase("all")) {

} else if (parameter.equals("all")) {
this.fillLiquid = true;
v.sendMessage(TextColors.AQUA, "Now filling liquids as well as air.");
} else if (par[i].equalsIgnoreCase("some")) {

} else if (parameter.equals("some")) {
this.fillLiquid = false;
v.sendMessage(TextColors.AQUA, "Now only filling air.");
} else if (par[i].equalsIgnoreCase("-e")) {

} else if (parameter.equals("-e")) {
this.fromExisting = !this.fromExisting;
v.sendMessage(TextColors.AQUA, "Now filling down from " + ((this.fromExisting) ? "existing" : "all") + " blocks.");

} else if (parameter.startsWith("r")) {
try {
this.verticalLimit = (int) Double.parseDouble(parameter.substring(1));
v.sendMessage(TextColors.AQUA, "Vertical range set to ", this.verticalLimit);
} catch (NumberFormatException e) {
v.sendMessage(TextColors.RED, "Invalid limit given");
}
} else {
v.sendMessage(TextColors.RED, "Invalid brush parameters! use the info parameter to display parameter info.");
}
Expand Down

This file was deleted.

Loading