#Can This Mod Add and Apply Item Attributes to Custom Items?

80 messages · Page 1 of 1 (latest)

candid compass
#

Alright, I'm losing my mind and I'm wondering if someone can point me in the right direction. There's a Minecraft mod for forge called "black powder gun" that's just an unofficial update for "ewewukek's Musket Mod" that I'm using in my modpack. There's also a mod called "Pufferfish's Skills" that allows you to make a skill tree that affects attributes. All I want to do is make an attribute that affects the musket items in the musket mod so that I can use the skills mod to alter the attribute so that it increases the damage of the musket if you "level" it up. I tried making a datapack for it, and everything I'm doing is coming out wrong despite what the tutorials are telling me. What's the best approach for this? Someone told me I might as well make a whole friggin' mod for it and I'm already at the point where I'm about to give up playing Minecraft forever because I feel like such an idiot and the stress is just making me really depressed and the hours are going by like seconds as I keep trying to troubleshoot why it's not working. The datapack looks like it should work, but it doesn't. Any advice would be helpful, and I'm not begging for someone to make the code for me - I understand the etiquette behind that and I wouldn't ask for someone to spoon-feed me the information. Is this mod capable of doing that?

idle helmBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

candid compass
#

I'm on the path to trying to figure it out but before I share what I'm trying to do with a script (which isn't quite working) I'll wait to make sure I'm not just being an idiot and see if anyone else has already done this and knows what would be wrong with the script I've been piecing together.

marsh zodiac
# candid compass I'm on the path to trying to figure it out but before I share what I'm trying to...

There's a lot to unpack here. First of all, you need to figure out if the musket mod ships it's own attributes. If the musket mod you're using adds an attribute to the game (like projectile damage), then you would just use that attribute provided by the musket mod to change the base value on a player to make muskets stronger. However, if there's no attribute shipped by the musket mod then you MUST figure out what the damage_type of the musket is and create an attribute using KubeJS to modify the damage_type output of a musket.

lament cloak
#

there is an event to detect a left/right click
you can also find nearby entities
supposing that a bullet is a projectile entity
there might be a data value that you can change
which will make it do more damage
I won't write code for you but you can use ItemEvents.rightClicked I believed

candid compass
candid compass
#

If I can find out which event to use I can probably figure this out, but none of the wiki pages seem to be made. I might be able to use a scoreboard to increase the damage from the projectile entity.

marsh zodiac
#

Since it's a projectile entity you'll have to use GoTeamRed's advice.

#

I've seen examples on here before of people changing the output of a projectile entity you'll just have to make a placeholder attribute that will calculate the value of the damage based on the player's attribute value and add/multiply that value into the projectile entity's damage calculation

candid compass
#

Oh, now I think I see... I'll let you guys know if I was successful, I appreciate it.

#

I think I should still be able to do that with a scoreboard

marsh zodiac
#

if that's how you want to keep track of a player's progress then yes that'll work.

#

does pufferfish's skills let you run a command when a skill is acquired?

candid compass
#

It does, yes

candid compass
#

Nevermind. I can't figure this out. Thanks anyway.

candid compass
# lament cloak there is an event to detect a left/right click you can also find nearby entities...

You don't have to write out the code, I'm not asking for it to be spoonfed, there's just almost no information on the wiki or an example similar to what I'm trying to do anywhere. I've been scouring the discord and the wiki, the best I've been able to pull together are snippets but since the onEvent got changed to what it is now there's no up-to-date info so most of what I've got is useless. I don't see how detecting a right click is going to help point toward the entity. I see there's a way to detect an entity being hurt. I don't even know where to start at this point and honestly it's such a stupid headache and the etiquette behind suffering through convoluted nonsense and withholding information about simple processes is some level of toxic garbage that I don't even want to touch it. There's no tutorial or guide on what I'm wanting to do because either nobody knows how to do it, or people want to hide what they're doing so they feel good about themselves. Nevermind. It's taken me three days of trying to interpret needlessly complex jargon to come to the conclusion that I don't need a friggin' musket in my modpack.

candid compass
#

This is my script. I guess it doesn't matter how obvious it is I have no idea what I'm doing if I'm this fed up with it:

EntityEvents.hurt, event => { let scoreboardValue; const scoreboardObjective = 'musket_damage'; const entity = event.entity; if (event.source.getName() === 'musketmod:bullet') { scoreboardValue = entity.getScoreboard().getOrCreatePlayerScore(entity.getScoreboard().getObjective(scoreboardObjective)).getScore(); const adjustedDamage = event.amount * (1 + scoreboardValue * 0.1); event.amount = adjustedDamage; } }

#

It's not throwing any errors, VS isn't noticing anything weird or wrong with it, it just... doesn't do anything. The musket_damage scoreboard objective is set, and I increased it by a ridiculous amount to make sure it was at least noticeable, but testing has resulted in nothing changing. It's probably an obvious problem.

#

I've even thrown in some console log functions to determine where I might be going wrong, but it's not even loading anything in the console.

lament cloak
candid compass
#

Like, it's bad. What is this?!

#

And the other one is full of "this hasn't been written yet"

#

I mean, don't get me wrong, I gotta learn this stuff on my own, but both wikis recommend coming to the discord for help if you're not sure what you're doing, and it's evident that is not only the case, but it seems like people just want to drop tiny hints that don't really lead anywhere. I even provided the small script I was working with (which I've been working on for hours on end now) and I've tried so many variants. Sure, I'm learning, and sure, it's really not a big deal if I don't include muskets in my modpack. But for once I'd really like something to work in my favor. There's a difference between giving pointers on someone's idea and letting them flounder for the sake of being vague. You don't have to write the script for them to say, "Yeah, you're using old syntax/functions, you might want to consider using this instead."

thorny lark
#

the wiki on kubejs.com is very wip (although it has most info, but not everything), and the bookstack one is missing a lot of stuff afaik

#

but for now, you will basically have to look at the source code of kubejs, use probejs (which is what I recommend), or just ask here for help heh

candid compass
# thorny lark but for now, you will basically have to look at the source code of kubejs, use p...

That's what I've done, I've BEEN asking for help (and I've been using probejs, it's not showing any errors during creation), but I guess my issue is pretty specific in that event to the point where nobody knows how to do what I'm trying to do. The alternative is that people know exactly what I'm trying to do and they don't want to say out of toxic behavior. I'm using the entity hurt event to try and adjust the projectile damage based on the scoreboard objective, but I see now where a right click event might be better. Either way though, regardless of what it's looking for, it's still not working. I'll keep working on it though.

#

EntityEvents.hurt(event => {
const scoreboardObjective = 'musket_damage';
const entity = event.getEntity();

if (entity && event.getSource().isProjectile() && event.getSource().getName() === 'musketmod:bullet') {
const shooter = event.getEntity();

if (shooter) {
  const scoreboard = shooter.getScoreboard();
  if (scoreboard) {
    const objective = scoreboard.getObjective(scoreboardObjective);
    if (objective) {
      const scoreboardValue = scoreboard.getOrCreatePlayerScore(shooter, objective).getScore();

      event.setDamage(event.getDamage() * (1 + scoreboardValue * 0.1));
    }
  }
}

}
});

It's throwing an error saying "musketattribute.js#5: Error in 'EntityEvents.hurt': TypeError: Cannot find function isProjectile in object DamageSource (musket)."

candid compass
#

Since nobody is willing to help me, can someone at least tell me which event will have a function that will allow me to adjust the damage of a damage source? I've gotten the script to work up until the very last part, which is to add the scoreboard value to the damage. It does this, but there doesn't seem to be a way to apply the scoreboard damage to the damage source.

flat rock
#

what do your logs say when you try to run the script and fire the event?

#

can you send your logs here?

misty ember
#

im pretty sure puffish skills ranged attribute accounts for all projectiles

#

looks like it accounts for the musket as well here

candid compass
#

I can see where it's going wrong, it's either because the event I'm using doesn't have the capacity to adjust the damage (I would assume EntityEvents.hurt is a dumb event to have chosen to begin with being that I'm wanting to adjust the damage before it's been applied) or I can't figure out the right function to use. I've got a constant set up to recognize the adjusted value to be "adjustedDamage", but when it tries to run the line "event.damage = adjustedDamage;" it throws the error "Error in 'EntityEvents.hurt': Java class "dev.latvian.mods.kubejs.entity.LivingEntityHurtEventJS" has no public instance field or method named "damage"." The problem is I started this endeavor trying to create an attribute, and then linking the weapon's damage (still not even sure if it's a projectile because every time I tried to identify it was a projectile with "isProjectile" it would ALSO throw an error) to the attribute, but every avenue I tried kept going wrong, so I decided to try an apply it to a scoreboard to make it easier and work from there. What's going to end up happening is that my inexperience is always going to get in the way of dealing with this rather small problem, and I am very much a firm believer in not just spoonfeeding code, so if I'm not going to be able to figure this out I'd rather just drop it.

misty ember
#

no need for a script, just reward the player with the attribute reward of ranged damage

candid compass
# misty ember

And sadly that's not the case. I've looked in the class files for the projectile data and while it's assigning it to "musketmod:bullet" I've created a script to figure out where the damage was coming from and it just says "musket". On top of that, attributes WILL affect the damage of the musket, but it is also affected by other things. Including... magic damage. Hence, the neccessity to apply something to this specific weapon/projectile and use a script to adjust the damage based on an attribute/scoreboard/tag/whatever I can.

misty ember
#

yeah but the ranged attribute wont increase anything except the bullet

candid compass
#

But it's not being affected by that

misty ember
#

wym

#

it one shot the husk

#

when without the attribute it 2 shots

#

meaning puffish's ranged attribute is doing it's job in increasing the projectile class damage attribute

candid compass
#

I've been testing as many of the possible attributes as I can, and the musket mod I'm using apparently isn't utilizing those attributes.

misty ember
#

it utilizest the ranged attribute from puffish skills built in attribute

#

as shown in the vid

candid compass
#

I don't know what to tell you. I just did it. It's not affecting it. I've been thoroughly testing it for two days.

misty ember
#

youre on 1.20.1?

#

and youre using this mod?

candid compass
#

Yes, ewewukek's musket mod

#

Not that one

misty ember
#

ewewukeks mod is not on 1.20

#

your tag says 1.20

candid compass
#

It is not, I'm using a fork

misty ember
#

you forked eweukeks mod?

candid compass
#

"There's a Minecraft mod for forge called "black powder gun" that's just an unofficial update for "ewewukek's Musket Mod" that I'm using in my modpack."

misty ember
#

oh there is a fork for it?

candid compass
#

Yup yup

misty ember
#

gotcha lemme try that one then

#

sec

#

this one?

#

or this one

#

oh its the one by dani

candid compass
#

I mean, I almost went nuts. I even got the necessary tools to use the source code to develop my own fork just so I could make the adjustments myself in the BulletEntity.class file, because the fork doesn't have the source available. But if I'm having trouble making a KubeJS script there's no way in hell I can figure out how to update a forge mod. And yes, sorry, the dani one.

#

I made a datapack instead. That didn't work either.

#

Look, you don't have to go through the trouble of testing it out yourself

misty ember
candid compass
#

If it's this much trouble, and I'm making this big a deal out of it, I shouldn't be trying to code because clearly I'm a moron and not capable of comprehending this.

#

Two days to try and develop a script to adjust the damage of a bullet. That's pretty bad.

#

I managed to get the debug script to get all the way to the end of the process before it crapped out at the last step:

[20:17:05] [Server thread/INFO]: musketattribute.js#3: Damage Source: [20:17:05] [Server thread/INFO]: musketattribute.js#3: DamageSource (musket) [net.minecraft.world.damagesource.DamageSource] [20:17:05] [Server thread/INFO]: musketattribute.js#7: Musket Damage Source Detected [20:17:05] [Server thread/INFO]: musketattribute.js#12: Shooter Detected: [20:17:05] [Server thread/INFO]: musketattribute.js#12: ServerPlayer['Merancapeman'/76368, l='ServerLevel[Test]', x=0.85, y=174.00, z=-34.54] [net.minecraft.server.level.ServerPlayer] [20:17:05] [Server thread/INFO]: musketattribute.js#18: Shooter has Scoreboard [20:17:05] [Server thread/INFO]: musketattribute.js#23: Scoreboard Objective Detected: [20:17:05] [Server thread/INFO]: musketattribute.js#23: net.minecraft.world.scores.Objective@56fb3bfa [net.minecraft.world.scores.Objective] [20:17:05] [Server thread/INFO]: musketattribute.js#26: Scoreboard Value: [20:17:05] [Server thread/INFO]: musketattribute.js#26: 0.0 [20:17:05] [Server thread/INFO]: musketattribute.js#29: Adjusted Damage: [20:17:05] [Server thread/INFO]: musketattribute.js#29: 20.66982650756836 [20:17:05] [Server thread/ERROR]: musketattribute.js#31: Error in 'EntityEvents.hurt': TypeError: Cannot find function setDamage in object dev.latvian.mods.kubejs.entity.LivingEntityHurtEventJS@70acf656.

#

I just can't figure out how to apply the adjusted damage, and that probably means I'm using the wrong syntax/event, which could mean starting all over, and I'm not putting myself through that, nor can I ask anyone else to put themselves through that on my behalf. I shouldn't have gotten so upset about it, and frankly if it's going to do that to my already fragile emotional state I probably shouldn't be coding and apologize for wasting people's time here.

misty ember
# candid compass I just can't figure out how to apply the adjusted damage, and that probably mean...

Here we're listening to the livinghurt forge event and detecting the player's persistent data, in the server event we're initializing that persistent data once upon login
Startup Script:```js
ForgeEvents.onEvent('net.minecraftforge.event.entity.living.LivingHurtEvent', event => {
global.livinghurt(event)
})
/**
*

  • @param {Internal.LivingHurtEvent} event
    */
    global.livinghurt = event => {
    const { amount, source: { actual }, source } = event
    if (!actual.isPlayer()) return
    if (source.getType() != 'musket') return
    let additionaldamage = actual.persistentData.musketstrength
    console.log(additionaldamage)
    event.amount = amount + additionaldamage
    }```

Server Script:js PlayerEvents.loggedIn(event => { if (!event.player.stages.has('new_join')) { event.player.stages.add('new_join') event.player.persistentData.musketstrength = 0 } });

this way you can give yourself the persistent data with this command here any way you need to /kubejs persistent_data entity @s merge {musketstrength:1}

candid compass
# misty ember Here we're listening to the livinghurt forge event and detecting the player's pe...

Alright, so what I'm gathering is that I clearly have no idea what I'm doing and don't even deserve to be using this mod let alone asking for help on the discord. I'm embarrassed. Nothing I made looks like that and I don't like the fact I was clearly so far off that it's evident I'm incompetent at coding. I will try to understand this first before implementation to make up for the fact that you felt kind enough to provide code that I had no business knowing.

#

I thank you, but I also apologize for being so obviously ignorant that you felt like you had to provide the code.

misty ember
candid compass
# misty ember i do it all the time for people, its not really a big deal tbh

I appreciate that, but I honestly don't deserve to use code that I don't understand. I'm frustrated with myself that in all the time I've spent working with Minecraft mods and modpacks and trying to dabble in coding, what little I've actually learned doesn't even seem to be applicable to what I was trying to do. Not only that, that looks ENTIRELY different from what I thought I was doing. It's like I was trying to reinvent the wheel with a piece of gum and a rusty paperclip. I feel like a straight up asshole. I'm sorry that I caused such a noise over something not only trivial, but clearly something that was so over my head that even the correct code to achieve my purpose looks like something that would take me many more years to comprehend. I respect your education on the matter and I apologize for taking up your all's time. I really need to figure out what the hell I'm even doing anymore.