From ac240ce23bd885b59a846d10576a1f33208c8ec6 Mon Sep 17 00:00:00 2001 From: Bixilon Date: Sat, 20 Jun 2020 00:28:22 +0200 Subject: [PATCH] IdentifierSet --- .../minosoft/game/datatypes/Identifier.java | 10 ++++ .../game/datatypes/IdentifierSet.java | 47 +++++++++++++++++++ .../game/datatypes/sounds/Sounds.java | 9 +++- 3 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 src/main/java/de/bixilon/minosoft/game/datatypes/IdentifierSet.java diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/Identifier.java b/src/main/java/de/bixilon/minosoft/game/datatypes/Identifier.java index 4ab095d84..4dfe143d0 100644 --- a/src/main/java/de/bixilon/minosoft/game/datatypes/Identifier.java +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/Identifier.java @@ -33,6 +33,16 @@ public class Identifier { names.put(ProtocolVersion.VERSION_1_13_2, Collections.singletonList(water)); } + public Identifier(HashMap> names) { + this.names = names; + } + + public Identifier(IdentifierSet... sets) { + for (IdentifierSet set : sets) { + names.put(set.getKey(), set.getValue()); + } + } + public Identifier(String name) { names.put(Protocol.getLowestVersionSupported(), Collections.singletonList(name)); } diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/IdentifierSet.java b/src/main/java/de/bixilon/minosoft/game/datatypes/IdentifierSet.java new file mode 100644 index 000000000..2dfb79239 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/IdentifierSet.java @@ -0,0 +1,47 @@ +/* + * Codename Minosoft + * Copyright (C) 2020 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.game.datatypes; + +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +import java.util.List; +import java.util.Map; + +public class IdentifierSet implements Map.Entry> { + final ProtocolVersion version; + List list; + + public IdentifierSet(ProtocolVersion version, List list) { + this.version = version; + this.list = list; + + } + + @Override + public ProtocolVersion getKey() { + return version; + } + + @Override + public List getValue() { + return list; + } + + + @Override + public List setValue(List list) { + this.list = list; + return list; + } +} diff --git a/src/main/java/de/bixilon/minosoft/game/datatypes/sounds/Sounds.java b/src/main/java/de/bixilon/minosoft/game/datatypes/sounds/Sounds.java index 7141ac2a8..d25f3fb40 100644 --- a/src/main/java/de/bixilon/minosoft/game/datatypes/sounds/Sounds.java +++ b/src/main/java/de/bixilon/minosoft/game/datatypes/sounds/Sounds.java @@ -14,6 +14,11 @@ package de.bixilon.minosoft.game.datatypes.sounds; import de.bixilon.minosoft.game.datatypes.Identifier; +import de.bixilon.minosoft.game.datatypes.IdentifierSet; +import de.bixilon.minosoft.protocol.protocol.ProtocolVersion; + +import java.util.Arrays; +import java.util.Collections; public enum Sounds { AMBIENT_WEATHER_THUNDER(new Identifier("ambient.weather.thunder"), SoundCategories.WEATHER), @@ -101,7 +106,7 @@ public enum Sounds { CROSSBOW_QUICK_CHARGE_START(new Identifier("crossbow.quick_charge.start"), SoundCategories.NEUTRAL), CROSSBOW_QUICK_CHARGE_MIDDLE(new Identifier("crossbow.quick_charge.middle"), SoundCategories.NEUTRAL), CROSSBOW_QUICK_CHARGE_END(new Identifier("crossbow.quick_charge.end"), SoundCategories.NEUTRAL), - DAMAGE_FALLBIG(new Identifier("game.player.hurt.fall.big", "damage.fallbig"), SoundCategories.PLAYER), + DAMAGE_FALLBIG(new Identifier(new IdentifierSet(ProtocolVersion.VERSION_1_7_10, Arrays.asList("game.player.hurt.fall.big", "game.neutral.hurt.fall.big", "game.hostile.hurt.fall.big")), new IdentifierSet(ProtocolVersion.VERSION_1_9_4, Collections.singletonList("damage.fallbig"))), SoundCategories.PLAYER), DAMAGE_FALLSMALL(new Identifier("damage.fallsmall"), SoundCategories.PLAYER), ELYTRA_LOOP(new Identifier("elytra.loop"), SoundCategories.NEUTRAL), GAME_PLAYER_ATTACK_NODAMAGE(new Identifier("game.player.attack.nodamage"), SoundCategories.OTHER), @@ -607,7 +612,7 @@ public enum Sounds { BLOCK_BEEHIVE_SHEAR(new Identifier("block.beehive.shear"), SoundCategories.BLOCK), BLOCK_BEEHIVE_WORK(new Identifier("block.beehive.work"), SoundCategories.BLOCK), BLOCK_BEEHIVE_DRIP(new Identifier("block.beehive.drip"), SoundCategories.BLOCK); - //ToDo add legacy names + //ToDo complete per version final Identifier identifier;