mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2024-12-15 04:41:37 +08:00
Add -w flag to butcher for water mobs (#1548)
* Add -w flag to butcher for water mobs * PR feedback
This commit is contained in:
parent
6925d3715a
commit
beb784e0ff
@ -41,6 +41,7 @@
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.WaterMob;
|
||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
@ -164,4 +165,9 @@ public boolean isArmorStand() {
|
||||
public boolean isPasteable() {
|
||||
return !(entity instanceof Player || entity instanceof ComplexEntityPart);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWaterCreature() {
|
||||
return entity instanceof WaterMob;
|
||||
}
|
||||
}
|
||||
|
@ -300,7 +300,9 @@ public void butcherBrush(Player player, LocalSession session,
|
||||
@Switch(name = 'f', desc = "Also kill all friendly mobs (Applies the flags `-abgnpt`)")
|
||||
boolean killFriendly,
|
||||
@Switch(name = 'r', desc = "Also destroy armor stands")
|
||||
boolean killArmorStands) throws WorldEditException {
|
||||
boolean killArmorStands,
|
||||
@Switch(name = 'w', desc = "Also kill water mobs")
|
||||
boolean killWater) throws WorldEditException {
|
||||
LocalConfiguration config = worldEdit.getConfiguration();
|
||||
|
||||
double maxRadius = config.maxBrushRadius;
|
||||
@ -324,6 +326,7 @@ public void butcherBrush(Player player, LocalSession session,
|
||||
flags.or(CreatureButcher.Flags.AMBIENT, killAmbient, "worldedit.butcher.ambient");
|
||||
flags.or(CreatureButcher.Flags.TAGGED, killWithName, "worldedit.butcher.tagged");
|
||||
flags.or(CreatureButcher.Flags.ARMOR_STAND, killArmorStands, "worldedit.butcher.armorstands");
|
||||
flags.or(CreatureButcher.Flags.WATER, killWater, "worldedit.butcher.water");
|
||||
|
||||
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
|
||||
tool.setSize(radius);
|
||||
|
@ -421,7 +421,9 @@ public int butcher(Actor actor,
|
||||
@Switch(name = 'f', desc = "Also kill all friendly mobs (Applies the flags `-abgnpt`)")
|
||||
boolean killFriendly,
|
||||
@Switch(name = 'r', desc = "Also destroy armor stands")
|
||||
boolean killArmorStands) throws WorldEditException {
|
||||
boolean killArmorStands,
|
||||
@Switch(name = 'w', desc = "Also kill water mobs")
|
||||
boolean killWater) throws WorldEditException {
|
||||
LocalConfiguration config = we.getConfiguration();
|
||||
|
||||
if (radius == null) {
|
||||
@ -447,6 +449,7 @@ public int butcher(Actor actor,
|
||||
flags.or(CreatureButcher.Flags.AMBIENT, killAmbient, "worldedit.butcher.ambient");
|
||||
flags.or(CreatureButcher.Flags.TAGGED, killWithName, "worldedit.butcher.tagged");
|
||||
flags.or(CreatureButcher.Flags.ARMOR_STAND, killArmorStands, "worldedit.butcher.armorstands");
|
||||
flags.or(CreatureButcher.Flags.WATER, killWater, "worldedit.butcher.water");
|
||||
|
||||
int killed = killMatchingEntities(radius, actor, flags::createFunction);
|
||||
|
||||
|
@ -36,8 +36,9 @@ public final class Flags {
|
||||
public static final int GOLEMS = 1 << 3;
|
||||
public static final int AMBIENT = 1 << 4;
|
||||
public static final int TAGGED = 1 << 5;
|
||||
public static final int FRIENDLY = PETS | NPCS | ANIMALS | GOLEMS | AMBIENT | TAGGED;
|
||||
public static final int ARMOR_STAND = 1 << 6;
|
||||
public static final int WATER = 1 << 7;
|
||||
public static final int FRIENDLY = PETS | NPCS | ANIMALS | GOLEMS | AMBIENT | TAGGED | WATER;
|
||||
|
||||
private Flags() {
|
||||
}
|
||||
@ -73,6 +74,7 @@ public EntityFunction createFunction() {
|
||||
boolean killAmbient = (flags & Flags.AMBIENT) != 0;
|
||||
boolean killTagged = (flags & Flags.TAGGED) != 0;
|
||||
boolean killArmorStands = (flags & Flags.ARMOR_STAND) != 0;
|
||||
boolean killWaterCreatures = (flags & Flags.WATER) != 0;
|
||||
|
||||
EntityProperties type = entity.getFacet(EntityProperties.class);
|
||||
|
||||
@ -116,6 +118,10 @@ public EntityFunction createFunction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!killWaterCreatures && type.isWaterCreature()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
entity.remove();
|
||||
return true;
|
||||
};
|
||||
|
@ -161,4 +161,11 @@ public interface EntityProperties {
|
||||
* @return true if pasteable
|
||||
*/
|
||||
boolean isPasteable();
|
||||
|
||||
/**
|
||||
* Test whether the entity is a water creature.
|
||||
*
|
||||
* @return true if water creature
|
||||
*/
|
||||
boolean isWaterCreature();
|
||||
}
|
||||
|
@ -32,6 +32,7 @@
|
||||
import net.minecraft.entity.decoration.painting.PaintingEntity;
|
||||
import net.minecraft.entity.mob.AmbientEntity;
|
||||
import net.minecraft.entity.mob.MobEntity;
|
||||
import net.minecraft.entity.mob.WaterCreatureEntity;
|
||||
import net.minecraft.entity.passive.AnimalEntity;
|
||||
import net.minecraft.entity.passive.GolemEntity;
|
||||
import net.minecraft.entity.passive.TameableEntity;
|
||||
@ -147,4 +148,9 @@ public boolean isArmorStand() {
|
||||
public boolean isPasteable() {
|
||||
return !(entity instanceof ServerPlayerEntity || entity instanceof EnderDragonEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWaterCreature() {
|
||||
return entity instanceof WaterCreatureEntity;
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@
|
||||
import net.minecraft.entity.passive.AnimalEntity;
|
||||
import net.minecraft.entity.passive.GolemEntity;
|
||||
import net.minecraft.entity.passive.TameableEntity;
|
||||
import net.minecraft.entity.passive.WaterMobEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
||||
@ -147,4 +148,9 @@ public boolean isArmorStand() {
|
||||
public boolean isPasteable() {
|
||||
return !(entity instanceof ServerPlayerEntity || entity instanceof EnderDragonPartEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWaterCreature() {
|
||||
return entity instanceof WaterMobEntity;
|
||||
}
|
||||
}
|
||||
|
@ -149,4 +149,9 @@ public boolean isArmorStand() {
|
||||
public boolean isPasteable() {
|
||||
return !(entity instanceof Player || entity instanceof ComplexLivingPart);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWaterCreature() {
|
||||
return false; // TODO api8
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user