mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-22 06:24:59 +01:00
remove isValidRepairItem in favor of component, remove unneeded item tiers, deprecate repair items and tool tier in NonVanillaCustomItemData
This commit is contained in:
parent
289a74975d
commit
650cb8d473
13 changed files with 19 additions and 233 deletions
|
@ -80,10 +80,9 @@ public interface NonVanillaCustomItemData extends CustomItemData {
|
||||||
@Nullable String toolType();
|
@Nullable String toolType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the tool tier of the item.
|
* @deprecated no longer used
|
||||||
*
|
|
||||||
* @return the tool tier of the item
|
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
@Nullable String toolTier();
|
@Nullable String toolTier();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -108,10 +107,9 @@ public interface NonVanillaCustomItemData extends CustomItemData {
|
||||||
@Nullable String translationString();
|
@Nullable String translationString();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the repair materials of the item.
|
* @deprecated No longer used.
|
||||||
*
|
|
||||||
* @return the repair materials of the item
|
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
@Nullable Set<String> repairMaterials();
|
@Nullable Set<String> repairMaterials();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -36,7 +36,6 @@ import org.geysermc.geyser.item.type.CrossbowItem;
|
||||||
import org.geysermc.geyser.item.type.DecoratedPotItem;
|
import org.geysermc.geyser.item.type.DecoratedPotItem;
|
||||||
import org.geysermc.geyser.item.type.DyeItem;
|
import org.geysermc.geyser.item.type.DyeItem;
|
||||||
import org.geysermc.geyser.item.type.DyeableArmorItem;
|
import org.geysermc.geyser.item.type.DyeableArmorItem;
|
||||||
import org.geysermc.geyser.item.type.ElytraItem;
|
|
||||||
import org.geysermc.geyser.item.type.EnchantedBookItem;
|
import org.geysermc.geyser.item.type.EnchantedBookItem;
|
||||||
import org.geysermc.geyser.item.type.FilledMapItem;
|
import org.geysermc.geyser.item.type.FilledMapItem;
|
||||||
import org.geysermc.geyser.item.type.FireworkRocketItem;
|
import org.geysermc.geyser.item.type.FireworkRocketItem;
|
||||||
|
@ -44,7 +43,6 @@ import org.geysermc.geyser.item.type.FireworkStarItem;
|
||||||
import org.geysermc.geyser.item.type.FishingRodItem;
|
import org.geysermc.geyser.item.type.FishingRodItem;
|
||||||
import org.geysermc.geyser.item.type.GoatHornItem;
|
import org.geysermc.geyser.item.type.GoatHornItem;
|
||||||
import org.geysermc.geyser.item.type.Item;
|
import org.geysermc.geyser.item.type.Item;
|
||||||
import org.geysermc.geyser.item.type.MaceItem;
|
|
||||||
import org.geysermc.geyser.item.type.MapItem;
|
import org.geysermc.geyser.item.type.MapItem;
|
||||||
import org.geysermc.geyser.item.type.PlayerHeadItem;
|
import org.geysermc.geyser.item.type.PlayerHeadItem;
|
||||||
import org.geysermc.geyser.item.type.PotionItem;
|
import org.geysermc.geyser.item.type.PotionItem;
|
||||||
|
@ -873,7 +871,7 @@ public final class Items {
|
||||||
public static final Item CARROT_ON_A_STICK = register(new Item("carrot_on_a_stick", builder()));
|
public static final Item CARROT_ON_A_STICK = register(new Item("carrot_on_a_stick", builder()));
|
||||||
public static final Item WARPED_FUNGUS_ON_A_STICK = register(new Item("warped_fungus_on_a_stick", builder()));
|
public static final Item WARPED_FUNGUS_ON_A_STICK = register(new Item("warped_fungus_on_a_stick", builder()));
|
||||||
public static final Item PHANTOM_MEMBRANE = register(new Item("phantom_membrane", builder()));
|
public static final Item PHANTOM_MEMBRANE = register(new Item("phantom_membrane", builder()));
|
||||||
public static final Item ELYTRA = register(new ElytraItem("elytra", builder()));
|
public static final Item ELYTRA = register(new Item("elytra", builder()));
|
||||||
public static final Item OAK_BOAT = register(new BoatItem("oak_boat", builder()));
|
public static final Item OAK_BOAT = register(new BoatItem("oak_boat", builder()));
|
||||||
public static final Item OAK_CHEST_BOAT = register(new BoatItem("oak_chest_boat", builder()));
|
public static final Item OAK_CHEST_BOAT = register(new BoatItem("oak_chest_boat", builder()));
|
||||||
public static final Item SPRUCE_BOAT = register(new BoatItem("spruce_boat", builder()));
|
public static final Item SPRUCE_BOAT = register(new BoatItem("spruce_boat", builder()));
|
||||||
|
@ -1215,7 +1213,7 @@ public final class Items {
|
||||||
public static final Item WRITABLE_BOOK = register(new WritableBookItem("writable_book", builder()));
|
public static final Item WRITABLE_BOOK = register(new WritableBookItem("writable_book", builder()));
|
||||||
public static final Item WRITTEN_BOOK = register(new WrittenBookItem("written_book", builder()));
|
public static final Item WRITTEN_BOOK = register(new WrittenBookItem("written_book", builder()));
|
||||||
public static final Item BREEZE_ROD = register(new Item("breeze_rod", builder()));
|
public static final Item BREEZE_ROD = register(new Item("breeze_rod", builder()));
|
||||||
public static final Item MACE = register(new MaceItem("mace", builder()));
|
public static final Item MACE = register(new Item("mace", builder()));
|
||||||
public static final Item ITEM_FRAME = register(new Item("item_frame", builder()));
|
public static final Item ITEM_FRAME = register(new Item("item_frame", builder()));
|
||||||
public static final Item GLOW_ITEM_FRAME = register(new Item("glow_item_frame", builder()));
|
public static final Item GLOW_ITEM_FRAME = register(new Item("glow_item_frame", builder()));
|
||||||
public static final Item FLOWER_POT = register(new BlockItem(builder(), Blocks.FLOWER_POT));
|
public static final Item FLOWER_POT = register(new BlockItem(builder(), Blocks.FLOWER_POT));
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.geyser.item.components;
|
|
||||||
|
|
||||||
import com.google.common.base.Suppliers;
|
|
||||||
import org.geysermc.geyser.item.Items;
|
|
||||||
import org.geysermc.geyser.item.type.Item;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public enum ToolTier {
|
|
||||||
WOODEN(2, () -> Set.of(Items.OAK_PLANKS, Items.SPRUCE_PLANKS, Items.BIRCH_PLANKS, Items.JUNGLE_PLANKS, Items.ACACIA_PLANKS, Items.DARK_OAK_PLANKS, Items.CRIMSON_PLANKS, Items.WARPED_PLANKS, Items.MANGROVE_PLANKS)), // PLANKS tag // TODO ?
|
|
||||||
STONE(4, () -> Set.of(Items.COBBLESTONE, Items.BLACKSTONE, Items.COBBLED_DEEPSLATE)), // STONE_TOOL_MATERIALS tag
|
|
||||||
IRON(6, () -> Collections.singleton(Items.IRON_INGOT)),
|
|
||||||
GOLDEN(12, () -> Collections.singleton(Items.GOLD_INGOT)),
|
|
||||||
DIAMOND(8, () -> Collections.singleton(Items.DIAMOND)),
|
|
||||||
NETHERITE(9, () -> Collections.singleton(Items.NETHERITE_INGOT));
|
|
||||||
|
|
||||||
private static final ToolTier[] VALUES = values();
|
|
||||||
|
|
||||||
private final int speed;
|
|
||||||
private final Supplier<Set<Item>> repairIngredients;
|
|
||||||
|
|
||||||
ToolTier(int speed, Supplier<Set<Item>> repairIngredients) {
|
|
||||||
this.speed = speed;
|
|
||||||
// Lazily initialize as this will likely be called as items are loading
|
|
||||||
this.repairIngredients = Suppliers.memoize(repairIngredients::get);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Item> getRepairIngredients() {
|
|
||||||
return repairIngredients.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return this.name().toLowerCase(Locale.ROOT);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -30,7 +30,6 @@ import org.cloudburstmc.nbt.NbtMap;
|
||||||
import org.cloudburstmc.nbt.NbtMapBuilder;
|
import org.cloudburstmc.nbt.NbtMapBuilder;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.TrimMaterial;
|
import org.cloudburstmc.protocol.bedrock.data.TrimMaterial;
|
||||||
import org.cloudburstmc.protocol.bedrock.data.TrimPattern;
|
import org.cloudburstmc.protocol.bedrock.data.TrimPattern;
|
||||||
import org.geysermc.geyser.item.ArmorMaterial;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
|
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.ArmorTrim;
|
import org.geysermc.mcprotocollib.protocol.data.game.item.component.ArmorTrim;
|
||||||
|
@ -38,11 +37,9 @@ import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponen
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
|
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
|
||||||
|
|
||||||
public class ArmorItem extends Item {
|
public class ArmorItem extends Item {
|
||||||
private final ArmorMaterial material;
|
|
||||||
|
|
||||||
public ArmorItem(String javaIdentifier, ArmorMaterial material, Builder builder) {
|
public ArmorItem(String javaIdentifier, Builder builder) {
|
||||||
super(javaIdentifier, builder);
|
super(javaIdentifier, builder);
|
||||||
this.material = material;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -68,11 +65,6 @@ public class ArmorItem extends Item {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValidRepairItem(Item other) {
|
|
||||||
return material.getRepairIngredient() == other;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO maybe some kind of namespace util?
|
// TODO maybe some kind of namespace util?
|
||||||
private static String getNamespace(String identifier) {
|
private static String getNamespace(String identifier) {
|
||||||
int i = identifier.indexOf(':');
|
int i = identifier.indexOf(':');
|
||||||
|
|
|
@ -26,14 +26,13 @@
|
||||||
package org.geysermc.geyser.item.type;
|
package org.geysermc.geyser.item.type;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.geysermc.geyser.item.ArmorMaterial;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
|
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
|
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
|
||||||
|
|
||||||
public class DyeableArmorItem extends ArmorItem {
|
public class DyeableArmorItem extends ArmorItem {
|
||||||
public DyeableArmorItem(String javaIdentifier, ArmorMaterial material, Builder builder) {
|
public DyeableArmorItem(String javaIdentifier, Builder builder) {
|
||||||
super(javaIdentifier, material, builder);
|
super(javaIdentifier, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.geyser.item.type;
|
|
||||||
|
|
||||||
import org.geysermc.geyser.item.Items;
|
|
||||||
|
|
||||||
public class ElytraItem extends Item {
|
|
||||||
public ElytraItem(String javaIdentifier, Builder builder) {
|
|
||||||
super(javaIdentifier, builder);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValidRepairItem(Item other) {
|
|
||||||
return other == Items.PHANTOM_MEMBRANE;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -60,7 +60,6 @@ public class LightItem extends BlockItem {
|
||||||
return super.toBedrockDefinition(components, mappings);
|
return super.toBedrockDefinition(components, mappings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static ItemMapping getLightLevelMapping(DataComponents components, ItemMappings mappings) {
|
private static ItemMapping getLightLevelMapping(DataComponents components, ItemMappings mappings) {
|
||||||
String lightLevel = "15";
|
String lightLevel = "15";
|
||||||
if (components != null) {
|
if (components != null) {
|
||||||
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019-2024 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.geyser.item.type;
|
|
||||||
|
|
||||||
import org.geysermc.geyser.item.Items;
|
|
||||||
|
|
||||||
public class MaceItem extends Item {
|
|
||||||
public MaceItem(String javaIdentifier, Builder builder) {
|
|
||||||
super(javaIdentifier, builder);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValidRepairItem(Item other) {
|
|
||||||
return other == Items.BREEZE_ROD;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -26,7 +26,6 @@
|
||||||
package org.geysermc.geyser.item.type;
|
package org.geysermc.geyser.item.type;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.geysermc.geyser.item.components.ToolTier;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
|
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.BannerPatternLayer;
|
import org.geysermc.mcprotocollib.protocol.data.game.item.component.BannerPatternLayer;
|
||||||
|
@ -54,10 +53,4 @@ public class ShieldItem extends Item {
|
||||||
builder.putInt("Base", 15 - baseColor);
|
builder.putInt("Base", 15 - baseColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValidRepairItem(Item other) {
|
|
||||||
// Java Edition 1.19.3 checks the tag, but TODO check to see if we want it or are simulating what Bedrock is doing
|
|
||||||
return ToolTier.WOODEN.getRepairIngredients().contains(other);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019-2022 GeyserMC. http://geysermc.org
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.geysermc.geyser.item.type;
|
|
||||||
|
|
||||||
import org.geysermc.geyser.item.components.ToolTier;
|
|
||||||
|
|
||||||
public class TieredItem extends Item {
|
|
||||||
private final ToolTier tier;
|
|
||||||
|
|
||||||
public TieredItem(String javaIdentifier, ToolTier tier, Builder builder) {
|
|
||||||
super(javaIdentifier, builder);
|
|
||||||
this.tier = tier;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ToolTier tier() {
|
|
||||||
return tier;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValidRepairItem(Item other) {
|
|
||||||
return tier.getRepairIngredients().contains(other);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -26,14 +26,13 @@
|
||||||
package org.geysermc.geyser.item.type;
|
package org.geysermc.geyser.item.type;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.geysermc.geyser.item.ArmorMaterial;
|
|
||||||
import org.geysermc.geyser.session.GeyserSession;
|
import org.geysermc.geyser.session.GeyserSession;
|
||||||
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
|
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
|
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
|
||||||
|
|
||||||
public class WolfArmorItem extends ArmorItem {
|
public class WolfArmorItem extends ArmorItem {
|
||||||
public WolfArmorItem(String javaIdentifier, ArmorMaterial material, Builder builder) {
|
public WolfArmorItem(String javaIdentifier, Builder builder) {
|
||||||
super(javaIdentifier, material, builder);
|
super(javaIdentifier, builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -51,7 +51,13 @@ import org.geysermc.geyser.registry.type.NonVanillaItemRegistration;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType;
|
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType;
|
||||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
|
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class CustomItemRegistryPopulator {
|
public class CustomItemRegistryPopulator {
|
||||||
public static void populate(Map<String, GeyserMappingItem> items, Multimap<String, CustomItemData> customItems, List<NonVanillaCustomItemData> nonVanillaCustomItems) {
|
public static void populate(Map<String, GeyserMappingItem> items, Multimap<String, CustomItemData> customItems, List<NonVanillaCustomItemData> nonVanillaCustomItems) {
|
||||||
|
@ -129,18 +135,11 @@ public class CustomItemRegistryPopulator {
|
||||||
public static NonVanillaItemRegistration registerCustomItem(NonVanillaCustomItemData customItemData, int customItemId, int protocolVersion) {
|
public static NonVanillaItemRegistration registerCustomItem(NonVanillaCustomItemData customItemData, int customItemId, int protocolVersion) {
|
||||||
String customIdentifier = customItemData.identifier();
|
String customIdentifier = customItemData.identifier();
|
||||||
|
|
||||||
Set<String> repairMaterials = customItemData.repairMaterials();
|
|
||||||
|
|
||||||
DataComponents components = new DataComponents(new HashMap<>());
|
DataComponents components = new DataComponents(new HashMap<>());
|
||||||
components.put(DataComponentType.MAX_STACK_SIZE, customItemData.stackSize());
|
components.put(DataComponentType.MAX_STACK_SIZE, customItemData.stackSize());
|
||||||
components.put(DataComponentType.MAX_DAMAGE, customItemData.maxDamage());
|
components.put(DataComponentType.MAX_DAMAGE, customItemData.maxDamage());
|
||||||
|
|
||||||
Item item = new Item(customIdentifier, Item.builder().components(components)) {
|
Item item = new Item(customIdentifier, Item.builder().components(components));
|
||||||
@Override
|
|
||||||
public boolean isValidRepairItem(Item other) {
|
|
||||||
return repairMaterials != null && repairMaterials.contains(other.javaIdentifier());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Items.register(item, customItemData.javaId());
|
Items.register(item, customItemData.javaId());
|
||||||
|
|
||||||
ItemMapping customItemMapping = ItemMapping.builder()
|
ItemMapping customItemMapping = ItemMapping.builder()
|
||||||
|
@ -148,7 +147,6 @@ public class CustomItemRegistryPopulator {
|
||||||
.bedrockData(0)
|
.bedrockData(0)
|
||||||
.bedrockBlockDefinition(null)
|
.bedrockBlockDefinition(null)
|
||||||
.toolType(customItemData.toolType())
|
.toolType(customItemData.toolType())
|
||||||
.toolTier(customItemData.toolTier())
|
|
||||||
.translationString(customItemData.translationString())
|
.translationString(customItemData.translationString())
|
||||||
.customItemOptions(Collections.emptyList())
|
.customItemOptions(Collections.emptyList())
|
||||||
.javaItem(item)
|
.javaItem(item)
|
||||||
|
|
|
@ -52,7 +52,6 @@ public class ItemMapping {
|
||||||
null, // Air is never sent in full over the network for this to serialize.
|
null, // Air is never sent in full over the network for this to serialize.
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
|
||||||
Collections.emptyList(),
|
Collections.emptyList(),
|
||||||
Items.AIR
|
Items.AIR
|
||||||
);
|
);
|
||||||
|
@ -68,7 +67,6 @@ public class ItemMapping {
|
||||||
BlockDefinition bedrockBlockDefinition;
|
BlockDefinition bedrockBlockDefinition;
|
||||||
|
|
||||||
String toolType;
|
String toolType;
|
||||||
String toolTier;
|
|
||||||
|
|
||||||
String translationString;
|
String translationString;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue