#How do I make a clickable custom entity

1 messages · Page 1 of 1 (latest)

serene raven
#

I can't figure it out,how to do it

serene raven
#

@cerulean lodge

cerulean lodge
#

right or left click?

serene raven
#

Could it be both

#

No wait

#

Left click

cerulean lodge
#

this needs minecraft:interact in entity.json

serene raven
#

Yeah sure

#

Ao

cerulean lodge
#

trigger an event on_interact

serene raven
#

How do I make it

#

Like

#

I know how to make forms but not the entity

#

I am very noob in tht

cerulean lodge
#

do u have the entity?

serene raven
#

No

cerulean lodge
#

oh well, better learn that 1st

serene raven
#

That's why I am here💀

cerulean lodge
#

#1067869022273667152 ask how to make one

serene raven
#

Or can make it a Minecraft villgar

#

villager

#

Like when we left click the villager we get teleported to a place

#

Can it be happen

cerulean lodge
#

ye

serene raven
#

How to make it then

cerulean lodge
#

make an entity.json 1st

serene raven
#

In the scripts right?

cerulean lodge
#

or copy the villager_v2.json

#

it's entity

#

in "entities" folder

serene raven
#

Yeah

cerulean lodge
#

actually, its possible without json

serene raven
#

How

#

But I want in json

cerulean lodge
#

wdym?

serene raven
#

Nothing

#

Now what should I do

cerulean lodge
#

import {world} from '@minecraft/server';

const overworld = world.getDimension('overworld')

world.events.entityHit.subscribe(hit => {
    const player = hit.entity
    if (player.typeId !== 'minecraft:player') return
    const villager = hit.hitEntity
    if (villager.hasTag('to_spawn')) {
        player.teleport({ x: 0, y: 80, z: 0 }, overworld, 0, 0)
    }

}, { entityTypes: ['minecraft:villager_v2'] })
hearty plover
#

@serene raven I have a sample Java script code if you want it

serene raven
hearty plover
#

Sure will send it soon

serene raven
#

Ok

hearty plover
#
{
    "format_version": "1.19.100",
    "minecraft:entity": {
        "description": {
            "identifier": "dhub:dhub",
            "is_spawnable": true,
            "is_summonable": true,
            "is_experimental": false
        },
        "component_groups": {},
        "components": {
            "minecraft:physics": {
                "has_gravity": false
            },
            "minecraft:health": {
                "value": 999999999
            },
            "minecraft:damage_sensor": {
                "triggers": {
                    "cause": "all",
                    "deals_damage": false
                }
            },
            "minecraft:interact": {
                "interactions": [
                    {
                        "on_interact": {
                            "event": "cos",
                            "target": "self"
                        },
                        "interact_text": "teleport"
                    }
                ]
            }
        },
        "events": {
            "cos": {
                "run_command": {
                    "command": [
                        "function commands"
                    ],
                    "target": "other"
                }
            }
        }
    }
}```
#

@serene raven

serene raven
#

Yeah thank you for the help

#

Umm

#

@hearty plover

hearty plover
#

All good

serene raven
#

How I use this?

serene raven
cerulean lodge
serene raven
#

Like I added it in to my scripts folder and it don't works

#

I summoned villager and it shows trade

#

@cerulean lodge

cerulean lodge
#

u said left click so...

#

@serene raven

serene raven
#

Ya

#

I tried

#

But the villager gets damage when I left click it

cerulean lodge
#

obviously

serene raven
cerulean lodge
#

world.events.entityHit.subscribe(hit => {
    const villager = hit.hitEntity
    if (villager.typeId !== 'minecraft:villager_v2') return
    const player = hit.entity;
    if (villager.hasTag('to_spawn')) {
        player.teleport({ x: 0, y: 80, z: 0 }, overworld, 0, 0)
    }

}, { entityTypes: ['minecraft:player'] })
serene raven
#

Don't work

#

At all

#

@cerulean lodge

cerulean lodge
#

does the villager have to_spawn tag?

serene raven
#

See this

cerulean lodge
#

add tickingarea to spawn

serene raven
#

How to add?

#

🙂

cerulean lodge
#

/execute in overworld run tickingarea add circle 0 0 0 0

serene raven
#

Still don't work

serene raven
#

No I am still in 1.19.83