Skip to content

Commit

Permalink
Fix PR notes
Browse files Browse the repository at this point in the history
  • Loading branch information
me4502 committed Feb 11, 2021
1 parent 0a0c027 commit 8358305
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
Expand Up @@ -134,7 +134,6 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
Expand Down
Expand Up @@ -203,6 +203,7 @@ public void splatterBrush(Player player, LocalSession session,
tool.setBrush(new SplatterBrush(decay), "worldedit.brush.splatter");

player.printInfo(TranslatableComponent.of("worldedit.brush.splatter.equip", TextComponent.of((int) radius), TextComponent.of(decay)));
ToolCommands.sendUnbindInstruction(player, UNBIND_COMMAND_COMPONENT);
}


Expand Down
Expand Up @@ -30,6 +30,7 @@ public class SplatterMask extends AbstractMask {

private final BlockVector3 position;
private final double decay;
private final double size;
private final double sizeSq;

public SplatterMask(BlockVector3 position, double decay, double size) {
Expand All @@ -38,6 +39,7 @@ public SplatterMask(BlockVector3 position, double decay, double size) {

this.position = position;
this.decay = decay;
this.size = size;
this.sizeSq = size * size;
}

Expand All @@ -54,6 +56,6 @@ public boolean test(BlockVector3 vector) {
@Nullable
@Override
public Mask2D toMask2D() {
return null;
return new SplatterMask2D(position.toBlockVector2(), decay, size);
}
}
@@ -0,0 +1,52 @@
/*
* WorldEdit, a Minecraft world manipulation toolkit
* Copyright (C) sk89q <http://www.sk89q.com>
* Copyright (C) WorldEdit team and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.sk89q.worldedit.function.mask;

import com.sk89q.worldedit.math.BlockVector2;

import java.util.concurrent.ThreadLocalRandom;

import static com.google.common.base.Preconditions.checkArgument;

public class SplatterMask2D extends AbstractMask2D {

private final BlockVector2 position;
private final double decay;
private final double sizeSq;

public SplatterMask2D(BlockVector2 position, double decay, double size) {
checkArgument(decay >= 0, "decay must be >= 0");
checkArgument(decay <= 1, "decay must be <= 1");

this.position = position;
this.decay = decay;
this.sizeSq = size * size;
}

@Override
public boolean test(BlockVector2 vector) {
double distSq = vector.distanceSq(position);
double distRatio = distSq / sizeSq;

double decayChance = distRatio * decay * 2;

return ThreadLocalRandom.current().nextDouble() > decayChance;
}
}

0 comments on commit 8358305

Please sign in to comment.