#How do I get an array of stuff in non-item tags?
71 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
i know i could do it in the tags event, but can i do it outside of that?
inside your event u can do this, feel free to move the loadings outside of the event
const Registries = Java.loadClass("net.minecraft.core.registries.BuiltInRegistries")
const TagKey = Java.loadClass("net.minecraft.tags.TagKey")
const myTag = TagKey.create(Registries.ENTITY_TYPE.key(), "minecraft:frog_food")
let level = event.getLevel();
let entity = event.getEntity();
Registries.ENTITY_TYPE.getTag(myTag).flatMap(holders => holders.getRandomElement(level.getRandom())).ifPresent(holder => {
let type = holder.value()
let createdEntity = type.create(entity.getLevel())
createdEntity.setPos(entity.x, entity.y, entity.z)
entity.getLevel().addFreshEntity(createdEntity)
});
you can take an example here how to get entities by a tag
BuiltInRegistries.ENTITY_TYPE.getTagOrEmpty(tag) also exists. It returns an iterable of holders. The holder.value() returns the entity type then
thanks for helping me out so much recently mate
kinda confused on what im looking at exactly though haha
at what part of this code is an array of stuff in that tag being returned?
also, where do i find the minecraft source code?
im assuming from some specific mapping but idk
is it const myTag = TagKey.create(Registries.ENTITY_TYPE.key(), "minecraft:frog_food")?
^ this create the TagKey object u need to lookup in the Registry yep
BuiltInRegistries.ENTITY_TYPE.getTagOrEmpty(myTag) returns a iterable you can loop over
for(let holder of BuiltInRegistries.ENTITY_TYPE.getTagOrEmpty(tag)) {
let entityType = holder.value();
}
got it alright, thanks
now uhh.. how do i convert net.minecraft.world.entity.EntityType into its entity id
like instead of entity.aether.slider i want aether:slider
time to find out
constants/vars.js#10: TypeError: Cannot find function location in object entity.aether.slider.
:(
did you call it on the holder or the entityType? 
i was doing it in the declaration ```js
for (let holder of Registries.ENTITY_TYPE.getTagOrEmpty(myTag)) {
let entityType = holder.value().location()
}
so yea holder
oh wut
damn momo 
alternative you can BuiltInRegistries.ENTITY_TYPE.getKey(entityType)
like BuiltInRegistries.ENTITY_TYPE.getKey(entityType).location()?
where do i find this class i wanna read some java 
no, that returns you already a resourcelocation
download an MDK, best u can do
yea but im lazy
BuiltInRegistries.ENTITY_TYPE.getKey(entityType).toString() is probably what u want
this was returning minecraft:pig 31 times until i realized i forgot to change to holder.value() instead of holder.key()
lmao
that does it though, thanks
is there a list of other tag types? how would i try to use biome tags or block tags?
assuming i just have to change ENTITY_TYPE
hm? how?
after dump it should be able to autocomplete BuiltInRegistries 

does it need a jsdoc for type 
/**
* @type {Internal.BuiltInRegistries}
*/
const BuiltInRegistries = Java.loadClass("net.minecraft.core.registries.BuiltInRegistries")
not sure if thats the correct type
u have to check somehow
im rusty on my jsdoc but i know this should theoretically work right?
if that is the right type even
no clue how i'd check lol
Alright hopefully lol


