Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.8] Help creating Custom Commands


CoalOres
 Share

Recommended Posts

So recently my friend got me into modding, and I've been trying to implement a basic command that returns the message "Hello" in chat when you do /coal. This is simply as a test so I can gain an understanding of how everything works.

 

This is my main class:

public class TutorialMain
{
    // The instance of your mod that Forge uses, in my case tutorial.
    @Instance("testmod")
    public static TutorialMain instance;
    
    @EventHandler
    public void serverLoad(FMLServerStartingEvent event)
    {
        // register server commands

    event.registerServerCommand(new SampleCommand());
    }

    @EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
        // Stub Method
    }

    @EventHandler
    public void init(FMLInitializationEvent event)
    {

    }

    @EventHandler
    public void postInit(FMLPostInitializationEvent event)
    {
        // Stub Method
    }
    

 

It is named TutorialMain because I was following the advice of a tutorial.

 

Here is the Sample Command class:

 

package com.testmod;

import java.util.ArrayList;
import java.util.List;
import eu.copybara.barra.util.*;

import net.minecraft.command.CommandException;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.BlockPos;

public class SampleCommand implements ICommand {

@Override
public int compareTo(Object o) {
	// TODO Auto-generated method stub
	return 0;
}

@Override
public List addTabCompletionOptions(ICommandSender arg0, String[] arg1, BlockPos arg2) {
	// TODO Auto-generated method stub
	return null;
}

@Override
public boolean canCommandSenderUse(ICommandSender arg0) {
	// TODO Auto-generated method stub
	return true;
}

@Override
public void execute(ICommandSender arg0, String[] arg1) throws CommandException {
	// TODO Auto-generated method stub
	new Messages("Hello").send();

}

@Override
public List getAliases() {
	// TODO Auto-generated method stub
	return null;
}

@Override
public String getCommandUsage(ICommandSender arg0) {
	// TODO Auto-generated method stub
	return "coal";
}

@Override
public String getName() {
	// TODO Auto-generated method stub
	return "coal";
}

@Override
public boolean isUsernameIndex(String[] arg0, int arg1) {
	// TODO Auto-generated method stub
	return false;
}}

 

Note: The Copybara.util is a package my friend sent me for sending chat messages, which I have tested and it worked before.

 

However when I run the mod and try to do /coal it informs me that there is no command like that.

 

 

I'm probably being really stupid and missing something but you must understand I have been following tutorials several years old.

 

Any help would be appreciated, thanks in advance!

 

Link to comment
Share on other sites

  • Replies 64
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

- For a start, do not implement ICommand. Extend CommandBase instead and override only the methods you need.

- Show the Messages class please.

- Why are you still on 1.8? Update.

 

1. I'm not entirely sure how the whole override thing works, could I have more detail? I'm assuming it is as simple as this:

package com.testmod;

import java.util.ArrayList;
import java.util.List;
import eu.copybara.barra.util.*;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.BlockPos;

public class SampleCommand extends CommandBase {

@Override
public int compareTo(Object o) {
	// TODO Auto-generated method stub
	return 0;
}


public List addTabCompletionOptions(ICommandSender arg0, String[] arg1, BlockPos arg2) {
	// TODO Auto-generated method stub
	return null;
}

@Override
public boolean canCommandSenderUse(ICommandSender arg0) {
	// TODO Auto-generated method stub
	return true;
}

@Override
public void execute(ICommandSender arg0, String[] arg1) throws CommandException {
	// TODO Auto-generated method stub
	new Messages("Hello").send();

}


public List getAliases() {
	// TODO Auto-generated method stub
	return null;
}

@Override
public String getCommandUsage(ICommandSender arg0) {
	// TODO Auto-generated method stub
	return "coal";
}

@Override
public String getName() {
	// TODO Auto-generated method stub
	return "coal";
}


public boolean isUsernameIndex(String[] arg0, int arg1) {
	// TODO Auto-generated method stub
	return false;
}}

 

2. Messages class:

 

package eu.copybara.barra.util;

import net.minecraft.event.ClickEvent;

import net.minecraft.event.HoverEvent;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.IChatComponent;
import net.minecraftforge.fml.client.FMLClientHandler;

import java.util.ArrayList;

public class Messages {
private static IChatComponent CHAT_PREFIX;
public static String SEPARATION_MESSAGE = "\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC";
private IChatComponent chatComponent;
private ArrayList<Messages> appendedMessages;

public Messages(String text) {
  this.chatComponent = new ChatComponentText(text);
}

public Messages(String text, EnumChatFormatting color) {
  this(text);
  this.addFormatting(color);
}

public Messages addFormatting(EnumChatFormatting formatting) {
  ChatStyle style = this.chatComponent.getChatStyle();
  switch (formatting) {
  case ITALIC:
   style.setItalic(true);
   break;
  case BOLD:
   style.setBold(true);
   break;
  case UNDERLINE:
   style.setUnderlined(true);
   break;
  case OBFUSCATED:
   style.setObfuscated(true);
   break;
  case STRIKETHROUGH:
   style.setStrikethrough(true);
   break;
  default:
   style.setColor(formatting);
   break;
  }
  this.chatComponent.setChatStyle(style);

  return this;
}

public Messages appendMessage(Messages message) {
  if (this.appendedMessages == null) {
   this.appendedMessages = new ArrayList<Messages>();
  }
  this.appendedMessages.add(message);
  if (message.appendedMessages != null) {
   this.appendedMessages.addAll(message.appendedMessages);
  }

  return this;
}

public Messages makeClickable(ClickEvent.Action action, String execute, Messages description) {
  ChatStyle style = this.chatComponent.getChatStyle();

  style.setChatClickEvent(new ClickEvent(action, execute));
  style.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, description.assembleMessage(false)));

  this.chatComponent.setChatStyle(style);

  return this;
}

public Messages makeLink(String url) {
  Messages description = new Messages("Click to visit ", EnumChatFormatting.GRAY);
  description
    .appendMessage(new Messages(url, EnumChatFormatting.AQUA).addFormatting(EnumChatFormatting.UNDERLINE));
  this.makeClickable(ClickEvent.Action.OPEN_URL, url, description);

  return this;
}

public Messages makeHover(Messages text) {
  ChatStyle style = this.chatComponent.getChatStyle();

  style.setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, text.assembleMessage(false)));

  this.chatComponent.setChatStyle(style);

  return this;
}

public void send() {
  this.send(false);
}

public void send(boolean prefix) {
  try {
   FMLClientHandler.instance().getClientPlayerEntity().addChatMessage(this.assembleMessage(prefix));
  } catch (Exception e) {
   e.printStackTrace();
  }
}

protected IChatComponent assembleMessage(boolean prefix) {
  IChatComponent result;
  if (prefix) {
   result = CHAT_PREFIX.createCopy();
  } else if (this.appendedMessages == null) {
   return this.chatComponent;
  } else {
   result = new ChatComponentText("");
  }

  result.appendSibling(this.chatComponent);
  if (this.appendedMessages != null) {
   for (Messages m : this.appendedMessages) {
    result.appendSibling(m.chatComponent);
   }
  }

  return result;
}

public static void printSeparationMessage(EnumChatFormatting color) {
  new Messages(SEPARATION_MESSAGE, color).addFormatting(EnumChatFormatting.BOLD).send(false);
}
}

 

3. I'm more familiar with 1.8 and my goal is to create a special mod which is based around Hypixel, which supports 1.8. 1.9 and 1.10 is new territory for me.

 

Link to comment
Share on other sites

@Override

 

take a monster for example it extends EntityMob

 

I really hope you know what "extends" means

 

anyway. In EntityMob, or rather down the line at Entity, there is a method called onUpdate()

 

Lets say we want to still use onUpdate() but make it do something else

 

you do

 

@Override
public void onUpdate(){

//do stuff

}

 

in this way it overrides to parent method and substitutes whatever you want.

 

Now if you want the parent method to still run and your own stuff to run as well you add the super in

 

@Override
public void onUpdate(){
super.onUpdate();
//do stuff

}

 

I probably butchered that explanation, and may get scolded for not telling you to "Go learn java". But I am bored at work.

 

That actually made sense, thank you!

 

The

send

method of the Messages class is absolutely broken. It will crash on servers and will not work reliably in single player.

 

Is there a better one you recommend?

Link to comment
Share on other sites

ICommandSender::addChatMessage

(every entity is an

ICommandSender

).

So this is my refined code:

 

package com.testmod;

import java.util.ArrayList;
import java.util.List;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;

public class SampleCommand extends CommandBase {

@Override
public int compareTo(Object o) {
	// TODO Auto-generated method stub
	return 0;
}


public List addTabCompletionOptions(ICommandSender icommandsender, String[] arg1, BlockPos arg2) {
	// TODO Auto-generated method stub
	return null;
}

@Override
public boolean canCommandSenderUse(ICommandSender icommandsender) {
	// TODO Auto-generated method stub
	return true;
}

@Override
public void execute(ICommandSender icommandsender, String[] arg1) throws CommandException {
	// TODO Auto-generated method stub
	icommandsender.addChatMessage(new ChatComponentText("Hello"));

}


public List getAliases() {
	// TODO Auto-generated method stub
	return null;
}

@Override
public String getCommandUsage(ICommandSender icommandsender) {
	// TODO Auto-generated method stub
	return "coal";
}

@Override
public String getName() {
	// TODO Auto-generated method stub
	return "coal";
}

@Override
public boolean isUsernameIndex(String[] arg0, int arg1) {
	// TODO Auto-generated method stub
	return false;
}}
}}

 

Yet still nothing happens when I do /coal.

 

I apologise if I'm missing something obvious and am sounding like an idiot.

 

PS: I'm also crashing when genning a new world and attempting to join it. Minecraft just freezes and I have to close it.

 

 

Link to comment
Share on other sites

You are still overriding all those methods. Why?

 

How exactly are you running the mod?

You told me to override all the methods I need, so I thought I needed to remove the "@Override" for all the methods that returned null. And I'm running it through eclipse with the run function, logged into my Minecraft account.

 

Edit: Just removed the overrides, still nothing.

Link to comment
Share on other sites

Post updated code.

Also the @Override annotation is not what overrides a method. Overriding a method means creating a method with the same name and parameter types as a method in a superclass. @Override is just marker that produces an error if you are not overriding.

 

How exactly are you running the mod?

Link to comment
Share on other sites

Post updated code.

Also the @Override annotation is not what overrides a method. Overriding a method means creating a method with the same name and parameter types as a method in a superclass. @Override is just marker that produces an error if you are not overriding.

 

How exactly are you running the mod?

package com.testmod;

import java.util.ArrayList;
import java.util.List;
import eu.copybara.barra.util.*;
import net.minecraft.command.CommandBase;
import net.minecraft.command.CommandException;
import net.minecraft.command.ICommand;
import net.minecraft.command.ICommandSender;
import net.minecraft.util.BlockPos;
import net.minecraft.util.ChatComponentText;

public class SampleCommand extends CommandBase {


public int compareTo(Object o) {
	// TODO Auto-generated method stub
	return 0;
}


public List addTabCompletionOptions(ICommandSender icommandsender, String[] arg1, BlockPos arg2) {
	// TODO Auto-generated method stub
	return null;
}


public boolean canCommandSenderUse(ICommandSender icommandsender) {
	// TODO Auto-generated method stub
	return true;
}


public void execute(ICommandSender icommandsender, String[] arg1) throws CommandException {
	// TODO Auto-generated method stub
	icommandsender.addChatMessage(new ChatComponentText("Hello"));

}


public List getAliases() {
	// TODO Auto-generated method stub
	return null;
}


public String getCommandUsage(ICommandSender icommandsender) {
	// TODO Auto-generated method stub
	return "coal";
}


public String getName() {
	// TODO Auto-generated method stub
	return "coal";
}


public boolean isUsernameIndex(String[] arg0, int arg1) {
	// TODO Auto-generated method stub
	return false;
}}

 

Main:

package com.testmod;

import com.testmod.SampleCommand;

import net.minecraftforge.client.ClientCommandHandler;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;

@Mod(modid="testmod", name="Test Mod", version="1.0")

public class TutorialMain
{
    // The instance of your mod that Forge uses, in my case tutorial.
    @Instance("testmod")
    public static TutorialMain instance;
    
    @EventHandler
    public void serverLoad(FMLServerStartingEvent event)
    {
        // register server commands

    event.registerServerCommand(new SampleCommand());
    }

    @EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
        // Stub Method
    }

    @EventHandler
    public void init(FMLInitializationEvent event)
    {

    }

    @EventHandler
    public void postInit(FMLPostInitializationEvent event)
    {
        // Stub Method
    }
    

   

}[code]


As I said, I click the "Run" button on eclipse, it opens Minecraft, I go onto a server (have to because single player crashes it for some reason) and do /coal.

 

Note: When it crashes on singleplayer it returns this on the console:

The state engine was in incorrect state ERRORED and forced into state SERVER_STOPPED. Errors may have been discarded.

The state engine was in incorrect state ERRORED and forced into state AVAILABLE. Errors may have been discarded.

Link to comment
Share on other sites

Again:

You are still overriding all those methods. Why?

 

As I said, I click the "Run" button on eclipse, it opens Minecraft, I go onto a server
What kind of server? Does it have your mod installed? If so: How?

 

have to because single player crashes it for some reason
Post the full crash.
Link to comment
Share on other sites

Again:

You are still overriding all those methods. Why?

 

As I said, I click the "Run" button on eclipse, it opens Minecraft, I go onto a server
What kind of server? Does it have your mod installed? If so: How?

 

have to because single player crashes it for some reason
Post the full crash.

 

1. I really don't understand what I'm overriding, how I'm doing it and what effect it is having, this is one of my first times modding.

 

2. It's Hypixel, so of course it doesn't have my mod installed.

 

3. Crash:

Caught exception from testmod

java.lang.NullPointerException

at net.minecraft.command.CommandHandler.registerCommand(CommandHandler.java:138) ~[forgeBin-1.8-11.14.1.1334.jar:?]

at net.minecraftforge.fml.common.event.FMLServerStartingEvent.registerServerCommand(FMLServerStartingEvent.java:44) ~[forgeBin-1.8-11.14.1.1334.jar:?]

at com.testmod.TutorialMain.serverLoad(TutorialMain.java:27) ~[bin/:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_101]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_101]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_101]

at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:518) ~[forgeBin-1.8-11.14.1.1334.jar:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_101]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_101]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_101]

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]

at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) ~[forgeBin-1.8-11.14.1.1334.jar:?]

at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:187) ~[forgeBin-1.8-11.14.1.1334.jar:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_101]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_101]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_101]

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]

at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118) [LoadController.class:?]

at net.minecraftforge.fml.common.Loader.serverStarting(Loader.java:738) [Loader.class:?]

at net.minecraftforge.fml.common.FMLCommonHandler.handleServerStarting(FMLCommonHandler.java:319) [FMLCommonHandler.class:?]

at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:128) [integratedServer.class:?]

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:438) [MinecraftServer.class:?]

at java.lang.Thread.run(Thread.java:745) [?:1.8.0_101]

[21:00:10] [server thread/ERROR]: A fatal exception occurred during the server starting event

java.lang.NullPointerException

at net.minecraft.command.CommandHandler.registerCommand(CommandHandler.java:138) ~[forgeBin-1.8-11.14.1.1334.jar:?]

at net.minecraftforge.fml.common.event.FMLServerStartingEvent.registerServerCommand(FMLServerStartingEvent.java:44) ~[forgeBin-1.8-11.14.1.1334.jar:?]

at com.testmod.TutorialMain.serverLoad(TutorialMain.java:27) ~[bin/:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_101]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_101]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_101]

at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:518) ~[forgeBin-1.8-11.14.1.1334.jar:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_101]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_101]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_101]

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]

at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) ~[LoadController.class:?]

at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:187) ~[LoadController.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_101]

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_101]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_101]

at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_101]

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]

at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]

at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118) ~[LoadController.class:?]

at net.minecraftforge.fml.common.Loader.serverStarting(Loader.java:738) [Loader.class:?]

at net.minecraftforge.fml.common.FMLCommonHandler.handleServerStarting(FMLCommonHandler.java:319) [FMLCommonHandler.class:?]

at net.minecraft.server.integrated.IntegratedServer.startServer(IntegratedServer.java:128) [integratedServer.class:?]

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:438) [MinecraftServer.class:?]

at java.lang.Thread.run(Thread.java:745) [?:1.8.0_101]

[21:00:10] [server thread/INFO]: Applying holder lookups

Link to comment
Share on other sites

I really don't understand what I'm overriding, how I'm doing it and what effect it is having, this is one of my first times modding.
You need to learn Java then. Before modding.

Like I said, overriding a method means having a method with the same name and signature (i.e. parameter types) as a superclass. As an example the method

addTabCompletionOptions

from your command class overrides the

addTabCompletionOptions

method in CommandBase, because it has the same name and signature. Like I also already said,

@Override

has nothing to do with whether you override or not. @Override simply produces an error if you are not overriding.

 

It's Hypixel, so of course it doesn't have my mod installed.

How do you expect a server-side command that you added to work on a server that is not yours?

 

3. Crash:

[snip]

This crash happens because you are still overriding all those methods to perform nonsense instead of their actual intended function.
Link to comment
Share on other sites

All those methods that are asking for a "return" and you specify "null" are getting really angry at you. because they are expecting data, and you are saying null aka "no data"
This is honestly a very confusing and bad explanation.

 

Please don't try to teach Java basics in here, there are other places for that.

Link to comment
Share on other sites

You need to learn Java then. Before modding.

Like I said, overriding a method means having a method with the same name and signature (i.e. parameter types) as a superclass. As an example the method

addTabCompletionOptions

from your command class overrides the

addTabCompletionOptions

method in CommandBase, because it has the same name and signature. Like I also already said,

@Override

has nothing to do with whether you override or not. @Override simply produces an error if you are not overriding.

 

 

It's Hypixel, so of course it doesn't have my mod installed.

How do you expect a server-side command that you added to work on a server that is not yours?

 

3. Crash:

[snip]

This crash happens because you are still overriding all those methods to perform nonsense instead of their actual intended function.

 

 

1. So I need to rename these things to something else? Anything of my choosing? And how am I supposed to change the parameters? Won't that screw stuff up?

 

 

2. I'm attempting to make a client side mod, eventually for convenience, for example a /afk command which will /reply to anybody who messages you after you have done /afk.

 

 

 

 

Link to comment
Share on other sites

You are trying  to create a mod that needs to have access to the server....

That would have been nice to know before hand. How does one create a client side mod then? Because all of the tutorials I have seen followed this exact procedure.

Link to comment
Share on other sites

What are you trying to do with /AFK?

The syntax would be:

/afk <reason>

 

And whenever somebody messaged you (could detect this by the pink "From" in chat) it would send "/r I am currently afk" + reason to the chat.

 

This was a simple test to see if I could have it print something to the chat upon a command.

Link to comment
Share on other sites

Sending chat messages is handled server side on servers, because it is the only way for other players to the the message though you could probably have your command run the other command to possibly fix that.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Sending chat messages is handled server side on servers, because it is the only way for other players to the the message though you could probably have your command run the other command to possibly fix that.

That's what I mean, I want it to send THROUGH MY PLAYER "/r" which is the /reply command.

Link to comment
Share on other sites

So if I understand correctly what you want to do is...

1. Run /AFK command

2. If the player that ran the command is AFK and receives a whisper/msg then send a reply back saying This player is AFK

Am I right?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

I don't think you can detect if the player has received a chat message but if you could it would be down with an Event provided by forge.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share




×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.