Replace all "minecraft" references and store the string in a constant

This commit is contained in:
Bixilon 2020-11-20 14:42:23 +01:00
parent a0b7bdeeee
commit fe890677e4
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
20 changed files with 144 additions and 142 deletions

View File

@ -35,4 +35,4 @@ you need to provide the full packet mapping. The id depends on the order.
--- ---
Note: Do not check for protocolIds (especially in EntityMetaData or Packets), this data is not reliable! Use version Ids. Note: Do not check for protocolIds (especially in EntityMetaData or Packets), this data is not reliable (because snapshot ids are that much higher)! Use version Ids.

View File

@ -19,7 +19,7 @@ import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition;
import java.util.TreeMap; import java.util.TreeMap;
public class ChangeableIdentifier extends VersionValueMap<String> { public class ChangeableIdentifier extends VersionValueMap<String> {
String mod = "minecraft"; String mod = ProtocolDefinition.DEFAULT_MOD;
public ChangeableIdentifier(String legacy, String water) { public ChangeableIdentifier(String legacy, String water) {
values.put(Versions.LOWEST_VERSION_SUPPORTED.getVersionId(), legacy); values.put(Versions.LOWEST_VERSION_SUPPORTED.getVersionId(), legacy);

View File

@ -43,124 +43,124 @@ import de.bixilon.minosoft.data.entities.entities.npc.WanderingTrader;
import de.bixilon.minosoft.data.entities.entities.player.PlayerEntity; import de.bixilon.minosoft.data.entities.entities.player.PlayerEntity;
import de.bixilon.minosoft.data.entities.entities.projectile.*; import de.bixilon.minosoft.data.entities.entities.projectile.*;
import de.bixilon.minosoft.data.entities.entities.vehicle.*; import de.bixilon.minosoft.data.entities.entities.vehicle.*;
import javafx.util.Pair; import de.bixilon.minosoft.data.mappings.ModIdentifier;
public final class EntityClassMappings { public final class EntityClassMappings {
public static final HashBiMap<Class<? extends Entity>, Pair<String, String>> ENTITY_CLASS_MAPPINGS = HashBiMap.create(); public static final HashBiMap<Class<? extends Entity>, ModIdentifier> ENTITY_CLASS_MAPPINGS = HashBiMap.create();
static { static {
ENTITY_CLASS_MAPPINGS.put(AreaEffectCloud.class, new Pair<>("minecraft", "area_effect_cloud")); ENTITY_CLASS_MAPPINGS.put(AreaEffectCloud.class, new ModIdentifier("area_effect_cloud"));
ENTITY_CLASS_MAPPINGS.put(ArmorStand.class, new Pair<>("minecraft", "armor_stand")); ENTITY_CLASS_MAPPINGS.put(ArmorStand.class, new ModIdentifier("armor_stand"));
ENTITY_CLASS_MAPPINGS.put(Arrow.class, new Pair<>("minecraft", "arrow")); ENTITY_CLASS_MAPPINGS.put(Arrow.class, new ModIdentifier("arrow"));
ENTITY_CLASS_MAPPINGS.put(Bat.class, new Pair<>("minecraft", "bat")); ENTITY_CLASS_MAPPINGS.put(Bat.class, new ModIdentifier("bat"));
ENTITY_CLASS_MAPPINGS.put(Bee.class, new Pair<>("minecraft", "bee")); ENTITY_CLASS_MAPPINGS.put(Bee.class, new ModIdentifier("bee"));
ENTITY_CLASS_MAPPINGS.put(Blaze.class, new Pair<>("minecraft", "blaze")); ENTITY_CLASS_MAPPINGS.put(Blaze.class, new ModIdentifier("blaze"));
ENTITY_CLASS_MAPPINGS.put(Boat.class, new Pair<>("minecraft", "boat")); ENTITY_CLASS_MAPPINGS.put(Boat.class, new ModIdentifier("boat"));
ENTITY_CLASS_MAPPINGS.put(Cat.class, new Pair<>("minecraft", "cat")); ENTITY_CLASS_MAPPINGS.put(Cat.class, new ModIdentifier("cat"));
ENTITY_CLASS_MAPPINGS.put(CaveSpider.class, new Pair<>("minecraft", "cave_spider")); ENTITY_CLASS_MAPPINGS.put(CaveSpider.class, new ModIdentifier("cave_spider"));
ENTITY_CLASS_MAPPINGS.put(Chicken.class, new Pair<>("minecraft", "chicken")); ENTITY_CLASS_MAPPINGS.put(Chicken.class, new ModIdentifier("chicken"));
ENTITY_CLASS_MAPPINGS.put(Cod.class, new Pair<>("minecraft", "cod")); ENTITY_CLASS_MAPPINGS.put(Cod.class, new ModIdentifier("cod"));
ENTITY_CLASS_MAPPINGS.put(Cow.class, new Pair<>("minecraft", "cow")); ENTITY_CLASS_MAPPINGS.put(Cow.class, new ModIdentifier("cow"));
ENTITY_CLASS_MAPPINGS.put(Creeper.class, new Pair<>("minecraft", "creeper")); ENTITY_CLASS_MAPPINGS.put(Creeper.class, new ModIdentifier("creeper"));
ENTITY_CLASS_MAPPINGS.put(Dolphin.class, new Pair<>("minecraft", "dolphin")); ENTITY_CLASS_MAPPINGS.put(Dolphin.class, new ModIdentifier("dolphin"));
ENTITY_CLASS_MAPPINGS.put(Donkey.class, new Pair<>("minecraft", "donkey")); ENTITY_CLASS_MAPPINGS.put(Donkey.class, new ModIdentifier("donkey"));
ENTITY_CLASS_MAPPINGS.put(DragonFireball.class, new Pair<>("minecraft", "dragon_fireball")); ENTITY_CLASS_MAPPINGS.put(DragonFireball.class, new ModIdentifier("dragon_fireball"));
ENTITY_CLASS_MAPPINGS.put(Drowned.class, new Pair<>("minecraft", "drowned")); ENTITY_CLASS_MAPPINGS.put(Drowned.class, new ModIdentifier("drowned"));
ENTITY_CLASS_MAPPINGS.put(ElderGuardian.class, new Pair<>("minecraft", "elder_guardian")); ENTITY_CLASS_MAPPINGS.put(ElderGuardian.class, new ModIdentifier("elder_guardian"));
ENTITY_CLASS_MAPPINGS.put(EndCrystal.class, new Pair<>("minecraft", "end_crystal")); ENTITY_CLASS_MAPPINGS.put(EndCrystal.class, new ModIdentifier("end_crystal"));
ENTITY_CLASS_MAPPINGS.put(EnderDragon.class, new Pair<>("minecraft", "ender_dragon")); ENTITY_CLASS_MAPPINGS.put(EnderDragon.class, new ModIdentifier("ender_dragon"));
ENTITY_CLASS_MAPPINGS.put(Enderman.class, new Pair<>("minecraft", "enderman")); ENTITY_CLASS_MAPPINGS.put(Enderman.class, new ModIdentifier("enderman"));
ENTITY_CLASS_MAPPINGS.put(Endermite.class, new Pair<>("minecraft", "endermite")); ENTITY_CLASS_MAPPINGS.put(Endermite.class, new ModIdentifier("endermite"));
ENTITY_CLASS_MAPPINGS.put(Evoker.class, new Pair<>("minecraft", "evoker")); ENTITY_CLASS_MAPPINGS.put(Evoker.class, new ModIdentifier("evoker"));
ENTITY_CLASS_MAPPINGS.put(EvokerFangs.class, new Pair<>("minecraft", "evoker_fangs")); ENTITY_CLASS_MAPPINGS.put(EvokerFangs.class, new ModIdentifier("evoker_fangs"));
ENTITY_CLASS_MAPPINGS.put(ExperienceOrb.class, new Pair<>("minecraft", "experience_orb")); ENTITY_CLASS_MAPPINGS.put(ExperienceOrb.class, new ModIdentifier("experience_orb"));
ENTITY_CLASS_MAPPINGS.put(ThrownEyeOfEnder.class, new Pair<>("minecraft", "eye_of_ender")); ENTITY_CLASS_MAPPINGS.put(ThrownEyeOfEnder.class, new ModIdentifier("eye_of_ender"));
ENTITY_CLASS_MAPPINGS.put(FallingBlock.class, new Pair<>("minecraft", "falling_block")); ENTITY_CLASS_MAPPINGS.put(FallingBlock.class, new ModIdentifier("falling_block"));
ENTITY_CLASS_MAPPINGS.put(FireworkRocketEntity.class, new Pair<>("minecraft", "firework_rocket")); ENTITY_CLASS_MAPPINGS.put(FireworkRocketEntity.class, new ModIdentifier("firework_rocket"));
ENTITY_CLASS_MAPPINGS.put(Fox.class, new Pair<>("minecraft", "fox")); ENTITY_CLASS_MAPPINGS.put(Fox.class, new ModIdentifier("fox"));
ENTITY_CLASS_MAPPINGS.put(Ghast.class, new Pair<>("minecraft", "ghast")); ENTITY_CLASS_MAPPINGS.put(Ghast.class, new ModIdentifier("ghast"));
ENTITY_CLASS_MAPPINGS.put(Giant.class, new Pair<>("minecraft", "giant")); ENTITY_CLASS_MAPPINGS.put(Giant.class, new ModIdentifier("giant"));
ENTITY_CLASS_MAPPINGS.put(Guardian.class, new Pair<>("minecraft", "guardian")); ENTITY_CLASS_MAPPINGS.put(Guardian.class, new ModIdentifier("guardian"));
ENTITY_CLASS_MAPPINGS.put(Hoglin.class, new Pair<>("minecraft", "hoglin")); ENTITY_CLASS_MAPPINGS.put(Hoglin.class, new ModIdentifier("hoglin"));
ENTITY_CLASS_MAPPINGS.put(Horse.class, new Pair<>("minecraft", "horse")); ENTITY_CLASS_MAPPINGS.put(Horse.class, new ModIdentifier("horse"));
ENTITY_CLASS_MAPPINGS.put(Husk.class, new Pair<>("minecraft", "husk")); ENTITY_CLASS_MAPPINGS.put(Husk.class, new ModIdentifier("husk"));
ENTITY_CLASS_MAPPINGS.put(Illusioner.class, new Pair<>("minecraft", "illusioner")); ENTITY_CLASS_MAPPINGS.put(Illusioner.class, new ModIdentifier("illusioner"));
ENTITY_CLASS_MAPPINGS.put(IronGolem.class, new Pair<>("minecraft", "iron_golem")); ENTITY_CLASS_MAPPINGS.put(IronGolem.class, new ModIdentifier("iron_golem"));
ENTITY_CLASS_MAPPINGS.put(ItemEntity.class, new Pair<>("minecraft", "item")); ENTITY_CLASS_MAPPINGS.put(ItemEntity.class, new ModIdentifier("item"));
ENTITY_CLASS_MAPPINGS.put(ItemFrame.class, new Pair<>("minecraft", "item_frame")); ENTITY_CLASS_MAPPINGS.put(ItemFrame.class, new ModIdentifier("item_frame"));
ENTITY_CLASS_MAPPINGS.put(LargeFireball.class, new Pair<>("minecraft", "fireball")); ENTITY_CLASS_MAPPINGS.put(LargeFireball.class, new ModIdentifier("fireball"));
ENTITY_CLASS_MAPPINGS.put(LeashFenceKnotEntity.class, new Pair<>("minecraft", "leash_knot")); ENTITY_CLASS_MAPPINGS.put(LeashFenceKnotEntity.class, new ModIdentifier("leash_knot"));
ENTITY_CLASS_MAPPINGS.put(LightningBolt.class, new Pair<>("minecraft", "lightning_bolt")); ENTITY_CLASS_MAPPINGS.put(LightningBolt.class, new ModIdentifier("lightning_bolt"));
ENTITY_CLASS_MAPPINGS.put(Llama.class, new Pair<>("minecraft", "llama")); ENTITY_CLASS_MAPPINGS.put(Llama.class, new ModIdentifier("llama"));
ENTITY_CLASS_MAPPINGS.put(LlamaSpit.class, new Pair<>("minecraft", "llama_spit")); ENTITY_CLASS_MAPPINGS.put(LlamaSpit.class, new ModIdentifier("llama_spit"));
ENTITY_CLASS_MAPPINGS.put(MagmaCube.class, new Pair<>("minecraft", "magma_cube")); ENTITY_CLASS_MAPPINGS.put(MagmaCube.class, new ModIdentifier("magma_cube"));
ENTITY_CLASS_MAPPINGS.put(Minecart.class, new Pair<>("minecraft", "minecart")); ENTITY_CLASS_MAPPINGS.put(Minecart.class, new ModIdentifier("minecart"));
ENTITY_CLASS_MAPPINGS.put(MinecartChest.class, new Pair<>("minecraft", "chest_minecart")); ENTITY_CLASS_MAPPINGS.put(MinecartChest.class, new ModIdentifier("chest_minecart"));
ENTITY_CLASS_MAPPINGS.put(MinecartCommandBlock.class, new Pair<>("minecraft", "command_block_minecart")); ENTITY_CLASS_MAPPINGS.put(MinecartCommandBlock.class, new ModIdentifier("command_block_minecart"));
ENTITY_CLASS_MAPPINGS.put(MinecartFurnace.class, new Pair<>("minecraft", "furnace_minecart")); ENTITY_CLASS_MAPPINGS.put(MinecartFurnace.class, new ModIdentifier("furnace_minecart"));
ENTITY_CLASS_MAPPINGS.put(MinecartHopper.class, new Pair<>("minecraft", "hopper_minecart")); ENTITY_CLASS_MAPPINGS.put(MinecartHopper.class, new ModIdentifier("hopper_minecart"));
ENTITY_CLASS_MAPPINGS.put(MinecartSpawner.class, new Pair<>("minecraft", "spawner_minecart")); ENTITY_CLASS_MAPPINGS.put(MinecartSpawner.class, new ModIdentifier("spawner_minecart"));
ENTITY_CLASS_MAPPINGS.put(MinecartTNT.class, new Pair<>("minecraft", "tnt_minecart")); ENTITY_CLASS_MAPPINGS.put(MinecartTNT.class, new ModIdentifier("tnt_minecart"));
ENTITY_CLASS_MAPPINGS.put(Mule.class, new Pair<>("minecraft", "mule")); ENTITY_CLASS_MAPPINGS.put(Mule.class, new ModIdentifier("mule"));
ENTITY_CLASS_MAPPINGS.put(Mooshroom.class, new Pair<>("minecraft", "mooshroom")); ENTITY_CLASS_MAPPINGS.put(Mooshroom.class, new ModIdentifier("mooshroom"));
ENTITY_CLASS_MAPPINGS.put(Ocelot.class, new Pair<>("minecraft", "ocelot")); ENTITY_CLASS_MAPPINGS.put(Ocelot.class, new ModIdentifier("ocelot"));
ENTITY_CLASS_MAPPINGS.put(Painting.class, new Pair<>("minecraft", "painting")); ENTITY_CLASS_MAPPINGS.put(Painting.class, new ModIdentifier("painting"));
ENTITY_CLASS_MAPPINGS.put(Panda.class, new Pair<>("minecraft", "panda")); ENTITY_CLASS_MAPPINGS.put(Panda.class, new ModIdentifier("panda"));
ENTITY_CLASS_MAPPINGS.put(Parrot.class, new Pair<>("minecraft", "parrot")); ENTITY_CLASS_MAPPINGS.put(Parrot.class, new ModIdentifier("parrot"));
ENTITY_CLASS_MAPPINGS.put(Phantom.class, new Pair<>("minecraft", "phantom")); ENTITY_CLASS_MAPPINGS.put(Phantom.class, new ModIdentifier("phantom"));
ENTITY_CLASS_MAPPINGS.put(Pig.class, new Pair<>("minecraft", "pig")); ENTITY_CLASS_MAPPINGS.put(Pig.class, new ModIdentifier("pig"));
ENTITY_CLASS_MAPPINGS.put(Piglin.class, new Pair<>("minecraft", "piglin")); ENTITY_CLASS_MAPPINGS.put(Piglin.class, new ModIdentifier("piglin"));
ENTITY_CLASS_MAPPINGS.put(PiglinBrute.class, new Pair<>("minecraft", "piglin_brute")); ENTITY_CLASS_MAPPINGS.put(PiglinBrute.class, new ModIdentifier("piglin_brute"));
ENTITY_CLASS_MAPPINGS.put(Pillager.class, new Pair<>("minecraft", "pillager")); ENTITY_CLASS_MAPPINGS.put(Pillager.class, new ModIdentifier("pillager"));
ENTITY_CLASS_MAPPINGS.put(PolarBear.class, new Pair<>("minecraft", "polar_bear")); ENTITY_CLASS_MAPPINGS.put(PolarBear.class, new ModIdentifier("polar_bear"));
ENTITY_CLASS_MAPPINGS.put(PrimedTNT.class, new Pair<>("minecraft", "tnt")); ENTITY_CLASS_MAPPINGS.put(PrimedTNT.class, new ModIdentifier("tnt"));
ENTITY_CLASS_MAPPINGS.put(PufferFish.class, new Pair<>("minecraft", "pufferfish")); ENTITY_CLASS_MAPPINGS.put(PufferFish.class, new ModIdentifier("pufferfish"));
ENTITY_CLASS_MAPPINGS.put(Rabbit.class, new Pair<>("minecraft", "rabbit")); ENTITY_CLASS_MAPPINGS.put(Rabbit.class, new ModIdentifier("rabbit"));
ENTITY_CLASS_MAPPINGS.put(Ravenger.class, new Pair<>("minecraft", "ravager")); ENTITY_CLASS_MAPPINGS.put(Ravenger.class, new ModIdentifier("ravager"));
ENTITY_CLASS_MAPPINGS.put(Salmon.class, new Pair<>("minecraft", "salmon")); ENTITY_CLASS_MAPPINGS.put(Salmon.class, new ModIdentifier("salmon"));
ENTITY_CLASS_MAPPINGS.put(Sheep.class, new Pair<>("minecraft", "sheep")); ENTITY_CLASS_MAPPINGS.put(Sheep.class, new ModIdentifier("sheep"));
ENTITY_CLASS_MAPPINGS.put(Shulker.class, new Pair<>("minecraft", "shulker")); ENTITY_CLASS_MAPPINGS.put(Shulker.class, new ModIdentifier("shulker"));
ENTITY_CLASS_MAPPINGS.put(ShulkerBullet.class, new Pair<>("minecraft", "shulker_bullet")); ENTITY_CLASS_MAPPINGS.put(ShulkerBullet.class, new ModIdentifier("shulker_bullet"));
ENTITY_CLASS_MAPPINGS.put(Silverfish.class, new Pair<>("minecraft", "silverfish")); ENTITY_CLASS_MAPPINGS.put(Silverfish.class, new ModIdentifier("silverfish"));
ENTITY_CLASS_MAPPINGS.put(Skeleton.class, new Pair<>("minecraft", "skeleton")); ENTITY_CLASS_MAPPINGS.put(Skeleton.class, new ModIdentifier("skeleton"));
ENTITY_CLASS_MAPPINGS.put(SkeletonHorse.class, new Pair<>("minecraft", "skeleton_horse")); ENTITY_CLASS_MAPPINGS.put(SkeletonHorse.class, new ModIdentifier("skeleton_horse"));
ENTITY_CLASS_MAPPINGS.put(Slime.class, new Pair<>("minecraft", "slime")); ENTITY_CLASS_MAPPINGS.put(Slime.class, new ModIdentifier("slime"));
ENTITY_CLASS_MAPPINGS.put(SmallFireball.class, new Pair<>("minecraft", "small_fireball")); ENTITY_CLASS_MAPPINGS.put(SmallFireball.class, new ModIdentifier("small_fireball"));
ENTITY_CLASS_MAPPINGS.put(SnowGolem.class, new Pair<>("minecraft", "snow_golem")); ENTITY_CLASS_MAPPINGS.put(SnowGolem.class, new ModIdentifier("snow_golem"));
ENTITY_CLASS_MAPPINGS.put(ThrownSnowball.class, new Pair<>("minecraft", "snowball")); ENTITY_CLASS_MAPPINGS.put(ThrownSnowball.class, new ModIdentifier("snowball"));
ENTITY_CLASS_MAPPINGS.put(SpectralArrow.class, new Pair<>("minecraft", "spectral_arrow")); ENTITY_CLASS_MAPPINGS.put(SpectralArrow.class, new ModIdentifier("spectral_arrow"));
ENTITY_CLASS_MAPPINGS.put(Spider.class, new Pair<>("minecraft", "spider")); ENTITY_CLASS_MAPPINGS.put(Spider.class, new ModIdentifier("spider"));
ENTITY_CLASS_MAPPINGS.put(Squid.class, new Pair<>("minecraft", "squid")); ENTITY_CLASS_MAPPINGS.put(Squid.class, new ModIdentifier("squid"));
ENTITY_CLASS_MAPPINGS.put(Stray.class, new Pair<>("minecraft", "stray")); ENTITY_CLASS_MAPPINGS.put(Stray.class, new ModIdentifier("stray"));
ENTITY_CLASS_MAPPINGS.put(Strider.class, new Pair<>("minecraft", "strider")); ENTITY_CLASS_MAPPINGS.put(Strider.class, new ModIdentifier("strider"));
ENTITY_CLASS_MAPPINGS.put(ThrownEgg.class, new Pair<>("minecraft", "egg")); ENTITY_CLASS_MAPPINGS.put(ThrownEgg.class, new ModIdentifier("egg"));
ENTITY_CLASS_MAPPINGS.put(ThrownEnderPearl.class, new Pair<>("minecraft", "ender_pearl")); ENTITY_CLASS_MAPPINGS.put(ThrownEnderPearl.class, new ModIdentifier("ender_pearl"));
ENTITY_CLASS_MAPPINGS.put(ThrownExperienceBottle.class, new Pair<>("minecraft", "experience_bottle")); ENTITY_CLASS_MAPPINGS.put(ThrownExperienceBottle.class, new ModIdentifier("experience_bottle"));
ENTITY_CLASS_MAPPINGS.put(ThrownPotion.class, new Pair<>("minecraft", "potion")); ENTITY_CLASS_MAPPINGS.put(ThrownPotion.class, new ModIdentifier("potion"));
ENTITY_CLASS_MAPPINGS.put(ThrownTrident.class, new Pair<>("minecraft", "trident")); ENTITY_CLASS_MAPPINGS.put(ThrownTrident.class, new ModIdentifier("trident"));
ENTITY_CLASS_MAPPINGS.put(TraderLlama.class, new Pair<>("minecraft", "trader_llama")); ENTITY_CLASS_MAPPINGS.put(TraderLlama.class, new ModIdentifier("trader_llama"));
ENTITY_CLASS_MAPPINGS.put(TropicalFish.class, new Pair<>("minecraft", "tropical_fish")); ENTITY_CLASS_MAPPINGS.put(TropicalFish.class, new ModIdentifier("tropical_fish"));
ENTITY_CLASS_MAPPINGS.put(Turtle.class, new Pair<>("minecraft", "turtle")); ENTITY_CLASS_MAPPINGS.put(Turtle.class, new ModIdentifier("turtle"));
ENTITY_CLASS_MAPPINGS.put(Vex.class, new Pair<>("minecraft", "vex")); ENTITY_CLASS_MAPPINGS.put(Vex.class, new ModIdentifier("vex"));
ENTITY_CLASS_MAPPINGS.put(Villager.class, new Pair<>("minecraft", "villager")); ENTITY_CLASS_MAPPINGS.put(Villager.class, new ModIdentifier("villager"));
ENTITY_CLASS_MAPPINGS.put(Vindicator.class, new Pair<>("minecraft", "vindicator")); ENTITY_CLASS_MAPPINGS.put(Vindicator.class, new ModIdentifier("vindicator"));
ENTITY_CLASS_MAPPINGS.put(WanderingTrader.class, new Pair<>("minecraft", "wandering_trader")); ENTITY_CLASS_MAPPINGS.put(WanderingTrader.class, new ModIdentifier("wandering_trader"));
ENTITY_CLASS_MAPPINGS.put(Witch.class, new Pair<>("minecraft", "witch")); ENTITY_CLASS_MAPPINGS.put(Witch.class, new ModIdentifier("witch"));
ENTITY_CLASS_MAPPINGS.put(WitherBoss.class, new Pair<>("minecraft", "wither")); ENTITY_CLASS_MAPPINGS.put(WitherBoss.class, new ModIdentifier("wither"));
ENTITY_CLASS_MAPPINGS.put(WitherSkeleton.class, new Pair<>("minecraft", "wither_skeleton")); ENTITY_CLASS_MAPPINGS.put(WitherSkeleton.class, new ModIdentifier("wither_skeleton"));
ENTITY_CLASS_MAPPINGS.put(WitherSkull.class, new Pair<>("minecraft", "wither_skull")); ENTITY_CLASS_MAPPINGS.put(WitherSkull.class, new ModIdentifier("wither_skull"));
ENTITY_CLASS_MAPPINGS.put(Wolf.class, new Pair<>("minecraft", "wolf")); ENTITY_CLASS_MAPPINGS.put(Wolf.class, new ModIdentifier("wolf"));
ENTITY_CLASS_MAPPINGS.put(Zoglin.class, new Pair<>("minecraft", "zoglin")); ENTITY_CLASS_MAPPINGS.put(Zoglin.class, new ModIdentifier("zoglin"));
ENTITY_CLASS_MAPPINGS.put(Zombie.class, new Pair<>("minecraft", "zombie")); ENTITY_CLASS_MAPPINGS.put(Zombie.class, new ModIdentifier("zombie"));
ENTITY_CLASS_MAPPINGS.put(ZombieHorse.class, new Pair<>("minecraft", "zombie_horse")); ENTITY_CLASS_MAPPINGS.put(ZombieHorse.class, new ModIdentifier("zombie_horse"));
ENTITY_CLASS_MAPPINGS.put(ZombieVillager.class, new Pair<>("minecraft", "zombie_villager")); ENTITY_CLASS_MAPPINGS.put(ZombieVillager.class, new ModIdentifier("zombie_villager"));
ENTITY_CLASS_MAPPINGS.put(ZombifiedPiglin.class, new Pair<>("minecraft", "zombified_piglin")); ENTITY_CLASS_MAPPINGS.put(ZombifiedPiglin.class, new ModIdentifier("zombified_piglin"));
ENTITY_CLASS_MAPPINGS.put(PlayerEntity.class, new Pair<>("minecraft", "player")); ENTITY_CLASS_MAPPINGS.put(PlayerEntity.class, new ModIdentifier("player"));
ENTITY_CLASS_MAPPINGS.put(FishingHook.class, new Pair<>("minecraft", "fishing_bobber")); ENTITY_CLASS_MAPPINGS.put(FishingHook.class, new ModIdentifier("fishing_bobber"));
} }
public static Class<? extends Entity> getByIdentifier(String mod, String identifier) { public static Class<? extends Entity> getByIdentifier(String mod, String identifier) {
return ENTITY_CLASS_MAPPINGS.inverse().get(new Pair<>(mod, identifier)); return ENTITY_CLASS_MAPPINGS.inverse().get(new ModIdentifier(mod, identifier));
} }
} }

View File

@ -52,7 +52,7 @@ public enum EntityMetaDataFields {
AREA_EFFECT_CLOUD_RADIUS(0.5f), AREA_EFFECT_CLOUD_RADIUS(0.5f),
AREA_EFFECT_CLOUD_COLOR(0), AREA_EFFECT_CLOUD_COLOR(0),
AREA_EFFECT_CLOUD_WAITING(false), AREA_EFFECT_CLOUD_WAITING(false),
AREA_EFFECT_CLOUD_PARTICLE(new ParticleData(new Particle("minecraft", "effect"))), AREA_EFFECT_CLOUD_PARTICLE(new ParticleData(new Particle("effect"))),
ABSTRACT_ARROW_FLAGS((byte) 0), ABSTRACT_ARROW_FLAGS((byte) 0),
ABSTRACT_ARROW_PIERCE_LEVEL((byte) 0), ABSTRACT_ARROW_PIERCE_LEVEL((byte) 0),

View File

@ -31,7 +31,7 @@ public class Painting extends Entity {
public Painting(Connection connection, int entityId, UUID uuid, Location location, EntityRotation rotation) { public Painting(Connection connection, int entityId, UUID uuid, Location location, EntityRotation rotation) {
super(connection, entityId, uuid, location, rotation); super(connection, entityId, uuid, location, rotation);
direction = Directions.NORTH; direction = Directions.NORTH;
motive = new Motive("minecraft", "kebab"); motive = new Motive("kebab");
} }
public Painting(Connection connection, int entityId, UUID uuid, BlockPosition position, Directions direction, Motive motive) { public Painting(Connection connection, int entityId, UUID uuid, BlockPosition position, Directions direction, Motive motive) {

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.network.Connection;
import java.util.UUID; import java.util.UUID;
public class LargeFireball extends Fireball { public class LargeFireball extends Fireball {
private static final Slot DEFAULT_ITEM = new Slot(new Item("minecraft", "fire_charge")); private static final Slot DEFAULT_ITEM = new Slot(new Item("fire_charge"));
public LargeFireball(Connection connection, int entityId, UUID uuid, Location location, EntityRotation rotation) { public LargeFireball(Connection connection, int entityId, UUID uuid, Location location, EntityRotation rotation) {
super(connection, entityId, uuid, location, rotation); super(connection, entityId, uuid, location, rotation);

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.network.Connection;
import java.util.UUID; import java.util.UUID;
public class SmallFireball extends Fireball { public class SmallFireball extends Fireball {
private static final Slot DEFAULT_ITEM = new Slot(new Item("minecraft", "fire_charge")); private static final Slot DEFAULT_ITEM = new Slot(new Item("fire_charge"));
public SmallFireball(Connection connection, int entityId, UUID uuid, Location location, EntityRotation rotation) { public SmallFireball(Connection connection, int entityId, UUID uuid, Location location, EntityRotation rotation) {
super(connection, entityId, uuid, location, rotation); super(connection, entityId, uuid, location, rotation);

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.network.Connection;
import java.util.UUID; import java.util.UUID;
public class ThrownEgg extends ThrowableItemProjectile { public class ThrownEgg extends ThrowableItemProjectile {
private static final Slot DEFAULT_ITEM = new Slot(new Item("minecraft", "egg")); private static final Slot DEFAULT_ITEM = new Slot(new Item("egg"));
public ThrownEgg(Connection connection, int entityId, UUID uuid, Location location, EntityRotation rotation) { public ThrownEgg(Connection connection, int entityId, UUID uuid, Location location, EntityRotation rotation) {
super(connection, entityId, uuid, location, rotation); super(connection, entityId, uuid, location, rotation);

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.network.Connection;
import java.util.UUID; import java.util.UUID;
public class ThrownEnderPearl extends ThrowableItemProjectile { public class ThrownEnderPearl extends ThrowableItemProjectile {
private static final Slot DEFAULT_ITEM = new Slot(new Item("minecraft", "ender_pearl")); private static final Slot DEFAULT_ITEM = new Slot(new Item("ender_pearl"));
public ThrownEnderPearl(Connection connection, int entityId, UUID uuid, Location location, EntityRotation rotation) { public ThrownEnderPearl(Connection connection, int entityId, UUID uuid, Location location, EntityRotation rotation) {
super(connection, entityId, uuid, location, rotation); super(connection, entityId, uuid, location, rotation);

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.network.Connection;
import java.util.UUID; import java.util.UUID;
public class ThrownExperienceBottle extends ThrowableItemProjectile { public class ThrownExperienceBottle extends ThrowableItemProjectile {
private static final Slot DEFAULT_ITEM = new Slot(new Item("minecraft", "experience_bottle")); private static final Slot DEFAULT_ITEM = new Slot(new Item("experience_bottle"));
public ThrownExperienceBottle(Connection connection, int entityId, UUID uuid, Location location, EntityRotation rotation) { public ThrownExperienceBottle(Connection connection, int entityId, UUID uuid, Location location, EntityRotation rotation) {
super(connection, entityId, uuid, location, rotation); super(connection, entityId, uuid, location, rotation);

View File

@ -25,7 +25,7 @@ import de.bixilon.minosoft.protocol.network.Connection;
import java.util.UUID; import java.util.UUID;
public class ThrownEyeOfEnder extends Entity { public class ThrownEyeOfEnder extends Entity {
private static final Slot DEFAULT_ITEM = new Slot(new Item("minecraft", "ender_eye")); private static final Slot DEFAULT_ITEM = new Slot(new Item("ender_eye"));
public ThrownEyeOfEnder(Connection connection, int entityId, UUID uuid, Location location, EntityRotation rotation) { public ThrownEyeOfEnder(Connection connection, int entityId, UUID uuid, Location location, EntityRotation rotation) {
super(connection, entityId, uuid, location, rotation); super(connection, entityId, uuid, location, rotation);

View File

@ -22,7 +22,7 @@ import de.bixilon.minosoft.protocol.network.Connection;
import java.util.UUID; import java.util.UUID;
public class ThrownSnowball extends ThrowableItemProjectile { public class ThrownSnowball extends ThrowableItemProjectile {
private static final Slot DEFAULT_ITEM = new Slot(new Item("minecraft", "snowball")); private static final Slot DEFAULT_ITEM = new Slot(new Item("snowball"));
public ThrownSnowball(Connection connection, int entityId, UUID uuid, Location location, EntityRotation rotation) { public ThrownSnowball(Connection connection, int entityId, UUID uuid, Location location, EntityRotation rotation) {
super(connection, entityId, uuid, location, rotation); super(connection, entityId, uuid, location, rotation);

View File

@ -17,6 +17,7 @@ import de.bixilon.minosoft.data.mappings.Enchantment;
import de.bixilon.minosoft.data.mappings.Item; import de.bixilon.minosoft.data.mappings.Item;
import de.bixilon.minosoft.data.mappings.versions.VersionMapping; import de.bixilon.minosoft.data.mappings.versions.VersionMapping;
import de.bixilon.minosoft.data.text.ChatComponent; import de.bixilon.minosoft.data.text.ChatComponent;
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition;
import de.bixilon.minosoft.util.BitByte; import de.bixilon.minosoft.util.BitByte;
import de.bixilon.minosoft.util.nbt.tag.*; import de.bixilon.minosoft.util.nbt.tag.*;
@ -261,7 +262,7 @@ public class Slot {
} }
public String getSkullOwner() { public String getSkullOwner() {
if (!item.getMod().equals("minecraft") || !item.getIdentifier().equals("skull")) { if (!item.getMod().equals(ProtocolDefinition.DEFAULT_MOD) || !item.getIdentifier().equals("skull")) {
throw new IllegalArgumentException("Item is not a skull!"); throw new IllegalArgumentException("Item is not a skull!");
} }
return skullOwner; return skullOwner;

View File

@ -13,8 +13,9 @@
package de.bixilon.minosoft.data.mappings; package de.bixilon.minosoft.data.mappings;
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition;
public class ModIdentifier { public class ModIdentifier {
public static final String DEFAULT_MOD = "minecraft";
protected final String mod; protected final String mod;
protected final String identifier; protected final String identifier;
@ -26,7 +27,7 @@ public class ModIdentifier {
public ModIdentifier(String fullIdentifier) { public ModIdentifier(String fullIdentifier) {
String[] split = fullIdentifier.split(":"); String[] split = fullIdentifier.split(":");
if (split.length == 1) { if (split.length == 1) {
this.mod = DEFAULT_MOD; this.mod = ProtocolDefinition.DEFAULT_MOD;
this.identifier = fullIdentifier; this.identifier = fullIdentifier;
return; return;
} }

View File

@ -45,6 +45,12 @@ public class Block extends ModIdentifier {
this.rotation = BlockRotations.NONE; this.rotation = BlockRotations.NONE;
} }
public Block(String fullIdentifier) {
super(fullIdentifier);
this.properties = new HashSet<>();
this.rotation = BlockRotations.NONE;
}
public BlockRotations getRotation() { public BlockRotations getRotation() {
return rotation; return rotation;
} }
@ -87,13 +93,15 @@ public class Block extends ModIdentifier {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (super.equals(obj)) { if (this == obj) {
return true; return true;
} }
if (hashCode() != obj.hashCode()) { if (hashCode() != obj.hashCode()) {
return false; return false;
} }
Block their = (Block) obj; if (!(obj instanceof Block their)) {
return false;
}
return getIdentifier().equals(their.getIdentifier()) && getRotation() == their.getRotation() && getProperties().equals(their.getProperties()) && getMod().equals(their.getMod()); return getIdentifier().equals(their.getIdentifier()) && getRotation() == their.getRotation() && getProperties().equals(their.getProperties()) && getMod().equals(their.getMod());
} }
} }

View File

@ -20,7 +20,7 @@ import com.google.gson.JsonObject;
import java.util.HashSet; import java.util.HashSet;
public class Blocks { public class Blocks {
public static final Block nullBlock = new Block("minecraft", "air"); public static final Block nullBlock = new Block("air");
public static HashBiMap<Integer, Block> load(String mod, JsonObject json, boolean metaData) { public static HashBiMap<Integer, Block> load(String mod, JsonObject json, boolean metaData) {
HashBiMap<Integer, Block> versionMapping = HashBiMap.create(); HashBiMap<Integer, Block> versionMapping = HashBiMap.create();

View File

@ -15,18 +15,7 @@ package de.bixilon.minosoft.data.mappings.recipes;
import de.bixilon.minosoft.data.inventory.Slot; import de.bixilon.minosoft.data.inventory.Slot;
import java.util.Arrays;
import java.util.HashSet;
public record Ingredient(Slot[] slot) { public record Ingredient(Slot[] slot) {
public static boolean slotEquals(Slot[] one, Slot[] two) {
if (one.length != two.length) {
return false;
}
HashSet<Slot> first = new HashSet<>(Arrays.asList(one));
HashSet<Slot> second = new HashSet<>(Arrays.asList(two));
return first.equals(second);
}
public Slot[] getSlot() { public Slot[] getSlot() {
return slot; return slot;

View File

@ -136,7 +136,7 @@ public class Versions {
data = files.get(mapping.getFilename() + ".json"); data = files.get(mapping.getFilename() + ".json");
} }
if (data == null) { if (data == null) {
loadVersionMappings(mapping, "minecraft", data, version); loadVersionMappings(mapping, ProtocolDefinition.DEFAULT_MOD, data, version);
continue; continue;
} }
for (String mod : data.keySet()) { for (String mod : data.keySet()) {

View File

@ -22,6 +22,7 @@ import de.bixilon.minosoft.logging.Log;
import de.bixilon.minosoft.protocol.packets.ClientboundPacket; import de.bixilon.minosoft.protocol.packets.ClientboundPacket;
import de.bixilon.minosoft.protocol.protocol.InByteBuffer; import de.bixilon.minosoft.protocol.protocol.InByteBuffer;
import de.bixilon.minosoft.protocol.protocol.PacketHandler; import de.bixilon.minosoft.protocol.protocol.PacketHandler;
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition;
import de.bixilon.minosoft.util.BitByte; import de.bixilon.minosoft.util.BitByte;
import de.bixilon.minosoft.util.nbt.tag.CompoundTag; import de.bixilon.minosoft.util.nbt.tag.CompoundTag;
import de.bixilon.minosoft.util.nbt.tag.ListTag; import de.bixilon.minosoft.util.nbt.tag.ListTag;
@ -98,9 +99,9 @@ public class PacketJoinGame implements ClientboundPacket {
} else { } else {
CompoundTag tag = (CompoundTag) buffer.readNBT(); CompoundTag tag = (CompoundTag) buffer.readNBT();
if (tag.getByteTag("has_skylight").getValue() == 0x01) { //ToDo: this is just for not messing up the skylight if (tag.getByteTag("has_skylight").getValue() == 0x01) { //ToDo: this is just for not messing up the skylight
dimension = dimensions.get("minecraft").get("overworld"); dimension = dimensions.get(ProtocolDefinition.DEFAULT_MOD).get("overworld");
} else { } else {
dimension = dimensions.get("minecraft").get("the_nether"); dimension = dimensions.get(ProtocolDefinition.DEFAULT_MOD).get("the_nether");
} }
} }
} }

View File

@ -35,6 +35,8 @@ public final class ProtocolDefinition {
public static final InetAddress LAN_SERVER_BROADCAST_ADDRESS; public static final InetAddress LAN_SERVER_BROADCAST_ADDRESS;
public static final int LAN_SERVER_MAXIMUM_SERVERS = 100; // maximum number of lan servers, set because otherwise dos attacks would be easy public static final int LAN_SERVER_MAXIMUM_SERVERS = 100; // maximum number of lan servers, set because otherwise dos attacks would be easy
public static final String DEFAULT_MOD = "minecraft";
static { static {
try { try {
LAN_SERVER_BROADCAST_ADDRESS = InetAddress.getByName("224.0.2.60"); LAN_SERVER_BROADCAST_ADDRESS = InetAddress.getByName("224.0.2.60");