Skip to content

Commit

Permalink
fix: fix Flesh Spike block not dropping the correct amount of spikes
Browse files Browse the repository at this point in the history
  • Loading branch information
Elenterius committed Aug 1, 2023
1 parent 5a346e9 commit 7fdba95
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.github.elenterius.biomancy.datagen.loot;

import com.github.elenterius.biomancy.block.DirectionalSlabBlock;
import com.github.elenterius.biomancy.block.fleshspike.FleshSpikeBlock;
import com.github.elenterius.biomancy.block.property.DirectionalSlabType;
import com.github.elenterius.biomancy.init.ModBlocks;
import net.minecraft.advancements.critereon.EnchantmentPredicate;
Expand Down Expand Up @@ -29,6 +30,7 @@

import java.util.List;
import java.util.function.Function;
import java.util.stream.IntStream;

import static com.github.elenterius.biomancy.BiomancyMod.LOGGER;

Expand Down Expand Up @@ -98,6 +100,16 @@ protected static LootTable.Builder createDirectionalSlabTable(Block slab) {
)));
}

protected static LootTable.Builder createFleshSpikeTable(FleshSpikeBlock block) {
return LootTable.lootTable().withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(applyExplosionDecay(block, LootItem.lootTableItem(block).apply(
IntStream.range(FleshSpikeBlock.MIN_SPIKES + 1, FleshSpikeBlock.MAX_SPIKES + 1).boxed().toList(),
spikes -> SetItemCountFunction.setCount(ConstantValue.exactly(spikes))
.when(LootItemBlockStatePropertyCondition.hasBlockStateProperties(block).setProperties(StatePropertiesPredicate.Builder.properties().hasProperty(FleshSpikeBlock.SPIKES, spikes)))
))));
}

@Override
protected void addTables() {
LOGGER.info(logMarker, "registering block loot...");
Expand Down Expand Up @@ -151,7 +163,7 @@ protected void addTables() {
addCustom(ModBlocks.FLESH_DOOR.get(), ModBlockLoot::createFleshDoorTable);
addCustom(ModBlocks.FULL_FLESH_DOOR.get(), ModBlockLoot::createFleshDoorTable);

dropSelf(ModBlocks.FLESH_SPIKE.get());
addCustom(ModBlocks.FLESH_SPIKE.get(), ModBlockLoot::createFleshSpikeTable);
}

protected <T extends Block> void addCustom(T block, Function<T, LootTable.Builder> function) {
Expand Down

0 comments on commit 7fdba95

Please sign in to comment.