Advertisement
Guest User

ColorfulBlock.java code

a guest
Sep 23rd, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. package net.coloration.mod;
  2.  
  3. import net.java.games.input.Component.Identifier;
  4. import net.minecraft.block.Block;
  5.  
  6. public class ColorfulBlock extends Block {
  7.  public ColorfulBlock(Block.Settings settings) {
  8.      super(settings);
  9.      
  10. @Override
  11.     public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
  12.         //EARLY DETECTION OF BUSTED LOOT TABLES:
  13.         Identifier tableId = this.getDropTableId();
  14.         System.out.println("Loot table ID is: "+tableId);
  15.        
  16.         if (tableId == LootTables.EMPTY) {
  17.             return Collections.emptyList();
  18.         } else {
  19.             LootContext context = builder.put(LootContextParameters.BLOCK_STATE, state).build(LootContextTypes.BLOCK);
  20.             ServerWorld world = context.getWorld();
  21.             LootSupplier lootSupplier = world.getServer().getLootManager().getSupplier(tableId);
  22.            
  23.             List<ItemStack> result = lootSupplier.getDrops(context);
  24.             if (result.isEmpty()) {
  25.                 //This might not be good. Confirm:
  26.                
  27.                 if (lootSupplier instanceof FabricLootSupplier) {
  28.                     List<LootPool> pools = ((FabricLootSupplier)lootSupplier).getPools();
  29.                     if (pools.isEmpty()) {
  30.                         System.out.println("The loot pool json really is bad somehow!");
  31.                     }
  32.                 }
  33.             }
  34.             return result;
  35.         }
  36.     }
  37.  
  38.  
  39.  
  40.  }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement