mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-18 11:19:19 +00:00
Bump Forge, replace GoG grass loot table inject with loot modifier
Closes #3342
This commit is contained in:
1 parent
50da75abb3
commit
d85dbcfbf8
11 files changed
+112
-48
No files matched your search
+1
-1
@@ -102,7 +102,7 @@ test {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "net.minecraftforge:forge:${mc_version}-31.2.22"
|
||||
minecraft "net.minecraftforge:forge:${mc_version}-31.2.30"
|
||||
compileOnly fg.deobf("vazkii.patchouli:Patchouli:1.15.2-1.2-35.185:api")
|
||||
runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:1.15.2-1.2-35.185")
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ def parseConfig(File config) {
|
||||
|
||||
ext.config = parseConfig(file('../build.properties'))
|
||||
|
||||
version = '1.2'
|
||||
version = '1.3'
|
||||
group = 'vazkii.botania' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'gardenofglass'
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ An extension to Botania that adds skyblock like gameplay.'''
|
||||
|
||||
[[dependencies.gardenofglass]]
|
||||
modId="botania"
|
||||
versionRange="NONE"
|
||||
versionRange="[r1.15-387,)"
|
||||
mandatory=true
|
||||
ordering="AFTER"
|
||||
side="BOTH"
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"replace": false,
|
||||
"entries": [
|
||||
"botania:skyblock_seeds"
|
||||
]
|
||||
}
|
||||
@@ -212,7 +212,6 @@ public class Botania {
|
||||
CorporeaHelper.instance().registerRequestMatcher(prefix("item_stack"), CorporeaItemStackMatcher.class, CorporeaItemStackMatcher::createFromNBT);
|
||||
|
||||
if (Botania.gardenOfGlassLoaded) {
|
||||
MinecraftForge.EVENT_BUS.addListener(SkyblockWorldEvents::loadLoot);
|
||||
MinecraftForge.EVENT_BUS.addListener(SkyblockWorldEvents::onPlayerUpdate);
|
||||
MinecraftForge.EVENT_BUS.addListener(SkyblockWorldEvents::onPlayerInteract);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* This class is distributed as part of the Botania Mod.
|
||||
* Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*/
|
||||
package vazkii.botania.common.core.loot;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.JSONUtils;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.storage.loot.LootContext;
|
||||
import net.minecraft.world.storage.loot.conditions.ILootCondition;
|
||||
import net.minecraftforge.common.crafting.CraftingHelper;
|
||||
import net.minecraftforge.common.loot.GlobalLootModifierSerializer;
|
||||
import net.minecraftforge.common.loot.LootModifier;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AddRandomItemModifier extends LootModifier {
|
||||
private final List<ItemStack> items;
|
||||
|
||||
protected AddRandomItemModifier(ILootCondition[] conditionsIn, List<ItemStack> items) {
|
||||
super(conditionsIn);
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
protected List<ItemStack> doApply(List<ItemStack> generatedLoot, LootContext context) {
|
||||
ItemStack stack = items.get(context.getRandom().nextInt(items.size()));
|
||||
generatedLoot.add(stack.copy());
|
||||
return generatedLoot;
|
||||
}
|
||||
|
||||
public static class Serializer extends GlobalLootModifierSerializer<AddRandomItemModifier> {
|
||||
@Override
|
||||
public AddRandomItemModifier read(ResourceLocation location, JsonObject object, ILootCondition[] ailootcondition) {
|
||||
JsonArray items = JSONUtils.getJsonArray(object, "items");
|
||||
ImmutableList.Builder<ItemStack> builder = ImmutableList.builder();
|
||||
for (JsonElement item : items) {
|
||||
builder.add(CraftingHelper.getItemStack(item.getAsJsonObject(), true));
|
||||
}
|
||||
return new AddRandomItemModifier(ailootcondition, builder.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,6 +35,7 @@ public class DisposeModifier extends LootModifier {
|
||||
|
||||
public static void register(RegistryEvent.Register<GlobalLootModifierSerializer<?>> evt) {
|
||||
evt.getRegistry().register(new Serializer().setRegistryName(prefix("dispose")));
|
||||
evt.getRegistry().register(new AddRandomItemModifier.Serializer().setRegistryName(prefix("add_item")));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
||||
@@ -123,14 +123,6 @@ public final class SkyblockWorldEvents {
|
||||
}
|
||||
}
|
||||
|
||||
private static final ResourceLocation TARGET_LOOT_TABLE = new ResourceLocation("blocks/grass");
|
||||
|
||||
public static void loadLoot(LootTableLoadEvent event) {
|
||||
if (Botania.gardenOfGlassLoaded && event.getName().equals(TARGET_LOOT_TABLE)) {
|
||||
event.getTable().addPool(LootHandler.getInjectPool("gog_grass"));
|
||||
}
|
||||
}
|
||||
|
||||
public static void spawnPlayer(PlayerEntity player, BlockPos pos, boolean fabricated) {
|
||||
CompoundNBT data = player.getPersistentData();
|
||||
if (!data.contains(PlayerEntity.PERSISTED_NBT_TAG)) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"conditions": [],
|
||||
"function": "botania:dispose"
|
||||
"type": "botania:dispose"
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:alternative",
|
||||
"terms": [
|
||||
{
|
||||
"condition": "minecraft:block_state_property",
|
||||
"block": "minecraft:grass"
|
||||
},
|
||||
{
|
||||
"condition": "minecraft:block_state_property",
|
||||
"block": "minecraft:tall_grass",
|
||||
"properties": {
|
||||
"half": "lower"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"condition": "minecraft:survives_explosion"
|
||||
},
|
||||
{
|
||||
"condition": "minecraft:random_chance",
|
||||
"chance": 0.03125
|
||||
},
|
||||
{
|
||||
"condition": "minecraft:inverted",
|
||||
"term": {
|
||||
"condition": "minecraft:match_tool",
|
||||
"predicate": {
|
||||
"item": "minecraft:shears"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"type": "botania:add_item",
|
||||
"items": [
|
||||
{
|
||||
"item": "minecraft:melon_seeds"
|
||||
},
|
||||
{
|
||||
"item": "minecraft:pumpkin_seeds"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
{
|
||||
"__comment": "This table is injected as its own pool into minecraft:blocks/grass if Garden of Glass is loaded",
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"name": "main",
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "minecraft:melon_seeds"
|
||||
},
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "minecraft:pumpkin_seeds"
|
||||
}
|
||||
],
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:random_chance",
|
||||
"chance": 0.03125
|
||||
},
|
||||
{
|
||||
"condition": "minecraft:inverted",
|
||||
"term": {
|
||||
"condition": "minecraft:match_tool",
|
||||
"predicate": {
|
||||
"item": "minecraft:shears"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user