mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-25 22:44:32 +00:00
Add ItemStack context to Enchantment#getDamageBonus (#8635)
This commit is contained in:
1 parent
03c43cf3da
commit
4285c931e7
3 files changed
+49
-1
No files matched your search
@@ -5,10 +5,18 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
-public abstract class Enchantment {
|
||||
+public abstract class Enchantment extends net.minecraftforge.registries.ForgeRegistryEntry<Enchantment> {
|
||||
+public abstract class Enchantment extends net.minecraftforge.registries.ForgeRegistryEntry<Enchantment> implements net.minecraftforge.common.extensions.IForgeEnchantment {
|
||||
private final EquipmentSlot[] f_44671_;
|
||||
private final Enchantment.Rarity f_44674_;
|
||||
public final EnchantmentCategory f_44672_;
|
||||
@@ -71,6 +_,7 @@
|
||||
return 0;
|
||||
}
|
||||
|
||||
+ @Deprecated // Forge: Use ItemStack aware version in IForgeEnchantment
|
||||
public float m_7335_(int p_44682_, MobType p_44683_) {
|
||||
return 0.0F;
|
||||
}
|
||||
@@ -111,7 +_,7 @@
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
--- a/net/minecraft/world/item/enchantment/EnchantmentHelper.java
|
||||
+++ b/net/minecraft/world/item/enchantment/EnchantmentHelper.java
|
||||
@@ -150,7 +_,7 @@
|
||||
public static float m_44833_(ItemStack p_44834_, MobType p_44835_) {
|
||||
MutableFloat mutablefloat = new MutableFloat();
|
||||
m_44850_((p_44887_, p_44888_) -> {
|
||||
- mutablefloat.add(p_44887_.m_7335_(p_44888_, p_44835_));
|
||||
+ mutablefloat.add(p_44887_.getDamageBonus(p_44888_, p_44835_, p_44834_));
|
||||
}, p_44834_);
|
||||
return mutablefloat.floatValue();
|
||||
}
|
||||
@@ -298,7 +_,7 @@
|
||||
|
||||
public static int m_44872_(Random p_44873_, int p_44874_, int p_44875_, ItemStack p_44876_) {
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) Forge Development LLC and contributors
|
||||
* SPDX-License-Identifier: LGPL-2.1-only
|
||||
*/
|
||||
|
||||
package net.minecraftforge.common.extensions;
|
||||
|
||||
import net.minecraft.world.entity.MobType;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
|
||||
public interface IForgeEnchantment
|
||||
{
|
||||
private Enchantment self()
|
||||
{
|
||||
return (Enchantment) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* ItemStack aware version of {@link Enchantment#getDamageBonus(int, MobType)}
|
||||
* @param level the level of the enchantment
|
||||
* @param mobType the mob type being attacked
|
||||
* @param enchantedItem the item used for the attack
|
||||
* @return the damage bonus
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
default float getDamageBonus(int level, MobType mobType, ItemStack enchantedItem)
|
||||
{
|
||||
return self().getDamageBonus(level, mobType);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user