Closed desagas closed 1 month ago
it seems kubejs changed some model logic for item model generation, will have to fix that
Fixed as of EntityJS version 1.21-1.0.5
@liopyu, There are a few other noticable issues with the code:
Not dropping when dismounting, but does drop when killed.
.onStopRiding(entity => {
// Drop a diamond above the entity when it stops riding
entity.block.popItemFromFace('minecraft:diamond', 'up')
})
Not dropping at all, even when killed.
.dropCustomDeathLoot(context => {
// Drop custom loot (iron ingot) when the entity dies with a looting multiplier of 2
if (context.lootingMultiplier == 2) context.entity.block.popItemFromFace('minecraft:iron_ingot', 'up')
})
Lastly, when mounting the entity, there is an extremely buggy thing that happens: While you now become in control of the entity itself, your camera does not change to the entity position, and, you can collide with yourself by moving the entity. As such, you can see the entity move, and still move your normal position at the same time. Further, the jumping while on entity function does not work. There are a few other things happening, but I can not remember right now.
The example scripts are not meant for practical use and are instead more meant to show all methods and what each function is capable of.
As for the other points:
onStopRiding()
only fires when the custom entity in question dismounts another entity, not the passenger dismounting the custom entity. I'll see if I can add the onRemovePassenger()
method which would work the other way around.
.onRemovePassenger(entity => {
entity.block.popItemFromFace('minecraft:diamond', 'up')
})
dropCustomDeathLoot
no longer haslootingMultiplier
as an argument in 1.21 in favor of damageSource. This has been corrected on the wiki page.
.dropCustomDeathLoot(context => {
const { damageSource, serverLevel, hitByPlayer, entity } = context
if (hitByPlayer) entity.block.popItemFromFace('minecraft:iron_ingot', 'up')
})
the camera offset when riding the entity is from the empty implementation of .positionRider
so remove it if you don't plan on modifying it. This is responsible for constantly setting the player at the position of the entity while riding.
.positionRider(context => {
const {entity, passenger, moveFunction} = context
// Position the entity with the moveFunction() method
})
Issues 1 & 4 are solved as of version 1.21-1.0.6 Feel free to keep the ticket open if you have anymore questions
Oh, I know. I am testing the code as is, as reporting back on it. I am doing this for all the JS mods, because there are a lot of updates being pushed with literally zero forethought or actual updates to KubeJS updated code. As a beginner to KubeJS, this not only helps me, it helps others as well.
I really enjoy your mod, and am invested in using it, so, thank you for the response and action to fix.
sure thing! entities are one of the more complicated registries and have so much to them so it's not surprising to see these questions. I will close this if that was all your questions, glad you're making use of the mod and i appreciate the testing :)
Oh, I am not asking nor do I have any questions, I am simply reporting errors in your provided example code, be it your code, Minecraft's or KubeJS's fault. I guess it is up to you to decide if they are bugs, and fix them, or not. In my eyes, if what a mod author show does not work, than it is a bug, if that makes sense.
Either way, if you want to close it, knowing that there are still a few unresolved bugs or non-current or out of date lines of code with in it, go ahead, it doesn't bother me. My only goal is to point out the errors and bugs, and I think I have done that. For myself, my own mods included, I only close issue reports once I know that they are fixed and working.
you thought onStopRiding was when the passenger stops riding and you thought the empty implementation of positionRider was a bug... these are things you did not know about which i've educated you on which is nothing to be ashamed of. these were not bugs in my code/example script but your own lack of understanding of them. the only bug i've seen you mention was the mount jump key not working which was fixed in the latest update. I am not in a hurry to close this ticket, that was more me asking you what other questions/issues you have. So if you've found more "bugs" in the code then please ask instead of insisting you are omniscient
I see. Thanks.
I didn’t so much assume it was when a player gets off a mount (onStopRiding), but, I knew that it was not supposed to be when the entity dies. And, given that entity dying part of the script didn’t trigger at all, that is the only reason I mentioned those two points. I assumed it was when it was mounting another entity and stopped, as the nbt would assign to this entity that it is riding.
I’m not new to Minecraft code, just new to KubeJS. My most downloaded mod was entirely built around non-readable Minecraft code, which was a pain to navigate through.
So, if I had a question, it would be … are your entity modifiers, like these ones mentioned, built around only KubeJS implementation, or are they built around Minecraft visible code? Or are the specific to your mod? This way, I can save you time of answering, and I can just dive into either or of their codebases?
In my kubejs mods I'll usually give base minecraft logic overriding to scripters, meaning it wont usually be custom logic as kubejs likes to do a lot of the time. I try not to add too much customization because when I do it on my end it will affect people's freedom of logic/current logic. This means that some methods when overridden may do something unexpected to the scripters, for instance the stopRiding method is called when the entity is removed so it'll also fire on the entity's death as per the minecraft default logic. This is one of those instances where I'm willing to add custom implementation such as adding the built in extra check of whether or not the entity is actually a passenger or not. At the same time this is also easily implemented on the scripter's side without custom implementation, for example
.onStopRiding(entity => {
if (!entity.isPassenger()) return
entity.block.popItemFromFace('minecraft:diamond', 'up')
})
Report an issue or feature request
Mod Version: 1.0.4
Minecraft Version: 1.21.1
Minecraft Modloader: Neoforge 21.1.50
Describe the Bug/Feature Request: The default code on your wiki for 1.21 fails to build an entity because a class can not be loaded/found. I have created a file under startup_scripts called entity.js, and copied the entire example into it, from beginning to end. I also tried separating the interaction portion into a client script, but it still didnt work. The logs are below:
Screenshots or Logs: my script (normally just .js, but git wont allow an attachment of .js, so I added .txt): entity.js
client log: client.log
startup log: startup.log
server log: server.log