mirror of
https://github.com/GeyserMC/Geyser.git
synced 2025-12-22 16:29:25 +00:00
Move CustomEntityDefinition into custom package
This commit is contained in:
@@ -30,18 +30,25 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.api.GeyserApi;
|
||||
import org.geysermc.geyser.api.util.Identifier;
|
||||
|
||||
/**
|
||||
* Represents a Java edition entity type
|
||||
*/
|
||||
public interface JavaEntityType {
|
||||
|
||||
Identifier javaIdentifier();
|
||||
/**
|
||||
* @return the identifier of the type
|
||||
*/
|
||||
Identifier identifier();
|
||||
|
||||
/**
|
||||
* @return the
|
||||
*/
|
||||
int javaId();
|
||||
|
||||
boolean isUnregistered();
|
||||
|
||||
boolean vanilla();
|
||||
|
||||
default boolean is(Identifier javaIdentifier) {
|
||||
return javaIdentifier().equals(javaIdentifier);
|
||||
return identifier().equals(javaIdentifier);
|
||||
}
|
||||
|
||||
static JavaEntityType ofVanilla(@NonNull Identifier javaIdentifier) {
|
||||
|
||||
@@ -23,17 +23,17 @@
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.geyser.api.entity;
|
||||
package org.geysermc.geyser.api.entity.custom;
|
||||
|
||||
import org.checkerframework.checker.index.qual.Positive;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.common.returnsreceiver.qual.This;
|
||||
import org.geysermc.geyser.api.GeyserApi;
|
||||
import org.geysermc.geyser.api.util.Identifier;
|
||||
|
||||
public interface CustomEntityDefinition {
|
||||
|
||||
// TODO Identifier
|
||||
String bedrockIdentifier();
|
||||
Identifier bedrockIdentifier();
|
||||
|
||||
float width();
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
package org.geysermc.geyser.api.event.lifecycle;
|
||||
|
||||
import org.geysermc.event.Event;
|
||||
import org.geysermc.geyser.api.entity.CustomEntityDefinition;
|
||||
import org.geysermc.geyser.api.entity.custom.CustomEntityDefinition;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.entity.CustomEntityDefinition;
|
||||
import org.geysermc.geyser.api.entity.custom.CustomEntityDefinition;
|
||||
import org.geysermc.geyser.api.entity.property.GeyserEntityProperty;
|
||||
import org.geysermc.geyser.api.entity.property.type.GeyserFloatEntityProperty;
|
||||
import org.geysermc.geyser.api.entity.property.type.GeyserStringEnumProperty;
|
||||
|
||||
@@ -32,7 +32,7 @@ import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.checkerframework.checker.index.qual.Positive;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.api.entity.CustomEntityDefinition;
|
||||
import org.geysermc.geyser.api.entity.custom.CustomEntityDefinition;
|
||||
import org.geysermc.geyser.api.entity.JavaEntityType;
|
||||
import org.geysermc.geyser.api.predicate.MinecraftPredicate;
|
||||
import org.geysermc.geyser.api.predicate.PredicateStrategy;
|
||||
|
||||
@@ -46,7 +46,7 @@ import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
public record GeyserEntityType(Identifier javaIdentifier, int javaId) implements JavaEntityType {
|
||||
public record GeyserEntityType(Identifier identifier, int javaId) implements JavaEntityType {
|
||||
private static final Identifier UNREGISTERED = IdentifierImpl.of(Constants.GEYSER_CUSTOM_NAMESPACE, "unregistered_sadface");
|
||||
|
||||
private static final Map<BuiltinEntityType, GeyserEntityType> VANILLA = new EnumMap<>(BuiltinEntityType.class);
|
||||
@@ -67,9 +67,8 @@ public record GeyserEntityType(Identifier javaIdentifier, int javaId) implements
|
||||
this(UNREGISTERED, javaId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnregistered() {
|
||||
return javaIdentifier.equals(UNREGISTERED);
|
||||
return identifier.equals(UNREGISTERED);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -138,7 +138,7 @@ public class VanillaEntityDefinition<T extends Entity> extends EntityDefinition<
|
||||
if (type == null) {
|
||||
throw new IllegalStateException("Missing entity type!");
|
||||
} else if (bedrockIdentifier == null) {
|
||||
bedrockIdentifier = type.javaIdentifier().toString();
|
||||
bedrockIdentifier = type.identifier().toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ public class VanillaEntityDefinition<T extends Entity> extends EntityDefinition<
|
||||
VanillaEntityDefinition<T> definition = new VanillaEntityDefinition<>(factory, type, bedrockIdentifier, width, height, offset, registeredProperties, translators);
|
||||
if (register && definition.entityType() != null) {
|
||||
Registries.ENTITY_DEFINITIONS.get().putIfAbsent(definition.entityType(), definition);
|
||||
Registries.JAVA_ENTITY_IDENTIFIERS.get().putIfAbsent(type.javaIdentifier().toString(), definition);
|
||||
Registries.JAVA_ENTITY_IDENTIFIERS.get().putIfAbsent(type.identifier().toString(), definition);
|
||||
}
|
||||
return definition;
|
||||
}
|
||||
|
||||
@@ -669,6 +669,8 @@ public class Entity implements GeyserEntity {
|
||||
return this.valid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Update the suggestion that the client currently has on their screen for this entity (for example, "Feed" or "Ride")
|
||||
*/
|
||||
|
||||
@@ -111,7 +111,7 @@ public interface RegistryHasher<DirectType> extends MinecraftHasher<Integer> {
|
||||
|
||||
RegistryHasher<?> ENTITY_TYPE = registry(JavaRegistries.ENTITY_TYPE);
|
||||
|
||||
MinecraftHasher<EntityType> ENTITY_TYPE_KEY = IDENTIFIER.cast(type -> GeyserEntityType.of(type).javaIdentifier());
|
||||
MinecraftHasher<EntityType> ENTITY_TYPE_KEY = IDENTIFIER.cast(type -> GeyserEntityType.of(type).identifier());
|
||||
|
||||
MinecraftHasher<BlockEntityType> BLOCK_ENTITY_TYPE_KEY = enumRegistry();
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ import org.cloudburstmc.protocol.bedrock.data.biome.BiomeDefinitions;
|
||||
import org.cloudburstmc.protocol.bedrock.data.inventory.crafting.PotionMixData;
|
||||
import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket;
|
||||
import org.geysermc.geyser.GeyserImpl;
|
||||
import org.geysermc.geyser.api.entity.CustomEntityDefinition;
|
||||
import org.geysermc.geyser.api.entity.JavaEntityType;
|
||||
import org.geysermc.geyser.entity.GeyserCustomEntityDefinition;
|
||||
import org.geysermc.geyser.entity.VanillaEntityDefinition;
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.geysermc.geyser.api.block.custom.component.GeometryComponent;
|
||||
import org.geysermc.geyser.api.block.custom.component.MaterialInstance;
|
||||
import org.geysermc.geyser.api.block.custom.nonvanilla.JavaBlockState;
|
||||
import org.geysermc.geyser.api.command.Command;
|
||||
import org.geysermc.geyser.api.entity.CustomEntityDefinition;
|
||||
import org.geysermc.geyser.api.entity.custom.CustomEntityDefinition;
|
||||
import org.geysermc.geyser.api.entity.JavaEntityType;
|
||||
import org.geysermc.geyser.api.event.EventRegistrar;
|
||||
import org.geysermc.geyser.api.extension.Extension;
|
||||
|
||||
@@ -189,7 +189,7 @@ public class JavaRegistries {
|
||||
}
|
||||
|
||||
private static RegistryEntryData<GeyserEntityType> wrap(GeyserEntityType type) {
|
||||
return new RegistryEntryData<>(type.javaId(), MinecraftKey.identifierToKey(type.javaIdentifier()), type);
|
||||
return new RegistryEntryData<>(type.javaId(), MinecraftKey.identifierToKey(type.identifier()), type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -366,7 +366,7 @@ public final class EntityUtils {
|
||||
return "Player"; // the player's name is always shown instead
|
||||
}
|
||||
// this works at least with all 1.20.5 entities, except the killer bunny since that's not an entity type.
|
||||
Identifier typeName = type.javaIdentifier();
|
||||
Identifier typeName = type.identifier();
|
||||
return translatedEntityName(typeName.namespace(), typeName.path(), session);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user