mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-27 15:17:59 +01:00
Reimplement our drops
This commit is contained in:
parent
de801147ac
commit
842148fc97
11 changed files with 464 additions and 59 deletions
|
@ -1,59 +0,0 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.minelittlepony.unicopia.block.UBlocks;
|
||||
import com.minelittlepony.unicopia.item.UItems;
|
||||
import com.minelittlepony.unicopia.magic.spell.SpellRegistry;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.GrassBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@Deprecated
|
||||
public class CustomDrops {
|
||||
// XXX: loot table
|
||||
public void addAuxiliaryDrops(World world, BlockState state, BlockPos pos, List<ItemStack> drops, int fortune) {
|
||||
Block block = state.getBlock();
|
||||
|
||||
int fortuneFactor = 1 + fortune * 15;
|
||||
|
||||
if (block == Blocks.STONE) {
|
||||
if (world.random.nextInt(500 / fortuneFactor) == 0) {
|
||||
for (int i = 0; i < 1 + fortune; i++) {
|
||||
if (world.random.nextInt(10) > 3) {
|
||||
drops.add(new ItemStack(UItems.CORRUPTED_GEM));
|
||||
} else {
|
||||
drops.add(new ItemStack(UItems.GEM));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (world.random.nextInt(5000) == 0) {
|
||||
drops.add(SpellRegistry.instance().enchantStack(new ItemStack(UItems.GEM), "awkward"));
|
||||
}
|
||||
} else if (block == Blocks.DIRT || block == Blocks.CLAY || block == Blocks.GRASS_PATH || block == Blocks.GRASS || block == UBlocks.HIVE_WALL_BLOCK) {
|
||||
if (world.random.nextInt(25 / fortuneFactor) == 0) {
|
||||
drops.add(new ItemStack(UItems.WHEAT_WORMS, 1 + fortune));
|
||||
}
|
||||
} else if (block instanceof GrassBlock) {
|
||||
if (world.random.nextInt(25 / fortuneFactor) == 0) {
|
||||
for (int i = 0; i < 1 + fortune; i++) {
|
||||
int chance = world.random.nextInt(3);
|
||||
|
||||
if (chance == 0) {
|
||||
drops.add(new ItemStack(UItems.ALFALFA_SEEDS));
|
||||
} else if (chance == 1) {
|
||||
drops.add(new ItemStack(UItems.APPLE_SEEDS));
|
||||
} else {
|
||||
drops.add(new ItemStack(UItems.TOMATO_SEEDS));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,12 @@
|
|||
package com.minelittlepony.unicopia;
|
||||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.loot.v1.FabricLootSupplier;
|
||||
import net.fabricmc.fabric.api.loot.v1.event.LootTableLoadingCallback;
|
||||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper;
|
||||
import net.minecraft.loot.LootTable;
|
||||
import net.minecraft.resource.ResourceType;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
@ -48,5 +52,17 @@ public class Unicopia implements ModInitializer {
|
|||
|
||||
CriterionsRegistry.register(BOHDeathCriterion.INSTANCE);
|
||||
ResourceManagerHelper.get(ResourceType.SERVER_DATA).registerReloadListener(Pages.instance());
|
||||
|
||||
LootTableLoadingCallback.EVENT.register((res, manager, id, supplier, setter) -> {
|
||||
if (!"minecraft".contentEquals(id.getNamespace())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Identifier modId = new Identifier("unicopiamc", id.getPath());
|
||||
LootTable table = manager.getSupplier(modId);
|
||||
if (table != LootTable.EMPTY) {
|
||||
supplier.withPools(((FabricLootSupplier)table).getPools());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,37 @@
|
|||
"entries": [
|
||||
{ "type": "minecraft:item", "name": "unicopia:hive_wall_block" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:table_bonus",
|
||||
"enchantment": "minecraft:fortune",
|
||||
"chances": [
|
||||
0.06, 0.072222223, 0.075, 0.096666665, 1
|
||||
]
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:set_count",
|
||||
"count": {
|
||||
"min": 1.0,
|
||||
"max": 2.0,
|
||||
"type": "minecraft:uniform"
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": "minecraft:explosion_decay"
|
||||
}
|
||||
],
|
||||
"name": "unicopia:wheat_worms"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:table_bonus",
|
||||
"enchantment": "minecraft:fortune",
|
||||
"chances": [
|
||||
0.07, 0.072222223, 0.075, 0.086666665, 0.2
|
||||
]
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:set_count",
|
||||
"count": {
|
||||
"min": 1.0,
|
||||
"max": 3.0,
|
||||
"type": "minecraft:uniform"
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": "minecraft:explosion_decay"
|
||||
}
|
||||
],
|
||||
"name": "unicopia:wheat_worms"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:table_bonus",
|
||||
"enchantment": "minecraft:fortune",
|
||||
"chances": [
|
||||
0.05, 0.052222223, 0.055, 0.066666665, 0.1
|
||||
]
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:set_count",
|
||||
"count": {
|
||||
"min": 1.0,
|
||||
"max": 2.0,
|
||||
"type": "minecraft:uniform"
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": "minecraft:explosion_decay"
|
||||
}
|
||||
],
|
||||
"name": "unicopia:wheat_worms"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:table_bonus",
|
||||
"enchantment": "minecraft:fortune",
|
||||
"chances": [
|
||||
0.05, 0.052222223, 0.055, 0.066666665, 0.1
|
||||
]
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:explosion_decay"
|
||||
}
|
||||
],
|
||||
"name": "unicopia:alfalfa_seeds"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:table_bonus",
|
||||
"enchantment": "minecraft:fortune",
|
||||
"chances": [
|
||||
0.05, 0.052222223, 0.055, 0.066666665, 0.1
|
||||
]
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:explosion_decay"
|
||||
}
|
||||
],
|
||||
"name": "unicopia:apple_seeds"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:table_bonus",
|
||||
"enchantment": "minecraft:fortune",
|
||||
"chances": [
|
||||
0.05, 0.052222223, 0.055, 0.066666665, 0.1
|
||||
]
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:explosion_decay"
|
||||
}
|
||||
],
|
||||
"name": "unicopia:tomato_seeds"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:table_bonus",
|
||||
"enchantment": "minecraft:fortune",
|
||||
"chances": [
|
||||
0.05, 0.052222223, 0.055, 0.066666665, 0.1
|
||||
]
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:set_count",
|
||||
"count": {
|
||||
"min": 1.0,
|
||||
"max": 2.0,
|
||||
"type": "minecraft:uniform"
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": "minecraft:explosion_decay"
|
||||
}
|
||||
],
|
||||
"name": "unicopia:wheat_worms"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:table_bonus",
|
||||
"enchantment": "minecraft:fortune",
|
||||
"chances": [
|
||||
0.05, 0.052222223, 0.055, 0.066666665, 0.1
|
||||
]
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:set_count",
|
||||
"count": {
|
||||
"min": 1.0,
|
||||
"max": 2.0,
|
||||
"type": "minecraft:uniform"
|
||||
}
|
||||
},
|
||||
{
|
||||
"function": "minecraft:explosion_decay"
|
||||
}
|
||||
],
|
||||
"name": "unicopia:wheat_worms"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:table_bonus",
|
||||
"enchantment": "minecraft:fortune",
|
||||
"chances": [
|
||||
0.15, 0.152222223, 0.155, 0.166666665, 0.4
|
||||
]
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:explosion_decay"
|
||||
}
|
||||
],
|
||||
"name": "unicopia:alfalfa_seeds"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:table_bonus",
|
||||
"enchantment": "minecraft:fortune",
|
||||
"chances": [
|
||||
0.15, 0.152222223, 0.155, 0.166666665, 0.4
|
||||
]
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:explosion_decay"
|
||||
}
|
||||
],
|
||||
"name": "unicopia:apple_seeds"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:table_bonus",
|
||||
"enchantment": "minecraft:fortune",
|
||||
"chances": [
|
||||
0.15, 0.152222223, 0.155, 0.166666665, 0.4
|
||||
]
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:explosion_decay"
|
||||
}
|
||||
],
|
||||
"name": "unicopia:tomato_seeds"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:table_bonus",
|
||||
"enchantment": "minecraft:fortune",
|
||||
"chances": [
|
||||
0.15, 0.152222223, 0.155, 0.166666665, 0.4
|
||||
]
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:explosion_decay"
|
||||
}
|
||||
],
|
||||
"name": "unicopia:gem"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"rolls": 2,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:table_bonus",
|
||||
"enchantment": "minecraft:fortune",
|
||||
"chances": [
|
||||
0.15, 0.152222223, 0.155, 0.166666665, 0.4
|
||||
]
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:explosion_decay"
|
||||
}
|
||||
],
|
||||
"name": "unicopia:corrupted_gem"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:table_bonus",
|
||||
"enchantment": "minecraft:fortune",
|
||||
"chances": [
|
||||
0.15, 0.152222223, 0.155, 0.166666665, 0.4
|
||||
]
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:explosion_decay"
|
||||
}
|
||||
],
|
||||
"name": "unicopia:alfalfa_seeds"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:table_bonus",
|
||||
"enchantment": "minecraft:fortune",
|
||||
"chances": [
|
||||
0.15, 0.152222223, 0.155, 0.166666665, 0.4
|
||||
]
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:explosion_decay"
|
||||
}
|
||||
],
|
||||
"name": "unicopia:apple_seeds"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:table_bonus",
|
||||
"enchantment": "minecraft:fortune",
|
||||
"chances": [
|
||||
0.15, 0.152222223, 0.155, 0.166666665, 0.4
|
||||
]
|
||||
}
|
||||
],
|
||||
"functions": [
|
||||
{
|
||||
"function": "minecraft:explosion_decay"
|
||||
}
|
||||
],
|
||||
"name": "unicopia:tomato_seeds"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue