Fix gamemode id and argument types

This commit is contained in:
D3ATHBRINGER13 2022-11-24 23:47:39 +00:00
parent 633d5bb789
commit 58a9b169be
5 changed files with 24 additions and 26 deletions

View file

@ -520,17 +520,17 @@ public class MagicValues {
register(CommandParser.TEAM, 31);
register(CommandParser.ITEM_SLOT, 32);
register(CommandParser.RESOURCE_LOCATION, 33);
register(CommandParser.MOB_EFFECT, 34);
register(CommandParser.FUNCTION, 35);
register(CommandParser.ENTITY_ANCHOR, 36);
register(CommandParser.INT_RANGE, 37);
register(CommandParser.FLOAT_RANGE, 38);
register(CommandParser.ITEM_ENCHANTMENT, 39);
register(CommandParser.ENTITY_SUMMON, 40);
register(CommandParser.DIMENSION, 41);
register(CommandParser.TIME, 42);
register(CommandParser.RESOURCE_OR_TAG, 43);
register(CommandParser.RESOURCE, 44);
register(CommandParser.FUNCTION, 34);
register(CommandParser.ENTITY_ANCHOR, 35);
register(CommandParser.INT_RANGE, 36);
register(CommandParser.FLOAT_RANGE, 37);
register(CommandParser.DIMENSION, 38);
register(CommandParser.GAMEMODE, 39);
register(CommandParser.TIME, 40);
register(CommandParser.RESOURCE_OR_TAG, 41);
register(CommandParser.RESOURCE_OR_TAG_KEY, 42);
register(CommandParser.RESOURCE, 43);
register(CommandParser.RESOURCE_KEY, 44);
register(CommandParser.TEMPLATE_MIRROR, 45);
register(CommandParser.TEMPLATE_ROTATION, 46);
register(CommandParser.UUID, 47);
@ -538,7 +538,6 @@ public class MagicValues {
register(SuggestionType.ASK_SERVER, "minecraft:ask_server");
register(SuggestionType.ALL_RECIPES, "minecraft:all_recipes");
register(SuggestionType.AVAILABLE_SOUNDS, "minecraft:available_sounds");
register(SuggestionType.AVAILABLE_BIOMES, "minecraft:available_biomes");
register(SuggestionType.SUMMONABLE_ENTITIES, "minecraft:summonable_entities");
register(StringProperties.SINGLE_WORD, 0);

View file

@ -1,10 +1,9 @@
package com.github.steveice10.mc.protocol.data.game.command;
public enum CommandParser {
ANGLE,
BOOL,
DOUBLE,
FLOAT,
DOUBLE,
INTEGER,
LONG,
STRING,
@ -28,25 +27,26 @@ public enum CommandParser {
OBJECTIVE_CRITERIA,
OPERATION,
PARTICLE,
ANGLE,
ROTATION,
SCOREBOARD_SLOT,
SCORE_HOLDER,
SWIZZLE,
UUID,
TEAM,
ITEM_SLOT,
RESOURCE_LOCATION,
MOB_EFFECT,
FUNCTION,
ENTITY_ANCHOR,
INT_RANGE,
FLOAT_RANGE,
ITEM_ENCHANTMENT,
ENTITY_SUMMON,
DIMENSION,
GAMEMODE,
TIME,
RESOURCE,
RESOURCE_OR_TAG,
RESOURCE_OR_TAG_KEY,
RESOURCE,
RESOURCE_KEY,
TEMPLATE_MIRROR,
TEMPLATE_ROTATION;
TEMPLATE_ROTATION,
UUID;
}

View file

@ -4,6 +4,5 @@ public enum SuggestionType {
ASK_SERVER,
ALL_RECIPES,
AVAILABLE_SOUNDS,
AVAILABLE_BIOMES,
SUMMONABLE_ENTITIES;
}

View file

@ -134,8 +134,10 @@ public class ClientboundCommandsPacket implements MinecraftPacket {
case SCORE_HOLDER:
properties = new ScoreHolderProperties(in.readBoolean());
break;
case RESOURCE:
case RESOURCE_OR_TAG:
case RESOURCE_OR_TAG_KEY:
case RESOURCE:
case RESOURCE_KEY:
properties = new ResourceProperties(helper.readString(in));
break;
default:

View file

@ -25,7 +25,7 @@ public class ClientboundGameEventPacket implements MinecraftPacket {
float value = in.readFloat();
// TODO: Handle this in MinecraftCodecHelper
if (this.notification == GameEvent.CHANGE_GAMEMODE) {
this.value = MagicValues.key(GameMode.class, ((int) value == -1) ? 255 : (int) value); // https://bugs.mojang.com/browse/MC-189885 - since we read as a float this bug doesn't apply here
this.value = MagicValues.key(GameMode.class, (int) value);
} else if (this.notification == GameEvent.DEMO_MESSAGE) {
this.value = MagicValues.key(DemoMessageValue.class, (int) value);
} else if (this.notification == GameEvent.ENTER_CREDITS) {
@ -46,9 +46,7 @@ public class ClientboundGameEventPacket implements MinecraftPacket {
out.writeByte(MagicValues.value(Integer.class, this.notification));
float value = 0;
// TODO: Handle this in MinecraftCodecHelper
if (this.value instanceof GameMode && this.value == GameMode.UNKNOWN) {
value = -1;
} else if (this.value instanceof Enum<?>) {
if (this.value instanceof Enum<?>) {
value = MagicValues.value(Integer.class, (Enum<?>) this.value);
} else if (this.value instanceof RainStrengthValue) {
value = ((RainStrengthValue) this.value).getStrength();