diff --git a/patches/minecraft/net/minecraft/world/level/block/PowderSnowBlock.java.patch b/patches/minecraft/net/minecraft/world/level/block/PowderSnowBlock.java.patch new file mode 100644 index 0000000000..b8cd391054 --- /dev/null +++ b/patches/minecraft/net/minecraft/world/level/block/PowderSnowBlock.java.patch @@ -0,0 +1,11 @@ +--- a/net/minecraft/world/level/block/PowderSnowBlock.java ++++ b/net/minecraft/world/level/block/PowderSnowBlock.java +@@ -109,7 +_,7 @@ + if (p_154256_.m_6095_().m_204039_(EntityTypeTags.f_144291_)) { + return true; + } else { +- return p_154256_ instanceof LivingEntity ? ((LivingEntity)p_154256_).m_6844_(EquipmentSlot.FEET).m_150930_(Items.f_42463_) : false; ++ return p_154256_ instanceof LivingEntity ? ((LivingEntity)p_154256_).m_6844_(EquipmentSlot.FEET).canWalkOnPowderedSnow((LivingEntity)p_154256_) : false; + } + } + diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java b/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java index fc1fc280a9..2887955a7d 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeItem.java @@ -732,6 +732,20 @@ public interface IForgeItem return false; } + /** + * Called by the powdered snow block to check if a living entity wearing this can walk on the snow, granting the same behavior as leather boots. + * Only affects items worn in the boots slot. + * + * @param stack Stack instance + * @param wearer The entity wearing this ItemStack + * + * @return True if the entity can walk on powdered snow + */ + default boolean canWalkOnPowderedSnow(ItemStack stack, LivingEntity wearer) + { + return stack.is(Items.LEATHER_BOOTS); + } + /** * Used to test if this item can be damaged, but with the ItemStack in question. * Please note that in some cases no ItemStack is available, so the stack-less method will be used. diff --git a/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java b/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java index 321787441e..ccf2154fee 100644 --- a/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java +++ b/src/main/java/net/minecraftforge/common/extensions/IForgeItemStack.java @@ -469,6 +469,19 @@ public interface IForgeItemStack extends ICapabilitySerializable { return self().getItem().elytraFlightTick(self(), entity, flightTicks); } + + /** + * Called by the powdered snow block to check if a living entity wearing this can walk on the snow, granting the same behavior as leather boots. + * Only affects items worn in the boots slot. + * + * @param wearer The entity wearing this ItemStack + * + * @return True if the entity can walk on powdered snow + */ + default boolean canWalkOnPowderedSnow(LivingEntity wearer) + { + return self().getItem().canWalkOnPowderedSnow(self(), wearer); + } /** * Get a bounding box ({@link AABB}) of a sweep attack. diff --git a/src/test/java/net/minecraftforge/debug/item/SnowBootsTest.java b/src/test/java/net/minecraftforge/debug/item/SnowBootsTest.java new file mode 100644 index 0000000000..3a07c98e40 --- /dev/null +++ b/src/test/java/net/minecraftforge/debug/item/SnowBootsTest.java @@ -0,0 +1,45 @@ +/* + * Minecraft Forge - Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only + */ + +package net.minecraftforge.debug.item; + +import net.minecraft.world.entity.EquipmentSlot; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.monster.EnderMan; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.item.ArmorItem; +import net.minecraft.world.item.ArmorMaterials; +import net.minecraft.world.item.CreativeModeTab; +import net.minecraft.world.item.Item; +import net.minecraft.world.item.ItemStack; +import net.minecraftforge.eventbus.api.IEventBus; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.registries.DeferredRegister; +import net.minecraftforge.registries.ForgeRegistries; +import net.minecraftforge.registries.RegistryObject; + +@Mod(SnowBootsTest.MODID) +public class SnowBootsTest +{ + public static final String MODID = "snow_boots_test"; + public static final DeferredRegister ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MODID); + + public static RegistryObject snow_boots = ITEMS.register("snow_boots", () -> + new ArmorItem(ArmorMaterials.DIAMOND, EquipmentSlot.FEET, (new Item.Properties().tab(CreativeModeTab.TAB_MISC))) + { + @Override + public boolean canWalkOnPowderedSnow(ItemStack stack, LivingEntity wearer) { + return wearer.getHealth() < 10; + } + } + ); + + public SnowBootsTest() + { + IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus(); + ITEMS.register(modEventBus); + } +} diff --git a/src/test/resources/META-INF/mods.toml b/src/test/resources/META-INF/mods.toml index ace159af99..faeb76b2c3 100644 --- a/src/test/resources/META-INF/mods.toml +++ b/src/test/resources/META-INF/mods.toml @@ -86,6 +86,8 @@ license="LGPL v2.1" modId="tool_interact_test" [[mods]] modId="custom_elytra_test" +[[mods]] + modId="snow_boots_test" [[mods]] modId="finite_water_test" [[mods]]