[Change] Add Flight Duration to Rockets from Village Loot (#309)

This commit is contained in:
Frank 2023-12-20 16:20:08 +01:00
parent 9c4d7d0c11
commit 964671317a
2 changed files with 13 additions and 1 deletions

View file

@ -138,6 +138,10 @@
{
"type": "minecraft:item",
"functions": [
{
"function": "minecraft:set_nbt",
"tag": "{Fireworks:{Flight:3b}}"
},
{
"add": false,
"count": {

View file

@ -6,6 +6,7 @@ import org.betterx.betterend.registry.EndItems;
import org.betterx.betterend.registry.EndTemplates;
import org.betterx.betterend.util.LootTableUtil;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Blocks;
@ -15,6 +16,7 @@ import net.minecraft.world.level.storage.loot.entries.LootItem;
import net.minecraft.world.level.storage.loot.functions.EnchantWithLevelsFunction;
import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction;
import net.minecraft.world.level.storage.loot.functions.SetItemDamageFunction;
import net.minecraft.world.level.storage.loot.functions.SetNbtFunction;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition;
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
@ -26,11 +28,15 @@ import net.fabricmc.fabric.api.datagen.v1.provider.SimpleFabricLootTableProvider
import java.util.function.BiConsumer;
public class EndChestLootTableProvider extends SimpleFabricLootTableProvider {
private final CompoundTag FIREWORK_ROCKET_TAG = new CompoundTag();
public EndChestLootTableProvider(
FabricDataOutput output
) {
super(output, LootContextParamSets.CHEST);
CompoundTag FIREWORKS_TAG = new CompoundTag();
FIREWORK_ROCKET_TAG.put("Fireworks", FIREWORKS_TAG);
FIREWORKS_TAG.putByte("Flight", (byte) 3);
}
@ -316,7 +322,9 @@ public class EndChestLootTableProvider extends SimpleFabricLootTableProvider {
).add(LootItem
.lootTableItem(Items.FIREWORK_ROCKET)
.setWeight(8)
.apply(SetItemCountFunction.setCount(UniformGenerator.between(4, 8)))
.apply(SetNbtFunction.setTag(FIREWORK_ROCKET_TAG))
.apply(SetItemCountFunction
.setCount(UniformGenerator.between(4, 8)))
)
.when(LootItemRandomChanceCondition.randomChance(chance));
}