Skip to content

Commit

Permalink
entity loot table gen
Browse files Browse the repository at this point in the history
  • Loading branch information
Partonetrain committed Jan 16, 2025
1 parent 9881132 commit aaaaf30
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class Stoneling extends PathfinderMob {
private static final String TAG_VARIANT = "variant";
private static final String TAG_HAS_LICHEN = "has_lichen";
private static final String TAG_HOLD_ANGLE = "itemAngle";
private static final String TAG_PLAYER_MADE = "playerMade";
public static final String TAG_PLAYER_MADE = "playerMade";
private final Vec3 PASSENGER_ATTACH_POINT = new Vec3(0, this.getBbHeight(), 0);

private ActWaryGoal waryGoal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public class CrabsModule extends ZetaModule {
public static boolean addCrabLegToFishermanTrades = true;

@Hint(key = "crab_info")
Item crab_leg;
public static Item crab_leg;
@Hint(key = "crab_info")
Item crab_shell;
public static Item crab_shell;
@Hint(key = "crab_info")
public static Item crab_bucket;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class WraithModule extends ZetaModule {
public static List<String> validWraithSounds = wraithSounds.stream().filter((s) -> s.split("\\|").length == 3).collect(Collectors.toList());

@Hint
Item soul_bead;
public static Item soul_bead;

@LoadEvent
public final void register(ZRegister event) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
package org.violetmoon.quark.datagen;

import net.minecraft.advancements.critereon.EntityPredicate;
import net.minecraft.advancements.critereon.NbtPredicate;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.loot.EntityLootSubProvider;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.entries.LootItem;
import net.minecraft.world.level.storage.loot.functions.EnchantedCountIncreaseFunction;
import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction;
import net.minecraft.world.level.storage.loot.functions.SmeltItemFunction;
import net.minecraft.world.level.storage.loot.predicates.*;
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator;
import org.violetmoon.quark.content.mobs.client.model.StonelingModel;
import org.violetmoon.quark.content.mobs.client.model.ToretoiseModel;
import org.violetmoon.quark.content.mobs.entity.Stoneling;
import org.violetmoon.quark.content.mobs.entity.Toretoise;
import org.violetmoon.quark.content.mobs.module.*;
import org.violetmoon.quark.content.tools.module.PathfinderMapsModule;

public class QuarkEntityLootTableProvider extends EntityLootSubProvider {
//TODO config conditions
//and pool names possibly? not sure if they are convention

static CompoundTag stonelingNotMade = new CompoundTag();
static {
stonelingNotMade.putBoolean(Stoneling.TAG_PLAYER_MADE, false);
}
protected QuarkEntityLootTableProvider(HolderLookup.Provider registries) {
super(FeatureFlags.REGISTRY.allFlags(), FeatureFlags.REGISTRY.allFlags(), registries);
//I'm not sure why this constructor takes two FeatureFlagSets - Partonetrain
Expand All @@ -14,6 +40,84 @@ protected QuarkEntityLootTableProvider(HolderLookup.Provider registries) {

@Override
public void generate() {
add(CrabsModule.crabType, LootTable.lootTable()
.withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(CrabsModule.crab_shell))
.when(LootItemKilledByPlayerCondition.killedByPlayer())
.when(LootItemRandomChanceWithEnchantedBonusCondition.randomChanceAndLootingBoost(this.registries, 0.25F, 0.03F))
)
.withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(CrabsModule.crab_leg))
.apply(SetItemCountFunction.setCount(UniformGenerator.between(0, 1)))
.apply(SmeltItemFunction.smelted().when(this.shouldSmeltLoot()))
.apply(EnchantedCountIncreaseFunction.lootingMultiplier(this.registries, UniformGenerator.between(0F, 1F)))
)
);

add(ForgottenModule.forgottenType, LootTable.lootTable()
.withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(Items.ARROW))
.apply(SetItemCountFunction.setCount(UniformGenerator.between(4, 8)))
.apply(EnchantedCountIncreaseFunction.lootingMultiplier(this.registries, UniformGenerator.between(1F, 2F)))
).withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(Items.BONE))
.apply(SetItemCountFunction.setCount(UniformGenerator.between(2, 3)))
.apply(EnchantedCountIncreaseFunction.lootingMultiplier(this.registries, UniformGenerator.between(0F, 1F)))
).withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(ForgottenModule.forgotten_hat))
.when(LootItemKilledByPlayerCondition.killedByPlayer())
)
);

add(FoxhoundModule.foxhoundType, LootTable.lootTable()
.withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(Items.LEATHER))
.apply(SetItemCountFunction.setCount(UniformGenerator.between(0, 3)))
.apply(EnchantedCountIncreaseFunction.lootingMultiplier(this.registries, UniformGenerator.between(0F, 1F)))
).withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(Items.COAL))
.apply(SetItemCountFunction.setCount(UniformGenerator.between(1, 2)))
.apply(EnchantedCountIncreaseFunction.lootingMultiplier(this.registries, UniformGenerator.between(0F, 2F)))
)
);

add(StonelingsModule.stonelingType, LootTable.lootTable()
.withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(StonelingsModule.diamondHeart))
//condition: stoneling_drop_diamond_heart config
).withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(PathfinderMapsModule.pathfinders_quill))
//condition: pathfinder_maps
//condition: glimmering_weald
//condition: stoneling_weald_pathfinder
.when(LootItemKilledByPlayerCondition.killedByPlayer())
.when(LootItemEntityPropertyCondition.hasProperties(LootContext.EntityTarget.THIS, EntityPredicate.Builder.entity().nbt(new NbtPredicate((stonelingNotMade)))))
.when(LootItemRandomChanceWithEnchantedBonusCondition.randomChanceAndLootingBoost(this.registries, 0.08F, 0.02F))
//.when(InvertedLootItemCondition.invert(biomeCheck.)) //vanilla location predicate supports biome, but vanilla datagen has no biome check
//there is a quark:in_biome condition but maybe we should be using the vanilla one, just make our own biomeCheck - Train
)
);

add(ToretoiseModule.toretoiseType, LootTable.lootTable()); //empty

add(WraithModule.wraithType, LootTable.lootTable()
.withPool(LootPool.lootPool()
.setRolls(ConstantValue.exactly(1))
.add(LootItem.lootTableItem(WraithModule.soul_bead))
.apply(SetItemCountFunction.setCount(ConstantValue.exactly(1)))
.apply(EnchantedCountIncreaseFunction.lootingMultiplier(this.registries, UniformGenerator.between(0F, 1F)))
)
);


}
}

0 comments on commit aaaaf30

Please sign in to comment.