absolutelyaya / ultracraft

A Minecraft mod recreating the game Ultrakill
MIT License
21 stars 3 forks source link

gamecrash on dedicated server when CC is inspecting item details #101

Closed walksanatora closed 3 months ago

walksanatora commented 5 months ago
java.lang.NoClassDefFoundError: net/minecraft/class_310
at absolutelyaya.ultracraft.item.AbstractWeaponItem.method_31567(AbstractWeaponItem.java:92) ~[ultracraft-1.20.1-2.0.4.i0:0/:?]
at dan200.computercraft.shared.details.ItemDetails.fill(ItemDetails.java:40) ~[computercraft-1.109.3.i0:0/:?]
at dan200.computercraft.impl.detail.DetailRegistryImpl.getDetails(DetailRegistryImpl.java:46) ~[computercraft-1.109.3.i0:0/:?]
at dan200.computercraft.shared.peripheral.generic.methods.InventoryMethods.getItemDetail(InventoryMethods.java:74) ~[computercraft-1.109.3.i0:0/:?]
at dan200.computercraft.core.asm.PeripheralMethodSupplier.lambda$static$0(PeripheralMethodSupplier.java:28) ~[computercraft-1.109.3.i0:0/:?]
at dan200.computercraft.core.asm.PeripheralMethodSupplier.lambda$static$2(PeripheralMethodSupplier.java:35) ~[computercraft-1.109.3.i0:0/:?]
at dan200.computercraft.api.lua.TaskCallback.execute(TaskCallback.java:30) ~[computercraft-1.109.3.i0:0/:?]
at dan200.computercraft.core.computer.LuaContext.lambda$issueMainThreadTask$0(LuaContext.java:29) ~[computercraft-1.109.3.i0:0/:?]
at dan200.computercraft.core.computer.mainthread.MainThreadExecutor.execute(MainThreadExecutor.java:138) ~[computercraft-1.109.3.i0:0/:?]
at dan200.computercraft.core.computer.mainthread.MainThread.tick(MainThread.java:139) ~[computercraft-1.109.3.i0:0/:?]
at dan200.computercraft.shared.computer.core.ServerContext.tick(ServerContext.java:156) ~[computercraft-1.109.3.i0:0/:?]
at dan200.computercraft.shared.CommonHooks.onServerTickStart(CommonHooks.java:48) ~[computercraft-1.109.3.i0:0/:?]

it cannot load the MinecraftClient class when calling Item#isBarVisible on the AbstractWeaponItem

walksanatora commented 5 months ago

the attempt to access client is here:

https://github.com/absolutelyaya/ultracraft/blob/fabric-1.20.1/src/main/java/absolutelyaya/ultracraft/item/AbstractWeaponItem.java#L92

absolutelyaya commented 5 months ago

I have no other way of accessing my cooldown handler, nor can I check the logical side with the data minecraft provides; computercraft shouldn't use methods that are just used for rendering otherwise to get info on an item server-side. guess that mod is just is incompatible then

walksanatora commented 5 months ago

the function is supposed to be used as a "does this item have durability". a simple fix would be to add a @WrapOperation mixin to computercraft

walksanatora commented 5 months ago

you can check if running on physical server by eg: in mod's init

try {
      Class.forName("net.minecraft.class_310");
      this.physicalServer=false
} catch(ClassNotFoundException e) {
      this.physicalServer=true
}
absolutelyaya commented 5 months ago

that's.. a fucked up way of checking, but kind of a cool solution ngl.

the function is supposed to be used as a "does this item have durability"

I don't fully get that one; just before this check, they're checking if the item is damageable at all, and if so, get the damage value and max damage. That's already getting the data they're trying to get from the check causing errors-

ah well, I may not understand it, but I'll still fix the issue using the solution you suggested

walksanatora commented 5 months ago

I just made a quick mod as a intermediary to @Overwrite mixin the function you could add a mixin to your mod to apply on server that does the same afterall all the mixin is

        @Overwrite()
    public boolean isItemBarVisible(ItemStack stack) {
        return false;
    }
walksanatora commented 5 months ago

(sorry for mentioning you random person. the nature of annotations is a pain)