-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move Loot modifiers to datagen and modify to neoforge format (#…
…1081) * feat: move Loot modifiers to datagen and modify to neoforge format * fix: fix seed drop rate and moved mobs to tags.
- Loading branch information
Showing
16 changed files
with
135 additions
and
57 deletions.
There are no files selected for viewing
18 changes: 9 additions & 9 deletions
18
...loot_modifiers/global_loot_modifiers.json → ...loot_modifiers/global_loot_modifiers.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
{ | ||
"replace": false, | ||
"entries": [ | ||
"occultism:datura_seed_from_grass", | ||
"occultism:datura_seed_from_tall_grass", | ||
"occultism:tallow_from_cows", | ||
"occultism:tallow_from_donkeys", | ||
"occultism:tallow_from_goats", | ||
"occultism:tallow_from_cows", | ||
"occultism:tallow_from_llamas", | ||
"occultism:tallow_from_hoglins", | ||
"occultism:datura_seed_from_tall_grass", | ||
"occultism:tallow_from_pigs", | ||
"occultism:tallow_from_sheep", | ||
"occultism:tallow_from_horses", | ||
"occultism:tallow_from_llamas", | ||
"occultism:tallow_from_mules", | ||
"occultism:tallow_from_pandas", | ||
"occultism:tallow_from_pigs", | ||
"occultism:tallow_from_sheep" | ||
] | ||
"occultism:datura_seed_from_grass", | ||
"occultism:tallow_from_goats" | ||
], | ||
"replace": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
src/main/java/com/klikli_dev/occultism/datagen/loot/OccultismLootModifiers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package com.klikli_dev.occultism.datagen.loot; | ||
|
||
import com.klikli_dev.occultism.Occultism; | ||
import com.klikli_dev.occultism.loot.AddItemModifier; | ||
import com.klikli_dev.occultism.registry.OccultismItems; | ||
import com.klikli_dev.occultism.registry.OccultismTags; | ||
import net.minecraft.advancements.critereon.*; | ||
import net.minecraft.data.PackOutput; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.tags.EntityTypeTags; | ||
import net.minecraft.tags.ItemTags; | ||
import net.minecraft.world.entity.EntityType; | ||
import net.minecraft.world.item.Items; | ||
import net.minecraft.world.level.block.Blocks; | ||
import net.minecraft.world.level.storage.loot.LootContext; | ||
import net.minecraft.world.level.storage.loot.predicates.*; | ||
import net.neoforged.neoforge.common.Tags; | ||
import net.neoforged.neoforge.common.data.GlobalLootModifierProvider; | ||
import net.neoforged.neoforge.common.data.internal.NeoForgeItemTagsProvider; | ||
import net.neoforged.neoforge.common.loot.IGlobalLootModifier; | ||
import net.neoforged.neoforge.common.loot.LootTableIdCondition; | ||
|
||
import java.util.Optional; | ||
|
||
public class OccultismLootModifiers extends GlobalLootModifierProvider { | ||
|
||
public OccultismLootModifiers(PackOutput output) { | ||
super(output, Occultism.MODID); | ||
} | ||
|
||
private EntityEquipmentPredicate mainHand(ItemPredicate.Builder itemPredicate) { | ||
EntityEquipmentPredicate.Builder builder = EntityEquipmentPredicate.Builder.equipment(); | ||
builder.mainhand(itemPredicate); | ||
return builder.build(); | ||
} | ||
|
||
private AddItemModifier tallow(String entityType, int count ) { | ||
return new AddItemModifier( | ||
new LootItemCondition[]{ | ||
LootItemEntityPropertyCondition | ||
.hasProperties(LootContext.EntityTarget.KILLER, | ||
EntityPredicate.Builder.entity() | ||
.equipment(mainHand(ItemPredicate.Builder.item().of(OccultismTags.makeItemTag(new ResourceLocation(Occultism.MODID,"tools/knives")))))).build(), | ||
LootItemEntityPropertyCondition | ||
.hasProperties(LootContext.EntityTarget.THIS,EntityPredicate.Builder.entity().of(OccultismTags.makeEntityTypeTag(new ResourceLocation("forge",entityType)))).build() | ||
},OccultismItems.TALLOW.get(),count); | ||
} | ||
|
||
@Override | ||
protected void start() { | ||
this.add("datura_seed_from_grass", new AddItemModifier(new LootItemCondition[]{ | ||
new LootItemRandomChanceCondition(0.02f), | ||
LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.SHORT_GRASS).build(), | ||
new InvertedLootItemCondition( | ||
MatchTool.toolMatches(ItemPredicate.Builder.item().of(Tags.Items.SHEARS)).build() | ||
) | ||
}, OccultismItems.DATURA_SEEDS.get(),1)); | ||
|
||
this.add("datura_seed_from_tall_grass",new AddItemModifier(new LootItemCondition[]{ | ||
new LootItemRandomChanceCondition(0.02f), | ||
LootItemBlockStatePropertyCondition.hasBlockStateProperties(Blocks.TALL_GRASS).build(), | ||
new InvertedLootItemCondition( | ||
MatchTool.toolMatches(ItemPredicate.Builder.item().of(Tags.Items.SHEARS)).build() | ||
) | ||
}, OccultismItems.DATURA_SEEDS.get(),1)); | ||
this.add("tallow_from_cows",tallow("cows",4)); | ||
this.add("tallow_from_donkeys",tallow("donkeys",3)); | ||
this.add("tallow_from_goats",tallow("goats",2)); | ||
this.add("tallow_from_hoglins",tallow("hoglins",4)); | ||
this.add("tallow_from_horses",tallow("horses",3)); | ||
this.add("tallow_from_llamas",tallow("llamas",3)); | ||
this.add("tallow_from_mules",tallow("mules",3)); | ||
this.add("tallow_from_pandas",tallow("pandas",3)); | ||
this.add("tallow_from_pigs",tallow("pigs",2)); | ||
this.add("tallow_from_sheep",tallow("sheep",2)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters