#its not finding the loot table thats in loot_tables/blocks/gravel.json

1 messages · Page 1 of 1 (latest)

velvet gulch
#
    "pools": [
        {
            "rolls": 1,
            "entries": [
                {
                    "type": "item",
                    "name": "minecraft:coal",
                    "weight": 25
                },
                {
                    "type": "item",
                    "name": "minecraft:iron_nugget",
                    "weight": 10
                },
                {
                    "type": "item",
                    "name": "minecraft:gold_nugget",
                    "weight": 5
                },
                {
                    "type": "item",
                    "name": "your_namespace:vault",
                    "weight": 5
                },
                {
                    "type": "item",
                    "name": "your_namespace:ominous_potion",
                    "weight": 3
                },
                {
                    "type": "item",
                    "name": "your_namespace:ominous_vault",
                    "weight": 1
                },
                {
                    "type": "item",
                    "name": "minecraft:netherite_scrap",
                    "weight": 1
                },
                {
                    "type": "item",
                    "name": "minecraft:diamond",
                    "weight": 1
                },
                {
                    "type": "empty",
                    "weight": 50
                }
            ]
        }
    ]
}``` other files will be in comments
#
import { world, system } from "@minecraft/server";
import { archeologyBlocks } from "./itemVar";

console.warn("archeology loaded");

world.beforeEvents.playerInteractWithBlock.subscribe(event => {
    const { block, itemStack, player } = event;
    console.warn(`ran event ${block.typeId} ${itemStack?.typeId} ${player.typeId}`);

    if (block.typeId === "minecraft:stonecutter_block") {
        const itemId = itemStack?.typeId;
        console.warn(`found item ${itemId}`);

        if (itemId && archeologyBlocks[itemId]) {
            event.cancel = true;

            const lootTablePath = archeologyBlocks[itemId];
            console.warn(`found loot table ${lootTablePath}`);
            const inventory = player.getComponent("minecraft:inventory").container;

            system.run(() => {
                for (let i = 0; i < inventory.size; i++) {
                    const item = inventory.getItem(i);
                    if (item && item.typeId === itemId) {
                        if (item.amount > 1) {
                            item.amount -= 1;
                            inventory.setItem(i, item);
                        } else {
                            inventory.setItem(i, undefined);
                        }
                        break;
                    }
                }

                try {
                    player.runCommand(`loot spawn ~ ~ ~ loot ${lootTablePath}`);
                } catch (e) {
                    console.warn(`Failed to run loot command: ${e}`);
                }
            });
        }
    }
});```
#

export const archeologyBlocks = {
"minecraft:gravel": "blocks:gravel.json",
"minecraft:sand": "blocks:sand.json",
};

velvet rapids
velvet gulch
#

Ill try but it did not like the / last time

velvet rapids
#

You need to put double quotes (") around it

velvet gulch
#

Ohhh tyvm

#

It says syntax error when i do it via script

#

@velvet rapids

velvet rapids
#

which error

velvet gulch
#

Unexpected/

#

player.runCommand(loot spawn ~ ~ ~ loot ${lootTablePath}); is this part correct or do the " need to be added here

velvet rapids
#

yes it needs to be there

#
player.runCommand(`loot spawn ~ ~ ~ loot "${lootTablePath}"`);
velvet gulch
#

Outside correct surronding the ${}

velvet rapids
#

yep

velvet gulch
#

So far its not throwing error but nothings given

#
import { archeologyBlocks } from "./itemVar";

console.warn("archeology loaded");

world.beforeEvents.playerInteractWithBlock.subscribe(event => {
    const { block, itemStack, player } = event;
    console.warn(`ran event ${block.typeId} ${itemStack?.typeId} ${player.typeId}`);

    if (block.typeId === "minecraft:stonecutter_block") {
        const itemId = itemStack?.typeId;
        console.warn(`found item ${itemId}`);

        if (itemId && archeologyBlocks[itemId]) {
            event.cancel = true;

            const lootTablePath = archeologyBlocks[itemId];
            console.warn(`found loot table ${lootTablePath}`);
            const inventory = player.getComponent("minecraft:inventory").container;

            system.run(() => {
                for (let i = 0; i < inventory.size; i++) {
                    const item = inventory.getItem(i);
                    if (item && item.typeId === itemId) {
                        if (item.amount > 1) {
                            item.amount -= 1;
                            inventory.setItem(i, item);
                        } else {
                            inventory.setItem(i, undefined);
                        }
                        break;
                    }
                }

                try {
                    player.runCommand(`loot spawn ~ ~ ~ loot "${lootTablePath}"`);
                } catch (e) {
                    console.warn(`Failed to run loot command: ${e}`);
                }
            });
        }
    }
});```
#

@velvet rapids also its not deleting the gravel

#

Nvm it will remove them

#

Just not run the loot table

#

/loot spawn ~~~ loot "blocks/gravel" works normally

#

"minecraft:gravel": "blocks/gravel.json",

#

ohh i see the issue i think

velvet rapids
#

remove the .json maybe

velvet gulch
#

Ya i saw it to

#

Hmm now i noticed another crazier error due to my baming wrong

#
    "pools": [
        {
            "rolls": 1,
            "entries": [
                {
                    "type": "item",
                    "name": "minecraft:coal",
                    "weight": 25
                },
                {
                    "type": "item",
                    "name": "minecraft:iron_nugget",
                    "weight": 10
                },
                {
                    "type": "item",
                    "name": "minecraft:gold_nugget",
                    "weight": 5
                },
                {
                    "type": "item",
                    "name": "your_namespace:vault",
                    "weight": 5
                },
                {
                    "type": "item",
                    "name": "your_namespace:ominous_potion",
                    "weight": 3
                },
                {
                    "type": "item",
                    "name": "your_namespace:ominous_vault",
                    "weight": 1
                },
                {
                    "type": "item",
                    "name": "minecraft:netherite_scrap",
                    "weight": 1
                },
                {
                    "type": "item",
                    "name": "minecraft:diamond",
                    "weight": 1
                },
                {
                    "type": "empty",
                    "weight": 50
                }
            ]
        }
    ]
}```
#

theres some items on here not correct

#

ohhhh

#

wow chatgpt i forgot to proofread this

#

i pulled a template

velvet rapids
#

epik!

#

does it remove the gravel now or no

velvet gulch
#

I cut corners i thoughtboh simple lootvtable it csn handle it...it forgot vsult snd ominous vault are vanilla

#

It does

#

@velvet rapids question csn i use loot table to give a vault in a blockstate

velvet rapids
#

as an example if your block has 2 states, it needs to choose one of them randomly

velvet gulch
#

Im trying to give omnimouse vaults

#

I mean thats fine but how

#

I mean i could instead just make a new key thats crafted with an omnimouse key and a new key snd on use gives omnimouse loot

velvet rapids
#
"functions": [
    {
      "function": "random_block_state",
      "block_state": "put block state id here",
      "values": {
        "min": 0,
        "max": 2
      }
    }
  ]
#

why not make a custom item and give that item to the player, and use script api to replace that item with an ominouse vault?

velvet gulch
#

Im actially thinking tho my key idea will prevent a vault liter

#

This way its not abusable

velvet rapids
velvet gulch
#

Ok no worries my key idea will work it req trial chambers you still benefit off its vsults but can still use your vault keys after

#

@velvet rapids any tips to make a balanced beneficual use for poisoned potatoes

velvet rapids
#

make it so there is a chance you get a good effect

velvet gulch
#

What does it normally do

#

Dois it poison you?

velvet rapids
#

yeah

velvet gulch
#

Im thinking of making it craft poison that can be applied to all your attacks

velvet rapids
#

maybe that too

#

idk, im bad with ideas

velvet gulch
#

Its ok im a very creative person not best at balancing but ideas is my strongsuit

#

Nitey nite