Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Trying to add new attributes to passive mobs throws an internal error #46

Closed
GoldenShad0w opened this issue Feb 15, 2023 · 11 comments · Fixed by #51
Closed

Trying to add new attributes to passive mobs throws an internal error #46

GoldenShad0w opened this issue Feb 15, 2023 · 11 comments · Fixed by #51
Assignees
Labels
bug Something isn't working ver: 1.8.1 Bug/Enhancement included or fixed in version 1.8.1

Comments

@GoldenShad0w
Copy link

Bug Type

Console Errors

Description

When trying to add the generic attack damage attribute to a passive mob with the code described on the wiki, an error gets thrown and the attribute isn't applied.

EntityBrain brain = BukkitBrain.getBrain((Mob) entity);

AttributeInstance attack = brain.getAttributeInstance(EntityAttribute.GENERIC_ATTACK_DAMAGE);
attack.setBaseValue(2.0D);
AttributeInstance knockback = brain.getAttributeInstance(EntityAttribute.GENERIC_ATTACK_KNOCKBACK);
knockback.setBaseValue(1.0D);

Btw there are also two syntax errors on the wiki:

getAttribteInstance is misspelt and attack.addModifier(new AttributeModifier(UUID.randomUUID(), "modifier-1", 5.0D, AttributeModifier.Operation.MULTIPLY_SCALAR_1); doesn't close all brackets.

Expected Behavior

The attribute should be applied and visible with /data get entity <uuid>

Actual Behavior

Console throws following error:

[15:56:01 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'aurum' in plugin Aurum v1.0-SNAPSHOT
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
    at org.bukkit.craftbukkit.v1_19_R2.CraftServer.dispatchCommand(CraftServer.java:929) ~[paper-1.19.3.jar:git-Paper-362]
    at org.bukkit.craftbukkit.v1_19_R2.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64) ~[paper-1.19.3.jar:git-Paper-362]
    at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:264) ~[paper-1.19.3.jar:?]
    at net.minecraft.commands.Commands.performCommand(Commands.java:313) ~[?:?]
    at net.minecraft.commands.Commands.performCommand(Commands.java:297) ~[?:?]
    at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2288) ~[?:?]
    at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$20(ServerGamePacketListenerImpl.java:2248) ~[?:?]
    at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?]
    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
    at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.19.3.jar:git-Paper-362]
    at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
    at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
    at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1341) ~[paper-1.19.3.jar:git-Paper-362]
    at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197) ~[paper-1.19.3.jar:git-Paper-362]
    at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
    at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1318) ~[paper-1.19.3.jar:git-Paper-362]
    at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1311) ~[paper-1.19.3.jar:git-Paper-362]
    at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
    at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1289) ~[paper-1.19.3.jar:git-Paper-362]
    at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1177) ~[paper-1.19.3.jar:git-Paper-362]
    at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[paper-1.19.3.jar:git-Paper-362]
    at java.lang.Thread.run(Thread.java:1589) ~[?:?]
Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.world.entity.ai.attributes.AttributeModifiable.a(double)" because "this.handle" is null
    at me.gamercoder215.mobchip.abstraction.v1_19_R2.AttributeInstance1_19_R2.setBaseValue(AttributeInstance1_19_R2.java:37) ~[aurum-1.0-SNAPSHOT.jar:?]
    at goldenshadow.aurum.Commands.onCommand(Commands.java:1531) ~[aurum-1.0-SNAPSHOT.jar:?]
    at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
    ... 23 more
@GoldenShad0w GoldenShad0w added the unconfirmed bug A Bug that has yet to be confirmed label Feb 15, 2023
@gmitch215 gmitch215 added bug Something isn't working and removed unconfirmed bug A Bug that has yet to be confirmed labels Feb 15, 2023
@gmitch215 gmitch215 self-assigned this Feb 15, 2023
@gmitch215
Copy link
Owner

Can confirm this happens. Will work on a fix for v1.8.1.

@gmitch215
Copy link
Owner

54f7d99 has been tested and works.

Marking as completed. Will be officially released along with v1.8.1, but you can manually clone the branch and build the JAR yourself if you want.

@gmitch215 gmitch215 added the ver: 1.8.1 Bug/Enhancement included or fixed in version 1.8.1 label Feb 24, 2023
@GoldenShad0w
Copy link
Author

@GamerCoder215 I've cloned your repository and checked out to the 1.18.1 branch but im unsure which maven build i need to run. Is it this one?
Screenshot 2023-03-05 at 19 07 19

@gmitch215
Copy link
Owner

It should be package, the regular JAR built in the bukkit/target folder (not sources or javadoc) should be the one you use.

@GoldenShad0w
Copy link
Author

@GamerCoder215 which one should i do? sorry if im annoying you
Screenshot 2023-03-05 at 19 52 36

@gmitch215
Copy link
Owner

It's fine;

The parent one will run all of them, which is necessary to build the jar you need.

@GoldenShad0w
Copy link
Author

GoldenShad0w commented Mar 5, 2023

@GamerCoder215 Ok I've done that but im getting a ClassNotFound exception when trying to create a EntityBrain like this EntityBrain brain = BukkitBrain.getBrain((Mob) entity);

[20:50:24 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'aurum' in plugin Aurum v1.0-SNAPSHOT
	at org.bukkit.command.PluginCommand.execute(PluginCommand.java:47) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:155) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.craftbukkit.v1_19_R2.CraftServer.dispatchCommand(CraftServer.java:912) ~[paper-1.19.3.jar:git-Paper-425]
	at org.bukkit.craftbukkit.v1_19_R2.command.BukkitCommandWrapper.run(BukkitCommandWrapper.java:64) ~[paper-1.19.3.jar:git-Paper-425]
	at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:264) ~[paper-1.19.3.jar:?]
	at net.minecraft.commands.Commands.performCommand(Commands.java:316) ~[?:?]
	at net.minecraft.commands.Commands.performCommand(Commands.java:300) ~[?:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.performChatCommand(ServerGamePacketListenerImpl.java:2288) ~[?:?]
	at net.minecraft.server.network.ServerGamePacketListenerImpl.lambda$handleChatCommand$20(ServerGamePacketListenerImpl.java:2248) ~[?:?]
	at net.minecraft.util.thread.BlockableEventLoop.lambda$submitAsync$0(BlockableEventLoop.java:59) ~[?:?]
	at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768) ~[?:?]
	at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.19.3.jar:git-Paper-425]
	at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:153) ~[?:?]
	at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[?:?]
	at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1341) ~[paper-1.19.3.jar:git-Paper-425]
	at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:197) ~[paper-1.19.3.jar:git-Paper-425]
	at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:126) ~[?:?]
	at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1318) ~[paper-1.19.3.jar:git-Paper-425]
	at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1311) ~[paper-1.19.3.jar:git-Paper-425]
	at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:136) ~[?:?]
	at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1289) ~[paper-1.19.3.jar:git-Paper-425]
	at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1177) ~[paper-1.19.3.jar:git-Paper-425]
	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[paper-1.19.3.jar:git-Paper-425]
	at java.lang.Thread.run(Thread.java:1589) ~[?:?]
Caused by: java.lang.NoClassDefFoundError: me/gamercoder215/mobchip/bukkit/BukkitBrain
	at goldenshadow.aurum.entities.CustomEntity.deserialize(CustomEntity.java:54) ~[aurum-1.0-SNAPSHOT.jar:?]
	at goldenshadow.aurum.Commands.onCommand(Commands.java:1669) ~[aurum-1.0-SNAPSHOT.jar:?]
	at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
	... 23 more
Caused by: java.lang.ClassNotFoundException: me.gamercoder215.mobchip.bukkit.BukkitBrain
	at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:181) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
	at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:148) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
	at java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[?:?]
	at goldenshadow.aurum.entities.CustomEntity.deserialize(CustomEntity.java:54) ~[aurum-1.0-SNAPSHOT.jar:?]
	at goldenshadow.aurum.Commands.onCommand(Commands.java:1669) ~[aurum-1.0-SNAPSHOT.jar:?]
	at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.19.3-R0.1-SNAPSHOT.jar:?]
	... 23 more

Am I maybe doing something wrong in my pom.xml?

Screenshot 2023-03-05 at 20 53 20

@gmitch215
Copy link
Owner

Your plugin isn't shading that JAR into the plugin jar.

Try changing your scope to compile.

@GoldenShad0w
Copy link
Author

@GamerCoder215 Ok ive done that but now it gives me the following error when trying to compile the plugin and if i remove then how will it know where to get the jar from?
Screenshot 2023-03-05 at 21 15 05

@GoldenShad0w
Copy link
Author

nvm i figured it out, ty for being so patient with me :)

@gmitch215
Copy link
Owner

gmitch215 commented Mar 6, 2023

I've just looked at it, and it seems like the system scope is deprecated, and it isn't possible to shade that JAR into your plugin jar.

I've created a wiki page that is an alternative to that method.

It seems all you need to do is to run the mvn clean install task in the MobChip directory, delete the JAR in your project, and use the <scope>compile</scope> setting.

@gmitch215 gmitch215 mentioned this issue Mar 6, 2023
4 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working ver: 1.8.1 Bug/Enhancement included or fixed in version 1.8.1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants