#How do I make a clickable custom entity
1 messages · Page 1 of 1 (latest)
@cerulean lodge
right or left click?
this needs minecraft:interact in entity.json
trigger an event on_interact
How do I make it
Like
I know how to make forms but not the entity
I am very noob in tht
do u have the entity?
No
oh well, better learn that 1st
That's why I am here💀
#1067869022273667152 ask how to make one
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
ye
How to make it then
make an entity.json 1st
In the scripts right?
Yeah
actually, its possible without json
wdym?
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'] })
@serene raven I have a sample Java script code if you want it
Ya sure you can show it
Sure will send it soon
Ok
{
"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
All good
How I use this?
It's not working @cerulean lodge
how exactly does it not work?
Like I added it in to my scripts folder and it don't works
I summoned villager and it shows trade
@cerulean lodge
obviously
But it should be teleport you right?
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'] })
does the villager have to_spawn tag?
add tickingarea to spawn
/execute in overworld run tickingarea add circle 0 0 0 0
Still don't work
dawg its afterEvents now
No I am still in 1.19.83