From 2d1a2f14e5a4993d69878398b771edfab9b5a764 Mon Sep 17 00:00:00 2001 From: Wroclaw Date: Sun, 13 Nov 2022 07:51:29 +0100 Subject: [PATCH] Add ore indicators as items placed on the ground Item placing on the ground is added by Draconic Evolution, I used a janky way to setblock generated indicator to that tile. That tile needs nbt so I had to set a block using execute as setblock command, which is bad, because it spams logs and operators chat --- config/oreveins/ore_veins.json | 16 ++++++- index.toml | 10 ++++- pack.toml | 2 +- scripts/ore_veins/indicators.1.zs | 71 +++++++++++++++++++++++++++++++ scripts/ore_veins/indicators.2.zs | 5 +++ 5 files changed, 100 insertions(+), 4 deletions(-) create mode 100644 scripts/ore_veins/indicators.1.zs create mode 100644 scripts/ore_veins/indicators.2.zs diff --git a/config/oreveins/ore_veins.json b/config/oreveins/ore_veins.json index f5cd122..fb23352 100644 --- a/config/oreveins/ore_veins.json +++ b/config/oreveins/ore_veins.json @@ -5,6 +5,12 @@ "block": "thermalfoundation:ore", "meta": 0 }, + "indicator": { + "blocks": "contenttweaker:juice/internal/indicator/copper", + "ignore_vegatation": false, + "ignore_liquids": false, + "rarity": 24 + }, "stone": "minecraft:stone", "rarity": 160, "min_y": 8, @@ -20,6 +26,12 @@ "block": "forestry:resources", "meta": 0 }, + "indicator": { + "blocks": "contenttweaker:juice/internal/indicator/apatite", + "ignore_vegatation": false, + "ignore_liquids": false, + "rarity": 24 + }, "stone": "minecraft:stone", "rarity": "100", "min_y": -10, @@ -35,9 +47,9 @@ "ore": "minecraft:gold_ore", "stone": "minecraft:stone", "indicator": { - "blocks": "minecraft:gold_ore", + "blocks": "contenttweaker:juice/internal/indicator/gold", "ignore_vegatation": false, - "ignore_liquids": true, + "ignore_liquids": false, "rarity": 24 }, "rarity": 170, diff --git a/index.toml b/index.toml index a5991da..024a896 100644 --- a/index.toml +++ b/index.toml @@ -302,7 +302,7 @@ hash = "5046cde3673ccd62ba2209aaab9a917b3e1b0da7f521477e89f68bdba1648187" [[files]] file = "config/oreveins/ore_veins.json" -hash = "214f7142f586483b47112fa0e39fc24a693e512634a71f3851e5cefbd4dbf6bb" +hash = "44c43ee20b7998d261565da99b0a54ad268eaa1f44bc14d323489a885a5a246c" [[files]] file = "config/sereneseasons/biome_info.json" @@ -1539,3 +1539,11 @@ hash = "b4aea7892748ecfa5cf775fb0a18f0909795c0b025666ecaea88bb3a923b4194" [[files]] file = "scripts/nc_script_addons/MoarRealisticRadiation/rad_qmd.zs" hash = "a07879875ad20ae8e285c3cb39beeee648bd080ec12985b76583ad707a3de3ee" + +[[files]] +file = "scripts/ore_veins/indicators.1.zs" +hash = "eee1737869c3a9a2d2261894b32f09d8dee48df55f07393eec54ba8748a13d79" + +[[files]] +file = "scripts/ore_veins/indicators.2.zs" +hash = "08d456f730c1a797aab31811ba5a24e319ce35d000c4af80348a964a6c471898" diff --git a/pack.toml b/pack.toml index bc18b45..4f20fe7 100644 --- a/pack.toml +++ b/pack.toml @@ -6,7 +6,7 @@ pack-format = "packwiz:1.1.0" [index] file = "index.toml" hash-format = "sha256" -hash = "1d97754f0f1410e1990d6465b9d99ad55e152fa11804dd642f72013a1acb0503" +hash = "dadadd056bd26d8a241d36194b27f48fe13db960074ae4a2475f8afe66af4ba6" [versions] forge = "14.23.5.2860" diff --git a/scripts/ore_veins/indicators.1.zs b/scripts/ore_veins/indicators.1.zs new file mode 100644 index 0000000..f0cee4f --- /dev/null +++ b/scripts/ore_veins/indicators.1.zs @@ -0,0 +1,71 @@ +#loader contenttweaker + +import mods.contenttweaker.Block; +import mods.contenttweaker.DropHandler; +import mods.contenttweaker.ResourceLocation; +import mods.contenttweaker.VanillaFactory; + +var nugget_table as string[][] = [ + # [name, id, meta] + ["copper", "thermalfoundation:ore", "0"], + ["apatite", "forestry:resources", "0"], + ["gold", "minecraft:gold_ore", "0"] +]; + +function replaceCommand(blockName as string, item as string, meta as string, blockPos as mods.contenttweaker.BlockPos) as string { + return "execute @a " + + blockPos.getX() as string + " " + + blockPos.getY() as string + " " + + blockPos.getZ() as string + " " + + "detect " + + blockPos.getX() as string + " " + + blockPos.getY() as string + " " + + blockPos.getZ() as string + " " + + "contenttweaker:" + blockName + " * " + + "setblock " + + blockPos.getX() as string + " " + + blockPos.getY() as string + " " + + blockPos.getZ() as string + " " + + "draconicevolution:placed_item " + + "0 " + + "replace " + + "{InventoryStacks: [{ id: \"" + item + "\", Count: 1, Damage: " + meta as string + " }]}"; +} + +for i in nugget_table { + var blockName as string = "juice/internal/indicator/" + i[0]; + var item as string = i[1]; + var meta as string = i[2]; + print("Adding internal ore indicator block: " + i[0]); + var block = VanillaFactory.createBlock(blockName, ); + block.setTextureLocation(ResourceLocation.create("contenttweaker:blocks/ore_nugget")); + block.setToolLevel(0); + # block.setAxisAlignedBB(mods.contenttweaker.AxisAlignedBB.create(0.375f, 0.0f, 0.375f, 0.625f, 0.125f, 0.625f)); + block.setEnumBlockRenderType("MODEL"); + block.setBlockHardness(0.1); + block.setBlockLayer("CUTOUT"); + block.setBlockResistance(0); + block.setDropHandler(function(drops, world, position, state, fortune) { drops.clear(); }); + block.setFullBlock(false); + block.setLightOpacity(0); + block.setPassable(true); + block.setReplaceable(true); + + # janky hack, mate + block.setOnBlockPlace(function(world, blockPos, blockState) { + var command as string = replaceCommand(blockName, item, meta, blockPos); + server.commandManager.executeCommand(server, command); + }); + + block.setOnRandomTick(function(world, blockPos, blockState) { + var command as string = replaceCommand(blockName, item, meta, blockPos); + server.commandManager.executeCommand(server, command); + }); + + block.setOnUpdateTick(function(world, blockPos, blockState) { + var command as string = replaceCommand(blockName, item, meta, blockPos); + server.commandManager.executeCommand(server, command); + }); + + block.register(); +} diff --git a/scripts/ore_veins/indicators.2.zs b/scripts/ore_veins/indicators.2.zs new file mode 100644 index 0000000..fb1c711 --- /dev/null +++ b/scripts/ore_veins/indicators.2.zs @@ -0,0 +1,5 @@ +for i in loadedMods["contenttweaker"].items { + if (i.definition.name.contains("internal")) { + mods.jei.JEI.hide(i); + } +}