mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Properly show dyed wolf armor
This commit is contained in:
parent
7fc370cef7
commit
d19807170d
6 changed files with 64 additions and 10 deletions
|
@ -123,7 +123,7 @@ public class WolfEntity extends TameableEntity {
|
|||
@Override
|
||||
public void setChestplate(ItemStack stack) {
|
||||
super.setChestplate(stack);
|
||||
isCurseOfBinding = ItemUtils.hasEffect(session, stack.getDataComponents(), EnchantmentComponent.PREVENT_ARMOR_CHANGE); // TODO test
|
||||
isCurseOfBinding = ItemUtils.hasEffect(session, stack, EnchantmentComponent.PREVENT_ARMOR_CHANGE); // TODO test
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -834,7 +834,7 @@ public final class Items {
|
|||
public static final Item TURTLE_HELMET = register(new ArmorItem("turtle_helmet", ArmorMaterial.TURTLE, builder().stackSize(1).maxDamage(275)));
|
||||
public static final Item TURTLE_SCUTE = register(new Item("turtle_scute", builder()));
|
||||
public static final Item ARMADILLO_SCUTE = register(new Item("armadillo_scute", builder()));
|
||||
public static final Item WOLF_ARMOR = register(new ArmorItem("wolf_armor", ArmorMaterial.ARMADILLO, builder().stackSize(1).maxDamage(64)));
|
||||
public static final Item WOLF_ARMOR = register(new WolfArmorItem("wolf_armor", ArmorMaterial.ARMADILLO, builder().stackSize(1).maxDamage(64)));
|
||||
public static final Item FLINT_AND_STEEL = register(new Item("flint_and_steel", builder().stackSize(1).maxDamage(64)));
|
||||
public static final Item BOWL = register(new Item("bowl", builder()));
|
||||
public static final Item APPLE = register(new Item("apple", builder()));
|
||||
|
@ -1042,7 +1042,7 @@ public final class Items {
|
|||
public static final Item BLAZE_POWDER = register(new Item("blaze_powder", builder()));
|
||||
public static final Item MAGMA_CREAM = register(new Item("magma_cream", builder()));
|
||||
public static final Item BREWING_STAND = register(new BlockItem(builder(), Blocks.BREWING_STAND));
|
||||
public static final Item CAULDRON = register(new BlockItem(builder(), Blocks.CAULDRON, Blocks.LAVA_CAULDRON, Blocks.WATER_CAULDRON, Blocks.POWDER_SNOW_CAULDRON));
|
||||
public static final Item CAULDRON = register(new BlockItem(builder(), Blocks.CAULDRON, Blocks.WATER_CAULDRON, Blocks.LAVA_CAULDRON, Blocks.POWDER_SNOW_CAULDRON));
|
||||
public static final Item ENDER_EYE = register(new Item("ender_eye", builder()));
|
||||
public static final Item GLISTERING_MELON_SLICE = register(new Item("glistering_melon_slice", builder()));
|
||||
public static final Item ARMADILLO_SPAWN_EGG = register(new SpawnEggItem("armadillo_spawn_egg", builder()));
|
||||
|
|
|
@ -29,9 +29,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||
import org.geysermc.geyser.item.ArmorMaterial;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
|
||||
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.DyedItemColor;
|
||||
|
||||
public class DyeableArmorItem extends ArmorItem {
|
||||
public DyeableArmorItem(String javaIdentifier, ArmorMaterial material, Builder builder) {
|
||||
|
@ -44,9 +42,6 @@ public class DyeableArmorItem extends ArmorItem {
|
|||
|
||||
// Note that this is handled as of 1.20.5 in the ItemColors class.
|
||||
// But horse leather armor and body leather armor are now both armor items. So it works!
|
||||
DyedItemColor dyedItemColor = components.get(DataComponentType.DYED_COLOR);
|
||||
if (dyedItemColor != null) {
|
||||
builder.putInt("customColor", dyedItemColor.getRgb());
|
||||
}
|
||||
translateDyedColor(components, builder);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ import org.geysermc.geyser.translator.text.MessageTranslator;
|
|||
import org.geysermc.mcprotocollib.protocol.data.game.Identifier;
|
||||
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.DyedItemColor;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.ItemEnchantments;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -253,6 +254,13 @@ public class Item {
|
|||
builder.getOrCreateLore().add(0, ChatColor.RESET + ChatColor.GRAY + enchantmentName + " " + lvlTranslation);
|
||||
}
|
||||
|
||||
protected final void translateDyedColor(DataComponents components, BedrockItemBuilder builder) {
|
||||
DyedItemColor dyedItemColor = components.get(DataComponentType.DYED_COLOR);
|
||||
if (dyedItemColor != null) {
|
||||
builder.putInt("customColor", dyedItemColor.getRgb());
|
||||
}
|
||||
}
|
||||
|
||||
/* Translation methods end */
|
||||
|
||||
public GeyserItemStack newItemStack(int count, DataComponents components) {
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright (c) 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.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.geysermc.geyser.item.ArmorMaterial;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
|
||||
|
||||
public class WolfArmorItem extends ArmorItem {
|
||||
public WolfArmorItem(String javaIdentifier, ArmorMaterial material, Builder builder) {
|
||||
super(javaIdentifier, material, builder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateComponentsToBedrock(@NonNull GeyserSession session, @NonNull DataComponents components, @NonNull BedrockItemBuilder builder) {
|
||||
super.translateComponentsToBedrock(session, components, builder);
|
||||
|
||||
// Note that this is handled as of 1.21 in the ItemColors class.
|
||||
translateDyedColor(components, builder);
|
||||
}
|
||||
}
|
|
@ -34,6 +34,7 @@ import org.geysermc.geyser.item.enchantment.EnchantmentComponent;
|
|||
import org.geysermc.geyser.item.type.FishingRodItem;
|
||||
import org.geysermc.geyser.item.type.Item;
|
||||
import org.geysermc.geyser.session.GeyserSession;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.item.ItemStack;
|
||||
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.ItemEnchantments;
|
||||
|
@ -65,7 +66,11 @@ public final class ItemUtils {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public static boolean hasEffect(GeyserSession session, @Nullable DataComponents components, EnchantmentComponent component) {
|
||||
public static boolean hasEffect(GeyserSession session, @Nullable ItemStack itemStack, EnchantmentComponent component) {
|
||||
if (itemStack == null) {
|
||||
return false;
|
||||
}
|
||||
DataComponents components = itemStack.getDataComponents();
|
||||
if (components == null) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue