Guest User

Untitled

a guest
Jul 23rd, 2023
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. package asierus.amktconstruct.event.loot;
  2.  
  3. import asierus.amktconstruct.amktconstruct;
  4. import net.minecraft.resources.ResourceLocation;
  5. import net.minecraft.world.item.ItemStack;
  6. import net.minecraft.world.level.storage.loot.LootContext;
  7. import net.minecraft.world.level.storage.loot.LootTable;
  8. import net.minecraft.world.level.storage.loot.LootTables;
  9. import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
  10. import net.minecraftforge.common.loot.GlobalLootModifierSerializer;
  11. import net.minecraftforge.common.loot.LootModifier;
  12. import javax.annotation.Nonnull;
  13. import java.util.List;
  14. import com.google.gson.JsonObject;
  15.  
  16.  
  17.  
  18. public class BrightSoulLoot extends LootModifier {
  19.  
  20. protected BrightSoulLoot(LootItemCondition[] conditionsIn) {
  21. super(conditionsIn);
  22. }
  23. @Nonnull
  24. @Override
  25. protected List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) {
  26.  
  27.  
  28. ResourceLocation loc = new ResourceLocation(amktconstruct.MOD_ID,"brightsoul");
  29. LootTables ltManager = context.getLevel().getServer().getLootTables();
  30. LootTable lt = ltManager.get(loc);
  31. List<ItemStack> result = lt.getRandomItems(context);
  32. generatedLoot.addAll(result);
  33. return generatedLoot;
  34. }
  35. public static class Serializer extends GlobalLootModifierSerializer<BrightSoulLoot> {
  36. @Override
  37. public BrightSoulLoot read(ResourceLocation name, JsonObject object, LootItemCondition[] conditionsIn) {
  38. return new BrightSoulLoot(conditionsIn);
  39. }
  40. @Override
  41. public JsonObject write(BrightSoulLoot instance) {
  42. JsonObject json = makeConditions(instance.conditions);
  43. return json;
  44. }
  45. }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment