"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
#its not finding the loot table thats in loot_tables/blocks/gravel.json
1 messages · Page 1 of 1 (latest)
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",
};
it should be like this
/loot spawn x y z loot "blocks/gravel"
Ill try but it did not like the / last time
You need to put double quotes (") around it
which error
Unexpected/
player.runCommand(loot spawn ~ ~ ~ loot ${lootTablePath}); is this part correct or do the " need to be added here
yes it needs to be there
player.runCommand(`loot spawn ~ ~ ~ loot "${lootTablePath}"`);
Outside correct surronding the ${}
yep
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
remove the .json maybe
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
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
im not sure, but based on my knowledge you can but it can't be a specific one
as an example if your block has 2 states, it needs to choose one of them randomly
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
"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?
Im actially thinking tho my key idea will prevent a vault liter
This way its not abusable
so I did some testing and it seems like you cant give ominous vault, it can only be placed
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
make it so there is a chance you get a good effect
yeah
Im thinking of making it craft poison that can be applied to all your attacks