-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3adb475
commit dd0a110
Showing
11 changed files
with
80 additions
and
68 deletions.
There are no files selected for viewing
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
41 changes: 0 additions & 41 deletions
41
src/main/java/dev/dubhe/anvilcraft/item/IHasDefaultEnchantment.java
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
src/main/java/dev/dubhe/anvilcraft/item/IInherentEnchantment.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,53 @@ | ||
package dev.dubhe.anvilcraft.item; | ||
|
||
import net.minecraft.ChatFormatting; | ||
import net.minecraft.core.Holder; | ||
import net.minecraft.network.chat.CommonComponents; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.network.chat.ComponentUtils; | ||
import net.minecraft.network.chat.MutableComponent; | ||
import net.minecraft.network.chat.Style; | ||
import net.minecraft.resources.ResourceKey; | ||
import net.minecraft.world.item.enchantment.Enchantment; | ||
import net.minecraft.world.level.Level; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* 有默认附魔 | ||
*/ | ||
public interface IInherentEnchantment { | ||
Map<ResourceKey<Enchantment>, Integer> getInherentEnchantments(); | ||
|
||
/** | ||
* @return 工具提示 | ||
*/ | ||
default List<Component> getInherentEnchantmentsTooltip(Level level) { | ||
List<Component> list = new ArrayList<>(); | ||
list.add(Component.translatable("item.anvilcraft.inherent_enchantment.tooltip") | ||
.withStyle(ChatFormatting.LIGHT_PURPLE)); | ||
|
||
for (var entry : getInherentEnchantments().entrySet()) { | ||
Holder<Enchantment> enchantmentHolder = level.registryAccess().holderOrThrow(entry.getKey()); | ||
int l = entry.getValue(); | ||
list.add( | ||
Component | ||
.literal("- ").withStyle(ChatFormatting.LIGHT_PURPLE) | ||
.append(getFullname(enchantmentHolder, l)) | ||
); | ||
} | ||
|
||
return list; | ||
} | ||
|
||
static Component getFullname(Holder<Enchantment> enchantment, int level) { | ||
MutableComponent component = enchantment.value().description().copy(); | ||
ComponentUtils.mergeStyles(component, Style.EMPTY.withColor(ChatFormatting.LIGHT_PURPLE)); | ||
if (level != 1 || enchantment.value().getMaxLevel() != 1) { | ||
component.append(CommonComponents.SPACE).append(Component.translatable("enchantment.level." + level)); | ||
} | ||
return component; | ||
} | ||
} |
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
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