#Loot Table generation with drop conditions

1 messages · Page 1 of 1 (latest)

steel raptor
#

[1.21] I have a 3 wide multi-block, which I only want the middle block to drop the item. I want the json file to look similar to this:

  "type": "minecraft:block",
  "pools": [
    {
      "rolls": 1,
      "entries": [
        {
          "type": "minecraft:item",
          "name": "turingcomplete:full_adder"
        }
      ],
      "conditions": [
        {
          "condition": "minecraft:survives_explosion"
        },
        {
          "block": "turingcomplete:full_adder",
          "condition": "minecraft:block_state_property",
          "properties": {
            "part": "middle"
          }
        }
      ]
    }
  ]
}```
Specifically, I want the 
```{
          "block": "turingcomplete:full_adder",
          "condition": "minecraft:block_state_property",
          "properties": {
            "part": "middle"
          }```

How do I make that happen with datagen? 
```@Override
    public void generate() {
        ...
        addDrop(blockInit.FULL_ADDER, drops(blockInit.FULL_ADDER));
        ...
    }```
I have this, but this doesn't add the condition that I want. What do I change/add to this?
spark raptor
#

You will probably get the pleasure of pooling it yourself

steel raptor
#

What do you mean?

steel raptor
#

I've found dropsWithProperty(Block drop, Property<T> property, T value), seems like that would be helpful? I can't figure out how to use the parameters though. Is that even the right function? I figured I'd use it in place of the addDrop() function

ebon birch
#

Does the full adder block have any properties? what is the condition you want to change the block drops with?

steel raptor
#

It's got the BLOCKPART property, a property I made to keep track of what part of the block it represents. I want it to drop if it is the MIDDLE part, which is shown in the json code I sent

#

I just want the data gen to generate that, so I don't have to go in manually and replace that file with my manually written one

spark raptor
#

it can, look into LootPool and LootCondition

ebon birch
steel raptor
gleaming linden
#

what is BLOCK_PART?

steel raptor
#

That's my property that can have the value MIDDLE

#

But I can't use that, the syntax is wrong apparently

#

No idea how to make it work :,)

steel raptor
steel raptor
#

import net.minecraft.util.StringIdentifiable;

public enum BLOCK_PART implements StringIdentifiable {
    TOP("top"),
    MIDDLE("middle"),
    BOTTOM("bottom");

    private final String name;

    BLOCK_PART(String name) {
        this.name = name;

    }
    public String toString() {
            return this.name;
    }

    @Override
    public String asString() {
            return this.name;
    }
}

This is how I had defined BLOCK_PART

gleaming linden
#

so this one is done without helper methods:

        this.lootTables.put(RegistryKey.of(RegistryKeys.LOOT_TABLE, Identifier.of("mymod","someblock")),
                LootTable.builder().type(LootContextTypes.BLOCK)
                    .pool(
                            LootPool.builder()
                                .rolls(ConstantLootNumberProvider.create(1.0f))
                                .conditionally(SurvivesExplosionLootCondition.builder())
                                .conditionally(
                                    BlockStatePropertyLootCondition.builder(Blocks.OAK_LOG)
                                        .properties(StatePredicate.Builder.create().exactMatch(Properties.AXIS, Direction.Axis.X))
                                )
                                .with(ItemEntry.builder(Items.OAK_LOG))
                    )
        );
#

it uses a manually generated registrykey, which means its not inside the block folder of loot table, but you can change that. in fact, you can pick apart most of this to use with helpers

steel raptor
#

I'm confused, where would I put this piece of code?

#

What is "this"?

#

I have a data generation file that points to a loot table generating file, where I have a generate() function, in which I have addDrop() for all the item recipes I want, and then I was trying addDrop(blockInit.FULL_ADDER, dropsWithProperty(blockInit.FULL_ADDER,BLOCK_PART,MIDDLE)); which evidently doesn't work :,)

gleaming linden
#

that code is inside the generate method

#

have you checked the way vanilla uses the addDrop method?