#how to make a constant for a mob's pehkui scale...
40 messages · Page 1 of 1 (latest)
if anyone knows how to get pehkui scale and set it to a const let me know
//creeper boss summons
onEvent('entity.hurt', event => {
// Check if the hurt entity is a creeper
if (event.entity.type === 'minecraft:creeper') {
const pehkuiscale = detectscale?;
event.source.player.tell(`creeper ${pehkuiscale}`);
global.lastCreeperHurtTime = currentTime;
}
}
);
"detectscale?" is the part idk what to put there
i see some codes with stuff like this to add pehkui to nbt.... no idea how to do some kind of 'get' for nbt, though
entity.mergeNbt({
"pehkui:scale_data_types": {
"pehkui:base": {
scale: 1.0,
},
"pehkui:jump_height": {
scale: 1.0,
},
"pehkui:motion": {
scale: 1.0,
},
"pehkui:falling": {
scale: 1.0,
},
hmmm maybe i will look into some 'nbt.get' examples in the morning... if anyone knows exactly what to use, it would save me a lot of time, though
unrelated but what does it mean when theres a $
i use when its a loadclass like this example
const $Either = Java.loadClass("com.mojang.datafixers.util.Either")
That's a convention set in this community - indicator that the constant is a reference to a Java class
ok slight progress.......
pehkui has an nbt command
and outputs this for me who is currently at a size of 2
i just have no idea how to tie this into nbt.get
onEvent('entity.hurt', event => {
// Check if the hurt entity is a creeper
if (event.entity.type === 'minecraft:creeper') {
const size = event.entity.nbt.get('pehkui:scale');
event.source.player.tell(`creeper ${size}`);
global.lastCreeperHurtTime = currentTime;
}
}
);
it reads as null
yea idk how to have the nbt.get actually read anything
ok this seems to work, was a bit harder than i bargained for
const size = event.entity.fullNBT.getCompound('pehkui:scale_data_types').getCompound('pehkui:base').getFloat('scale');
ok so a bit of an issue
const damagefactor = [entity.maxHealth / 1.5];
const extraheight = [event.entity.y + 12];
let size = event.entity.fullNBT.getCompound('pehkui:scale_data_types').getCompound('pehkui:base').getFloat('scale');
if (size = 0) {let size = 1}
const halfsize = [size / 1.15];
so sometimes size returns as 0, because pehkui didnt alter the size
but i want to make it so that if it comes as zero, to let size = 1
but it doesnt seem to work
if (size = 0) {let size = 1}
You fell into two pitfalls on this line:
- You are using an assignment expression in the condition (if). You probably meant to use:
if (size == 0)
- You are redeclaring a variable inside of a block.
So the line should be:
if (size == 0) {
size = 1;
};
const damagefactor = [entity.maxHealth / 1.5];
const extraheight = [event.entity.y + 12];
And why exactly you put results of calculations into a 1-element array?
ah i did end up getting everything working, after way more work than i thought it'd be lol
the sheep still fusing into dead sheep threw me for a loop, apparently entities stay 'alive' for around 2.5 seconds after 'death'
but i did find a new issue
i am trying to fix a mod that has a broken attribute for attack
i got the code 95% working, but i cant get the damage attributed to the mob
onEvent('entity.hurt', event => {
if (event.entity.type == 'minecraft:cow') {
if (event.source.player) {
let player = event.source.player
player.attack(600)
}
}
})
this is my test code
i need player.attack to be attributed to the cow, right now a death message will just say "username died"
ill make a new thread for it
Ticket re-opened!
onEvent('entity.spawned', event => {
if (event.entity.type == 'minecraft:sheep') {
let size = event.entity.fullNBT.getCompound('pehkui:scale_data_types').getCompound('pehkui:base').getFloat('scale');
if (size == 0) {size = 1}
if (size >= 1) { event.entity.customName = 'Amalgamation'}
let regen = size * 3
// event.server.runCommandSilent(`say regen is ${regen}`)
regen = Math.round(regen * 1) / 1;
// event.server.runCommandSilent(`say regen is ${regen}`)
let healthsize = size * 40;
healthsize = Math.round(healthsize * 10) / 10;
event.entity.mergeFullNBT({
'pehkui:scale_data_types': {
'pehkui:base': {
'scale': size
}
},
'ActiveEffects': [{
'Ambient': 0,
'Amplifier': regen,
'Duration': 1999994525,
'Id': 10,
'ShowIcon': 0,
'ShowParticles': 0
}],
'PersistenceRequired': 1 // Makes the mob persistent (won't despawn)
})
event.entity.mergeFullNBT({
'Attributes': [
{
'Name': 'minecraft:generic.max_health',
'Base': healthsize
}
]
})
}
})
i know i have a few rounds that are probably not needed
but anyways a working code that makes sheep stats scale off pehkui base size. note that some scaling mods do not use pehkui base, and use other pehkui modifiers