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

refactor: remove unwanted meta properties

This commit is contained in:
Boy
2024-08-01 15:55:23 +02:00
parent fb6f402c69
commit 74fce41db0
4 changed files with 12 additions and 57 deletions

View File

@@ -91,8 +91,6 @@ public abstract class Cosmetic {
ConfigurationNode scaleNode = config.node("scale"); ConfigurationNode scaleNode = config.node("scale");
ConfigurationNode rotationLeftNode = config.node("rotation-left"); ConfigurationNode rotationLeftNode = config.node("rotation-left");
ConfigurationNode rotationRightNode = config.node("rotation-right"); ConfigurationNode rotationRightNode = config.node("rotation-right");
ConfigurationNode billboardNode = config.node("billboard");
ConfigurationNode blockLightNode = config.node("block-light");
ConfigurationNode skyLightNode = config.node("sky-light"); ConfigurationNode skyLightNode = config.node("sky-light");
ConfigurationNode viewRangeNode = config.node("viewrange"); ConfigurationNode viewRangeNode = config.node("viewrange");
ConfigurationNode widthNode = config.node("width"); ConfigurationNode widthNode = config.node("width");
@@ -104,10 +102,6 @@ public abstract class Cosmetic {
if (!scaleNode.virtual()) metadata.scale = stringToVector(scaleNode.getString("1,1,1")); if (!scaleNode.virtual()) metadata.scale = stringToVector(scaleNode.getString("1,1,1"));
if (!rotationLeftNode.virtual()) metadata.rotationLeft = stringToQuaternion(rotationLeftNode.getString("0,0,0,1")); if (!rotationLeftNode.virtual()) metadata.rotationLeft = stringToQuaternion(rotationLeftNode.getString("0,0,0,1"));
if (!rotationRightNode.virtual()) metadata.rotationRight = stringToQuaternion(rotationRightNode.getString("0,0,0,1")); if (!rotationRightNode.virtual()) metadata.rotationRight = stringToQuaternion(rotationRightNode.getString("0,0,0,1"));
if (!billboardNode.virtual()) try {
metadata.billboard = Display.Billboard.valueOf(billboardNode.getString("VERTICAL"));
} catch (Exception ignored) {}
if (!blockLightNode.virtual()) metadata.blockLight = blockLightNode.getInt(0);
if (!skyLightNode.virtual()) metadata.skyLight = skyLightNode.getInt(15); if (!skyLightNode.virtual()) metadata.skyLight = skyLightNode.getInt(15);
if (!viewRangeNode.virtual()) metadata.viewRange = viewRangeNode.getFloat(1); if (!viewRangeNode.virtual()) metadata.viewRange = viewRangeNode.getFloat(1);
if (!widthNode.virtual()) metadata.width = widthNode.getFloat(0); if (!widthNode.virtual()) metadata.width = widthNode.getFloat(0);

View File

@@ -46,8 +46,8 @@ public class CosmeticBackpackType extends Cosmetic {
this.height = config.node("height").getInt(5); this.height = config.node("height").getInt(5);
} }
this.firstPersonMetadata = generateItemDisplayMetadata(config.node("firstperson-metadata")); this.firstPersonMetadata = generateItemDisplayMetadata(config.node("firstperson-metadata")).setVertical();
this.metadata = generateItemDisplayMetadata(config.node("metadata")); this.metadata = generateItemDisplayMetadata(config.node("metadata")).setFixed();
} }
@Override @Override

View File

@@ -12,14 +12,11 @@ import java.util.Map;
public class ItemDisplayMetadata { public class ItemDisplayMetadata {
public static final Map<Integer, ItemDisplayMetadata> metadataCache = new HashMap<>();
public Vector3f translation; public Vector3f translation;
public Vector3f scale; public Vector3f scale;
public Quaternionf rotationLeft; public Quaternionf rotationLeft;
public Quaternionf rotationRight; public Quaternionf rotationRight;
public Display.Billboard billboard; public Display.Billboard billboard;
public int blockLight;
public int skyLight; public int skyLight;
public float viewRange; public float viewRange;
public float width; public float width;
@@ -32,9 +29,7 @@ public class ItemDisplayMetadata {
this.scale = new Vector3f(1.0f, 1.0f, 1.0f); this.scale = new Vector3f(1.0f, 1.0f, 1.0f);
this.rotationLeft = new Quaternionf(); this.rotationLeft = new Quaternionf();
this.rotationRight = new Quaternionf(); this.rotationRight = new Quaternionf();
this.billboard = Display.Billboard.FIXED; this.skyLight = 15;
this.blockLight = 0;
this.skyLight = 0;
this.viewRange = 1.0f; this.viewRange = 1.0f;
this.width = 0.0f; this.width = 0.0f;
this.height = 0.0f; this.height = 0.0f;
@@ -42,46 +37,13 @@ public class ItemDisplayMetadata {
this.itemStack = new ItemStack(Material.AIR); this.itemStack = new ItemStack(Material.AIR);
} }
public ItemDisplayMetadata(ItemDisplayMetadata metadata) { public ItemDisplayMetadata setFixed() {
this.translation = metadata.translation; this.billboard = Display.Billboard.FIXED;
this.scale = metadata.scale; return this;
this.rotationLeft = metadata.rotationLeft;
this.rotationRight = metadata.rotationRight;
this.billboard = metadata.billboard;
this.blockLight = metadata.blockLight;
this.skyLight = metadata.skyLight;
this.viewRange = metadata.viewRange;
this.width = metadata.width;
this.height = metadata.height;
this.displayTransform = metadata.displayTransform;
this.itemStack = metadata.itemStack;
} }
public ItemDisplayMetadata( public ItemDisplayMetadata setVertical() {
Vector3f translation, this.billboard = Display.Billboard.VERTICAL;
Vector3f scale, return this;
Quaternionf rotationLeft,
Quaternionf rotationRight,
Display.Billboard billboard,
int blockLight,
int skyLight,
float viewRange,
float width,
float height,
ItemDisplay.ItemDisplayTransform displayTransform,
ItemStack itemStack
) {
this.translation = translation;
this.scale = scale;
this.rotationLeft = rotationLeft;
this.rotationRight = rotationRight;
this.billboard = billboard;
this.blockLight = blockLight;
this.skyLight = skyLight;
this.viewRange = viewRange;
this.width = width;
this.height = height;
this.displayTransform = displayTransform;
this.itemStack = itemStack;
} }
} }

View File

@@ -94,16 +94,15 @@ public class HMCCPacketManager extends PacketManager {
public static void sendItemDisplayMetadata(int entityId, ItemStack itemStack, List<Player> sendTo) { public static void sendItemDisplayMetadata(int entityId, ItemStack itemStack, List<Player> sendTo) {
ItemDisplayMetadata metadata = new ItemDisplayMetadata(); ItemDisplayMetadata metadata = new ItemDisplayMetadata();
PacketManager.sendItemDisplayMetadataPacket(entityId, metadata.translation, metadata.scale, metadata.rotationLeft, metadata.rotationRight, metadata.billboard, metadata.blockLight, metadata.skyLight, metadata.viewRange, metadata.width, metadata.height, metadata.displayTransform, itemStack, sendTo); PacketManager.sendItemDisplayMetadataPacket(entityId, metadata.translation, metadata.scale, metadata.rotationLeft, metadata.rotationRight, metadata.billboard, 0, metadata.skyLight, metadata.viewRange, metadata.width, metadata.height, metadata.displayTransform, itemStack, sendTo);
} }
public static void sendItemDisplayMetadata(int entityId, ItemDisplayMetadata metadata, List<Player> sendTo) { public static void sendItemDisplayMetadata(int entityId, ItemDisplayMetadata metadata, List<Player> sendTo) {
ItemDisplayMetadata.metadataCache.put(entityId, metadata); PacketManager.sendItemDisplayMetadataPacket(entityId, metadata.translation, metadata.scale, metadata.rotationLeft, metadata.rotationRight, metadata.billboard, 0, metadata.skyLight, metadata.viewRange, metadata.width, metadata.height, metadata.displayTransform, metadata.itemStack, sendTo);
PacketManager.sendItemDisplayMetadataPacket(entityId, metadata.translation, metadata.scale, metadata.rotationLeft, metadata.rotationRight, metadata.billboard, metadata.blockLight, metadata.skyLight, metadata.viewRange, metadata.width, metadata.height, metadata.displayTransform, metadata.itemStack, sendTo);
} }
public static void sendItemDisplayMetadata(int entityId, ItemDisplayMetadata metadata, ItemStack itemStack, List<Player> sendTo) { public static void sendItemDisplayMetadata(int entityId, ItemDisplayMetadata metadata, ItemStack itemStack, List<Player> sendTo) {
PacketManager.sendItemDisplayMetadataPacket(entityId, metadata.translation, metadata.scale, metadata.rotationLeft, metadata.rotationRight, metadata.billboard, metadata.blockLight, metadata.skyLight, metadata.viewRange, metadata.width, metadata.height, metadata.displayTransform, itemStack, sendTo); PacketManager.sendItemDisplayMetadataPacket(entityId, metadata.translation, metadata.scale, metadata.rotationLeft, metadata.rotationRight, metadata.billboard, 0, metadata.skyLight, metadata.viewRange, metadata.width, metadata.height, metadata.displayTransform, itemStack, sendTo);
} }
public static void sendInvisibilityPacket( public static void sendInvisibilityPacket(