mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-11-14 19:34:58 -05:00
Store EntityType in entity statistics; rename GenericStatistic (#674)
This commit is contained in:
parent
69709912fe
commit
a991afe629
10 changed files with 213 additions and 262 deletions
|
@ -57,8 +57,6 @@ import com.github.steveice10.mc.protocol.data.game.scoreboard.ScoreboardPosition
|
|||
import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.Difficulty;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.GenericStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.StatisticCategory;
|
||||
import com.github.steveice10.mc.protocol.data.game.inventory.AdvancementTabAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.inventory.ClickItemAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.inventory.CraftingBookStateType;
|
||||
|
@ -436,92 +434,6 @@ public class MagicValues {
|
|||
register(RespawnScreenValue.ENABLE_RESPAWN_SCREEN, 0);
|
||||
register(RespawnScreenValue.IMMEDIATE_RESPAWN, 1);
|
||||
|
||||
register(GenericStatistic.LEAVE_GAME, 0);
|
||||
register(GenericStatistic.PLAY_TIME, 1);
|
||||
register(GenericStatistic.TOTAL_WORLD_TIME, 2);
|
||||
register(GenericStatistic.TIME_SINCE_DEATH, 3);
|
||||
register(GenericStatistic.TIME_SINCE_REST, 4);
|
||||
register(GenericStatistic.SNEAK_TIME, 5);
|
||||
register(GenericStatistic.WALK_ONE_CM, 6);
|
||||
register(GenericStatistic.CROUCH_ONE_CM, 7);
|
||||
register(GenericStatistic.SPRINT_ONE_CM, 8);
|
||||
register(GenericStatistic.WALK_ON_WATER_ONE_CM, 9);
|
||||
register(GenericStatistic.FALL_ONE_CM, 10);
|
||||
register(GenericStatistic.CLIMB_ONE_CM, 11);
|
||||
register(GenericStatistic.FLY_ONE_CM, 12);
|
||||
register(GenericStatistic.WALK_UNDER_WATER_ONE_CM, 13);
|
||||
register(GenericStatistic.MINECART_ONE_CM, 14);
|
||||
register(GenericStatistic.BOAT_ONE_CM, 15);
|
||||
register(GenericStatistic.PIG_ONE_CM, 16);
|
||||
register(GenericStatistic.HORSE_ONE_CM, 17);
|
||||
register(GenericStatistic.AVIATE_ONE_CM, 18);
|
||||
register(GenericStatistic.SWIM_ONE_CM, 19);
|
||||
register(GenericStatistic.STRIDER_ONE_CM, 20);
|
||||
register(GenericStatistic.JUMP, 21);
|
||||
register(GenericStatistic.DROP, 22);
|
||||
register(GenericStatistic.DAMAGE_DEALT, 23);
|
||||
register(GenericStatistic.DAMAGE_DEALT_ABSORBED, 24);
|
||||
register(GenericStatistic.DAMAGE_DEALT_RESISTED, 25);
|
||||
register(GenericStatistic.DAMAGE_TAKEN, 26);
|
||||
register(GenericStatistic.DAMAGE_BLOCKED_BY_SHIELD, 27);
|
||||
register(GenericStatistic.DAMAGE_ABSORBED, 28);
|
||||
register(GenericStatistic.DAMAGE_RESISTED, 29);
|
||||
register(GenericStatistic.DEATHS, 30);
|
||||
register(GenericStatistic.MOB_KILLS, 31);
|
||||
register(GenericStatistic.ANIMALS_BRED, 32);
|
||||
register(GenericStatistic.PLAYER_KILLS, 33);
|
||||
register(GenericStatistic.FISH_CAUGHT, 34);
|
||||
register(GenericStatistic.TALKED_TO_VILLAGER, 35);
|
||||
register(GenericStatistic.TRADED_WITH_VILLAGER, 36);
|
||||
register(GenericStatistic.EAT_CAKE_SLICE, 37);
|
||||
register(GenericStatistic.FILL_CAULDRON, 38);
|
||||
register(GenericStatistic.USE_CAULDRON, 39);
|
||||
register(GenericStatistic.CLEAN_ARMOR, 40);
|
||||
register(GenericStatistic.CLEAN_BANNER, 41);
|
||||
register(GenericStatistic.CLEAN_SHULKER_BOX, 42);
|
||||
register(GenericStatistic.INTERACT_WITH_BREWINGSTAND, 43);
|
||||
register(GenericStatistic.INTERACT_WITH_BEACON, 44);
|
||||
register(GenericStatistic.INSPECT_DROPPER, 45);
|
||||
register(GenericStatistic.INSPECT_HOPPER, 46);
|
||||
register(GenericStatistic.INSPECT_DISPENSER, 47);
|
||||
register(GenericStatistic.PLAY_NOTEBLOCK, 48);
|
||||
register(GenericStatistic.TUNE_NOTEBLOCK, 49);
|
||||
register(GenericStatistic.POT_FLOWER, 50);
|
||||
register(GenericStatistic.TRIGGER_TRAPPED_CHEST, 51);
|
||||
register(GenericStatistic.OPEN_ENDERCHEST, 52);
|
||||
register(GenericStatistic.ENCHANT_ITEM, 53);
|
||||
register(GenericStatistic.PLAY_RECORD, 54);
|
||||
register(GenericStatistic.INTERACT_WITH_FURNACE, 55);
|
||||
register(GenericStatistic.INTERACT_WITH_CRAFTING_TABLE, 56);
|
||||
register(GenericStatistic.OPEN_CHEST, 57);
|
||||
register(GenericStatistic.SLEEP_IN_BED, 58);
|
||||
register(GenericStatistic.OPEN_SHULKER_BOX, 59);
|
||||
register(GenericStatistic.OPEN_BARREL, 60);
|
||||
register(GenericStatistic.INTERACT_WITH_BLAST_FURNACE, 61);
|
||||
register(GenericStatistic.INTERACT_WITH_SMOKER, 62);
|
||||
register(GenericStatistic.INTERACT_WITH_LECTERN, 63);
|
||||
register(GenericStatistic.INTERACT_WITH_CAMPFIRE, 64);
|
||||
register(GenericStatistic.INTERACT_WITH_CARTOGRAPHY_TABLE, 65);
|
||||
register(GenericStatistic.INTERACT_WITH_LOOM, 66);
|
||||
register(GenericStatistic.INTERACT_WITH_STONECUTTER, 67);
|
||||
register(GenericStatistic.BELL_RING, 68);
|
||||
register(GenericStatistic.RAID_TRIGGER, 69);
|
||||
register(GenericStatistic.RAID_WIN, 70);
|
||||
register(GenericStatistic.INTERACT_WITH_ANVIL, 71);
|
||||
register(GenericStatistic.INTERACT_WITH_GRINDSTONE, 72);
|
||||
register(GenericStatistic.TARGET_HIT, 73);
|
||||
register(GenericStatistic.INTERACT_WITH_SMITHING_TABLE, 74);
|
||||
|
||||
register(StatisticCategory.BREAK_BLOCK, 0);
|
||||
register(StatisticCategory.CRAFT_ITEM, 1);
|
||||
register(StatisticCategory.USE_ITEM, 2);
|
||||
register(StatisticCategory.BREAK_ITEM, 3);
|
||||
register(StatisticCategory.PICKED_UP_ITEM, 4);
|
||||
register(StatisticCategory.DROP_ITEM, 5);
|
||||
register(StatisticCategory.KILL_ENTITY, 6);
|
||||
register(StatisticCategory.KILLED_BY_ENTITY, 7);
|
||||
register(StatisticCategory.GENERIC, 8);
|
||||
|
||||
register(NoteBlockValueType.HARP, 0);
|
||||
register(NoteBlockValueType.DOUBLE_BASS, 1);
|
||||
register(NoteBlockValueType.SNARE_DRUM, 2);
|
||||
|
|
|
@ -124,4 +124,8 @@ public enum EntityType {
|
|||
public static EntityType read(NetInput in) throws IOException {
|
||||
return in.readEnum(VALUES);
|
||||
}
|
||||
|
||||
public static EntityType fromId(int id) {
|
||||
return VALUES[id];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,109 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.MagicValues;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
import lombok.Getter;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class CustomStatistic implements Statistic {
|
||||
private final int category;
|
||||
private final int id;
|
||||
import java.io.IOException;
|
||||
|
||||
public CustomStatistic(int id) {
|
||||
this(MagicValues.value(Integer.class, StatisticCategory.GENERIC), id);
|
||||
/**
|
||||
* "Custom" statistics in Minecraft that don't belong to any
|
||||
* specific category.
|
||||
*/
|
||||
public enum CustomStatistic implements Statistic {
|
||||
LEAVE_GAME,
|
||||
PLAY_TIME(StatisticFormat.TIME),
|
||||
TOTAL_WORLD_TIME(StatisticFormat.TIME),
|
||||
TIME_SINCE_DEATH(StatisticFormat.TIME),
|
||||
TIME_SINCE_REST(StatisticFormat.TIME),
|
||||
SNEAK_TIME(StatisticFormat.TIME),
|
||||
WALK_ONE_CM(StatisticFormat.DISTANCE),
|
||||
CROUCH_ONE_CM(StatisticFormat.DISTANCE),
|
||||
SPRINT_ONE_CM(StatisticFormat.DISTANCE),
|
||||
WALK_ON_WATER_ONE_CM(StatisticFormat.DISTANCE),
|
||||
FALL_ONE_CM(StatisticFormat.DISTANCE),
|
||||
CLIMB_ONE_CM(StatisticFormat.DISTANCE),
|
||||
FLY_ONE_CM(StatisticFormat.DISTANCE),
|
||||
WALK_UNDER_WATER_ONE_CM(StatisticFormat.DISTANCE),
|
||||
MINECART_ONE_CM(StatisticFormat.DISTANCE),
|
||||
BOAT_ONE_CM(StatisticFormat.DISTANCE),
|
||||
PIG_ONE_CM(StatisticFormat.DISTANCE),
|
||||
HORSE_ONE_CM(StatisticFormat.DISTANCE),
|
||||
AVIATE_ONE_CM(StatisticFormat.DISTANCE),
|
||||
SWIM_ONE_CM(StatisticFormat.DISTANCE),
|
||||
STRIDER_ONE_CM(StatisticFormat.DISTANCE),
|
||||
JUMP,
|
||||
DROP,
|
||||
DAMAGE_DEALT(StatisticFormat.TENTHS),
|
||||
DAMAGE_DEALT_ABSORBED(StatisticFormat.TENTHS),
|
||||
DAMAGE_DEALT_RESISTED(StatisticFormat.TENTHS),
|
||||
DAMAGE_TAKEN(StatisticFormat.TENTHS),
|
||||
DAMAGE_BLOCKED_BY_SHIELD(StatisticFormat.TENTHS),
|
||||
DAMAGE_ABSORBED(StatisticFormat.TENTHS),
|
||||
DAMAGE_RESISTED(StatisticFormat.TENTHS),
|
||||
DEATHS,
|
||||
MOB_KILLS,
|
||||
ANIMALS_BRED,
|
||||
PLAYER_KILLS,
|
||||
FISH_CAUGHT,
|
||||
TALKED_TO_VILLAGER,
|
||||
TRADED_WITH_VILLAGER,
|
||||
EAT_CAKE_SLICE,
|
||||
FILL_CAULDRON,
|
||||
USE_CAULDRON,
|
||||
CLEAN_ARMOR,
|
||||
CLEAN_BANNER,
|
||||
CLEAN_SHULKER_BOX,
|
||||
INTERACT_WITH_BREWINGSTAND,
|
||||
INTERACT_WITH_BEACON,
|
||||
INSPECT_DROPPER,
|
||||
INSPECT_HOPPER,
|
||||
INSPECT_DISPENSER,
|
||||
PLAY_NOTEBLOCK,
|
||||
TUNE_NOTEBLOCK,
|
||||
POT_FLOWER,
|
||||
TRIGGER_TRAPPED_CHEST,
|
||||
OPEN_ENDERCHEST,
|
||||
ENCHANT_ITEM,
|
||||
PLAY_RECORD,
|
||||
INTERACT_WITH_FURNACE,
|
||||
INTERACT_WITH_CRAFTING_TABLE,
|
||||
OPEN_CHEST,
|
||||
SLEEP_IN_BED,
|
||||
OPEN_SHULKER_BOX,
|
||||
OPEN_BARREL,
|
||||
INTERACT_WITH_BLAST_FURNACE,
|
||||
INTERACT_WITH_SMOKER,
|
||||
INTERACT_WITH_LECTERN,
|
||||
INTERACT_WITH_CAMPFIRE,
|
||||
INTERACT_WITH_CARTOGRAPHY_TABLE,
|
||||
INTERACT_WITH_LOOM,
|
||||
INTERACT_WITH_STONECUTTER,
|
||||
BELL_RING,
|
||||
RAID_TRIGGER,
|
||||
RAID_WIN,
|
||||
INTERACT_WITH_ANVIL,
|
||||
INTERACT_WITH_GRINDSTONE,
|
||||
TARGET_HIT,
|
||||
INTERACT_WITH_SMITHING_TABLE;
|
||||
|
||||
private static final CustomStatistic[] VALUES = values();
|
||||
|
||||
@Getter
|
||||
private final StatisticFormat format;
|
||||
|
||||
CustomStatistic() {
|
||||
format = StatisticFormat.INTEGER;
|
||||
}
|
||||
|
||||
CustomStatistic(StatisticFormat format) {
|
||||
this.format = format;
|
||||
}
|
||||
|
||||
public static CustomStatistic read(NetInput in) throws IOException {
|
||||
return in.readEnum(VALUES);
|
||||
}
|
||||
|
||||
public static CustomStatistic fromId(int id) {
|
||||
return VALUES[id];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
public enum GenericStatistic implements Statistic {
|
||||
LEAVE_GAME,
|
||||
PLAY_TIME,
|
||||
TOTAL_WORLD_TIME,
|
||||
TIME_SINCE_DEATH,
|
||||
TIME_SINCE_REST,
|
||||
SNEAK_TIME,
|
||||
WALK_ONE_CM,
|
||||
CROUCH_ONE_CM,
|
||||
SPRINT_ONE_CM,
|
||||
WALK_ON_WATER_ONE_CM,
|
||||
FALL_ONE_CM,
|
||||
CLIMB_ONE_CM,
|
||||
FLY_ONE_CM,
|
||||
WALK_UNDER_WATER_ONE_CM,
|
||||
MINECART_ONE_CM,
|
||||
BOAT_ONE_CM,
|
||||
PIG_ONE_CM,
|
||||
HORSE_ONE_CM,
|
||||
AVIATE_ONE_CM,
|
||||
SWIM_ONE_CM,
|
||||
STRIDER_ONE_CM,
|
||||
JUMP,
|
||||
DROP,
|
||||
DAMAGE_DEALT,
|
||||
DAMAGE_DEALT_ABSORBED,
|
||||
DAMAGE_DEALT_RESISTED,
|
||||
DAMAGE_TAKEN,
|
||||
DAMAGE_BLOCKED_BY_SHIELD,
|
||||
DAMAGE_ABSORBED,
|
||||
DAMAGE_RESISTED,
|
||||
DEATHS,
|
||||
MOB_KILLS,
|
||||
ANIMALS_BRED,
|
||||
PLAYER_KILLS,
|
||||
FISH_CAUGHT,
|
||||
TALKED_TO_VILLAGER,
|
||||
TRADED_WITH_VILLAGER,
|
||||
EAT_CAKE_SLICE,
|
||||
FILL_CAULDRON,
|
||||
USE_CAULDRON,
|
||||
CLEAN_ARMOR,
|
||||
CLEAN_BANNER,
|
||||
CLEAN_SHULKER_BOX,
|
||||
INTERACT_WITH_BREWINGSTAND,
|
||||
INTERACT_WITH_BEACON,
|
||||
INSPECT_DROPPER,
|
||||
INSPECT_HOPPER,
|
||||
INSPECT_DISPENSER,
|
||||
PLAY_NOTEBLOCK,
|
||||
TUNE_NOTEBLOCK,
|
||||
POT_FLOWER,
|
||||
TRIGGER_TRAPPED_CHEST,
|
||||
OPEN_ENDERCHEST,
|
||||
ENCHANT_ITEM,
|
||||
PLAY_RECORD,
|
||||
INTERACT_WITH_FURNACE,
|
||||
INTERACT_WITH_CRAFTING_TABLE,
|
||||
OPEN_CHEST,
|
||||
SLEEP_IN_BED,
|
||||
OPEN_SHULKER_BOX,
|
||||
OPEN_BARREL,
|
||||
INTERACT_WITH_BLAST_FURNACE,
|
||||
INTERACT_WITH_SMOKER,
|
||||
INTERACT_WITH_LECTERN,
|
||||
INTERACT_WITH_CAMPFIRE,
|
||||
INTERACT_WITH_CARTOGRAPHY_TABLE,
|
||||
INTERACT_WITH_LOOM,
|
||||
INTERACT_WITH_STONECUTTER,
|
||||
BELL_RING,
|
||||
RAID_TRIGGER,
|
||||
RAID_WIN,
|
||||
INTERACT_WITH_ANVIL,
|
||||
INTERACT_WITH_GRINDSTONE,
|
||||
TARGET_HIT,
|
||||
INTERACT_WITH_SMITHING_TABLE
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class KillEntityStatistic implements Statistic {
|
||||
private final int id;
|
||||
private final EntityType entity;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class KilledByEntityStatistic implements Statistic {
|
||||
private final int id;
|
||||
private final EntityType entity;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
import com.github.steveice10.packetlib.io.NetInput;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public enum StatisticCategory {
|
||||
BREAK_BLOCK,
|
||||
CRAFT_ITEM,
|
||||
|
@ -9,5 +13,15 @@ public enum StatisticCategory {
|
|||
DROP_ITEM,
|
||||
KILL_ENTITY,
|
||||
KILLED_BY_ENTITY,
|
||||
GENERIC;
|
||||
CUSTOM;
|
||||
|
||||
private static final StatisticCategory[] VALUES = values();
|
||||
|
||||
public static StatisticCategory read(NetInput in) throws IOException {
|
||||
return in.readEnum(VALUES);
|
||||
}
|
||||
|
||||
public static StatisticCategory fromId(int id) {
|
||||
return VALUES[id];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.github.steveice10.mc.protocol.data.game.statistic;
|
||||
|
||||
public enum StatisticFormat {
|
||||
/**
|
||||
* Distance in centimeters
|
||||
*/
|
||||
DISTANCE,
|
||||
|
||||
/**
|
||||
* Time in ticks
|
||||
*/
|
||||
TIME,
|
||||
|
||||
INTEGER,
|
||||
|
||||
/**
|
||||
* Used for damage statistics.
|
||||
*/
|
||||
TENTHS
|
||||
}
|
|
@ -1,13 +1,11 @@
|
|||
package com.github.steveice10.mc.protocol.packet.ingame.clientbound;
|
||||
|
||||
import com.github.steveice10.mc.protocol.data.MagicValues;
|
||||
import com.github.steveice10.mc.protocol.data.UnmappedValueException;
|
||||
import com.github.steveice10.mc.protocol.data.game.entity.type.EntityType;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.BreakBlockStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.BreakItemStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.CraftItemStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.CustomStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.DropItemStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.GenericStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.CustomStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.KillEntityStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.KilledByEntityStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.PickupItemStatistic;
|
||||
|
@ -35,43 +33,39 @@ public class ClientboundAwardStatsPacket implements Packet {
|
|||
public ClientboundAwardStatsPacket(NetInput in) throws IOException {
|
||||
int length = in.readVarInt();
|
||||
for (int index = 0; index < length; index++) {
|
||||
int categoryId = in.readVarInt();
|
||||
StatisticCategory category = StatisticCategory.read(in);
|
||||
int statisticId = in.readVarInt();
|
||||
Statistic statistic;
|
||||
try {
|
||||
switch (MagicValues.key(StatisticCategory.class, categoryId)) {
|
||||
case BREAK_BLOCK:
|
||||
statistic = new BreakBlockStatistic(statisticId);
|
||||
break;
|
||||
case CRAFT_ITEM:
|
||||
statistic = new CraftItemStatistic(statisticId);
|
||||
break;
|
||||
case USE_ITEM:
|
||||
statistic = new UseItemStatistic(statisticId);
|
||||
break;
|
||||
case BREAK_ITEM:
|
||||
statistic = new BreakItemStatistic(statisticId);
|
||||
break;
|
||||
case PICKED_UP_ITEM:
|
||||
statistic = new PickupItemStatistic(statisticId);
|
||||
break;
|
||||
case DROP_ITEM:
|
||||
statistic = new DropItemStatistic(statisticId);
|
||||
break;
|
||||
case KILL_ENTITY:
|
||||
statistic = new KillEntityStatistic(statisticId);
|
||||
break;
|
||||
case KILLED_BY_ENTITY:
|
||||
statistic = new KilledByEntityStatistic(statisticId);
|
||||
break;
|
||||
case GENERIC:
|
||||
statistic = MagicValues.key(GenericStatistic.class, statisticId);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
} catch (UnmappedValueException e) {
|
||||
statistic = new CustomStatistic(categoryId, statisticId);
|
||||
switch (category) {
|
||||
case BREAK_BLOCK:
|
||||
statistic = new BreakBlockStatistic(statisticId);
|
||||
break;
|
||||
case CRAFT_ITEM:
|
||||
statistic = new CraftItemStatistic(statisticId);
|
||||
break;
|
||||
case USE_ITEM:
|
||||
statistic = new UseItemStatistic(statisticId);
|
||||
break;
|
||||
case BREAK_ITEM:
|
||||
statistic = new BreakItemStatistic(statisticId);
|
||||
break;
|
||||
case PICKED_UP_ITEM:
|
||||
statistic = new PickupItemStatistic(statisticId);
|
||||
break;
|
||||
case DROP_ITEM:
|
||||
statistic = new DropItemStatistic(statisticId);
|
||||
break;
|
||||
case KILL_ENTITY:
|
||||
statistic = new KillEntityStatistic(EntityType.fromId(statisticId));
|
||||
break;
|
||||
case KILLED_BY_ENTITY:
|
||||
statistic = new KilledByEntityStatistic(EntityType.fromId(statisticId));
|
||||
break;
|
||||
case CUSTOM:
|
||||
statistic = CustomStatistic.fromId(statisticId);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
this.statistics.put(statistic, in.readVarInt());
|
||||
}
|
||||
|
@ -80,49 +74,44 @@ public class ClientboundAwardStatsPacket implements Packet {
|
|||
@Override
|
||||
public void write(NetOutput out) throws IOException {
|
||||
out.writeVarInt(this.statistics.size());
|
||||
for (Statistic statistic : this.statistics.keySet()) {
|
||||
int categoryId;
|
||||
for (Map.Entry<Statistic, Integer> entry : statistics.entrySet()) {
|
||||
Statistic statistic = entry.getKey();
|
||||
|
||||
StatisticCategory category;
|
||||
int statisticId;
|
||||
if (statistic instanceof CustomStatistic) {
|
||||
categoryId = ((CustomStatistic) statistic).getCategory();
|
||||
statisticId = ((CustomStatistic) statistic).getId();
|
||||
if (statistic instanceof BreakBlockStatistic) {
|
||||
category = StatisticCategory.BREAK_BLOCK;
|
||||
statisticId = ((BreakBlockStatistic) statistic).getId();
|
||||
} else if (statistic instanceof CraftItemStatistic) {
|
||||
category = StatisticCategory.CRAFT_ITEM;
|
||||
statisticId = ((CraftItemStatistic) statistic).getId();
|
||||
} else if (statistic instanceof UseItemStatistic) {
|
||||
category = StatisticCategory.USE_ITEM;
|
||||
statisticId = ((UseItemStatistic) statistic).getId();
|
||||
} else if (statistic instanceof BreakItemStatistic) {
|
||||
category = StatisticCategory.BREAK_ITEM;
|
||||
statisticId = ((BreakItemStatistic) statistic).getId();
|
||||
} else if (statistic instanceof PickupItemStatistic) {
|
||||
category = StatisticCategory.PICKED_UP_ITEM;
|
||||
statisticId = ((PickupItemStatistic) statistic).getId();
|
||||
} else if (statistic instanceof DropItemStatistic) {
|
||||
category = StatisticCategory.DROP_ITEM;
|
||||
statisticId = ((DropItemStatistic) statistic).getId();
|
||||
} else if (statistic instanceof KillEntityStatistic) {
|
||||
category = StatisticCategory.KILL_ENTITY;
|
||||
statisticId = ((KillEntityStatistic) statistic).getEntity().ordinal();
|
||||
} else if (statistic instanceof KilledByEntityStatistic) {
|
||||
category = StatisticCategory.KILLED_BY_ENTITY;
|
||||
statisticId = ((KilledByEntityStatistic) statistic).getEntity().ordinal();
|
||||
} else if (statistic instanceof CustomStatistic) {
|
||||
category = StatisticCategory.CUSTOM;
|
||||
statisticId = ((CustomStatistic) statistic).ordinal();
|
||||
} else {
|
||||
StatisticCategory category;
|
||||
if (statistic instanceof CraftItemStatistic) {
|
||||
category = StatisticCategory.CRAFT_ITEM;
|
||||
statisticId = ((CraftItemStatistic) statistic).getId();
|
||||
} else if (statistic instanceof BreakBlockStatistic) {
|
||||
category = StatisticCategory.BREAK_BLOCK;
|
||||
statisticId = ((BreakBlockStatistic) statistic).getId();
|
||||
} else if (statistic instanceof UseItemStatistic) {
|
||||
category = StatisticCategory.USE_ITEM;
|
||||
statisticId = ((UseItemStatistic) statistic).getId();
|
||||
} else if (statistic instanceof BreakItemStatistic) {
|
||||
category = StatisticCategory.BREAK_ITEM;
|
||||
statisticId = ((BreakItemStatistic) statistic).getId();
|
||||
} else if (statistic instanceof KillEntityStatistic) {
|
||||
category = StatisticCategory.KILL_ENTITY;
|
||||
statisticId = ((KillEntityStatistic) statistic).getId();
|
||||
} else if (statistic instanceof KilledByEntityStatistic) {
|
||||
category = StatisticCategory.KILLED_BY_ENTITY;
|
||||
statisticId = ((KilledByEntityStatistic) statistic).getId();
|
||||
} else if (statistic instanceof DropItemStatistic) {
|
||||
category = StatisticCategory.DROP_ITEM;
|
||||
statisticId = ((DropItemStatistic) statistic).getId();
|
||||
} else if (statistic instanceof PickupItemStatistic) {
|
||||
category = StatisticCategory.PICKED_UP_ITEM;
|
||||
statisticId = ((PickupItemStatistic) statistic).getId();
|
||||
} else if (statistic instanceof GenericStatistic) {
|
||||
category = StatisticCategory.GENERIC;
|
||||
statisticId = MagicValues.value(Integer.class, statistic);
|
||||
} else {
|
||||
throw new IllegalArgumentException(statistic.getClass().getName());
|
||||
}
|
||||
categoryId = MagicValues.value(Integer.class, category);
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
out.writeVarInt(categoryId);
|
||||
out.writeVarInt(category.ordinal());
|
||||
out.writeVarInt(statisticId);
|
||||
out.writeVarInt(this.statistics.get(statistic));
|
||||
out.writeVarInt(entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,8 +55,6 @@ import com.github.steveice10.mc.protocol.data.game.scoreboard.ScoreboardPosition
|
|||
import com.github.steveice10.mc.protocol.data.game.scoreboard.TeamAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.ChatVisibility;
|
||||
import com.github.steveice10.mc.protocol.data.game.setting.Difficulty;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.GenericStatistic;
|
||||
import com.github.steveice10.mc.protocol.data.game.statistic.StatisticCategory;
|
||||
import com.github.steveice10.mc.protocol.data.game.inventory.AdvancementTabAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.inventory.ClickItemAction;
|
||||
import com.github.steveice10.mc.protocol.data.game.inventory.CraftingBookStateType;
|
||||
|
@ -136,8 +134,6 @@ public class MagicValuesTest {
|
|||
this.register(StructureMirror.class, Integer.class);
|
||||
this.register(DemoMessageValue.class, Integer.class);
|
||||
this.register(EnterCreditsValue.class, Integer.class);
|
||||
this.register(GenericStatistic.class, Integer.class);
|
||||
this.register(StatisticCategory.class, Integer.class);
|
||||
this.register(NoteBlockValueType.class, Integer.class);
|
||||
this.register(PistonValueType.class, Integer.class);
|
||||
this.register(MobSpawnerValueType.class, Integer.class);
|
||||
|
|
Loading…
Reference in a new issue