9
0
mirror of https://github.com/GeyserExtensionists/GeyserUtils.git synced 2025-12-19 15:09:24 +00:00

Update api version

This commit is contained in:
zimzaza4
2025-10-15 11:07:19 +08:00
parent 6250e69c68
commit 6c99efe401
9 changed files with 45 additions and 46 deletions

Binary file not shown.

View File

@@ -22,7 +22,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.4.1</version>
<version>3.6.0</version>
<executions>
<execution>
<phase>package</phase>
@@ -79,7 +79,7 @@
<dependency>
<groupId>org.geysermc.geyser</groupId>
<artifactId>core</artifactId>
<version>2.8.0-SNAPSHOT</version>
<version>2.9.0-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/Geyser-Standalone.jar</systemPath>
</dependency>

View File

@@ -40,8 +40,12 @@ import org.geysermc.geyser.api.skin.Cape;
import org.geysermc.geyser.api.skin.Skin;
import org.geysermc.geyser.api.skin.SkinData;
import org.geysermc.geyser.api.skin.SkinGeometry;
import org.geysermc.geyser.api.util.Identifier;
import org.geysermc.geyser.entity.EntityDefinition;
import org.geysermc.geyser.entity.properties.GeyserEntityProperties;
import org.geysermc.geyser.entity.properties.type.BooleanProperty;
import org.geysermc.geyser.entity.properties.type.FloatProperty;
import org.geysermc.geyser.entity.properties.type.IntProperty;
import org.geysermc.geyser.entity.type.Entity;
import org.geysermc.geyser.entity.type.player.PlayerEntity;
import org.geysermc.geyser.registry.Registries;
@@ -94,20 +98,20 @@ public class GeyserUtils implements Extension {
}
// the static here is crazy ;(
private static GeyserEntityProperties getProperties(String id) {
private static GeyserEntityProperties.Builder getProperties(String id) {
if (!properties.containsKey(id)) return null;
GeyserEntityProperties.Builder builder = new GeyserEntityProperties.Builder();
GeyserEntityProperties.Builder builder = new GeyserEntityProperties.Builder(id);
List<Map.Entry<String, Class<?>>> pairs = properties.get(id);
pairs.forEach(p -> {
// only bool, float and int support for now
if (p.getValue() == Boolean.class) builder.addBoolean(p.getKey());
else if (p.getValue() == Float.class) builder.addFloat(p.getKey());
else if (p.getValue() == Integer.class) builder.addInt(p.getKey());
if (p.getValue() == Boolean.class) builder.add(new BooleanProperty(Identifier.of(p.getKey()), false));
else if (p.getValue() == Float.class) builder.add(new FloatProperty(Identifier.of(p.getKey()), Float.MAX_VALUE, Float.MIN_VALUE,0f));
else if (p.getValue() == Integer.class) builder.add(new IntProperty(Identifier.of(p.getKey()), Integer.MAX_VALUE, Integer.MIN_VALUE, 0));
else instance.logger().info("Found unknown property: " + p.getKey());
});
return builder.build();
return builder;
}
private static boolean containsProperty(String entityId, String identifier) {
@@ -135,7 +139,7 @@ public class GeyserUtils implements Extension {
public static void registerPropertiesForGeyser(String entityId) {
GeyserEntityProperties entityProperties = getProperties(entityId);
GeyserEntityProperties entityProperties = getProperties(entityId).build();
if (entityProperties == null) return;
properties.values().stream()
.flatMap(List::stream)
@@ -188,7 +192,7 @@ public class GeyserUtils implements Extension {
);
EntityDefinition<Entity> def = EntityDefinition.builder(null)
.height(0.1f).width(0.1f).identifier(id).registeredProperties(getProperties(id)).build();
.height(0.1f).width(0.1f).identifier(id).propertiesBuilder(getProperties(id)).build();
LOADED_ENTITY_DEFINITIONS.put(id, def);
}
@@ -572,9 +576,9 @@ public class GeyserUtils implements Extension {
if (entity.getPropertyManager() == null) return;
if (entityPropertyPacket.getValue() instanceof Boolean value) {
entity.getPropertyManager().add(entityPropertyPacket.getIdentifier(), value);
entity.getPropertyManager().addProperty(new BooleanProperty(Identifier.of(entityPropertyPacket.getIdentifier()), false), value);
} else if (entityPropertyPacket.getValue() instanceof Integer value) {
entity.getPropertyManager().add(entityPropertyPacket.getIdentifier(), value);
entity.getPropertyManager().addProperty(new IntProperty(Identifier.of(entityPropertyPacket.getIdentifier()), Integer.MAX_VALUE, Integer.MIN_VALUE, 0), value);
}
entity.updateBedrockEntityProperties();
}

View File

@@ -47,7 +47,11 @@ import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.entity.Clie
import static me.zimzaza4.geyserutils.geyser.GeyserUtils.CUSTOM_ENTITIES;
import static me.zimzaza4.geyserutils.geyser.GeyserUtils.LOADED_ENTITY_DEFINITIONS;
public class JavaAddEntityTranslatorReplace extends PacketTranslator<ClientboundAddEntityPacket> {
private static final boolean SHOW_PLAYER_LIST_LOGS = Boolean.parseBoolean(System.getProperty("Geyser.ShowPlayerListLogs", "true"));
@Override
public void translate(GeyserSession session, ClientboundAddEntityPacket packet) {
EntityDefinition<?> definition = Registries.ENTITY_DEFINITIONS.get(packet.getType());
@@ -57,7 +61,7 @@ public class JavaAddEntityTranslatorReplace extends PacketTranslator<Clientbound
}
Vector3f position = Vector3f.from(packet.getX(), packet.getY(), packet.getZ());
Vector3f motion = Vector3f.from(packet.getMotionX(), packet.getMotionY(), packet.getMotionZ());
Vector3f motion = packet.getMovement().toFloat();
float yaw = packet.getYaw();
float pitch = packet.getPitch();
float headYaw = packet.getHeadYaw();
@@ -73,7 +77,9 @@ public class JavaAddEntityTranslatorReplace extends PacketTranslator<Clientbound
} else {
entity = session.getEntityCache().getPlayerEntity(packet.getUuid());
if (entity == null) {
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.entity.player.failed_list", packet.getUuid()));
if (SHOW_PLAYER_LIST_LOGS) {
GeyserImpl.getInstance().getLogger().error(GeyserLocale.getLocaleStringLog("geyser.entity.player.failed_list", packet.getUuid()));
}
return;
}
@@ -110,7 +116,6 @@ public class JavaAddEntityTranslatorReplace extends PacketTranslator<Clientbound
return;
}
} else if (packet.getType() == EntityType.AREA_EFFECT_CLOUD) {
/* todo this fix gets rid of aec's in general, we should see if it's a meg aec somehow */
definition = Registries.ENTITY_DEFINITIONS.get(EntityType.INTERACTION);
entity = definition.factory().create(session, packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(),
packet.getUuid(), definition, position, motion, yaw, pitch, headYaw);
@@ -142,4 +147,7 @@ public class JavaAddEntityTranslatorReplace extends PacketTranslator<Clientbound
session.getEntityCache().spawnEntity(entity);
}
/*
*/
}