Added an entity, weathertype, and gamemode registry.

This commit is contained in:
Matthew Miller
2018-07-19 22:41:26 +10:00
parent 572bf04482
commit 663dd1f4d8
33 changed files with 747 additions and 115 deletions

View File

@ -20,7 +20,7 @@
package com.sk89q.worldedit.command.util;
import com.sk89q.minecraft.util.commands.CommandContext;
import com.sk89q.worldedit.entity.metadata.EntityType;
import com.sk89q.worldedit.entity.metadata.EntityProperties;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.function.EntityFunction;
@ -87,7 +87,7 @@ public class CreatureButcher {
boolean killTagged = (flags & Flags.TAGGED) != 0;
boolean killArmorStands = (flags & Flags.ARMOR_STAND) != 0;
EntityType type = entity.getFacet(EntityType.class);
EntityProperties type = entity.getFacet(EntityProperties.class);
if (type == null) {
return false;

View File

@ -22,7 +22,7 @@ package com.sk89q.worldedit.command.util;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.worldedit.entity.metadata.EntityType;
import com.sk89q.worldedit.entity.metadata.EntityProperties;
import com.sk89q.worldedit.function.EntityFunction;
import java.util.regex.Pattern;
@ -37,7 +37,7 @@ public class EntityRemover {
public enum Type {
ALL("all") {
@Override
boolean matches(EntityType type) {
boolean matches(EntityProperties type) {
for (Type value : values()) {
if (value != this && value.matches(type)) {
return true;
@ -48,55 +48,55 @@ public class EntityRemover {
},
PROJECTILES("projectiles?|arrows?") {
@Override
boolean matches(EntityType type) {
boolean matches(EntityProperties type) {
return type.isProjectile();
}
},
ITEMS("items?|drops?") {
@Override
boolean matches(EntityType type) {
boolean matches(EntityProperties type) {
return type.isItem();
}
},
FALLING_BLOCKS("falling(blocks?|sand|gravel)") {
@Override
boolean matches(EntityType type) {
boolean matches(EntityProperties type) {
return type.isFallingBlock();
}
},
PAINTINGS("paintings?|art") {
@Override
boolean matches(EntityType type) {
boolean matches(EntityProperties type) {
return type.isPainting();
}
},
ITEM_FRAMES("(item)frames?") {
@Override
boolean matches(EntityType type) {
boolean matches(EntityProperties type) {
return type.isItemFrame();
}
},
BOATS("boats?") {
@Override
boolean matches(EntityType type) {
boolean matches(EntityProperties type) {
return type.isBoat();
}
},
MINECARTS("(mine)?carts?") {
@Override
boolean matches(EntityType type) {
boolean matches(EntityProperties type) {
return type.isMinecart();
}
},
TNT("tnt") {
@Override
boolean matches(EntityType type) {
boolean matches(EntityProperties type) {
return type.isTNT();
}
},
XP_ORBS("xp") {
@Override
boolean matches(EntityType type) {
boolean matches(EntityProperties type) {
return type.isExperienceOrb();
}
};
@ -111,7 +111,7 @@ public class EntityRemover {
return pattern.matcher(str).matches();
}
abstract boolean matches(EntityType type);
abstract boolean matches(EntityProperties type);
@Nullable
public static Type findByPattern(String str) {
@ -140,7 +140,7 @@ public class EntityRemover {
final Type type = this.type;
checkNotNull(type, "type can't be null");
return entity -> {
EntityType registryType = entity.getFacet(EntityType.class);
EntityProperties registryType = entity.getFacet(EntityProperties.class);
if (registryType != null) {
if (type.matches(registryType)) {
entity.remove();