#Looking for method to get a (+DATA) item using scripts.

1 messages · Page 1 of 1 (latest)

carmine sorrel
#

Its somewhat possible to get a spawner block with the entity data inside of it using scripts.

The publicly available addons that do this (linked in the comments below) are completely obfuscated. While its possible to deobfuscate them to a degree, finding the specific process or function to do this would take forever and might break the license agreements within those addons.

Any information will help a lot, and will lead to an open source addon, with everyone involved credited.

fickle fractal
#

You can .clone an itemStack

carmine sorrel
#
import { world, ItemStack, ItemTypes } from "@minecraft/server";

// Subscribe to the playerInteractWithBlock event
world.afterEvents.playerInteractWithBlock.subscribe(event => {
    const player = event.player;
    const block = event.block;

    // Check if the player has the "admin" tag
    if (!player.hasTag("admin")) {
        return; // Exit if the player does not have the "admin" tag
    }

    const item = player.getComponent("minecraft:inventory").container.getItem(player.selectedSlotIndex);

    // Check if the player is holding a stick
    if (item && item.typeId === "minecraft:stick") {
        // Get an ItemStack of the block with copied data
        const blockItem = block.getItemStack(1, true);

        // Give the item to the player
        player.getComponent("minecraft:inventory").container.addItem(blockItem);

        // Optionally, you can send a message to the player
        player.sendMessage(`You have received: ${blockItem.typeId}`);
    }
});```
carmine sorrel
# fickle fractal You can .clone an itemStack
import { world, ItemStack, ItemTypes } from "@minecraft/server";

// Subscribe to the playerInteractWithBlock event
world.afterEvents.playerInteractWithBlock.subscribe(event => {
    const player = event.player;
    const block = event.block;
    const item = player.getComponent("minecraft:inventory").container.getItem(player.selectedSlotIndex);

    // Check if the player is holding a stick
    if (item && item.typeId === "minecraft:stick") {
        // Get an ItemStack of the block with copied data
        const blockItem = block.getItemStack(1, true);

        // Give the item to the player
        player.getComponent("minecraft:inventory").container.addItem(blockItem);

        // Optionally, you can send a message to the player
        player.sendMessage(`You have received: ${blockItem.typeId}`);
    }
});```
This works but its a little limited.
pliant canopy
carmine sorrel
#

But not normal or modded blocks

#

Its still useful. Just weirdly limited.

dense drift
#

Store the item in a container,
copy the itemStack in a variable
clone it anytime

dense drift
#

Ah, yes. Totally fogor that one 💀

fickle fractal
#

Now we just need getData and setData there are some cool things we could edit for spawners if they gave us access

#

Only obfuscated the pack so people wouldn’t flat out copy my code but the add on has been stolen 2x already and since they were too lazy to make changes I was easily able to get it taken down

fickle fractal
#

Im talking about accessing and modifying the nbt data inside the spawner, like spawn radius, spawn min, spawn max, spawn rate, minecraft entity ect. There are a few more

#

Its not accessible or modifiable in api u can just clone it

fickle fractal
#

Ik thats why I said would be cool if they gave us access

carmine sorrel
fickle fractal