36 lines
974 B
Java
36 lines
974 B
Java
package de.jottyfan.minecraft.block;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
import de.jottyfan.minecraft.item.QuicklyItems;
|
|
import net.minecraft.resources.Identifier;
|
|
import net.minecraft.world.item.ItemStack;
|
|
import net.minecraft.world.level.block.Block;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.level.storage.loot.LootParams.Builder;
|
|
|
|
/**
|
|
*
|
|
* @author jotty
|
|
*
|
|
*/
|
|
public class BlockDrops extends Block {
|
|
|
|
private Identifier dropItem;
|
|
private Integer count;
|
|
|
|
public BlockDrops(Properties properties, Identifier dropItem, Integer count) {
|
|
super(properties);
|
|
this.dropItem = dropItem;
|
|
this.count = count;
|
|
}
|
|
|
|
@Override
|
|
protected List<ItemStack> getDrops(BlockState state, Builder builder) {
|
|
ItemStack droppable = count == null || count < 1 || dropItem == null ? new ItemStack(this.asItem())
|
|
: new ItemStack(QuicklyItems.of(dropItem), count);
|
|
return Arrays.asList(new ItemStack[] { droppable });
|
|
}
|
|
}
|