mirror of
https://github.com/chylex/Hardcore-Ender-Expansion-2.git
synced 2025-04-11 03:15:44 +02:00
Replace 'pick_colored_gloomrock' and 'pick_music_disk' functions w/ 'set_item'
This commit is contained in:
parent
73974c71b6
commit
02bbb1b850
src/main
java/chylex/hee
resources/data/hee
loot_tables/chests
tags/items
@ -1,40 +0,0 @@
|
||||
package chylex.hee.game.loot.functions
|
||||
import chylex.hee.init.ModBlocks
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import chylex.hee.system.util.nextItem
|
||||
import chylex.hee.system.util.size
|
||||
import com.google.gson.JsonDeserializationContext
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.JsonSerializationContext
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.world.storage.loot.LootContext
|
||||
import net.minecraft.world.storage.loot.LootFunction
|
||||
import net.minecraft.world.storage.loot.conditions.ILootCondition
|
||||
|
||||
class FunctionPickColoredGloomrock(conditions: Array<ILootCondition>) : LootFunction(conditions){
|
||||
private companion object{
|
||||
private val BLOCKS = arrayOf(
|
||||
ModBlocks.GLOOMROCK_SMOOTH_RED,
|
||||
ModBlocks.GLOOMROCK_SMOOTH_ORANGE,
|
||||
ModBlocks.GLOOMROCK_SMOOTH_YELLOW,
|
||||
ModBlocks.GLOOMROCK_SMOOTH_GREEN,
|
||||
ModBlocks.GLOOMROCK_SMOOTH_CYAN,
|
||||
ModBlocks.GLOOMROCK_SMOOTH_BLUE,
|
||||
ModBlocks.GLOOMROCK_SMOOTH_PURPLE,
|
||||
ModBlocks.GLOOMROCK_SMOOTH_MAGENTA,
|
||||
ModBlocks.GLOOMROCK_SMOOTH_WHITE
|
||||
)
|
||||
}
|
||||
|
||||
override fun doApply(stack: ItemStack, context: LootContext): ItemStack{
|
||||
return ItemStack(context.random.nextItem(BLOCKS), stack.size)
|
||||
}
|
||||
|
||||
object Serializer : LootFunction.Serializer<FunctionPickColoredGloomrock>(Resource.Custom("pick_colored_gloomrock"), FunctionPickColoredGloomrock::class.java){
|
||||
override fun serialize(json: JsonObject, value: FunctionPickColoredGloomrock, context: JsonSerializationContext){}
|
||||
|
||||
override fun deserialize(json: JsonObject, context: JsonDeserializationContext, conditions: Array<ILootCondition>): FunctionPickColoredGloomrock{
|
||||
return FunctionPickColoredGloomrock(conditions)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
package chylex.hee.game.loot.functions
|
||||
import chylex.hee.system.migration.vanilla.Items
|
||||
import chylex.hee.system.util.facades.Resource
|
||||
import chylex.hee.system.util.nextItem
|
||||
import chylex.hee.system.util.size
|
||||
import com.google.gson.JsonDeserializationContext
|
||||
import com.google.gson.JsonObject
|
||||
import com.google.gson.JsonSerializationContext
|
||||
import net.minecraft.item.Item
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.util.JSONUtils
|
||||
import net.minecraft.world.storage.loot.LootContext
|
||||
import net.minecraft.world.storage.loot.LootFunction
|
||||
import net.minecraft.world.storage.loot.conditions.ILootCondition
|
||||
|
||||
class FunctionPickMusicDisk(conditions: Array<ILootCondition>, private val picks: Array<Item>) : LootFunction(conditions){
|
||||
private companion object{
|
||||
private val DISKS = mapOf(
|
||||
"obsidiantower" to arrayOf(
|
||||
Items.MUSIC_DISC_13,
|
||||
Items.MUSIC_DISC_CAT,
|
||||
Items.MUSIC_DISC_BLOCKS,
|
||||
Items.MUSIC_DISC_CHIRP,
|
||||
Items.MUSIC_DISC_FAR,
|
||||
Items.MUSIC_DISC_MALL,
|
||||
Items.MUSIC_DISC_MELLOHI,
|
||||
Items.MUSIC_DISC_STAL,
|
||||
Items.MUSIC_DISC_STRAD
|
||||
// TODO replace with custom music disks
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun doApply(stack: ItemStack, context: LootContext): ItemStack{
|
||||
return ItemStack(context.random.nextItem(picks), stack.size)
|
||||
}
|
||||
|
||||
object Serializer : LootFunction.Serializer<FunctionPickMusicDisk>(Resource.Custom("pick_music_disk"), FunctionPickMusicDisk::class.java){
|
||||
override fun serialize(json: JsonObject, value: FunctionPickMusicDisk, context: JsonSerializationContext){}
|
||||
|
||||
override fun deserialize(json: JsonObject, context: JsonDeserializationContext, conditions: Array<ILootCondition>): FunctionPickMusicDisk{
|
||||
return FunctionPickMusicDisk(conditions, DISKS.getValue(JSONUtils.getString(json, "type")))
|
||||
}
|
||||
}
|
||||
}
|
@ -9,8 +9,6 @@ import chylex.hee.game.loot.conditions.ConditionSilkTouch
|
||||
import chylex.hee.game.loot.conditions.ConditionWasExploded
|
||||
import chylex.hee.game.loot.conditions.ConditionWasSheared
|
||||
import chylex.hee.game.loot.functions.FunctionInfuse
|
||||
import chylex.hee.game.loot.functions.FunctionPickColoredGloomrock
|
||||
import chylex.hee.game.loot.functions.FunctionPickMusicDisk
|
||||
import chylex.hee.game.loot.functions.FunctionPickUndreadGem
|
||||
import chylex.hee.game.loot.functions.FunctionSetItem
|
||||
import chylex.hee.game.loot.rng.RandomBiasedValueRange
|
||||
@ -49,8 +47,6 @@ object ModLoot{
|
||||
LootConditionManager.registerCondition(ConditionWasSheared.Serializer)
|
||||
|
||||
LootFunctionManager.registerFunction(FunctionInfuse.Serializer)
|
||||
LootFunctionManager.registerFunction(FunctionPickColoredGloomrock.Serializer)
|
||||
LootFunctionManager.registerFunction(FunctionPickMusicDisk.Serializer)
|
||||
LootFunctionManager.registerFunction(FunctionPickUndreadGem.Serializer)
|
||||
LootFunctionManager.registerFunction(FunctionSetItem.Serializer)
|
||||
}
|
||||
|
@ -36,7 +36,7 @@
|
||||
"rolls": 1,
|
||||
"name": "colored_blocks_1#sort_order=2",
|
||||
"entries": [
|
||||
{ "type": "item", "name": "hee:gloomrock_smooth", "weight": 100, "functions": [{ "function": "set_count", "count": { "min": 1, "max": 7 } }, { "function": "hee:pick_colored_gloomrock" }], "entryName": "#1" }
|
||||
{ "type": "item", "name": "hee:gloomrock_smooth", "weight": 100, "functions": [{ "function": "hee:set_item", "tag": "hee:gloomrock_colors" }, { "function": "set_count", "count": { "min": 1, "max": 7 } }], "entryName": "#1" }
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -44,7 +44,7 @@
|
||||
"name": "colored_blocks_2#sort_order=2",
|
||||
"entries": [
|
||||
{ "type": "item", "name": "hee:gloomrock_smooth", "weight": 25, "functions": [{ "function": "set_count", "count": 0 }], "entryName": "#0" },
|
||||
{ "type": "item", "name": "hee:gloomrock_smooth", "weight": 75, "functions": [{ "function": "set_count", "count": { "min": 1, "max": 6 } }, { "function": "hee:pick_colored_gloomrock" }], "entryName": "#1" }
|
||||
{ "type": "item", "name": "hee:gloomrock_smooth", "weight": 75, "functions": [{ "function": "hee:set_item", "tag": "hee:gloomrock_colors" }, { "function": "set_count", "count": { "min": 1, "max": 6 } }], "entryName": "#1" }
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -52,7 +52,7 @@
|
||||
"name": "colored_blocks_3#sort_order=2",
|
||||
"entries": [
|
||||
{ "type": "item", "name": "hee:gloomrock_smooth", "weight": 70, "functions": [{ "function": "set_count", "count": 0 }], "entryName": "#0" },
|
||||
{ "type": "item", "name": "hee:gloomrock_smooth", "weight": 30, "functions": [{ "function": "set_count", "count": { "min": 1, "max": 5 } }, { "function": "hee:pick_colored_gloomrock" }], "entryName": "#1" }
|
||||
{ "type": "item", "name": "hee:gloomrock_smooth", "weight": 30, "functions": [{ "function": "hee:set_item", "tag": "hee:gloomrock_colors" }, { "function": "set_count", "count": { "min": 1, "max": 5 } }], "entryName": "#1" }
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -60,7 +60,7 @@
|
||||
"name": "colored_blocks_4#sort_order=2",
|
||||
"entries": [
|
||||
{ "type": "item", "name": "hee:gloomrock_smooth", "weight": 88, "functions": [{ "function": "set_count", "count": 0 }], "entryName": "#0" },
|
||||
{ "type": "item", "name": "hee:gloomrock_smooth", "weight": 12, "functions": [{ "function": "set_count", "count": { "min": 1, "max": 4 } }, { "function": "hee:pick_colored_gloomrock" }], "entryName": "#1" }
|
||||
{ "type": "item", "name": "hee:gloomrock_smooth", "weight": 12, "functions": [{ "function": "hee:set_item", "tag": "hee:gloomrock_colors" }, { "function": "set_count", "count": { "min": 1, "max": 4 } }], "entryName": "#1" }
|
||||
]
|
||||
},
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
{ "type": "item", "name": "hee:ethereum", "weight": 10, "functions": [{ "function": "set_count", "count": { "min": 2, "max": 5 } }], "entryName": "ethereum" },
|
||||
{ "type": "item", "name": "minecraft:book", "weight": 10, "functions": [{ "function": "set_count", "count": { "min": 1, "max": 3 } }], "entryName": "book" },
|
||||
{ "type": "item", "name": "hee:endium_ingot", "weight": 8, "functions": [{ "function": "set_count", "count": { "min": 1, "max": 2 } }], "entryName": "endium_ingot" },
|
||||
{ "type": "item", "name": "minecraft:music_disc_13", "weight": 3, "functions": [{ "function": "set_count", "count": 1 }, { "function": "hee:pick_music_disk", "type": "obsidiantower" }], "entryName": "music_disk" },
|
||||
{ "type": "item", "name": "minecraft:music_disc_13", "weight": 3, "functions": [{ "function": "hee:set_item", "tag": "minecraft:music_discs", "TODO": "REPLACE WITH CUSTOM MUSIC DISKS" }, { "function": "set_count", "count": 1 }], "entryName": "music_disk" },
|
||||
{ "type": "item", "name": "minecraft:book", "weight": 2, "functions": [{ "function": "set_count", "count": 1 }, { "function": "enchant_with_levels", "treasure": false, "levels": { "min": 2, "max": 7 } }], "entryName": "enchanted_book" },
|
||||
{ "type": "item", "name": "minecraft:enchanted_golden_apple", "weight": 1, "functions": [{ "function": "set_count", "count": 1 }], "entryName": "enchanted_golden_apple" }
|
||||
]
|
||||
|
13
src/main/resources/data/hee/tags/items/gloomrock_colors.json
Normal file
13
src/main/resources/data/hee/tags/items/gloomrock_colors.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"values": [
|
||||
"hee:gloomrock_smooth_red",
|
||||
"hee:gloomrock_smooth_orange",
|
||||
"hee:gloomrock_smooth_yellow",
|
||||
"hee:gloomrock_smooth_green",
|
||||
"hee:gloomrock_smooth_cyan",
|
||||
"hee:gloomrock_smooth_blue",
|
||||
"hee:gloomrock_smooth_purple",
|
||||
"hee:gloomrock_smooth_magenta",
|
||||
"hee:gloomrock_smooth_white"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user