2021-07-13 01:19:40 +00:00
|
|
|
/*
|
2022-01-01 19:03:05 +00:00
|
|
|
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
2021-07-13 01:19:40 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* @author GeyserMC
|
|
|
|
* @link https://github.com/GeyserMC/Geyser
|
|
|
|
*/
|
|
|
|
|
2021-11-20 23:29:46 +00:00
|
|
|
package org.geysermc.geyser.inventory.item;
|
2021-07-13 01:19:40 +00:00
|
|
|
|
|
|
|
import lombok.Getter;
|
|
|
|
import lombok.experimental.Accessors;
|
2021-11-20 21:34:30 +00:00
|
|
|
import org.geysermc.geyser.registry.type.ItemMapping;
|
2021-07-13 01:19:40 +00:00
|
|
|
|
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A class to have easy access to specific item mappings per-version.
|
|
|
|
*/
|
|
|
|
@Getter
|
|
|
|
@Accessors(fluent = true)
|
|
|
|
public class StoredItemMappings {
|
2022-10-30 03:02:11 +00:00
|
|
|
private final ItemMapping amethystShard;
|
2021-07-13 01:19:40 +00:00
|
|
|
private final ItemMapping bamboo;
|
|
|
|
private final ItemMapping banner;
|
|
|
|
private final ItemMapping barrier;
|
2022-10-30 03:02:11 +00:00
|
|
|
private final ItemMapping bowl;
|
|
|
|
private final ItemMapping bucket;
|
|
|
|
private final ItemMapping chest;
|
2021-07-13 01:19:40 +00:00
|
|
|
private final ItemMapping compass;
|
|
|
|
private final ItemMapping crossbow;
|
2021-11-15 01:15:25 +00:00
|
|
|
private final ItemMapping enchantedBook;
|
2021-07-13 01:19:40 +00:00
|
|
|
private final ItemMapping fishingRod;
|
2022-10-30 03:02:11 +00:00
|
|
|
private final ItemMapping flintAndSteel;
|
|
|
|
private final ItemMapping frogspawn;
|
|
|
|
private final ItemMapping goatHorn;
|
|
|
|
private final ItemMapping glassBottle;
|
|
|
|
private final ItemMapping goldenApple;
|
|
|
|
private final ItemMapping goldIngot;
|
|
|
|
private final ItemMapping ironIngot;
|
|
|
|
private final ItemMapping lead;
|
|
|
|
private final ItemMapping lilyPad;
|
2021-07-13 01:19:40 +00:00
|
|
|
private final ItemMapping milkBucket;
|
2022-10-30 03:02:11 +00:00
|
|
|
private final ItemMapping nameTag;
|
2021-08-02 02:20:15 +00:00
|
|
|
private final ItemMapping powderSnowBucket;
|
2021-11-22 19:49:55 +00:00
|
|
|
private final ItemMapping playerHead;
|
2021-07-13 01:19:40 +00:00
|
|
|
private final ItemMapping egg;
|
2022-10-30 03:02:11 +00:00
|
|
|
private final ItemMapping saddle;
|
|
|
|
private final ItemMapping shears;
|
2021-07-13 01:19:40 +00:00
|
|
|
private final ItemMapping shield;
|
2022-10-30 03:02:11 +00:00
|
|
|
private final ItemMapping slimeBall;
|
|
|
|
private final ItemMapping waterBucket;
|
2021-07-13 01:19:40 +00:00
|
|
|
private final ItemMapping wheat;
|
|
|
|
private final ItemMapping writableBook;
|
|
|
|
|
|
|
|
public StoredItemMappings(Map<String, ItemMapping> itemMappings) {
|
2022-10-30 03:02:11 +00:00
|
|
|
this.amethystShard = load(itemMappings, "amethyst_shard");
|
2021-07-13 01:19:40 +00:00
|
|
|
this.bamboo = load(itemMappings, "bamboo");
|
|
|
|
this.banner = load(itemMappings, "white_banner"); // As of 1.17.10, all banners have the same Bedrock ID
|
|
|
|
this.barrier = load(itemMappings, "barrier");
|
2022-10-30 03:02:11 +00:00
|
|
|
this.bowl = load(itemMappings, "bowl");
|
|
|
|
this.bucket = load(itemMappings, "bucket");
|
|
|
|
this.chest = load(itemMappings, "chest");
|
2021-07-13 01:19:40 +00:00
|
|
|
this.compass = load(itemMappings, "compass");
|
|
|
|
this.crossbow = load(itemMappings, "crossbow");
|
2021-11-15 01:15:25 +00:00
|
|
|
this.enchantedBook = load(itemMappings, "enchanted_book");
|
2021-07-13 01:19:40 +00:00
|
|
|
this.fishingRod = load(itemMappings, "fishing_rod");
|
2022-10-30 03:02:11 +00:00
|
|
|
this.flintAndSteel = load(itemMappings, "flint_and_steel");
|
|
|
|
this.frogspawn = load(itemMappings, "frogspawn");
|
|
|
|
this.goatHorn = load(itemMappings, "goat_horn");
|
|
|
|
this.glassBottle = load(itemMappings, "glass_bottle");
|
|
|
|
this.goldenApple = load(itemMappings, "golden_apple");
|
|
|
|
this.goldIngot = load(itemMappings, "gold_ingot");
|
|
|
|
this.ironIngot = load(itemMappings, "iron_ingot");
|
|
|
|
this.lead = load(itemMappings, "lead");
|
|
|
|
this.lilyPad = load(itemMappings, "lily_pad");
|
2021-07-13 01:19:40 +00:00
|
|
|
this.milkBucket = load(itemMappings, "milk_bucket");
|
2022-10-30 03:02:11 +00:00
|
|
|
this.nameTag = load(itemMappings, "name_tag");
|
2021-08-02 02:20:15 +00:00
|
|
|
this.powderSnowBucket = load(itemMappings, "powder_snow_bucket");
|
2021-11-22 19:49:55 +00:00
|
|
|
this.playerHead = load(itemMappings, "player_head");
|
2021-07-13 01:19:40 +00:00
|
|
|
this.egg = load(itemMappings, "egg");
|
2022-10-30 03:02:11 +00:00
|
|
|
this.saddle = load(itemMappings, "saddle");
|
|
|
|
this.shears = load(itemMappings, "shears");
|
2021-07-13 01:19:40 +00:00
|
|
|
this.shield = load(itemMappings, "shield");
|
2022-10-30 03:02:11 +00:00
|
|
|
this.slimeBall = load(itemMappings, "slime_ball");
|
|
|
|
this.waterBucket = load(itemMappings, "water_bucket");
|
2021-07-13 01:19:40 +00:00
|
|
|
this.wheat = load(itemMappings, "wheat");
|
|
|
|
this.writableBook = load(itemMappings, "writable_book");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Nonnull
|
|
|
|
private ItemMapping load(Map<String, ItemMapping> itemMappings, String cleanIdentifier) {
|
|
|
|
ItemMapping mapping = itemMappings.get("minecraft:" + cleanIdentifier);
|
|
|
|
if (mapping == null) {
|
|
|
|
throw new RuntimeException("Could not find item " + cleanIdentifier);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mapping;
|
|
|
|
}
|
|
|
|
}
|