mirror of
https://github.com/GeyserExtensionists/GeyserUtils.git
synced 2025-12-20 07:29:22 +00:00
General cleanup & black particles fix.
This commit is contained in:
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@@ -1,3 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="EntryPointsManager">
|
<component name="EntryPointsManager">
|
||||||
<list size="4">
|
<list size="4">
|
||||||
@@ -19,7 +20,7 @@
|
|||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="corretto-17" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -11,6 +11,31 @@ import java.util.TreeMap;
|
|||||||
@Getter
|
@Getter
|
||||||
public class CameraPreset {
|
public class CameraPreset {
|
||||||
private static final Map<String, CameraPreset> PRESETS = new TreeMap<>();
|
private static final Map<String, CameraPreset> PRESETS = new TreeMap<>();
|
||||||
|
public static CameraPreset FIRST_PERSON;
|
||||||
|
public static CameraPreset FREE;
|
||||||
|
public static CameraPreset THIRD_PERSON;
|
||||||
|
public static CameraPreset THIRD_PERSON_FRONT;
|
||||||
|
private String identifier;
|
||||||
|
@Getter
|
||||||
|
private String inheritFrom;
|
||||||
|
@Getter
|
||||||
|
@Nullable
|
||||||
|
private Pos pos;
|
||||||
|
@Getter
|
||||||
|
@Nullable
|
||||||
|
private Rot rot;
|
||||||
|
@Getter
|
||||||
|
private int id;
|
||||||
|
@Builder
|
||||||
|
public CameraPreset(String identifier, String inheritFrom, @Nullable Pos pos, @Nullable Rot rot) {
|
||||||
|
this.identifier = identifier;
|
||||||
|
this.inheritFrom = inheritFrom != null ? inheritFrom : "";
|
||||||
|
this.pos = pos;
|
||||||
|
this.rot = rot;
|
||||||
|
}
|
||||||
|
protected CameraPreset() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static Map<String, CameraPreset> getPresets() {
|
public static Map<String, CameraPreset> getPresets() {
|
||||||
return PRESETS;
|
return PRESETS;
|
||||||
@@ -34,11 +59,6 @@ public class CameraPreset {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CameraPreset FIRST_PERSON;
|
|
||||||
public static CameraPreset FREE;
|
|
||||||
public static CameraPreset THIRD_PERSON;
|
|
||||||
public static CameraPreset THIRD_PERSON_FRONT;
|
|
||||||
|
|
||||||
public static void load() {
|
public static void load() {
|
||||||
FIRST_PERSON = CameraPreset.builder()
|
FIRST_PERSON = CameraPreset.builder()
|
||||||
.identifier("minecraft:first_person")
|
.identifier("minecraft:first_person")
|
||||||
@@ -57,29 +77,4 @@ public class CameraPreset {
|
|||||||
|
|
||||||
registerCameraPresets(FIRST_PERSON, FREE, THIRD_PERSON, THIRD_PERSON_FRONT);
|
registerCameraPresets(FIRST_PERSON, FREE, THIRD_PERSON, THIRD_PERSON_FRONT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String identifier;
|
|
||||||
@Getter
|
|
||||||
private String inheritFrom;
|
|
||||||
@Getter
|
|
||||||
@Nullable
|
|
||||||
private Pos pos;
|
|
||||||
@Getter
|
|
||||||
@Nullable
|
|
||||||
private Rot rot;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private int id;
|
|
||||||
|
|
||||||
@Builder
|
|
||||||
public CameraPreset(String identifier, String inheritFrom, @Nullable Pos pos, @Nullable Rot rot) {
|
|
||||||
this.identifier = identifier;
|
|
||||||
this.inheritFrom = inheritFrom != null ? inheritFrom : "";
|
|
||||||
this.pos = pos;
|
|
||||||
this.rot = rot;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected CameraPreset() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
package me.zimzaza4.geyserutils.common.camera.data;
|
package me.zimzaza4.geyserutils.common.camera.data;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ public enum EaseType {
|
|||||||
|
|
||||||
private final String type;
|
private final String type;
|
||||||
private final int index;
|
private final int index;
|
||||||
|
|
||||||
EaseType(String type, int index) {
|
EaseType(String type, int index) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ public class ClearInstruction implements Instruction {
|
|||||||
private static final ClearInstruction INSTANCE = new ClearInstruction();
|
private static final ClearInstruction INSTANCE = new ClearInstruction();
|
||||||
private final int clear = 1;
|
private final int clear = 1;
|
||||||
|
|
||||||
private ClearInstruction() {}
|
private ClearInstruction() {
|
||||||
|
}
|
||||||
|
|
||||||
public static ClearInstruction instance() {
|
public static ClearInstruction instance() {
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
|
|||||||
@@ -16,5 +16,6 @@ public class FadeInstruction implements Instruction {
|
|||||||
@Nullable
|
@Nullable
|
||||||
private Time time;
|
private Time time;
|
||||||
|
|
||||||
protected FadeInstruction() {}
|
protected FadeInstruction() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package me.zimzaza4.geyserutils.common.camera.instruction;
|
package me.zimzaza4.geyserutils.common.camera.instruction;
|
||||||
|
|
||||||
import lombok.*;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
import me.zimzaza4.geyserutils.common.camera.data.CameraPreset;
|
import me.zimzaza4.geyserutils.common.camera.data.CameraPreset;
|
||||||
import me.zimzaza4.geyserutils.common.camera.data.Ease;
|
import me.zimzaza4.geyserutils.common.camera.data.Ease;
|
||||||
import me.zimzaza4.geyserutils.common.util.Pos;
|
|
||||||
import me.zimzaza4.geyserutils.common.camera.data.Rot;
|
import me.zimzaza4.geyserutils.common.camera.data.Rot;
|
||||||
|
import me.zimzaza4.geyserutils.common.util.Pos;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@@ -23,5 +25,7 @@ public class SetInstruction implements Instruction {
|
|||||||
private CameraPreset preset;
|
private CameraPreset preset;
|
||||||
@Nullable
|
@Nullable
|
||||||
private FadeInstruction fade;
|
private FadeInstruction fade;
|
||||||
protected SetInstruction() {}
|
|
||||||
|
protected SetInstruction() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,8 @@ package me.zimzaza4.geyserutils.common.form.element;
|
|||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.Value;
|
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@@ -16,6 +14,7 @@ public class NpcDialogueButton {
|
|||||||
private List<String> commands;
|
private List<String> commands;
|
||||||
private ButtonMode mode;
|
private ButtonMode mode;
|
||||||
private boolean hasNextForm;
|
private boolean hasNextForm;
|
||||||
|
|
||||||
public enum ButtonMode {
|
public enum ButtonMode {
|
||||||
BUTTON_MODE,
|
BUTTON_MODE,
|
||||||
ON_ENTER,
|
ON_ENTER,
|
||||||
|
|||||||
@@ -2,18 +2,13 @@ package me.zimzaza4.geyserutils.common.manager;
|
|||||||
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.jsontype.BasicPolymorphicTypeValidator;
|
|
||||||
import com.fasterxml.jackson.databind.jsontype.PolymorphicTypeValidator;
|
|
||||||
import me.zimzaza4.geyserutils.common.packet.CustomPayloadPacket;
|
import me.zimzaza4.geyserutils.common.packet.CustomPayloadPacket;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
|
|
||||||
public class PacketManager {
|
public class PacketManager {
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package me.zimzaza4.geyserutils.common.packet;
|
package me.zimzaza4.geyserutils.common.packet;
|
||||||
|
|
||||||
import lombok.*;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ import lombok.Getter;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
|||||||
@@ -4,12 +4,8 @@ import lombok.AllArgsConstructor;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.experimental.Accessors;
|
|
||||||
import me.zimzaza4.geyserutils.common.animation.Animation;
|
|
||||||
import me.zimzaza4.geyserutils.common.packet.CustomPayloadPacket;
|
|
||||||
import me.zimzaza4.geyserutils.common.particle.CustomParticle;
|
import me.zimzaza4.geyserutils.common.particle.CustomParticle;
|
||||||
import me.zimzaza4.geyserutils.common.util.Pos;
|
import me.zimzaza4.geyserutils.common.util.Pos;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
|||||||
@@ -1,11 +1,6 @@
|
|||||||
package me.zimzaza4.geyserutils.common.packet;
|
package me.zimzaza4.geyserutils.common.packet;
|
||||||
|
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
public abstract class CustomPayloadPacket {
|
public abstract class CustomPayloadPacket {
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,6 @@ import lombok.Getter;
|
|||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Setter
|
@Setter
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
|||||||
@@ -3,5 +3,4 @@ package me.zimzaza4.geyserutils.common.util;
|
|||||||
public class CustomPayloadPacketUtils {
|
public class CustomPayloadPacketUtils {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,30 +72,20 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class GeyserUtils implements Extension {
|
public class GeyserUtils implements Extension {
|
||||||
|
|
||||||
|
|
||||||
|
public static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(2);
|
||||||
|
private static final Map<String, List<Map.Entry<String, Class<?>>>> properties = new HashMap<>();
|
||||||
@Getter
|
@Getter
|
||||||
public static PacketManager packetManager = new PacketManager();
|
public static PacketManager packetManager = new PacketManager();
|
||||||
|
|
||||||
public static List<String> REGISTERED_ENTITIES = new ArrayList<>();
|
public static List<String> REGISTERED_ENTITIES = new ArrayList<>();
|
||||||
private static List<String> ENTITIES_WAIT_FOR_LOAD = new ArrayList<>();
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean GEYSER_LOADED = false;
|
public static boolean GEYSER_LOADED = false;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public static Map<String, SkinData> LOADED_SKIN_DATA = new HashMap<>();
|
public static Map<String, SkinData> LOADED_SKIN_DATA = new HashMap<>();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public static Map<String, EntityDefinition> LOADED_ENTITY_DEFINITIONS = new HashMap<>();
|
public static Map<String, EntityDefinition> LOADED_ENTITY_DEFINITIONS = new HashMap<>();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public static Map<GeyserConnection, Cache<Integer, String>> CUSTOM_ENTITIES = new ConcurrentHashMap<>();
|
public static Map<GeyserConnection, Cache<Integer, String>> CUSTOM_ENTITIES = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
static Cape EMPTY_CAPE = new Cape("", "no-cape", new byte[0], true);
|
static Cape EMPTY_CAPE = new Cape("", "no-cape", new byte[0], true);
|
||||||
|
private static List<String> ENTITIES_WAIT_FOR_LOAD = new ArrayList<>();
|
||||||
public static final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(2);
|
|
||||||
|
|
||||||
private static final Map<String, List<Map.Entry<String, Class<?>>>> properties = new HashMap<>();
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private static GeyserUtils instance;
|
private static GeyserUtils instance;
|
||||||
|
|
||||||
@@ -103,25 +93,6 @@ public class GeyserUtils implements Extension {
|
|||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onEnable(GeyserPostInitializeEvent event) {
|
|
||||||
Registries.BEDROCK_PACKET_TRANSLATORS.register(NpcRequestPacket.class, new NPCFormResponseTranslator());
|
|
||||||
loadSkins();
|
|
||||||
ReflectionUtils.init();
|
|
||||||
CameraPreset.load();
|
|
||||||
|
|
||||||
replaceTranslator();
|
|
||||||
GEYSER_LOADED = true;
|
|
||||||
for (String registeredEntity : REGISTERED_ENTITIES) {
|
|
||||||
registerEntityToGeyser(registeredEntity);
|
|
||||||
}
|
|
||||||
for (String id : ENTITIES_WAIT_FOR_LOAD) {
|
|
||||||
registerPropertiesForGeyser(id);
|
|
||||||
}
|
|
||||||
logger().info("Defined " + LOADED_ENTITY_DEFINITIONS.size() + " entities");
|
|
||||||
MountFix.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
// the static here is crazy ;(
|
// the static here is crazy ;(
|
||||||
private static GeyserEntityProperties getProperties(String id) {
|
private static GeyserEntityProperties getProperties(String id) {
|
||||||
if (!properties.containsKey(id)) return null;
|
if (!properties.containsKey(id)) return null;
|
||||||
@@ -200,6 +171,7 @@ public class GeyserUtils implements Extension {
|
|||||||
}
|
}
|
||||||
REGISTERED_ENTITIES.add(id);
|
REGISTERED_ENTITIES.add(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerEntityToGeyser(String id) {
|
public static void registerEntityToGeyser(String id) {
|
||||||
NbtMap registry = Registries.BEDROCK_ENTITY_IDENTIFIERS.get();
|
NbtMap registry = Registries.BEDROCK_ENTITY_IDENTIFIERS.get();
|
||||||
List<NbtMap> idList = new ArrayList<>(registry.getList("idlist", NbtType.COMPOUND));
|
List<NbtMap> idList = new ArrayList<>(registry.getList("idlist", NbtType.COMPOUND));
|
||||||
@@ -221,6 +193,153 @@ public class GeyserUtils implements Extension {
|
|||||||
LOADED_ENTITY_DEFINITIONS.put(id, def);
|
LOADED_ENTITY_DEFINITIONS.put(id, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static AnimateEntityPacket getAnimateEntityPacket(AnimateEntityCustomPayloadPacket animateEntityCustomPayloadPacket) {
|
||||||
|
AnimateEntityPacket animateEntityPacket = new AnimateEntityPacket();
|
||||||
|
animateEntityPacket.setAnimation(animateEntityCustomPayloadPacket.getAnimation());
|
||||||
|
animateEntityPacket.setController(animateEntityCustomPayloadPacket.getController());
|
||||||
|
animateEntityPacket.setBlendOutTime(animateEntityCustomPayloadPacket.getBlendOutTime());
|
||||||
|
animateEntityPacket.setNextState(animateEntityCustomPayloadPacket.getNextState());
|
||||||
|
animateEntityPacket.setStopExpressionVersion(animateEntityCustomPayloadPacket.getStopExpressionVersion());
|
||||||
|
animateEntityPacket.setStopExpression(animateEntityCustomPayloadPacket.getStopExpression());
|
||||||
|
return animateEntityPacket;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendSkinPacket(GeyserSession session, PlayerEntity entity, SkinData skinData) {
|
||||||
|
Skin skin = skinData.skin();
|
||||||
|
Cape cape = skinData.cape();
|
||||||
|
SkinGeometry geometry = skinData.geometry();
|
||||||
|
|
||||||
|
if (entity.getUuid().equals(session.getPlayerEntity().getUuid())) {
|
||||||
|
PlayerListPacket.Entry updatedEntry = buildEntryManually(
|
||||||
|
session,
|
||||||
|
entity.getUuid(),
|
||||||
|
entity.getUsername(),
|
||||||
|
entity.getGeyserId(),
|
||||||
|
skin,
|
||||||
|
cape,
|
||||||
|
geometry
|
||||||
|
);
|
||||||
|
|
||||||
|
PlayerListPacket playerAddPacket = new PlayerListPacket();
|
||||||
|
playerAddPacket.setAction(PlayerListPacket.Action.ADD);
|
||||||
|
playerAddPacket.getEntries().add(updatedEntry);
|
||||||
|
session.sendUpstreamPacket(playerAddPacket);
|
||||||
|
} else {
|
||||||
|
PlayerSkinPacket packet = new PlayerSkinPacket();
|
||||||
|
packet.setUuid(entity.getUuid());
|
||||||
|
packet.setOldSkinName("");
|
||||||
|
packet.setNewSkinName(skin.textureUrl());
|
||||||
|
packet.setSkin(getSkin(skin.textureUrl(), skin, cape, geometry));
|
||||||
|
packet.setTrustedSkin(true);
|
||||||
|
session.sendUpstreamPacket(packet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PlayerListPacket.Entry buildEntryManually(GeyserSession session, UUID uuid, String username, long geyserId,
|
||||||
|
Skin skin,
|
||||||
|
Cape cape,
|
||||||
|
SkinGeometry geometry) {
|
||||||
|
SerializedSkin serializedSkin = getSkin(skin.textureUrl(), skin, cape, geometry);
|
||||||
|
|
||||||
|
String xuid = "";
|
||||||
|
GeyserSession playerSession = GeyserImpl.getInstance().connectionByUuid(uuid);
|
||||||
|
|
||||||
|
if (playerSession != null) {
|
||||||
|
xuid = playerSession.getAuthData().xuid();
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerListPacket.Entry entry;
|
||||||
|
if (session.getPlayerEntity().getUuid().equals(uuid)) {
|
||||||
|
entry = new PlayerListPacket.Entry(session.getAuthData().uuid());
|
||||||
|
} else {
|
||||||
|
entry = new PlayerListPacket.Entry(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
entry.setName(username);
|
||||||
|
entry.setEntityId(geyserId);
|
||||||
|
entry.setSkin(serializedSkin);
|
||||||
|
entry.setXuid(xuid);
|
||||||
|
entry.setPlatformChatId("");
|
||||||
|
entry.setTeacher(false);
|
||||||
|
entry.setTrustedSkin(true);
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static SerializedSkin getSkin(String skinId, Skin skin, Cape cape, SkinGeometry geometry) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
ImageData image = ImageData.from(ImageIO.read(new ByteArrayInputStream(skin.skinData())));
|
||||||
|
return SerializedSkin.of(skinId, "", geometry.geometryName(), image, Collections.emptyList(), ImageData.of(cape.capeData()), geometry.geometryData(), "", true, false, false, cape.capeId(), skinId);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Cape getEmptyCapeData() {
|
||||||
|
return EMPTY_CAPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getColor(int argb) {
|
||||||
|
int r = (argb >> 16) & 0xFF;
|
||||||
|
int g = (argb >> 8) & 0xFF;
|
||||||
|
int b = argb & 0xFF;
|
||||||
|
|
||||||
|
double[] colorLab = DeltaUtils.rgbToLab(r, g, b);
|
||||||
|
|
||||||
|
List<int[]> colors = Arrays.asList(
|
||||||
|
new int[]{249, 255, 254}, // 0: White
|
||||||
|
new int[]{249, 128, 29}, // 1: Orange
|
||||||
|
new int[]{199, 78, 189}, // 2: Magenta
|
||||||
|
new int[]{58, 179, 218}, // 3: Light Blue
|
||||||
|
new int[]{254, 216, 61}, // 4: Yellow
|
||||||
|
new int[]{128, 199, 31}, // 5: Lime
|
||||||
|
new int[]{243, 139, 170}, // 6: Pink
|
||||||
|
new int[]{71, 79, 82}, // 7: Gray
|
||||||
|
new int[]{159, 157, 151}, // 8: Light Gray
|
||||||
|
new int[]{22, 156, 156}, // 9: Cyan
|
||||||
|
new int[]{137, 50, 184}, // 10: Purple
|
||||||
|
new int[]{60, 68, 170}, // 11: Blue
|
||||||
|
new int[]{131, 84, 50}, // 12: Brown
|
||||||
|
new int[]{94, 124, 22}, // 13: Green
|
||||||
|
new int[]{176, 46, 38}, // 14: Red
|
||||||
|
new int[]{29, 29, 33} // 15: Black
|
||||||
|
);
|
||||||
|
|
||||||
|
int closestColorIndex = -1;
|
||||||
|
double minDeltaE = Double.MAX_VALUE;
|
||||||
|
|
||||||
|
for (int i = 0; i < colors.size(); i++) {
|
||||||
|
int[] rgb = colors.get(i);
|
||||||
|
double[] lab = DeltaUtils.rgbToLab(rgb[0], rgb[1], rgb[2]);
|
||||||
|
double deltaE = DeltaUtils.calculateDeltaE(colorLab, lab);
|
||||||
|
if (deltaE < minDeltaE) {
|
||||||
|
minDeltaE = deltaE;
|
||||||
|
closestColorIndex = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return closestColorIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onEnable(GeyserPostInitializeEvent event) {
|
||||||
|
Registries.BEDROCK_PACKET_TRANSLATORS.register(NpcRequestPacket.class, new NPCFormResponseTranslator());
|
||||||
|
loadSkins();
|
||||||
|
ReflectionUtils.init();
|
||||||
|
CameraPreset.load();
|
||||||
|
|
||||||
|
replaceTranslator();
|
||||||
|
GEYSER_LOADED = true;
|
||||||
|
for (String registeredEntity : REGISTERED_ENTITIES) {
|
||||||
|
registerEntityToGeyser(registeredEntity);
|
||||||
|
}
|
||||||
|
for (String id : ENTITIES_WAIT_FOR_LOAD) {
|
||||||
|
registerPropertiesForGeyser(id);
|
||||||
|
}
|
||||||
|
logger().info("Defined " + LOADED_ENTITY_DEFINITIONS.size() + " entities");
|
||||||
|
MountFix.start();
|
||||||
|
}
|
||||||
|
|
||||||
public void replaceTranslator() {
|
public void replaceTranslator() {
|
||||||
Registries.JAVA_PACKET_TRANSLATORS
|
Registries.JAVA_PACKET_TRANSLATORS
|
||||||
@@ -294,8 +413,6 @@ public class GeyserUtils implements Extension {
|
|||||||
CUSTOM_ENTITIES.remove(event.connection());
|
CUSTOM_ENTITIES.remove(event.connection());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void registerPacketListener(GeyserSession session) {
|
public void registerPacketListener(GeyserSession session) {
|
||||||
|
|
||||||
scheduler.schedule(() -> {
|
scheduler.schedule(() -> {
|
||||||
@@ -334,9 +451,7 @@ public class GeyserUtils implements Extension {
|
|||||||
private void handleCustomPacket(GeyserSession session, CustomPayloadPacket customPacket) {
|
private void handleCustomPacket(GeyserSession session, CustomPayloadPacket customPacket) {
|
||||||
if (customPacket instanceof BundlePacket bundlePacket) {
|
if (customPacket instanceof BundlePacket bundlePacket) {
|
||||||
bundlePacket.getPackets().forEach(p -> handleCustomPacket(session, p));
|
bundlePacket.getPackets().forEach(p -> handleCustomPacket(session, p));
|
||||||
}
|
} else if (customPacket instanceof CameraShakeCustomPayloadPacket cameraShakePacket) {
|
||||||
|
|
||||||
else if (customPacket instanceof CameraShakeCustomPayloadPacket cameraShakePacket) {
|
|
||||||
session.camera().shakeCamera(cameraShakePacket.getIntensity(), cameraShakePacket.getDuration(), CameraShake.values()[cameraShakePacket.getType()]);
|
session.camera().shakeCamera(cameraShakePacket.getIntensity(), cameraShakePacket.getDuration(), CameraShake.values()[cameraShakePacket.getType()]);
|
||||||
} else if (customPacket instanceof NpcDialogueFormDataCustomPayloadPacket formData) {
|
} else if (customPacket instanceof NpcDialogueFormDataCustomPayloadPacket formData) {
|
||||||
|
|
||||||
@@ -437,9 +552,12 @@ public class GeyserUtils implements Extension {
|
|||||||
} else if (customPacket instanceof CustomEntityDataPacket customEntityDataPacket) {
|
} else if (customPacket instanceof CustomEntityDataPacket customEntityDataPacket) {
|
||||||
Entity entity = session.getEntityCache().getEntityByJavaId(customEntityDataPacket.getEntityId());
|
Entity entity = session.getEntityCache().getEntityByJavaId(customEntityDataPacket.getEntityId());
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
if (customEntityDataPacket.getHeight() != null) entity.setBoundingBoxHeight(customEntityDataPacket.getHeight());
|
if (customEntityDataPacket.getHeight() != null)
|
||||||
if (customEntityDataPacket.getWidth() != null) entity.setBoundingBoxWidth(customEntityDataPacket.getWidth());
|
entity.setBoundingBoxHeight(customEntityDataPacket.getHeight());
|
||||||
if (customEntityDataPacket.getScale() != null) entity.getDirtyMetadata().put(EntityDataTypes.SCALE, customEntityDataPacket.getScale());
|
if (customEntityDataPacket.getWidth() != null)
|
||||||
|
entity.setBoundingBoxWidth(customEntityDataPacket.getWidth());
|
||||||
|
if (customEntityDataPacket.getScale() != null)
|
||||||
|
entity.getDirtyMetadata().put(EntityDataTypes.SCALE, customEntityDataPacket.getScale());
|
||||||
if (customEntityDataPacket.getColor() != null)
|
if (customEntityDataPacket.getColor() != null)
|
||||||
entity.getDirtyMetadata().put(EntityDataTypes.COLOR, Byte.parseByte(String.valueOf(getColor(customEntityDataPacket.getColor()))));
|
entity.getDirtyMetadata().put(EntityDataTypes.COLOR, Byte.parseByte(String.valueOf(getColor(customEntityDataPacket.getColor()))));
|
||||||
if (customEntityDataPacket.getVariant() != null)
|
if (customEntityDataPacket.getVariant() != null)
|
||||||
@@ -481,135 +599,5 @@ public class GeyserUtils implements Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private static AnimateEntityPacket getAnimateEntityPacket(AnimateEntityCustomPayloadPacket animateEntityCustomPayloadPacket) {
|
|
||||||
AnimateEntityPacket animateEntityPacket = new AnimateEntityPacket();
|
|
||||||
animateEntityPacket.setAnimation(animateEntityCustomPayloadPacket.getAnimation());
|
|
||||||
animateEntityPacket.setController(animateEntityCustomPayloadPacket.getController());
|
|
||||||
animateEntityPacket.setBlendOutTime(animateEntityCustomPayloadPacket.getBlendOutTime());
|
|
||||||
animateEntityPacket.setNextState(animateEntityCustomPayloadPacket.getNextState());
|
|
||||||
animateEntityPacket.setStopExpressionVersion(animateEntityCustomPayloadPacket.getStopExpressionVersion());
|
|
||||||
animateEntityPacket.setStopExpression(animateEntityCustomPayloadPacket.getStopExpression());
|
|
||||||
return animateEntityPacket;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendSkinPacket(GeyserSession session, PlayerEntity entity, SkinData skinData) {
|
|
||||||
Skin skin = skinData.skin();
|
|
||||||
Cape cape = skinData.cape();
|
|
||||||
SkinGeometry geometry = skinData.geometry();
|
|
||||||
|
|
||||||
if (entity.getUuid().equals(session.getPlayerEntity().getUuid())) {
|
|
||||||
PlayerListPacket.Entry updatedEntry = buildEntryManually(
|
|
||||||
session,
|
|
||||||
entity.getUuid(),
|
|
||||||
entity.getUsername(),
|
|
||||||
entity.getGeyserId(),
|
|
||||||
skin,
|
|
||||||
cape,
|
|
||||||
geometry
|
|
||||||
);
|
|
||||||
|
|
||||||
PlayerListPacket playerAddPacket = new PlayerListPacket();
|
|
||||||
playerAddPacket.setAction(PlayerListPacket.Action.ADD);
|
|
||||||
playerAddPacket.getEntries().add(updatedEntry);
|
|
||||||
session.sendUpstreamPacket(playerAddPacket);
|
|
||||||
} else {
|
|
||||||
PlayerSkinPacket packet = new PlayerSkinPacket();
|
|
||||||
packet.setUuid(entity.getUuid());
|
|
||||||
packet.setOldSkinName("");
|
|
||||||
packet.setNewSkinName(skin.textureUrl());
|
|
||||||
packet.setSkin(getSkin(skin.textureUrl(), skin, cape, geometry));
|
|
||||||
packet.setTrustedSkin(true);
|
|
||||||
session.sendUpstreamPacket(packet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PlayerListPacket.Entry buildEntryManually(GeyserSession session, UUID uuid, String username, long geyserId,
|
|
||||||
Skin skin,
|
|
||||||
Cape cape,
|
|
||||||
SkinGeometry geometry) {
|
|
||||||
SerializedSkin serializedSkin = getSkin(skin.textureUrl(), skin, cape, geometry);
|
|
||||||
|
|
||||||
String xuid = "";
|
|
||||||
GeyserSession playerSession = GeyserImpl.getInstance().connectionByUuid(uuid);
|
|
||||||
|
|
||||||
if (playerSession != null) {
|
|
||||||
xuid = playerSession.getAuthData().xuid();
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerListPacket.Entry entry;
|
|
||||||
if (session.getPlayerEntity().getUuid().equals(uuid)) {
|
|
||||||
entry = new PlayerListPacket.Entry(session.getAuthData().uuid());
|
|
||||||
} else {
|
|
||||||
entry = new PlayerListPacket.Entry(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
entry.setName(username);
|
|
||||||
entry.setEntityId(geyserId);
|
|
||||||
entry.setSkin(serializedSkin);
|
|
||||||
entry.setXuid(xuid);
|
|
||||||
entry.setPlatformChatId("");
|
|
||||||
entry.setTeacher(false);
|
|
||||||
entry.setTrustedSkin(true);
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static SerializedSkin getSkin(String skinId, Skin skin, Cape cape, SkinGeometry geometry) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
ImageData image = ImageData.from(ImageIO.read(new ByteArrayInputStream(skin.skinData())));
|
|
||||||
return SerializedSkin.of(skinId, "", geometry.geometryName(),image , Collections.emptyList(), ImageData.of(cape.capeData()), geometry.geometryData(), "", true, false, false, cape.capeId(), skinId);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Cape getEmptyCapeData() {
|
|
||||||
return EMPTY_CAPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int getColor(int argb) {
|
|
||||||
int r = (argb >> 16) & 0xFF;
|
|
||||||
int g = (argb >> 8) & 0xFF;
|
|
||||||
int b = argb & 0xFF;
|
|
||||||
|
|
||||||
double[] colorLab = DeltaUtils.rgbToLab(r, g, b);
|
|
||||||
|
|
||||||
List<int[]> colors = Arrays.asList(
|
|
||||||
new int[]{249, 255, 254}, // 0: White
|
|
||||||
new int[]{249, 128, 29}, // 1: Orange
|
|
||||||
new int[]{199, 78, 189}, // 2: Magenta
|
|
||||||
new int[]{58, 179, 218}, // 3: Light Blue
|
|
||||||
new int[]{254, 216, 61}, // 4: Yellow
|
|
||||||
new int[]{128, 199, 31}, // 5: Lime
|
|
||||||
new int[]{243, 139, 170}, // 6: Pink
|
|
||||||
new int[]{71, 79, 82}, // 7: Gray
|
|
||||||
new int[]{159, 157, 151}, // 8: Light Gray
|
|
||||||
new int[]{22, 156, 156}, // 9: Cyan
|
|
||||||
new int[]{137, 50, 184}, // 10: Purple
|
|
||||||
new int[]{60, 68, 170}, // 11: Blue
|
|
||||||
new int[]{131, 84, 50}, // 12: Brown
|
|
||||||
new int[]{94, 124, 22}, // 13: Green
|
|
||||||
new int[]{176, 46, 38}, // 14: Red
|
|
||||||
new int[]{29, 29, 33} // 15: Black
|
|
||||||
);
|
|
||||||
|
|
||||||
int closestColorIndex = -1;
|
|
||||||
double minDeltaE = Double.MAX_VALUE;
|
|
||||||
|
|
||||||
for (int i = 0; i < colors.size(); i++) {
|
|
||||||
int[] rgb = colors.get(i);
|
|
||||||
double[] lab = DeltaUtils.rgbToLab(rgb[0], rgb[1], rgb[2]);
|
|
||||||
double deltaE = DeltaUtils.calculateDeltaE(colorLab, lab);
|
|
||||||
if (deltaE < minDeltaE) {
|
|
||||||
minDeltaE = deltaE;
|
|
||||||
closestColorIndex = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return closestColorIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package me.zimzaza4.geyserutils.geyser;
|
|||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityLinkData;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityLinkData;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.SetEntityLinkPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.SetEntityLinkPacket;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
import org.geysermc.geyser.GeyserImpl;
|
||||||
import org.geysermc.geyser.entity.EntityDefinition;
|
|
||||||
import org.geysermc.geyser.entity.EntityDefinitions;
|
import org.geysermc.geyser.entity.EntityDefinitions;
|
||||||
import org.geysermc.geyser.entity.type.Entity;
|
import org.geysermc.geyser.entity.type.Entity;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ package me.zimzaza4.geyserutils.geyser.camera;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.cloudburstmc.protocol.common.NamedDefinition;
|
import org.cloudburstmc.protocol.common.NamedDefinition;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class CameraPresetDefinition implements NamedDefinition {
|
public class CameraPresetDefinition implements NamedDefinition {
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import me.zimzaza4.geyserutils.geyser.form.element.Button;
|
|||||||
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
import org.cloudburstmc.protocol.bedrock.data.entity.EntityDataTypes;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.NpcDialoguePacket;
|
import org.cloudburstmc.protocol.bedrock.packet.NpcDialoguePacket;
|
||||||
import org.cloudburstmc.protocol.bedrock.packet.SetEntityDataPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.SetEntityDataPacket;
|
||||||
import org.geysermc.geyser.GeyserImpl;
|
|
||||||
import org.geysermc.geyser.entity.GeyserDirtyMetadata;
|
import org.geysermc.geyser.entity.GeyserDirtyMetadata;
|
||||||
import org.geysermc.geyser.entity.type.Entity;
|
import org.geysermc.geyser.entity.type.Entity;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
@@ -19,7 +18,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@Accessors(fluent = true, chain = true)
|
@Accessors(fluent = true, chain = true)
|
||||||
public class NpcDialogueForm {
|
public class NpcDialogueForm {
|
||||||
@@ -28,29 +26,25 @@ public class NpcDialogueForm {
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final String sceneName = UUID.randomUUID().toString();
|
private final String sceneName = UUID.randomUUID().toString();
|
||||||
|
@Getter
|
||||||
|
private final ObjectArrayList<Button> dialogueButtons = new ObjectArrayList<>();
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private String title;
|
private String title;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private String dialogue;
|
private String dialogue;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private Entity bindEntity;
|
private Entity bindEntity;
|
||||||
private String actionJson = "";
|
private String actionJson = "";
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private String skinData = "{\"picker_offsets\":{\"scale\":[1.70,1.70,1.70],\"translate\":[0,20,0]},\"portrait_offsets\":{\"scale\":[1.750,1.750,1.750],\"translate\":[-7,50,0]},\"skin_list\":[{\"variant\":0},{\"variant\":1},{\"variant\":2},{\"variant\":3},{\"variant\":4},{\"variant\":5},{\"variant\":6},{\"variant\":7},{\"variant\":8},{\"variant\":9},{\"variant\":10},{\"variant\":11},{\"variant\":12},{\"variant\":13},{\"variant\":14},{\"variant\":15},{\"variant\":16},{\"variant\":17},{\"variant\":18},{\"variant\":19},{\"variant\":20},{\"variant\":21},{\"variant\":22},{\"variant\":23},{\"variant\":24},{\"variant\":25},{\"variant\":26},{\"variant\":27},{\"variant\":28},{\"variant\":29},{\"variant\":30},{\"variant\":31},{\"variant\":32},{\"variant\":33},{\"variant\":34}]}";
|
private String skinData = "{\"picker_offsets\":{\"scale\":[1.70,1.70,1.70],\"translate\":[0,20,0]},\"portrait_offsets\":{\"scale\":[1.750,1.750,1.750],\"translate\":[-7,50,0]},\"skin_list\":[{\"variant\":0},{\"variant\":1},{\"variant\":2},{\"variant\":3},{\"variant\":4},{\"variant\":5},{\"variant\":6},{\"variant\":7},{\"variant\":8},{\"variant\":9},{\"variant\":10},{\"variant\":11},{\"variant\":12},{\"variant\":13},{\"variant\":14},{\"variant\":15},{\"variant\":16},{\"variant\":17},{\"variant\":18},{\"variant\":19},{\"variant\":20},{\"variant\":21},{\"variant\":22},{\"variant\":23},{\"variant\":24},{\"variant\":25},{\"variant\":26},{\"variant\":27},{\"variant\":28},{\"variant\":29},{\"variant\":30},{\"variant\":31},{\"variant\":32},{\"variant\":33},{\"variant\":34}]}";
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final ObjectArrayList<Button> dialogueButtons = new ObjectArrayList<>();
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private Runnable closeHandler = () -> { };
|
private Runnable closeHandler = () -> {
|
||||||
|
};
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
package me.zimzaza4.geyserutils.geyser.form;
|
package me.zimzaza4.geyserutils.geyser.form;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class NpcDialogueForms {
|
public class NpcDialogueForms {
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ import static me.zimzaza4.geyserutils.geyser.GeyserUtils.LOADED_ENTITY_DEFINITIO
|
|||||||
|
|
||||||
public class JavaAddEntityTranslatorReplace extends PacketTranslator<ClientboundAddEntityPacket> {
|
public class JavaAddEntityTranslatorReplace extends PacketTranslator<ClientboundAddEntityPacket> {
|
||||||
@Override
|
@Override
|
||||||
public void translate(GeyserSession session, ClientboundAddEntityPacket packet) { EntityDefinition<?> definition = Registries.ENTITY_DEFINITIONS.get(packet.getType());
|
public void translate(GeyserSession session, ClientboundAddEntityPacket packet) {
|
||||||
|
EntityDefinition<?> definition = Registries.ENTITY_DEFINITIONS.get(packet.getType());
|
||||||
if (definition == null) {
|
if (definition == null) {
|
||||||
session.getGeyser().getLogger().debug("Could not find an entity definition with type " + packet.getType());
|
session.getGeyser().getLogger().debug("Could not find an entity definition with type " + packet.getType());
|
||||||
return;
|
return;
|
||||||
@@ -115,6 +116,8 @@ public class JavaAddEntityTranslatorReplace extends PacketTranslator<Clientbound
|
|||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else if (packet.getType() == EntityType.AREA_EFFECT_CLOUD) { /* TODO find a way to only remove the MEG ones */
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
entity = definition.factory().create(session, packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(),
|
entity = definition.factory().create(session, packet.getEntityId(), session.getEntityCache().getNextEntityId().incrementAndGet(),
|
||||||
packet.getUuid(), definition, position, motion, yaw, pitch, headYaw);
|
packet.getUuid(), definition, position, motion, yaw, pitch, headYaw);
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import org.cloudburstmc.protocol.bedrock.data.NpcRequestType;
|
|||||||
import org.cloudburstmc.protocol.bedrock.packet.NpcRequestPacket;
|
import org.cloudburstmc.protocol.bedrock.packet.NpcRequestPacket;
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
import org.geysermc.geyser.translator.protocol.PacketTranslator;
|
||||||
import org.geysermc.geyser.translator.protocol.Translator;
|
|
||||||
|
|
||||||
public class NPCFormResponseTranslator extends PacketTranslator<NpcRequestPacket> {
|
public class NPCFormResponseTranslator extends PacketTranslator<NpcRequestPacket> {
|
||||||
|
|
||||||
@@ -31,8 +30,6 @@ public class NPCFormResponseTranslator extends PacketTranslator<NpcRequestPacket
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Button button = form.dialogueButtons().get(packet.getActionType());
|
Button button = form.dialogueButtons().get(packet.getActionType());
|
||||||
|
|
||||||
if (button == null) {
|
if (button == null) {
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import me.zimzaza4.geyserutils.common.camera.data.*;
|
|||||||
import me.zimzaza4.geyserutils.common.camera.instruction.FadeInstruction;
|
import me.zimzaza4.geyserutils.common.camera.instruction.FadeInstruction;
|
||||||
import me.zimzaza4.geyserutils.common.camera.instruction.SetInstruction;
|
import me.zimzaza4.geyserutils.common.camera.instruction.SetInstruction;
|
||||||
import me.zimzaza4.geyserutils.common.util.Pos;
|
import me.zimzaza4.geyserutils.common.util.Pos;
|
||||||
import me.zimzaza4.geyserutils.geyser.camera.CameraPresetDefinition;
|
|
||||||
import org.cloudburstmc.math.vector.Vector2f;
|
import org.cloudburstmc.math.vector.Vector2f;
|
||||||
import org.cloudburstmc.math.vector.Vector3f;
|
import org.cloudburstmc.math.vector.Vector3f;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.camera.CameraAudioListener;
|
import org.cloudburstmc.protocol.bedrock.data.camera.CameraAudioListener;
|
||||||
@@ -12,7 +11,10 @@ import org.cloudburstmc.protocol.bedrock.data.camera.CameraEase;
|
|||||||
import org.cloudburstmc.protocol.bedrock.data.camera.CameraFadeInstruction;
|
import org.cloudburstmc.protocol.bedrock.data.camera.CameraFadeInstruction;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.camera.CameraSetInstruction;
|
import org.cloudburstmc.protocol.bedrock.data.camera.CameraSetInstruction;
|
||||||
import org.cloudburstmc.protocol.common.util.OptionalBoolean;
|
import org.cloudburstmc.protocol.common.util.OptionalBoolean;
|
||||||
import org.geysermc.geyser.api.bedrock.camera.*;
|
import org.geysermc.geyser.api.bedrock.camera.CameraEaseType;
|
||||||
|
import org.geysermc.geyser.api.bedrock.camera.CameraFade;
|
||||||
|
import org.geysermc.geyser.api.bedrock.camera.CameraPerspective;
|
||||||
|
import org.geysermc.geyser.api.bedrock.camera.CameraPosition;
|
||||||
|
|
||||||
public class Converter {
|
public class Converter {
|
||||||
|
|
||||||
@@ -86,6 +88,7 @@ public class Converter {
|
|||||||
}
|
}
|
||||||
return CameraPerspective.FREE;
|
return CameraPerspective.FREE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CameraPosition serializeSetInstruction(SetInstruction instruction) {
|
public static CameraPosition serializeSetInstruction(SetInstruction instruction) {
|
||||||
|
|
||||||
CameraPosition.Builder builder = CameraPosition.builder();
|
CameraPosition.Builder builder = CameraPosition.builder();
|
||||||
|
|||||||
@@ -45,10 +45,12 @@ public class ReflectionUtils {
|
|||||||
}
|
}
|
||||||
KEY_BUILD_METHOD = KEY_CLASS.getMethod("key", String.class);
|
KEY_BUILD_METHOD = KEY_CLASS.getMethod("key", String.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public static Object getChannel(ClientboundCustomPayloadPacket packet) {
|
public static Object getChannel(ClientboundCustomPayloadPacket packet) {
|
||||||
return CLIENTBOUND_GET_CHANNEL_METHOD.invoke(packet);
|
return CLIENTBOUND_GET_CHANNEL_METHOD.invoke(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public static Object getChannel(ServerboundCustomPayloadPacket packet) {
|
public static Object getChannel(ServerboundCustomPayloadPacket packet) {
|
||||||
return SERVERBOUND_GET_CHANNEL_METHOD.invoke(packet);
|
return SERVERBOUND_GET_CHANNEL_METHOD.invoke(packet);
|
||||||
@@ -58,6 +60,7 @@ public class ReflectionUtils {
|
|||||||
public static ServerboundCustomPayloadPacket buildServerboundPayloadPacket(String key, byte[] data) {
|
public static ServerboundCustomPayloadPacket buildServerboundPayloadPacket(String key, byte[] data) {
|
||||||
return (ServerboundCustomPayloadPacket) SERVERBOUND_PAYLOAD_PACKET_CONSTRUCTOR.newInstance(buildKey(key), data);
|
return (ServerboundCustomPayloadPacket) SERVERBOUND_PAYLOAD_PACKET_CONSTRUCTOR.newInstance(buildKey(key), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public static Object buildKey(String key) {
|
public static Object buildKey(String key) {
|
||||||
if (OLD_VERSION) return key;
|
if (OLD_VERSION) return key;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public final class GeyserUtils extends JavaPlugin {
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private static PacketManager packetManager;
|
private static PacketManager packetManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
// Plugin startup logic
|
// Plugin startup logic
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package me.zimzaza4.geyserutils.spigot.api;
|
|||||||
import me.zimzaza4.geyserutils.common.channel.GeyserUtilsChannels;
|
import me.zimzaza4.geyserutils.common.channel.GeyserUtilsChannels;
|
||||||
import me.zimzaza4.geyserutils.common.packet.*;
|
import me.zimzaza4.geyserutils.common.packet.*;
|
||||||
import me.zimzaza4.geyserutils.spigot.GeyserUtils;
|
import me.zimzaza4.geyserutils.spigot.GeyserUtils;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import me.zimzaza4.geyserutils.common.packet.*;
|
|||||||
import me.zimzaza4.geyserutils.common.particle.CustomParticle;
|
import me.zimzaza4.geyserutils.common.particle.CustomParticle;
|
||||||
import me.zimzaza4.geyserutils.common.util.Pos;
|
import me.zimzaza4.geyserutils.common.util.Pos;
|
||||||
import me.zimzaza4.geyserutils.spigot.GeyserUtils;
|
import me.zimzaza4.geyserutils.spigot.GeyserUtils;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import lombok.experimental.Accessors;
|
|||||||
import me.zimzaza4.geyserutils.common.channel.GeyserUtilsChannels;
|
import me.zimzaza4.geyserutils.common.channel.GeyserUtilsChannels;
|
||||||
import me.zimzaza4.geyserutils.common.form.element.NpcDialogueButton;
|
import me.zimzaza4.geyserutils.common.form.element.NpcDialogueButton;
|
||||||
import me.zimzaza4.geyserutils.common.packet.NpcDialogueFormDataCustomPayloadPacket;
|
import me.zimzaza4.geyserutils.common.packet.NpcDialogueFormDataCustomPayloadPacket;
|
||||||
import me.zimzaza4.geyserutils.common.util.CustomPayloadPacketUtils;
|
|
||||||
import me.zimzaza4.geyserutils.spigot.GeyserUtils;
|
import me.zimzaza4.geyserutils.spigot.GeyserUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@@ -41,6 +40,14 @@ public class NpcDialogueForm {
|
|||||||
BiConsumer<String, Integer> handler;
|
BiConsumer<String, Integer> handler;
|
||||||
Consumer<String> closeHandler;
|
Consumer<String> closeHandler;
|
||||||
|
|
||||||
|
public static void closeForm(FloodgatePlayer floodgatePlayer) {
|
||||||
|
NpcDialogueFormDataCustomPayloadPacket data = new NpcDialogueFormDataCustomPayloadPacket(null, null, null, null, -1, null, "CLOSE", false);
|
||||||
|
Player p = Bukkit.getPlayer(floodgatePlayer.getCorrectUniqueId());
|
||||||
|
if (p != null) {
|
||||||
|
p.sendPluginMessage(GeyserUtils.getInstance(), GeyserUtilsChannels.MAIN, GeyserUtils.getPacketManager().encodePacket(data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void send(FloodgatePlayer floodgatePlayer) {
|
public void send(FloodgatePlayer floodgatePlayer) {
|
||||||
UUID formId = UUID.randomUUID();
|
UUID formId = UUID.randomUUID();
|
||||||
NpcDialogueFormDataCustomPayloadPacket data = new NpcDialogueFormDataCustomPayloadPacket(formId.toString(), title, dialogue, skinData, bindEntity.getEntityId(), buttons, "OPEN", hasNextForm);
|
NpcDialogueFormDataCustomPayloadPacket data = new NpcDialogueFormDataCustomPayloadPacket(formId.toString(), title, dialogue, skinData, bindEntity.getEntityId(), buttons, "OPEN", hasNextForm);
|
||||||
@@ -65,12 +72,4 @@ public class NpcDialogueForm {
|
|||||||
}.runTaskTimerAsynchronously(GeyserUtils.getInstance(), 10, 10);
|
}.runTaskTimerAsynchronously(GeyserUtils.getInstance(), 10, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void closeForm(FloodgatePlayer floodgatePlayer) {
|
|
||||||
NpcDialogueFormDataCustomPayloadPacket data = new NpcDialogueFormDataCustomPayloadPacket(null, null, null, null, -1, null, "CLOSE", false);
|
|
||||||
Player p = Bukkit.getPlayer(floodgatePlayer.getCorrectUniqueId());
|
|
||||||
if (p != null) {
|
|
||||||
p.sendPluginMessage(GeyserUtils.getInstance(), GeyserUtilsChannels.MAIN, GeyserUtils.getPacketManager().encodePacket(data));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import java.nio.file.Path;
|
|||||||
public class GeyserUtils {
|
public class GeyserUtils {
|
||||||
|
|
||||||
private final ProxyServer server;
|
private final ProxyServer server;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public GeyserUtils(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) {
|
public GeyserUtils(ProxyServer server, Logger logger, @DataDirectory Path dataDirectory) {
|
||||||
this.server = server;
|
this.server = server;
|
||||||
|
|||||||
Reference in New Issue
Block a user