#Need a tag for hostile mobs
48 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
Please read #rules 5.
FTB support is not offered in this server.
If you need help with FTB-related mods, packs, or scripts, head over to the official FTB Discord Server by clicking the button:
if you are specifically trying to use kubejs for it, then say so
hello?
Please be patient, we're helping as fast as we can
We volunteer our time and knowledge to help people as we can.
Not everyone here will have your answer the moment you want it.
Time zones, work/life/schedules etc. also change when people are available to help.
TL;DR: Please have patience. IF and WHEN someone knows, they will assist you.
@old karma updated macro </ftb:967625732551503922>!
link fixed
i havent used ftb much, but i assume it would allow using at least an entity type tag
hang on
how did i misread the original question so badly
assuming that ftbquests does allow for entity type tags, you can make a custom one with the ServerEvents.tags('entity_type' event.
Then you can loop over all entity types in the game (probably using something like Utils.registries.entityTypes.keySet.forEach(() => stuff()) and check something to see if they are hostile, which is...difficult to say the least
when you loop over all entities in the game you will be looping over entity types, not actual entities, so most things you could check (like if it inherits from Monster, or has an attack goal) cant be checked. im not too sure how you could solve that issue... it may be easier to just write a manual list
you cant choose a tag for entitys :C
oh great, and its been a requested feature for only almost three years https://github.com/FTBTeam/FTB-Mods-Issues/issues/38 🙄.
In that case i believe you can use a custom task that you can complete with kubejs, but i havent used that before so wont be as helpful
Looks like there is an event for it, FTBQuestsEvents.customTask
which takes the task id as an extra parameter
tho.. you need to listen to the entity death event, then do something in this event, so well need to use player persistent data
//requires: ftbquests
//side: server
const $Monster = Java.loadClass('net.minecraft.world.entity.monster.Monster')
EntityEvents.death(event => {
if (event.entity instanceof $Monster // check if it is a 'monster', which should be basically all hostile mobs
&& event.source.entity != null && event.source.entity.isPlayer() // check if a player killed it
) {
let player = event.source.entity
if (player.persistentData.hostilesKilled) { // this is true if it is defined as a number greater than 0. if it is undefined, or 0, the else block will execute instead
player.persistentData.hostilesKilled++ // increase the number of hostiles killed by one
} else { // if it is not set already then we have to initialize it as a number, else we will get NaNs being thrown around
// this will also run when it is set to 0, but theres no harm in that
player.persistentData.hostilesKilled = 1
}
}
})
// then the task event
FTBQuestsEvents.customTask('task id goes here', event => {
event.check = (taskData, player) => {
if (player.persistentData.hostilesKilled > 0) // if they have killed mobs since we last checked, then increase the progress by that amount
taskData.addProgress(player.persistentData.hostilesKilled)
player.persistentData.hostilesKilled = 0 // reset the temp tracker to 0 so it isnt counted twice
}
}
// you can do other stuff here like say how often it should be checked. See <https://github.com/FTBTeam/FTB-XMod-Compat/blob/main/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomTaskEventJS.java#L21-L30> for what you can do
})
Based on the docs, source code and my knowledge of kubejs, this should work however it is untested
however as often happens when i dont test things its almost guaranteed to not run for some reason or another. im happy to help with errors
So how do u use this?
make a custom task in ftbquests
put the script into a new script file in server_scripts
then copy the task id to the bit that says task id goes here
then save and /reload and the task should progress when you kill a mob
ah
missing a { after the closing bracket of the if condition
- if (player.persistentData.hostilesKilled > 0) // if they have killed mobs since we last checked, then increase the progress by that amount
+ if (player.persistentData.hostilesKilled > 0) { // if they have killed mobs since we last checked, then increase the progress by that amount
also how do i add tags to items
You can modify tags with KubeJS, and the wiki has a page on that!
im confused as hell on this
so would I do
ServerEvents.tags('item', event => {
// Get the #vsas_woodenpickaxes tag collection and add oak pickaxe to it
event.add('vsas_woodenpickaxes', 'minecraft:wooden_pickaxe')
?
if I wanted to add the Oak pickaxe to the list of custom wooden pickaxes
yes
ServerEvents.tags('item', event => {
// Get the #vsas_woodenpickaxes tag collection and add oak pickaxe to it
event.add('vsas_woodenpickaxes', 'minecraft:wooden_pickaxe')})
do i put task id where it says task id goes here
so 379529F761EA6B8E
yes
its not working
//requires: ftbquests
//side: server
const $Monster = Java.loadClass('net.minecraft.world.entity.monster.Monster')
EntityEvents.death(event => {
if (event.entity instanceof $Monster // check if it is a 'monster', which should be basically all hostile mobs
&& event.source.entity != null && event.source.entity.isPlayer() // check if a player killed it
) {
let player = event.source.entity
if (player.persistentData.hostilesKilled) { // this is true if it is defined as a number greater than 0. if it is undefined, or 0, the else block will execute instead
player.persistentData.hostilesKilled++ // increase the number of hostiles killed by one
} else { // if it is not set already then we have to initialize it as a number, else we will get NaNs being thrown around
// this will also run when it is set to 0, but theres no harm in that
player.persistentData.hostilesKilled = 1
}
}
})
// then the task event
FTBQuestsEvents.customTask('7E72BFB3C073DEEC', event => {
event.check = (taskData, player) => {
if (player.persistentData.hostilesKilled > 0) { // if they have killed mobs since we last checked, then increase the progress by that amount
taskData.addProgress(player.persistentData.hostilesKilled)
player.persistentData.hostilesKilled = 0 // reset the temp tracker to 0 so it isnt counted twice
}
}
// you can do other stuff here like say how often it should be checked. See https://github.com/FTBTeam/FTB-XMod-Compat/blob/main/common/src/main/java/dev/ftb/mods/ftbxmodcompat/ftbquests/kubejs/CustomTaskEventJS.java#L21-L30 for what you can do
})
Never say 'it crashed', 'it errored', or 'it didn't work' without providing the full crash report, log, and scripts!
and how is it not working
what does happen (even if thats 'the counter doesnt go up/the task never completes)
nothing happens at all when I kill a monster. the quest doesnt complete
send the logs
there is no logs. it says no error. it just doesnt complete the quest