Added loot table with nbt

This commit is contained in:
Buuz135 2021-12-18 14:18:09 +01:00
parent 4dfe1834ed
commit 07f0eb8fc4
25 changed files with 735 additions and 2 deletions

View File

@ -19,3 +19,24 @@ a75ff2ba030156b42ed5e545fbf8e06f9854bf2c assets/functionalstorage/blockstates/ju
3bb73e777f6977390b83eba51463e9584cd332ae assets/functionalstorage/blockstates/warped_hyphae_x_1.json
42ca0c251f479a2cf839738d1a65b03358c309b3 assets/functionalstorage/blockstates/warped_hyphae_x_2.json
3756536ab32dc69545328177f3e5c734061b7ab6 assets/functionalstorage/blockstates/warped_hyphae_x_4.json
840e2c0f041b1206ea17bfbbb63388f70cbf52d7 data/functionalstorage/loot_tables/blocks/acacia_wood_x_1.json
9d9e2071dd6af473adb42febf7433c0a417605bc data/functionalstorage/loot_tables/blocks/acacia_wood_x_2.json
a0f7a648fc02bbe7951b1616e8b5024e98b9f4bc data/functionalstorage/loot_tables/blocks/acacia_wood_x_4.json
9e61407957cd64d6bf221214d2766fbf0387f810 data/functionalstorage/loot_tables/blocks/birch_wood_x_1.json
6dc0f3e0eb3c0d95946727dc7a94889eba7b3d9d data/functionalstorage/loot_tables/blocks/birch_wood_x_2.json
bb380824c89d14571908e3283170112c0425f832 data/functionalstorage/loot_tables/blocks/birch_wood_x_4.json
751843faeb73f732abf09285fa5db1c22d3e9aa7 data/functionalstorage/loot_tables/blocks/crimson_hyphae_x_1.json
f5f4160a7223af9205e2df1917b58bd00a65a1bc data/functionalstorage/loot_tables/blocks/crimson_hyphae_x_2.json
598f9907cefdc9a2acd5019ea744979f24c561b2 data/functionalstorage/loot_tables/blocks/crimson_hyphae_x_4.json
a3f6195051ee19033bb167e924645cfff1982c13 data/functionalstorage/loot_tables/blocks/jungle_wood_x_1.json
a9054f38503082c4448495eb28477f4aad833b6c data/functionalstorage/loot_tables/blocks/jungle_wood_x_2.json
7d0ec816a992ae76cf1b32cffa386a60ed59a7c8 data/functionalstorage/loot_tables/blocks/jungle_wood_x_4.json
2aa74a4cb56fa1d54860f35a9649866b7ffa605e data/functionalstorage/loot_tables/blocks/oak_wood_x_1.json
36baee2a35c9184e2573a906de0ea96ae3bcaa3b data/functionalstorage/loot_tables/blocks/oak_wood_x_2.json
48c6fcf44a9b0a41bae3e797976fd79f671539e3 data/functionalstorage/loot_tables/blocks/oak_wood_x_4.json
3cd7cdd11c699a7ead8fa2dfe1965c1c2cf9654b data/functionalstorage/loot_tables/blocks/spruce_wood_x_1.json
0528d7c046f1f770a5eef9566c729a4c0c54e869 data/functionalstorage/loot_tables/blocks/spruce_wood_x_2.json
6b8533faf19a670d5a6c973a9961a6d425b5d3e4 data/functionalstorage/loot_tables/blocks/spruce_wood_x_4.json
3f2a08f75aa45dd2f92c1e837aa06af47ad03050 data/functionalstorage/loot_tables/blocks/warped_hyphae_x_1.json
3a99f38209e3d0bcab46c0919873e55d9bbf278f data/functionalstorage/loot_tables/blocks/warped_hyphae_x_2.json
7d5d8197d10ae97e44ac4a1552da398ab67a43f0 data/functionalstorage/loot_tables/blocks/warped_hyphae_x_4.json

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:acacia_wood_x_1"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:acacia_wood_x_2"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:acacia_wood_x_4"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:birch_wood_x_1"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:birch_wood_x_2"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:birch_wood_x_4"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:crimson_hyphae_x_1"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:crimson_hyphae_x_2"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:crimson_hyphae_x_4"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:jungle_wood_x_1"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:jungle_wood_x_2"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:jungle_wood_x_4"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:oak_wood_x_1"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:oak_wood_x_2"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:oak_wood_x_4"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:spruce_wood_x_1"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:spruce_wood_x_2"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:spruce_wood_x_4"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:warped_hyphae_x_1"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:warped_hyphae_x_2"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -0,0 +1,33 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "handler",
"target": "BlockEntityTag.handler",
"op": "replace"
}
]
}
],
"name": "functionalstorage:warped_hyphae_x_4"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View File

@ -4,6 +4,7 @@ import com.buuz135.functionalstorage.block.DrawerBlock;
import com.buuz135.functionalstorage.client.DrawerRenderer;
import com.buuz135.functionalstorage.data.FunctionalStorageBlockstateProvider;
import com.hrznstudio.titanium.block.BasicTileBlock;
import com.hrznstudio.titanium.datagenerator.loot.TitaniumLootTableProvider;
import com.hrznstudio.titanium.datagenerator.model.BlockItemModelGeneratorProvider;
import com.hrznstudio.titanium.event.handler.EventManager;
import com.hrznstudio.titanium.module.ModuleController;
@ -115,5 +116,6 @@ public class FunctionalStorage extends ModuleController {
);
event.getGenerator().addProvider(new BlockItemModelGeneratorProvider(event.getGenerator(), MOD_ID, blocksToProcess));
event.getGenerator().addProvider(new FunctionalStorageBlockstateProvider(event.getGenerator(), event.getExistingFileHelper(), blocksToProcess));
event.getGenerator().addProvider(new TitaniumLootTableProvider(event.getGenerator(), blocksToProcess));
}
}

View File

@ -5,20 +5,26 @@ import com.buuz135.functionalstorage.block.tile.DrawerTile;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.hrznstudio.titanium.block.RotatableBlock;
import com.hrznstudio.titanium.datagenerator.loot.block.BasicBlockLootTables;
import com.hrznstudio.titanium.module.DeferredRegistryHelper;
import com.hrznstudio.titanium.util.RayTraceUtils;
import com.hrznstudio.titanium.util.TileUtil;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.NonNullList;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.functions.CopyNbtFunction;
import net.minecraft.world.level.storage.loot.providers.nbt.ContextNbtProvider;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
@ -147,7 +153,6 @@ public class DrawerBlock extends RotatableBlock<DrawerTile> {
List<VoxelShape> shapes = new ArrayList<>();
shapes.addAll(CACHED_SHAPES.get(type).get(state.getValue(RotatableBlock.FACING_HORIZONTAL)));
for (int i = 0; i < shapes.size(); i++) {
System.out.println(shapes.get(i));
if (Shapes.joinIsNotEmpty(shapes.get(i), hit, BooleanOp.AND)) {
return i;
}
@ -156,4 +161,17 @@ public class DrawerBlock extends RotatableBlock<DrawerTile> {
}
return -1;
}
@Override
public LootTable.Builder getLootTable(@Nonnull BasicBlockLootTables blockLootTables) {
CopyNbtFunction.Builder nbtBuilder = CopyNbtFunction.copyData(ContextNbtProvider.BLOCK_ENTITY);
nbtBuilder.copy("handler", "BlockEntityTag.handler");
return blockLootTables.droppingSelfWithNbt(this, nbtBuilder);
}
@Override
public NonNullList<ItemStack> getDynamicDrops(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) {
return NonNullList.create();
}
}

View File

@ -124,7 +124,6 @@ public abstract class BigInventoryHandler implements IItemHandler, INBTSerializa
public void deserializeNBT(CompoundTag nbt) {
this.voidItems = nbt.getBoolean(VOID);
for (String allKey : nbt.getCompound(BIG_ITEMS).getAllKeys()) {
System.out.println(nbt.getCompound(BIG_ITEMS).getCompound(allKey).getCompound(STACK));
this.storedStacks.get(Integer.parseInt(allKey)).setStack(ItemStack.of(nbt.getCompound(BIG_ITEMS).getCompound(allKey).getCompound(STACK)));
this.storedStacks.get(Integer.parseInt(allKey)).setAmount(nbt.getCompound(BIG_ITEMS).getCompound(allKey).getInt(AMOUNT));
}