This repository has been archived by the owner on Jan 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
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
f31a00d
commit aa06a6e
Showing
1 changed file
with
9 additions
and
9 deletions.
There are no files selected for viewing
18 changes: 9 additions & 9 deletions
18
src/main/java/org/auioc/mods/ahutils/utils/game/EnchUtils.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 |
---|---|---|
@@ -1,33 +1,33 @@ | ||
package org.auioc.mods.ahutils.utils.game; | ||
|
||
import java.util.Random; | ||
import net.minecraft.enchantment.Enchantment; | ||
import net.minecraft.nbt.CompoundNBT; | ||
import net.minecraft.nbt.ListNBT; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.nbt.ListTag; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.item.enchantment.Enchantment; | ||
import net.minecraftforge.registries.ForgeRegistries; | ||
|
||
public interface EnchUtils { | ||
static Enchantment getEnchantment(String id) { | ||
return ForgeRegistries.ENCHANTMENTS.getValue(new ResourceLocation(id)); | ||
} | ||
|
||
static void enchantAll(ListNBT enchantments) { | ||
static void enchantAll(ListTag enchantments) { | ||
for (int i = 0; i < enchantments.size(); i++) { | ||
CompoundNBT nbt = enchantments.getCompound(i); | ||
CompoundTag nbt = enchantments.getCompound(i); | ||
nbt.putShort("lvl", (short) (nbt.getShort("lvl") + 1)); | ||
} | ||
} | ||
|
||
static void enchantOne(ListNBT enchantments, int index) { | ||
CompoundNBT nbt = enchantments.getCompound(index); | ||
static void enchantOne(ListTag enchantments, int index) { | ||
CompoundTag nbt = enchantments.getCompound(index); | ||
nbt.putShort("lvl", (short) (nbt.getShort("lvl") + 1)); | ||
} | ||
|
||
static void enchantRandom(ListNBT enchantments) { | ||
static void enchantRandom(ListTag enchantments) { | ||
int enchCount = enchantments.size(); | ||
int index = (new Random()).nextInt((enchCount - 0) + 1) + 0; | ||
CompoundNBT nbt = enchantments.getCompound(index); | ||
CompoundTag nbt = enchantments.getCompound(index); | ||
nbt.putShort("lvl", (short) (nbt.getShort("lvl") + 1)); | ||
} | ||
} |