#type erasure issues.
1 messages ยท Page 1 of 1 (latest)
package com.example.commands;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import org.jetbrains.annotations.NotNull;
import thunder.hack.ThunderHack;
import thunder.hack.cmd.Command;
import java.util.concurrent.atomic.AtomicBoolean;
import static com.mojang.brigadier.Command.SINGLE_SUCCESS;
public abstract class ExampleCommand extends Command {
public ExampleCommand() {
super("help");
}
@Override
public void executeBuild(@NotNull LiteralArgumentBuilder<ServerCommandSource> builder) {
builder.executes(context -> {
sendMessage("Commands: \n");
AtomicBoolean flip = new AtomicBoolean(false);
ThunderHack.commandManager.getCommands().forEach(command -> {
context.getSource().getPlayer().sendMessage(Text.of(
(flip.get() ? Formatting.LIGHT_PURPLE : Formatting.DARK_PURPLE)
+ ThunderHack.commandManager.getPrefix()
+ (flip.get() ? Formatting.AQUA : Formatting.DARK_AQUA)
+ command.getName()
+ (command.getAliases().isEmpty() ? "" : " (" + command.getAliases() + ")")
+ Formatting.DARK_GRAY + " -> "
+ (flip.get() ? Formatting.WHITE : Formatting.GRAY)
+ command.getDescription()
));
flip.set(!flip.get());
}
);
return SINGLE_SUCCESS;
});
}
}
Detected code, here are some useful tools:
Request failed: Too Many Requests. Too many sessions, try again later :(.
I uploaded your attachments as Gist.
generics are not covariant
a Type<Super> is not the same as a Type<Sub>
Type<Animal> is not the same as Type<Cat>
so you are not overriding the method, since the super expects CommandSource, but the sub is defining ServerCommandSource
Oh wait, that makes sense. Let me try that
'executeBuild(LiteralArgumentBuilder<CommandSource>)' in 'com.example.commands.ExampleCommand' clashes with 'executeBuild(LiteralArgumentBuilder<class_2172>)' in 'thunder.hack.cmd.Command'; both methods have same erasure, yet neither overrides the other
seems to be an obfuscated minecraft class
The thing im trying to access the Command from is a different mod itself.
I have it included
its the thunderhack
so use the expected types. apparently class_2172 is the expected type
There is so many issues
also says Cannot resolve method 'getPlayer()'
But this code is the exact same inside the main mod
the issue is just that im using it from a different mod
how did you add the dependency?
if its from a different mod, how are you accessing the types from that mod?
though jitpack with gradle
share the link
the repo link?
the artifact
or the jitpack
the jitpack dependency
'com.github.Pan4ur:ThunderHack-Recode:c37468bbed'
The command?
the one you're trying to access
its thunder.hack.cmd.Command
the CommandSource is built into minecraft itself
import net.minecraft.command.CommandSource;
so i found the recode repo, i went the cmd package
cant find CommandSource
CommandSource is the type thats expected
Yeah
CommandSource isnt built into the mod
its from minecraft
net.minecraft.command.CommandSource;
yeah so that seems to be the issue
im no MC dev, slowly been getting exposed to the environment
arent there mappings you could apply?
no need. if you encountered the issue before running, its a compiler error
Yeah it wont even build, its a compiler error
im just trying to understand why a decompiled name would show up in a compiler error when you're referencing a non-decompiled library
I have no clue, its weird.
this is probably better suited for the MC community. theres something going on that isnt being shown here
and until we see it, not much we can do, other than make assumpsions based on the error
๐
the library doesnt have any decompiled-like naming
so some system is existing in between somewhere
MC devs may know about it more
but yeah, in terms of generics, gotta make sure its the exact type, or use another feature (bounded wildcards) to allow covariance
but tbh, that is the least of your worries ๐
Will do.
Thanks for the help!