-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enchantment changes and fixes for Beta 12
- Loading branch information
1 parent
c6713f3
commit a94496f
Showing
8 changed files
with
60 additions
and
58 deletions.
There are no files selected for viewing
12 changes: 0 additions & 12 deletions
12
src/main/java/net/atlas/combatify/extensions/IEnchantmentHelper.java
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
src/main/java/net/atlas/combatify/mixin/EnchantCommandMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package net.atlas.combatify.mixin; | ||
|
||
import com.llamalad7.mixinextras.injector.ModifyExpressionValue; | ||
import com.llamalad7.mixinextras.sugar.Local; | ||
import net.atlas.combatify.extensions.CustomEnchantment; | ||
import net.minecraft.server.commands.EnchantCommand; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.enchantment.Enchantment; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
|
||
@Mixin(EnchantCommand.class) | ||
public class EnchantCommandMixin { | ||
@ModifyExpressionValue(method = "enchant", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/enchantment/Enchantment;canEnchant(Lnet/minecraft/world/item/ItemStack;)Z")) | ||
private static boolean redirectCanEnchant(boolean original, @Local(ordinal = 0) Enchantment currentEnchantment, @Local(ordinal = 0) ItemStack itemStack) { | ||
return currentEnchantment instanceof CustomEnchantment customEnchantment && itemStack != null ? customEnchantment.isAcceptibleConditions(itemStack) : original; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/java/net/atlas/combatify/util/CustomEnchantmentHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package net.atlas.combatify.util; | ||
|
||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.MobType; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.item.enchantment.Enchantment; | ||
import net.minecraft.world.item.enchantment.EnchantmentHelper; | ||
|
||
import static net.minecraft.world.item.enchantment.EnchantmentHelper.getItemEnchantmentLevel; | ||
|
||
public interface CustomEnchantmentHelper { | ||
static float getDamageBonus(ItemStack level, LivingEntity entity) { | ||
if(entity.getMobType() == MobType.WATER || entity.isInWaterOrRain()) { | ||
return EnchantmentHelper.getDamageBonus(level, MobType.WATER); | ||
} | ||
return EnchantmentHelper.getDamageBonus(level, entity.getMobType()); | ||
} | ||
static float getKnockbackDebuff(ItemStack level, LivingEntity entity) { | ||
return getDamageBonus(level, entity) / 2.5F; | ||
} | ||
|
||
static int getFullEnchantmentLevel(Enchantment enchantment, LivingEntity entity) { | ||
Iterable<ItemStack> iterable = enchantment.getSlotItems(entity).values(); | ||
int i = 0; | ||
|
||
for(ItemStack itemStack : iterable) { | ||
int j = getItemEnchantmentLevel(enchantment, itemStack); | ||
i += j; | ||
} | ||
|
||
return i; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters