mc 26.1-snap-1
This commit is contained in:
1 parent
4e160d235a
commit
be1211dda7
24 files changed
+61
-60
No files matched your search
@@ -92,6 +92,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.BiPredicate;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
@@ -297,6 +298,8 @@ public class EntityValue extends Value
|
||||
public static final Map<String, EntityClassDescriptor> byName = new HashMap<>()
|
||||
{{
|
||||
List<EntityType<?>> allTypes = BuiltInRegistries.ENTITY_TYPE.stream().toList();
|
||||
BiPredicate<EntityType<?>, TagKey<EntityType<?>>> is = (type, tag) -> type.builtInRegistryHolder().is(tag);
|
||||
|
||||
// nonliving types
|
||||
Set<EntityType<?>> projectiles = Set.of(
|
||||
EntityType.ARROW, EntityType.DRAGON_FIREBALL, EntityType.FIREWORK_ROCKET,
|
||||
@@ -340,7 +343,7 @@ public class EntityValue extends Value
|
||||
);
|
||||
|
||||
Set<EntityType<?>> living = allTypes.stream().filter(et ->
|
||||
!deads.contains(et) && !projectiles.contains(et) && !minecarts.contains(et) && !et.is(EntityTypeTags.BOAT)
|
||||
!deads.contains(et) && !projectiles.contains(et) && !minecarts.contains(et) && !is.test(et, EntityTypeTags.BOAT)
|
||||
).collect(Collectors.toSet());
|
||||
|
||||
Set<EntityType<?>> regular = allTypes.stream().filter(et ->
|
||||
@@ -364,17 +367,17 @@ public class EntityValue extends Value
|
||||
|
||||
// combat groups
|
||||
|
||||
put("arthropod", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (e.getType().is(EntityTypeTags.ARTHROPOD) && e.isAlive()), allTypes.stream().filter(arthropods::contains)));
|
||||
put("!arthropod", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!e.getType().is(EntityTypeTags.ARTHROPOD) && e.isAlive()), allTypes.stream().filter(et -> !arthropods.contains(et) && living.contains(et))));
|
||||
put("arthropod", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (is.test(e.getType(), EntityTypeTags.ARTHROPOD) && e.isAlive()), allTypes.stream().filter(arthropods::contains)));
|
||||
put("!arthropod", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!is.test(e.getType(), EntityTypeTags.ARTHROPOD) && e.isAlive()), allTypes.stream().filter(et -> !arthropods.contains(et) && living.contains(et))));
|
||||
|
||||
put("undead", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (e.getType().is(EntityTypeTags.UNDEAD) && e.isAlive()), allTypes.stream().filter(undeads::contains)));
|
||||
put("!undead", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!e.getType().is(EntityTypeTags.UNDEAD) && e.isAlive()), allTypes.stream().filter(et -> !undeads.contains(et) && living.contains(et))));
|
||||
put("undead", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (is.test(e.getType(), EntityTypeTags.UNDEAD) && e.isAlive()), allTypes.stream().filter(undeads::contains)));
|
||||
put("!undead", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!is.test(e.getType(), EntityTypeTags.UNDEAD) && e.isAlive()), allTypes.stream().filter(et -> !undeads.contains(et) && living.contains(et))));
|
||||
|
||||
put("aquatic", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (e.getType().is(EntityTypeTags.AQUATIC) && e.isAlive()), allTypes.stream().filter(aquatique::contains)));
|
||||
put("!aquatic", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!e.getType().is(EntityTypeTags.AQUATIC) && e.isAlive()), allTypes.stream().filter(et -> !aquatique.contains(et) && living.contains(et))));
|
||||
put("aquatic", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (is.test(e.getType(), EntityTypeTags.AQUATIC) && e.isAlive()), allTypes.stream().filter(aquatique::contains)));
|
||||
put("!aquatic", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!is.test(e.getType(), EntityTypeTags.AQUATIC) && e.isAlive()), allTypes.stream().filter(et -> !aquatique.contains(et) && living.contains(et))));
|
||||
|
||||
put("illager", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (e.getType().is(EntityTypeTags.ILLAGER) && e.isAlive()), allTypes.stream().filter(illagers::contains)));
|
||||
put("!illager", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!e.getType().is(EntityTypeTags.ILLAGER) && e.isAlive()), allTypes.stream().filter(et -> !illagers.contains(et) && living.contains(et))));
|
||||
put("illager", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (is.test(e.getType(), EntityTypeTags.ILLAGER) && e.isAlive()), allTypes.stream().filter(illagers::contains)));
|
||||
put("!illager", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> (!is.test(e.getType(), EntityTypeTags.ILLAGER) && e.isAlive()), allTypes.stream().filter(et -> !illagers.contains(et) && living.contains(et))));
|
||||
|
||||
put("regular", new EntityClassDescriptor(EntityTypeTest.forClass(LivingEntity.class), e -> {
|
||||
EntityType<?> type = e.getType();
|
||||
@@ -457,17 +460,17 @@ public class EntityValue extends Value
|
||||
put("mount", (e, a) -> (e.getVehicle() != null) ? new EntityValue(e.getVehicle()) : Value.NULL);
|
||||
put("unmountable", (e, a) -> BooleanValue.of(Vanilla.Entity_isPermanentVehicle(e)));
|
||||
// deprecated
|
||||
put("tags", (e, a) -> ListValue.wrap(e.getTags().stream().map(StringValue::new)));
|
||||
put("tags", (e, a) -> ListValue.wrap(e.entityTags().stream().map(StringValue::new)));
|
||||
|
||||
put("scoreboard_tags", (e, a) -> ListValue.wrap(e.getTags().stream().map(StringValue::new)));
|
||||
put("scoreboard_tags", (e, a) -> ListValue.wrap(e.entityTags().stream().map(StringValue::new)));
|
||||
put("entity_tags", (e, a) -> {
|
||||
EntityType<?> type = e.getType();
|
||||
return ListValue.wrap(e.level().getServer().registryAccess().lookupOrThrow(Registries.ENTITY_TYPE).getTags().filter(entry -> entry.stream().anyMatch(h -> h.value() == type)).map(entry -> ValueConversions.of(entry)));
|
||||
});
|
||||
// deprecated
|
||||
put("has_tag", (e, a) -> BooleanValue.of(e.getTags().contains(a.getString())));
|
||||
put("has_tag", (e, a) -> BooleanValue.of(e.entityTags().contains(a.getString())));
|
||||
|
||||
put("has_scoreboard_tag", (e, a) -> BooleanValue.of(e.getTags().contains(a.getString())));
|
||||
put("has_scoreboard_tag", (e, a) -> BooleanValue.of(e.entityTags().contains(a.getString())));
|
||||
put("has_entity_tag", (e, a) -> {
|
||||
Optional<HolderSet.Named<EntityType<?>>> tag = e.level().getServer().registryAccess().lookupOrThrow(Registries.ENTITY_TYPE).get(TagKey.create(Registries.ENTITY_TYPE, InputValidator.identifierOf(a.getString())));
|
||||
if (tag.isEmpty())
|
||||
|
||||
Reference in new issue
Block a user