first attempt to overwrite loottables
This commit is contained in:
parent
273de51797
commit
b44c9abf8e
|
@ -2,6 +2,7 @@ package me.parsell.glowstonewire;
|
|||
|
||||
import me.parsell.glowstonewire.core.glowBlocks;
|
||||
import me.parsell.glowstonewire.core.glowItems;
|
||||
import me.parsell.glowstonewire.core.glowLootTables;
|
||||
import me.parsell.glowstonewire.core.glowRecipes;
|
||||
import me.shedaniel.autoconfig.AutoConfig;
|
||||
import me.shedaniel.autoconfig.serializer.GsonConfigSerializer;
|
||||
|
@ -19,5 +20,6 @@ public class GlowstoneWire implements ModInitializer {
|
|||
glowBlocks.init();
|
||||
glowItems.init();
|
||||
glowRecipes.init();
|
||||
glowLootTables.init();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,127 @@
|
|||
package me.parsell.glowstonewire.core;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import me.parsell.glowstonewire.GlowstoneWire;
|
||||
|
||||
public class glowLootTables {
|
||||
public static JsonObject glowstonelootTable;
|
||||
|
||||
public static void init(){
|
||||
if(GlowstoneWire.CONFIG.replaceGlowstoneDrop) {
|
||||
JsonObject explosion;
|
||||
JsonObject limitValues, limit;
|
||||
JsonObject bonus, parametersValues;
|
||||
JsonObject count, countValues;
|
||||
JsonArray secondItemArray;
|
||||
JsonObject secondItem;
|
||||
|
||||
JsonObject levelsValues, silktouch;
|
||||
JsonArray enchantmentsArray;
|
||||
JsonObject enchantments, match;
|
||||
JsonArray firstItemArray;
|
||||
JsonObject firstItem;
|
||||
|
||||
JsonArray alternativesArray;
|
||||
JsonObject alternatives;
|
||||
|
||||
JsonArray rollsArray;
|
||||
JsonObject rolls;
|
||||
|
||||
JsonArray lootPoolsArray;
|
||||
|
||||
explosion = new JsonObject();
|
||||
explosion.addProperty("function", "minecraft:explosion_decay");
|
||||
|
||||
limit = new JsonObject();
|
||||
limit.addProperty("function", "minecraft:limit_count");
|
||||
limitValues = new JsonObject();
|
||||
limitValues.addProperty("max", 4);
|
||||
limitValues.addProperty("min", 1);
|
||||
limit.add("limit", limitValues);
|
||||
|
||||
bonus = new JsonObject();
|
||||
bonus.addProperty("function", "minecraft:apply_bonus");
|
||||
bonus.addProperty("enchantment", "minecraft:fortune");
|
||||
bonus.addProperty("formula", "minecraft:uniform_bonus_count");
|
||||
parametersValues = new JsonObject();
|
||||
parametersValues.addProperty("bonusMultiplier", 1);
|
||||
bonus.add("parameters", parametersValues);
|
||||
|
||||
count = new JsonObject();
|
||||
count.addProperty("function", "minecraft:set_count");
|
||||
countValues = new JsonObject();
|
||||
countValues.addProperty("min", 2.0);
|
||||
countValues.addProperty("max", 4.0);
|
||||
countValues.addProperty("type", "minecraft:uniform");
|
||||
count.add("count", countValues);
|
||||
|
||||
secondItemArray = new JsonArray();
|
||||
secondItemArray.add(count);
|
||||
secondItemArray.add(bonus);
|
||||
secondItemArray.add(limit);
|
||||
secondItemArray.add(explosion);
|
||||
|
||||
secondItem = new JsonObject();
|
||||
secondItem.addProperty("type", "minecraft:item");
|
||||
secondItem.add("functions", secondItemArray);
|
||||
secondItem.addProperty("name", "glowstonewire:glowstone_dust");
|
||||
|
||||
//
|
||||
|
||||
levelsValues = new JsonObject();
|
||||
levelsValues.addProperty("min", 1);
|
||||
silktouch = new JsonObject();
|
||||
silktouch.addProperty("enchantment", "minecraft:silk_touch");
|
||||
silktouch.add("levels", levelsValues);
|
||||
|
||||
enchantmentsArray = new JsonArray();
|
||||
enchantmentsArray.add(silktouch);
|
||||
enchantments = new JsonObject();
|
||||
enchantments.add("enchantments", enchantmentsArray);
|
||||
|
||||
match = new JsonObject();
|
||||
match.addProperty("condition", "minecraft:match_tool");
|
||||
match.add("predicate", enchantments);
|
||||
|
||||
firstItemArray = new JsonArray();
|
||||
firstItemArray.add(match);
|
||||
|
||||
firstItem = new JsonObject();
|
||||
firstItem.addProperty("type", "minecraft:item");
|
||||
firstItem.add("conditions", firstItemArray);
|
||||
firstItem.addProperty("name", "minecraft:glowstone");
|
||||
|
||||
//
|
||||
|
||||
alternativesArray = new JsonArray();
|
||||
alternativesArray.add(firstItem);
|
||||
alternativesArray.add(secondItem);
|
||||
|
||||
alternatives = new JsonObject();
|
||||
alternatives.addProperty("type", "minecraft:alternatives");
|
||||
alternatives.add("children", alternativesArray);
|
||||
|
||||
//
|
||||
|
||||
rollsArray = new JsonArray();
|
||||
rollsArray.add(alternatives);
|
||||
|
||||
rolls = new JsonObject();
|
||||
rolls.addProperty("rolls", 1);
|
||||
rolls.add("entries", rollsArray);
|
||||
|
||||
//
|
||||
|
||||
lootPoolsArray = new JsonArray();
|
||||
lootPoolsArray.add(rolls);
|
||||
|
||||
glowstonelootTable = new JsonObject();
|
||||
glowstonelootTable.addProperty("type", "minecraft:block");
|
||||
glowstonelootTable.add("pools", lootPoolsArray);
|
||||
|
||||
System.out.println(glowstonelootTable.toString());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package me.parsell.glowstonewire.mixin;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
import me.parsell.glowstonewire.GlowstoneWire;
|
||||
import me.parsell.glowstonewire.core.glowLootTables;
|
||||
import net.minecraft.loot.LootManager;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.profiler.Profiler;
|
||||
|
||||
@Mixin(LootManager.class)
|
||||
public class LootManagerInjector {
|
||||
@Inject(method = "apply", at = @At("HEAD"))
|
||||
public void interceptApply(Map<Identifier, JsonElement> map, ResourceManager resourceManager, Profiler profiler, CallbackInfo info) {
|
||||
if (GlowstoneWire.CONFIG.replaceGlowstoneDrop) {
|
||||
map.put(new Identifier("minecraft", "glowstone"), glowLootTables.glowstonelootTable);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"type": "minecraft:block",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"name": "glowstonewire:glowstone_dust"
|
||||
}
|
||||
],
|
||||
"conditions": [
|
||||
{
|
||||
"condition": "minecraft:survives_explosion"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
"client": [
|
||||
"BrewingRecipeRegistryInvoker",
|
||||
"RecipeManagerInjector",
|
||||
"LootManagerInjector",
|
||||
"FireworkStarRecipeAccessor"
|
||||
],
|
||||
"injectors": {
|
||||
|
|
Loading…
Reference in New Issue