Actually do prisma random drops
This commit is contained in:
@@ -3,55 +3,137 @@
|
|||||||
"pools": [
|
"pools": [
|
||||||
{
|
{
|
||||||
"bonus_rolls": 0.0,
|
"bonus_rolls": 0.0,
|
||||||
"entries": [
|
"conditions": [
|
||||||
{
|
{
|
||||||
"type": "minecraft:alternatives",
|
"condition": "minecraft:match_tool",
|
||||||
"children": [
|
"predicate": {
|
||||||
{
|
"predicates": {
|
||||||
"type": "minecraft:item",
|
"minecraft:enchantments": [
|
||||||
"conditions": [
|
|
||||||
{
|
{
|
||||||
"condition": "minecraft:match_tool",
|
"enchantments": "minecraft:silk_touch",
|
||||||
"predicate": {
|
"levels": {
|
||||||
"predicates": {
|
"min": 1
|
||||||
"minecraft:enchantments": [
|
|
||||||
{
|
|
||||||
"enchantments": "minecraft:silk_touch",
|
|
||||||
"levels": {
|
|
||||||
"min": 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"name": "acesbs:entropy_ore"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "minecraft:item",
|
|
||||||
"functions": [
|
|
||||||
{
|
|
||||||
"add": false,
|
|
||||||
"count": {
|
|
||||||
"type": "minecraft:uniform",
|
|
||||||
"max": 5.0,
|
|
||||||
"min": 1.0
|
|
||||||
},
|
|
||||||
"function": "minecraft:set_count"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"enchantment": "minecraft:fortune",
|
|
||||||
"formula": "minecraft:ore_drops",
|
|
||||||
"function": "minecraft:apply_bonus"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"function": "minecraft:explosion_decay"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"name": "acesbs:raw_entropy"
|
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"type": "minecraft:item",
|
||||||
|
"name": "acesbs:entropy_ore"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"functions": [
|
||||||
|
{
|
||||||
|
"function": "minecraft:explosion_decay"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rolls": 1.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bonus_rolls": 0.0,
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"condition": "minecraft:inverted",
|
||||||
|
"term": {
|
||||||
|
"condition": "minecraft:match_tool",
|
||||||
|
"predicate": {
|
||||||
|
"predicates": {
|
||||||
|
"minecraft:enchantments": [
|
||||||
|
{
|
||||||
|
"enchantments": "minecraft:silk_touch",
|
||||||
|
"levels": {
|
||||||
|
"min": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"condition": "minecraft:match_tool",
|
||||||
|
"predicate": {
|
||||||
|
"items": "acesbs:prisma_steel_pickaxe"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"type": "minecraft:item",
|
||||||
|
"name": "acesbs:raw_entropy",
|
||||||
|
"weight": 20
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "minecraft:item",
|
||||||
|
"name": "acesbs:lemon",
|
||||||
|
"weight": 10
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "minecraft:item",
|
||||||
|
"name": "minecraft:diamond"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"functions": [
|
||||||
|
{
|
||||||
|
"enchantment": "minecraft:fortune",
|
||||||
|
"formula": "minecraft:ore_drops",
|
||||||
|
"function": "minecraft:apply_bonus"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"function": "minecraft:explosion_decay"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rolls": 1.0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bonus_rolls": 0.0,
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"condition": "minecraft:inverted",
|
||||||
|
"term": {
|
||||||
|
"condition": "minecraft:match_tool",
|
||||||
|
"predicate": {
|
||||||
|
"predicates": {
|
||||||
|
"minecraft:enchantments": [
|
||||||
|
{
|
||||||
|
"enchantments": "minecraft:silk_touch",
|
||||||
|
"levels": {
|
||||||
|
"min": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"condition": "minecraft:inverted",
|
||||||
|
"term": {
|
||||||
|
"condition": "minecraft:match_tool",
|
||||||
|
"predicate": {
|
||||||
|
"items": "acesbs:prisma_steel_pickaxe"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"entries": [
|
||||||
|
{
|
||||||
|
"type": "minecraft:item",
|
||||||
|
"name": "acesbs:raw_entropy"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"functions": [
|
||||||
|
{
|
||||||
|
"enchantment": "minecraft:fortune",
|
||||||
|
"formula": "minecraft:ore_drops",
|
||||||
|
"function": "minecraft:apply_bonus"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"function": "minecraft:explosion_decay"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"rolls": 1.0
|
"rolls": 1.0
|
||||||
|
|||||||
@@ -2,25 +2,49 @@ package com.acethewildfire.acesbs.datagen;
|
|||||||
|
|
||||||
import com.acethewildfire.acesbs.block.ModBlocks;
|
import com.acethewildfire.acesbs.block.ModBlocks;
|
||||||
import com.acethewildfire.acesbs.item.ModItems;
|
import com.acethewildfire.acesbs.item.ModItems;
|
||||||
|
import com.acethewildfire.acesbs.util.ModTags;
|
||||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider;
|
import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.enchantment.Enchantment;
|
import net.minecraft.enchantment.Enchantment;
|
||||||
import net.minecraft.enchantment.Enchantments;
|
import net.minecraft.enchantment.Enchantments;
|
||||||
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemConvertible;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.Items;
|
||||||
|
import net.minecraft.loot.LootPool;
|
||||||
import net.minecraft.loot.LootTable;
|
import net.minecraft.loot.LootTable;
|
||||||
|
import net.minecraft.loot.condition.InvertedLootCondition;
|
||||||
|
import net.minecraft.loot.condition.LootCondition;
|
||||||
|
import net.minecraft.loot.condition.MatchToolLootCondition;
|
||||||
import net.minecraft.loot.entry.ItemEntry;
|
import net.minecraft.loot.entry.ItemEntry;
|
||||||
import net.minecraft.loot.entry.LeafEntry;
|
import net.minecraft.loot.entry.LeafEntry;
|
||||||
import net.minecraft.loot.function.ApplyBonusLootFunction;
|
import net.minecraft.loot.function.ApplyBonusLootFunction;
|
||||||
|
import net.minecraft.loot.function.ConditionalLootFunction;
|
||||||
|
import net.minecraft.loot.function.ExplosionDecayLootFunction;
|
||||||
import net.minecraft.loot.function.SetCountLootFunction;
|
import net.minecraft.loot.function.SetCountLootFunction;
|
||||||
|
import net.minecraft.loot.provider.number.ConstantLootNumberProvider;
|
||||||
import net.minecraft.loot.provider.number.UniformLootNumberProvider;
|
import net.minecraft.loot.provider.number.UniformLootNumberProvider;
|
||||||
|
import net.minecraft.predicate.NumberRange;
|
||||||
|
import net.minecraft.predicate.item.EnchantmentPredicate;
|
||||||
|
import net.minecraft.predicate.item.EnchantmentsPredicate;
|
||||||
|
import net.minecraft.predicate.item.ItemPredicate;
|
||||||
|
import net.minecraft.predicate.item.ItemSubPredicateTypes;
|
||||||
import net.minecraft.registry.RegistryKeys;
|
import net.minecraft.registry.RegistryKeys;
|
||||||
import net.minecraft.registry.RegistryWrapper;
|
import net.minecraft.registry.RegistryWrapper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class ModLootTableProvider extends FabricBlockLootTableProvider {
|
public class ModLootTableProvider extends FabricBlockLootTableProvider {
|
||||||
|
|
||||||
|
private boolean isValidItem(ItemStack stack) {
|
||||||
|
return stack.isIn(ModTags.Items.PRISMA_CONVERTABLE);
|
||||||
|
}
|
||||||
|
|
||||||
public ModLootTableProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) {
|
public ModLootTableProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) {
|
||||||
super(dataOutput, registryLookup);
|
super(dataOutput, registryLookup);
|
||||||
}
|
}
|
||||||
@@ -42,13 +66,66 @@ public class ModLootTableProvider extends FabricBlockLootTableProvider {
|
|||||||
addDrop(ModBlocks.LEMONWOOD_DOOR, doorDrops(ModBlocks.LEMONWOOD_DOOR));
|
addDrop(ModBlocks.LEMONWOOD_DOOR, doorDrops(ModBlocks.LEMONWOOD_DOOR));
|
||||||
addDrop(ModBlocks.LEMONWOOD_TRAPDOOR);
|
addDrop(ModBlocks.LEMONWOOD_TRAPDOOR);
|
||||||
|
|
||||||
addDrop(ModBlocks.ENTROPY_ORE, multipleOreDrops(ModBlocks.ENTROPY_ORE, ModItems.RAW_ENTROPY, 1, 5));
|
addDrop(ModBlocks.ENTROPY_ORE, prismaSteelOreDrops(ModBlocks.ENTROPY_ORE, ModItems.RAW_ENTROPY, ModItems.PRISMA_STEEL_PICKAXE, 1, 6));
|
||||||
}
|
}
|
||||||
|
|
||||||
public LootTable.Builder multipleOreDrops(Block drop, Item item, float minDrops, float maxDrops) {
|
public LootTable.Builder multipleOreDrops(Block drop, Item item, float minDrops, float maxDrops) {
|
||||||
RegistryWrapper.Impl<Enchantment> impl = this.registryLookup.getWrapperOrThrow(RegistryKeys.ENCHANTMENT);
|
RegistryWrapper.Impl<Enchantment> impl = this.registryLookup.getWrapperOrThrow(RegistryKeys.ENCHANTMENT);
|
||||||
return this.dropsWithSilkTouch(drop, this.applyExplosionDecay(drop, ((LeafEntry.Builder<?>)
|
return this.dropsWithSilkTouch(
|
||||||
ItemEntry.builder(item).apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(minDrops, maxDrops))))
|
drop,
|
||||||
.apply(ApplyBonusLootFunction.oreDrops(impl.getOrThrow(Enchantments.FORTUNE)))));
|
this.applyExplosionDecay(drop, ((LeafEntry.Builder<?>)ItemEntry.builder(item)
|
||||||
|
.apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(minDrops, maxDrops))))
|
||||||
|
.apply(ApplyBonusLootFunction.oreDrops(impl.getOrThrow(Enchantments.FORTUNE)))));
|
||||||
|
}
|
||||||
|
|
||||||
|
public LootCondition.Builder specialToolCondition(ItemConvertible... tools){
|
||||||
|
return MatchToolLootCondition.builder(
|
||||||
|
ItemPredicate.Builder.create()
|
||||||
|
.items(tools)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public LootTable.Builder prismaSteelOreDrops(Block block, Item defaultItem, ItemConvertible tools, float minDrops, float maxDrops){
|
||||||
|
RegistryWrapper.Impl<Enchantment> impl = this.registryLookup.getWrapperOrThrow(RegistryKeys.ENCHANTMENT);
|
||||||
|
LootCondition.Builder silkTouchCondition = MatchToolLootCondition.builder(
|
||||||
|
ItemPredicate.Builder.create()
|
||||||
|
.subPredicate(
|
||||||
|
ItemSubPredicateTypes.ENCHANTMENTS,
|
||||||
|
EnchantmentsPredicate.enchantments(List.of(new EnchantmentPredicate(impl.getOrThrow(Enchantments.SILK_TOUCH), NumberRange.IntRange.atLeast(1))))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
LootPool.Builder defaultPool = LootPool.builder()
|
||||||
|
.rolls(UniformLootNumberProvider.create(minDrops, maxDrops))
|
||||||
|
.conditionally(InvertedLootCondition.builder(silkTouchCondition))
|
||||||
|
.conditionally(InvertedLootCondition.builder(specialToolCondition(tools)))
|
||||||
|
.with(ItemEntry.builder(defaultItem).weight(1))
|
||||||
|
.apply(ApplyBonusLootFunction.oreDrops(impl.getOrThrow(Enchantments.FORTUNE)))
|
||||||
|
.apply(ExplosionDecayLootFunction.builder());
|
||||||
|
|
||||||
|
LootPool.Builder silkTouchPool = LootPool.builder()
|
||||||
|
.rolls(ConstantLootNumberProvider.create(1))
|
||||||
|
.conditionally(silkTouchCondition)
|
||||||
|
.with(ItemEntry.builder(block.asItem()).weight(1))
|
||||||
|
.apply(ExplosionDecayLootFunction.builder());
|
||||||
|
|
||||||
|
LootPool.Builder prismaPool = LootPool.builder()
|
||||||
|
.rolls(UniformLootNumberProvider.create(minDrops, maxDrops))
|
||||||
|
.conditionally(InvertedLootCondition.builder(silkTouchCondition))
|
||||||
|
.conditionally(specialToolCondition(tools))
|
||||||
|
.with(ItemEntry.builder(defaultItem).weight(360))
|
||||||
|
.with(ItemEntry.builder(Items.COAL).weight(14))
|
||||||
|
.with(ItemEntry.builder(Items.RAW_COPPER).weight(10))
|
||||||
|
.with(ItemEntry.builder(Items.RAW_IRON).weight(8))
|
||||||
|
.with(ItemEntry.builder(Items.RAW_GOLD).weight(6))
|
||||||
|
.with(ItemEntry.builder(Items.DIAMOND).weight(2))
|
||||||
|
.apply(ApplyBonusLootFunction.oreDrops(impl.getOrThrow(Enchantments.FORTUNE)))
|
||||||
|
.apply(ExplosionDecayLootFunction.builder());
|
||||||
|
|
||||||
|
return LootTable.builder()
|
||||||
|
.pool(silkTouchPool)
|
||||||
|
.pool(prismaPool)
|
||||||
|
.pool(defaultPool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user