Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package asierus.amktconstruct.event.loot;
- import asierus.amktconstruct.amktconstruct;
- import net.minecraft.resources.ResourceLocation;
- import net.minecraft.world.item.ItemStack;
- import net.minecraft.world.level.storage.loot.LootContext;
- import net.minecraft.world.level.storage.loot.LootTable;
- import net.minecraft.world.level.storage.loot.LootTables;
- import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
- import net.minecraftforge.common.loot.GlobalLootModifierSerializer;
- import net.minecraftforge.common.loot.LootModifier;
- import javax.annotation.Nonnull;
- import java.util.List;
- import com.google.gson.JsonObject;
- public class BrightSoulLoot extends LootModifier {
- protected BrightSoulLoot(LootItemCondition[] conditionsIn) {
- super(conditionsIn);
- }
- @Nonnull
- @Override
- protected List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) {
- ResourceLocation loc = new ResourceLocation(amktconstruct.MOD_ID,"brightsoul");
- LootTables ltManager = context.getLevel().getServer().getLootTables();
- LootTable lt = ltManager.get(loc);
- List<ItemStack> result = lt.getRandomItems(context);
- generatedLoot.addAll(result);
- return generatedLoot;
- }
- public static class Serializer extends GlobalLootModifierSerializer<BrightSoulLoot> {
- @Override
- public BrightSoulLoot read(ResourceLocation name, JsonObject object, LootItemCondition[] conditionsIn) {
- return new BrightSoulLoot(conditionsIn);
- }
- @Override
- public JsonObject write(BrightSoulLoot instance) {
- JsonObject json = makeConditions(instance.conditions);
- return json;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment