mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-11-14 19:34:58 -05:00
Rename entity types to match Java and move away from MagicValues (#669)
* Rename entity types to match Java and move away from MagicValues Removed WeatherEntityType since it was unused since 1.16 Renamed: MINECART_CHEST -> CHEST_MINECART MINECART_COMMAND_BLOCK -> COMMAND_BLOCK_MINECART MINECART_FURNACE -> FURNACE_MINECART MINECART_HOPPER -> HOPPER_MINECART MINECART_SPAWNER -> SPAWNER_MINECART MINECART_TNT -> TNT_MINECART PRIMED_TNT -> TNT THROWN_EGG -> EGG THROWN_ENDERPEARL -> ENDER_PEARL THROWN_EXP_BOTTLE -> EXPERIENCE_BOTTLE THROWN_POTION -> POTION * Use readEnum in EntityType * Fix HORIZONTAL_VALUES in Direction This fixes painting direction in ClientboundAddPaintingPacket
This commit is contained in:
parent
7f7808e231
commit
f7f84e73cf
7 changed files with 41 additions and 160 deletions
|
@ -25,9 +25,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.player.InteractAction;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerState;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PositionElement;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.PaintingType;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.WeatherEntityType;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.CommandBlockMode;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.StructureMirror;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.StructureRotation;
|
||||
|
@ -253,122 +251,6 @@ public class MagicValues {
|
|||
register(PositionElement.PITCH, 3);
|
||||
register(PositionElement.YAW, 4);
|
||||
|
||||
register(WeatherEntityType.LIGHTNING_BOLT, 1);
|
||||
|
||||
register(EntityType.AREA_EFFECT_CLOUD, 0);
|
||||
register(EntityType.ARMOR_STAND, 1);
|
||||
register(EntityType.ARROW, 2);
|
||||
register(EntityType.AXOLOTL, 3);
|
||||
register(EntityType.BAT, 4);
|
||||
register(EntityType.BEE, 5);
|
||||
register(EntityType.BLAZE, 6);
|
||||
register(EntityType.BOAT, 7);
|
||||
register(EntityType.CAT, 8);
|
||||
register(EntityType.CAVE_SPIDER, 9);
|
||||
register(EntityType.CHICKEN, 10);
|
||||
register(EntityType.COD, 11);
|
||||
register(EntityType.COW, 12);
|
||||
register(EntityType.CREEPER, 13);
|
||||
register(EntityType.DOLPHIN, 14);
|
||||
register(EntityType.DONKEY, 15);
|
||||
register(EntityType.DRAGON_FIREBALL, 16);
|
||||
register(EntityType.DROWNED, 17);
|
||||
register(EntityType.ELDER_GUARDIAN, 18);
|
||||
register(EntityType.END_CRYSTAL, 19);
|
||||
register(EntityType.ENDER_DRAGON, 20);
|
||||
register(EntityType.ENDERMAN, 21);
|
||||
register(EntityType.ENDERMITE, 22);
|
||||
register(EntityType.EVOKER, 23);
|
||||
register(EntityType.EVOKER_FANGS, 24);
|
||||
register(EntityType.EXPERIENCE_ORB, 25);
|
||||
register(EntityType.EYE_OF_ENDER, 26);
|
||||
register(EntityType.FALLING_BLOCK, 27);
|
||||
register(EntityType.FIREWORK_ROCKET, 28);
|
||||
register(EntityType.FOX, 29);
|
||||
register(EntityType.GHAST, 30);
|
||||
register(EntityType.GIANT, 31);
|
||||
register(EntityType.GLOW_ITEM_FRAME, 32);
|
||||
register(EntityType.GLOW_SQUID, 33);
|
||||
register(EntityType.GOAT, 34);
|
||||
register(EntityType.GUARDIAN, 35);
|
||||
register(EntityType.HOGLIN, 36);
|
||||
register(EntityType.HORSE, 37);
|
||||
register(EntityType.HUSK, 38);
|
||||
register(EntityType.ILLUSIONER, 39);
|
||||
register(EntityType.IRON_GOLEM, 40);
|
||||
register(EntityType.ITEM, 41);
|
||||
register(EntityType.ITEM_FRAME, 42);
|
||||
register(EntityType.FIREBALL, 43);
|
||||
register(EntityType.LEASH_KNOT, 44);
|
||||
register(EntityType.LIGHTNING_BOLT, 45);
|
||||
register(EntityType.LLAMA, 46);
|
||||
register(EntityType.LLAMA_SPIT, 47);
|
||||
register(EntityType.MAGMA_CUBE, 48);
|
||||
register(EntityType.MARKER, 49);
|
||||
register(EntityType.MINECART, 50);
|
||||
register(EntityType.MINECART_CHEST, 51);
|
||||
register(EntityType.MINECART_COMMAND_BLOCK, 52);
|
||||
register(EntityType.MINECART_FURNACE, 53);
|
||||
register(EntityType.MINECART_HOPPER, 54);
|
||||
register(EntityType.MINECART_SPAWNER, 55);
|
||||
register(EntityType.MINECART_TNT, 56);
|
||||
register(EntityType.MULE, 57);
|
||||
register(EntityType.MOOSHROOM, 58);
|
||||
register(EntityType.OCELOT, 59);
|
||||
register(EntityType.PAINTING, 60);
|
||||
register(EntityType.PANDA, 61);
|
||||
register(EntityType.PARROT, 62);
|
||||
register(EntityType.PHANTOM, 63);
|
||||
register(EntityType.PIG, 64);
|
||||
register(EntityType.PIGLIN, 65);
|
||||
register(EntityType.PIGLIN_BRUTE, 66);
|
||||
register(EntityType.PILLAGER, 67);
|
||||
register(EntityType.POLAR_BEAR, 68);
|
||||
register(EntityType.PRIMED_TNT, 69);
|
||||
register(EntityType.PUFFERFISH, 70);
|
||||
register(EntityType.RABBIT, 71);
|
||||
register(EntityType.RAVAGER, 72);
|
||||
register(EntityType.SALMON, 73);
|
||||
register(EntityType.SHEEP, 74);
|
||||
register(EntityType.SHULKER, 75);
|
||||
register(EntityType.SHULKER_BULLET, 76);
|
||||
register(EntityType.SILVERFISH, 77);
|
||||
register(EntityType.SKELETON, 78);
|
||||
register(EntityType.SKELETON_HORSE, 79);
|
||||
register(EntityType.SLIME, 80);
|
||||
register(EntityType.SMALL_FIREBALL, 81);
|
||||
register(EntityType.SNOW_GOLEM, 82);
|
||||
register(EntityType.SNOWBALL, 83);
|
||||
register(EntityType.SPECTRAL_ARROW, 84);
|
||||
register(EntityType.SPIDER, 85);
|
||||
register(EntityType.SQUID, 86);
|
||||
register(EntityType.STRAY, 87);
|
||||
register(EntityType.STRIDER, 88);
|
||||
register(EntityType.THROWN_EGG, 89);
|
||||
register(EntityType.THROWN_ENDERPEARL, 90);
|
||||
register(EntityType.THROWN_EXP_BOTTLE, 91);
|
||||
register(EntityType.THROWN_POTION, 92);
|
||||
register(EntityType.TRIDENT, 93);
|
||||
register(EntityType.TRADER_LLAMA, 94);
|
||||
register(EntityType.TROPICAL_FISH, 95);
|
||||
register(EntityType.TURTLE, 96);
|
||||
register(EntityType.VEX, 97);
|
||||
register(EntityType.VILLAGER, 98);
|
||||
register(EntityType.VINDICATOR, 99);
|
||||
register(EntityType.WANDERING_TRADER, 100);
|
||||
register(EntityType.WITCH, 101);
|
||||
register(EntityType.WITHER, 102);
|
||||
register(EntityType.WITHER_SKELETON, 103);
|
||||
register(EntityType.WITHER_SKULL, 104);
|
||||
register(EntityType.WOLF, 105);
|
||||
register(EntityType.ZOGLIN, 106);
|
||||
register(EntityType.ZOMBIE, 107);
|
||||
register(EntityType.ZOMBIE_HORSE, 108);
|
||||
register(EntityType.ZOMBIE_VILLAGER, 109);
|
||||
register(EntityType.ZOMBIFIED_PIGLIN, 110);
|
||||
register(EntityType.PLAYER, 111);
|
||||
register(EntityType.FISHING_BOBBER, 112);
|
||||
|
||||
register(MinecartType.NORMAL, 0);
|
||||
register(MinecartType.CHEST, 1);
|
||||
register(MinecartType.POWERED, 2);
|
||||
|
|
|
@ -17,7 +17,7 @@ public enum Direction implements ObjectData {
|
|||
this.horizontalIndex = horizontalIndex;
|
||||
}
|
||||
|
||||
private static final Direction[] HORIZONTAL_VALUES = {NORTH, SOUTH, EAST, WEST};
|
||||
private static final Direction[] HORIZONTAL_VALUES = {NORTH, SOUTH, WEST, EAST};
|
||||
public static final Direction[] VALUES = values();
|
||||
|
||||
public static Direction getByHorizontalIndex(int index) {
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.type;
|
||||
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public enum EntityType {
|
||||
AREA_EFFECT_CLOUD,
|
||||
ARMOR_STAND,
|
||||
|
@ -7,16 +11,16 @@ public enum EntityType {
|
|||
AXOLOTL,
|
||||
BAT,
|
||||
BEE,
|
||||
BOAT,
|
||||
BLAZE,
|
||||
BOAT,
|
||||
CAT,
|
||||
CAVE_SPIDER,
|
||||
CHICKEN,
|
||||
COD,
|
||||
COW,
|
||||
CREEPER,
|
||||
DONKEY,
|
||||
DOLPHIN,
|
||||
DONKEY,
|
||||
DRAGON_FIREBALL,
|
||||
DROWNED,
|
||||
ELDER_GUARDIAN,
|
||||
|
@ -24,22 +28,24 @@ public enum EntityType {
|
|||
ENDER_DRAGON,
|
||||
ENDERMAN,
|
||||
ENDERMITE,
|
||||
EVOKER_FANGS,
|
||||
EVOKER,
|
||||
EVOKER_FANGS,
|
||||
EXPERIENCE_ORB,
|
||||
EYE_OF_ENDER,
|
||||
FALLING_BLOCK,
|
||||
FIREWORK_ROCKET,
|
||||
FOX,
|
||||
GOAT,
|
||||
GHAST,
|
||||
GIANT,
|
||||
GLOW_ITEM_FRAME,
|
||||
GLOW_SQUID,
|
||||
GOAT,
|
||||
GUARDIAN,
|
||||
HOGLIN,
|
||||
HORSE,
|
||||
HUSK,
|
||||
ILLUSIONER,
|
||||
IRON_GOLEM,
|
||||
ITEM,
|
||||
ITEM_FRAME,
|
||||
FIREBALL,
|
||||
|
@ -50,25 +56,28 @@ public enum EntityType {
|
|||
MAGMA_CUBE,
|
||||
MARKER,
|
||||
MINECART,
|
||||
MINECART_CHEST,
|
||||
MINECART_COMMAND_BLOCK,
|
||||
MINECART_FURNACE,
|
||||
MINECART_HOPPER,
|
||||
MINECART_SPAWNER,
|
||||
MINECART_TNT,
|
||||
CHEST_MINECART,
|
||||
COMMAND_BLOCK_MINECART,
|
||||
FURNACE_MINECART,
|
||||
HOPPER_MINECART,
|
||||
SPAWNER_MINECART,
|
||||
TNT_MINECART,
|
||||
MULE,
|
||||
MOOSHROOM,
|
||||
OCELOT,
|
||||
PAINTING,
|
||||
PANDA,
|
||||
PARROT,
|
||||
PHANTOM,
|
||||
PIG,
|
||||
PIGLIN,
|
||||
PIGLIN_BRUTE,
|
||||
PUFFERFISH,
|
||||
PILLAGER,
|
||||
POLAR_BEAR,
|
||||
PRIMED_TNT,
|
||||
TNT,
|
||||
PUFFERFISH,
|
||||
RABBIT,
|
||||
RAVAGER,
|
||||
SALMON,
|
||||
SHEEP,
|
||||
SHULKER,
|
||||
|
@ -84,34 +93,35 @@ public enum EntityType {
|
|||
SPIDER,
|
||||
SQUID,
|
||||
STRAY,
|
||||
STRIDER,
|
||||
EGG,
|
||||
ENDER_PEARL,
|
||||
EXPERIENCE_BOTTLE,
|
||||
POTION,
|
||||
TRIDENT,
|
||||
TRADER_LLAMA,
|
||||
TROPICAL_FISH,
|
||||
TURTLE,
|
||||
THROWN_EGG,
|
||||
THROWN_ENDERPEARL,
|
||||
THROWN_EXP_BOTTLE,
|
||||
THROWN_POTION,
|
||||
TRIDENT,
|
||||
VEX,
|
||||
VILLAGER,
|
||||
IRON_GOLEM,
|
||||
VINDICATOR,
|
||||
PILLAGER,
|
||||
WANDERING_TRADER,
|
||||
WITCH,
|
||||
WITHER,
|
||||
WITHER_SKELETON,
|
||||
WITHER_SKULL,
|
||||
WOLF,
|
||||
ZOGLIN,
|
||||
ZOMBIE,
|
||||
ZOMBIE_HORSE,
|
||||
ZOMBIFIED_PIGLIN,
|
||||
ZOMBIE_VILLAGER,
|
||||
PHANTOM,
|
||||
RAVAGER,
|
||||
HOGLIN,
|
||||
STRIDER,
|
||||
ZOGLIN,
|
||||
ZOMBIFIED_PIGLIN,
|
||||
PLAYER,
|
||||
FISHING_BOBBER;
|
||||
|
||||
private static final EntityType[] VALUES = values();
|
||||
|
||||
public static EntityType read(NetInput in) throws IOException {
|
||||
return in.readEnum(VALUES);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.entity.type;
|
||||
|
||||
public enum WeatherEntityType {
|
||||
LIGHTNING_BOLT;
|
||||
}
|
|
@ -58,7 +58,7 @@ public class ClientboundAddEntityPacket implements Packet {
|
|||
public ClientboundAddEntityPacket(NetInput in) throws IOException {
|
||||
this.entityId = in.readVarInt();
|
||||
this.uuid = in.readUUID();
|
||||
this.type = MagicValues.key(EntityType.class, in.readVarInt());
|
||||
this.type = EntityType.read(in);
|
||||
this.x = in.readDouble();
|
||||
this.y = in.readDouble();
|
||||
this.z = in.readDouble();
|
||||
|
@ -72,7 +72,7 @@ public class ClientboundAddEntityPacket implements Packet {
|
|||
this.data = Direction.VALUES[data];
|
||||
} else if (this.type == EntityType.FALLING_BLOCK) {
|
||||
this.data = new FallingBlockData(data & 65535, data >> 16);
|
||||
} else if (this.type == EntityType.THROWN_POTION) {
|
||||
} else if (this.type == EntityType.POTION) {
|
||||
this.data = new SplashPotionData(data);
|
||||
} else if (this.type == EntityType.SPECTRAL_ARROW || this.type == EntityType.FIREBALL || this.type == EntityType.SMALL_FIREBALL
|
||||
|| this.type == EntityType.DRAGON_FIREBALL || this.type == EntityType.WITHER_SKULL || this.type == EntityType.FISHING_BOBBER) {
|
||||
|
@ -94,7 +94,7 @@ public class ClientboundAddEntityPacket implements Packet {
|
|||
public void write(NetOutput out) throws IOException {
|
||||
out.writeVarInt(this.entityId);
|
||||
out.writeUUID(this.uuid);
|
||||
out.writeVarInt(MagicValues.value(Integer.class, this.type));
|
||||
out.writeVarInt(this.type.ordinal());
|
||||
out.writeDouble(this.x);
|
||||
out.writeDouble(this.y);
|
||||
out.writeDouble(this.z);
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.spawn;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.MagicValues;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import com.github.steveice10.packetlib.io.NetOutput;
|
||||
|
@ -33,7 +32,7 @@ public class ClientboundAddMobPacket implements Packet {
|
|||
public ClientboundAddMobPacket(NetInput in) throws IOException {
|
||||
this.entityId = in.readVarInt();
|
||||
this.uuid = in.readUUID();
|
||||
this.type = MagicValues.key(EntityType.class, in.readVarInt());
|
||||
this.type = EntityType.read(in);
|
||||
this.x = in.readDouble();
|
||||
this.y = in.readDouble();
|
||||
this.z = in.readDouble();
|
||||
|
@ -49,7 +48,7 @@ public class ClientboundAddMobPacket implements Packet {
|
|||
public void write(NetOutput out) throws IOException {
|
||||
out.writeVarInt(this.entityId);
|
||||
out.writeUUID(this.uuid);
|
||||
out.writeVarInt(MagicValues.value(Integer.class, this.type));
|
||||
out.writeVarInt(this.type.ordinal());
|
||||
out.writeDouble(this.x);
|
||||
out.writeDouble(this.y);
|
||||
out.writeDouble(this.z);
|
||||
|
|
|
@ -25,9 +25,7 @@ import com.github.steveice10.mc.protocol.data.game.entity.player.InteractAction;
|
|||
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerState;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.player.PositionElement;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.PaintingType;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.WeatherEntityType;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.CommandBlockMode;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.StructureMirror;
|
||||
import com.github.steveice10.mc.protocol.data.game.level.block.StructureRotation;
|
||||
|
@ -85,7 +83,6 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
@ -119,8 +116,6 @@ public class MagicValuesTest {
|
|||
this.register(Animation.class, Integer.class);
|
||||
this.register(EntityEvent.class, Integer.class);
|
||||
this.register(PositionElement.class, Integer.class);
|
||||
this.register(WeatherEntityType.class, Integer.class);
|
||||
this.register(EntityType.class, Integer.class);
|
||||
this.register(MinecartType.class, Integer.class);
|
||||
this.register(PaintingType.class, Integer.class);
|
||||
this.register(ScoreboardPosition.class, Integer.class);
|
||||
|
|
Loading…
Reference in a new issue