1
0
mirror of https://github.com/GeyserMC/Geyser.git synced 2025-12-19 14:59:27 +00:00

Minor cleanup

This commit is contained in:
onebeastchris
2025-12-17 14:58:12 +01:00
parent 199737d1ef
commit 2916f3f18f
6 changed files with 46 additions and 17 deletions

View File

@@ -25,6 +25,7 @@
package org.geysermc.geyser.api.entity.data;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.api.GeyserApi;
import org.geysermc.geyser.api.entity.type.GeyserEntity;
@@ -46,7 +47,7 @@ public interface GeyserEntityDataType<T> {
*
* @return the class of the value used by this entity data type
*/
Class<T> typeClass();
@NonNull Class<T> typeClass();
/**
* Gets the unique name of this data type.
@@ -56,12 +57,12 @@ public interface GeyserEntityDataType<T> {
*
* @return the name of this entity data type
*/
String name();
@NonNull String name();
/**
* For API usage only; use the types defined in {@link GeyserEntityDataTypes}
*/
static <T> GeyserEntityDataType<T> of(Class<T> typeClass, String name) {
static <T> GeyserEntityDataType<T> of(@NonNull Class<T> typeClass, @NonNull String name) {
return GeyserApi.api().provider(GeyserEntityDataType.class, typeClass, name);
}
}

View File

@@ -25,24 +25,28 @@
package org.geysermc.geyser.api.entity.data;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.geyser.api.GeyserApi;
import java.util.List;
/**
* Represents a list of objects for an entity data types
* For example, there can be multiple hitboxes on an entity
* Represents a list of objects for specific entity data types.
* For example, there can be multiple hitboxes on an entity.
*
* @param <T>
* @param <T> the object type in the list
*/
public interface GeyserListEntityDataType<T> extends GeyserEntityDataType<List<T>> {
Class<T> listTypeClass();
/**
* @return the class of the list entries
*/
@NonNull Class<T> listEntryClass();
/**
* API usage only, use the types defined in {@link GeyserEntityDataTypes}
*/
static <T> GeyserListEntityDataType<T> of(Class<T> typeClass, String name) {
static <T> GeyserListEntityDataType<T> of(@NonNull Class<T> typeClass, @NonNull String name) {
return GeyserApi.api().provider(GeyserListEntityDataType.class, List.class, typeClass, name);
}
}

View File

@@ -25,6 +25,7 @@
package org.geysermc.geyser.api.entity.data.types;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.math.vector.Vector3f;
import org.geysermc.geyser.api.GeyserApi;
@@ -47,7 +48,7 @@ public interface Hitbox {
/**
* The pivot of the hitbox
* @return
* @return the pivot
*/
Vector3f pivot();
@@ -60,12 +61,33 @@ public interface Hitbox {
*/
interface Builder {
Builder min(Vector3f min);
/**
* Sets the min corner of the hitbox
* @param min the vector of the corner
* @return this builder
*/
Builder min(@NonNull Vector3f min);
Builder max(Vector3f max);
/**
* Sets the max corner of the hitbox
* @param max the vector of the corner
* @return this builder
*/
Builder max(@NonNull Vector3f max);
Builder origin(Vector3f pivot);
/**
* Sets the pivot of the hitbox
* @param pivot the pivot vector
* @return this builder
*/
Builder pivot(@NonNull Vector3f pivot);
/**
* Builds this hitbox, defaulting to {@code Vector3f.ZERO} if
* any one vector was not provided.
*
* @return a new hitbox
*/
Hitbox build();
}
}

View File

@@ -27,6 +27,7 @@ package org.geysermc.geyser.impl.entity;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import lombok.AllArgsConstructor;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataType;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityFlag;
@@ -97,12 +98,12 @@ public class GeyserEntityDataImpl<T> implements GeyserEntityDataType<T> {
}
@Override
public Class<T> typeClass() {
public @NonNull Class<T> typeClass() {
return typeClass;
}
@Override
public String name() {
public @NonNull String name() {
return name;
}

View File

@@ -26,6 +26,7 @@
package org.geysermc.geyser.impl.entity;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.nbt.NbtMap;
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
import org.geysermc.geyser.api.entity.data.GeyserListEntityDataType;
@@ -57,7 +58,7 @@ public class GeyserListEntityDataImpl<ListType> extends GeyserEntityDataImpl<Lis
}
@Override
public Class<ListType> listTypeClass() {
public @NonNull Class<ListType> listEntryClass() {
return listTypeClass;
}
@@ -74,7 +75,7 @@ public class GeyserListEntityDataImpl<ListType> extends GeyserEntityDataImpl<Lis
if (type == null) {
throw new IllegalArgumentException("Unknown entity data type: " + name);
}
if (type.listTypeClass() == listTypeClass) {
if (type.listEntryClass() == listTypeClass) {
return TYPES.get(name);
}
throw new IllegalArgumentException("Unknown entity data type: " + name);

View File

@@ -102,7 +102,7 @@ public record HitboxImpl(
}
@Override
public Hitbox.Builder origin(Vector3f pivot) {
public Hitbox.Builder pivot(Vector3f pivot) {
Objects.requireNonNull(pivot, "pivot");
this.pivot = pivot;
return this;