Jump to content

outflows

Members
  • Posts

    82
  • Joined

  • Last visited

Everything posted by outflows

  1. I was wondering if there was a method or something that I could use in order to swing at a block as a player and actually BREAK the block. I tried using player.swingArm() but that doesn't actually break the block that the player is swinging at. If anyone could help that would be great
  2. Yeah idk that's what someone said to do on a different forum. I didn't really think about it at the time but I see now
  3. @EventHandler public void serverStarting(FMLServerStartingEvent event) { ClientCommandHandler.instance.registerCommand(new ListTargetsCommand(new ArrayList<>(Arrays.asList("listtargets", "lt")))); }
  4. Oh ok, I was unaware that there was already a CommandBase class. That method just gets an arraylist of all the pokemon that I need to retrieve. When I say it doesn't work I mean that I'm just entirely unable to execute the command. All it says is that the command is unknown. I'll try doing what you said though and see if that works.
  5. I tried to do that like this: ClientCommandHandler.instance.registerCommand(new ListTargetsCommand(new ArrayList<>(Arrays.asList("listtargets", "lt")))); But for some reason this doesn't work when I join servers Here are my classes for both the command in question and my commandbase class: public class ListTargetsCommand extends CommandBase { public ListTargetsCommand(ArrayList<String> alias) { super(alias, "ListTargets"); } @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) { ArrayList<EntityPixelmon> pokes = PokemonDetection.getTargets(); for(EntityPixelmon poke: pokes) { PokemonDetection.privateChat(poke.getPokemonName()); } } } package com.outflows.pokalert.commands; import java.util.ArrayList; import java.util.List; import net.minecraft.command.CommandException; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.server.MinecraftServer; import net.minecraft.util.math.BlockPos; import net.minecraft.util.text.TextComponentString; public abstract class CommandBase implements ICommand { private ArrayList<String> aliases = new ArrayList<>(); private String commandName; public CommandBase(ArrayList<String> aliasList, String commandName) { for(String word: aliasList) { this.aliases.add(word); } this.commandName = commandName; } public String getCommandName() { return this.commandName; } public String getCommandUsage(ICommandSender icommandsender) { return this.commandName+" <text/help>"; } public List<String> getCommandAliases() { return this.aliases; } public void processCommand(ICommandSender icommandsender, String[] astring) { if(astring.length == 0) { icommandsender.sendMessage(new TextComponentString("Invalid Arguments. Usage: " + this.getCommandUsage(icommandsender))); return; } if (astring[0] == "help") { icommandsender.sendMessage(new TextComponentString("Usage: " + this.getCommandUsage(icommandsender))); return; } else { TextComponentString msg = new TextComponentString("Output: ["); for (int i = 0;i < astring.length; ++i) { msg.appendText(" " + astring[i]); } msg.appendText(" ]"); icommandsender.sendMessage(msg); } } public boolean canCommandSenderUseCommand(ICommandSender icommandsender) { return true; } public List<?> addTabCompletionOptions(ICommandSender icommandsender, String[] astring) { return aliases; } @Override public boolean isUsernameIndex(String[] astring, int i) { return false; } @Override public int compareTo(ICommand arg0) { // TODO Auto-generated method stub return 0; } @Override public String getName() { // TODO Auto-generated method stub return this.commandName; } @Override public String getUsage(ICommandSender sender) { // TODO Auto-generated method stub return getCommandUsage(sender); } @Override public List<String> getAliases() { return aliases; } @Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { } @Override public boolean checkPermission(MinecraftServer server, ICommandSender sender) { // TODO Auto-generated method stub return true; } @Override public List<String> getTabCompletions(MinecraftServer server, ICommandSender sender, String[] args, BlockPos targetPos) { return aliases; } }
  6. So what I'm trying to do is pretty simple. I want to make a command that can be run by a player in order to open my mod's gui. The problem is that I want this to be entirely client side and also be able to run it on a server from the client. I know that I could just check whether or not the client types the command in chat by using a ServerChatEvent event but I want to know if there's actually a way to register a command for the client and not for the server and still make it possible to run said command while the client is on any server.
  7. Does anyone have any idea where to find the code that is executed when the player joins the server?
  8. So would it work if I were to use something like ClientChatReceivedEvent?
  9. For some reason, I have my GuiScreen working and all but I can't figure out how to make the mouse appear on the screen. The cursor is there but it's just not visible to the user for some reason. If I move the cursor around a bunch it will eventually appear but I want it to appear right when I open the GUI. I have a feeling that I'm doing something very wrong but I've been looking everywhere and can't really figure out exactly what I'm supposed to do here. Also, how would I be able to add a button into the options menu such as the forge's mod options button. I looked through the GuiIngameMenu class and found that the mod options button was actually implemented directly into the class so I'm pretty confused as to how I'd be able to do this from within my own mod. This is my Gui class: package com.outflows.pokalert.gui; import java.io.IOException; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiListExtended; import net.minecraft.client.gui.GuiOptionsRowList; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiSlot; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.resources.I18n; import net.minecraft.client.settings.GameSettings; import net.minecraft.inventory.Container; import net.minecraftforge.client.event.GuiOpenEvent; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.event.ServerChatEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class MainMenu extends GuiScreen { private String screenTitle = "Pokalert Settings"; //private final GuiScreen parentGuiScreen; public MainMenu() { //this.parentGuiScreen = pgs; } public void initGui() { this.buttonList.clear(); this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height - 27, "Done")); } protected void actionPerformed(GuiButton button) throws IOException { System.out.println("Button Pressed"); if(button.id ==200) { System.out.println("Here"); closeGui(); } } public void closeGui() { this.mc.displayGuiScreen((GuiScreen)null); if (this.mc.currentScreen == null) { this.mc.setIngameFocus(); } } public void drawScreen(int mouseX, int mouseY, float partialTicks) { this.drawDefaultBackground(); // this.optionsRowList.drawScreen(mouseX, mouseY, partialTicks); this.drawCenteredString(this.fontRenderer, this.screenTitle, this.width / 2, 5, 16777215); super.drawScreen(mouseX, mouseY, partialTicks); } @Override public void onGuiClosed() { super.onGuiClosed(); this.mc.gameSettings.onGuiClosed(); } } This is my GuiHandler: package com.outflows.pokalert.gui; import org.lwjgl.input.Mouse; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.client.event.GuiOpenEvent; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.event.ServerChatEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class GuiHandler { @SubscribeEvent public void printGui(GuiOpenEvent event) { System.out.println(event.getGui()); } @SubscribeEvent public void addMainMenu(ServerChatEvent event) { MainMenu mm = new MainMenu(); if(event.getMessage().equals("test")) { Minecraft.getMinecraft().displayGuiScreen(mm); Mouse.setGrabbed(false); } } @SubscribeEvent public void handleButtonClicked(GuiScreenEvent.ActionPerformedEvent event) { System.out.println(event.getButton().id); } public void closeGui(GuiScreen screen) { screen.mc.displayGuiScreen((GuiScreen)null); if (screen.mc.currentScreen == null) { screen.mc.setIngameFocus(); } } } And I just register the GuiHandler in my initialization method by doing: MinecraftForge.EVENT_BUS.register(new GuiHandler());
  10. If I could find that code for that then I would've done that
  11. I want to rejoin when I disconnect from the server. Not when I get kicked.
  12. Maybe you misunderstood the question. What I'm trying to do is create a mod that allows the player to join back to a server that they were previously on if they get kicked or something.
  13. If I understand your question, I believe you're looking for player.swingArm()
  14. I just want to know how I can get the player to join the server. Is there a certain interface that I need to implement or something?
  15. So I'm trying to make a command for specifically the client but I've run into a problem where I'm unable to find the command manager for the client. I found one for the integrated server but I was unable to cast that to a ClientCommandHandler. Here's my code: @EventHandler public void serverStarting(FMLServerStartingEvent event) { ClientCommandHandler ch = new ClientCommandHandler(); ch.registerCommand(new ListTargetsCommand(new ArrayList<>(Arrays.asList("listtargets", "lt")))); } I had the ClientCommandHandler assigned to (ClientCommandHandler)Minecraft.getMinecraft().getIntegratedServer.commandManager but I changed it because it kept making me crash upon start up
  16. Thanks for all your help and for being patient with me as I try to figure stuff out.
  17. Oh I wasn't aware that there was a keyboard class. I was just using this as a resource: https://minecraft.gamepedia.com/Key_codes Also, it might be slightly unrelated but do you have any idea how I could make a custom GUI that looks something like the escape menu or even like the control menu?
  18. Yeah I chose 37 on purpose as it was one that wasn't already in use (K). Would I store the object in the main class where I have the preInit and stuff?
  19. Oh sorry, I misunderstood what you meant, and yeah I'm in 1.12.2. Also, where would I instantiate that new object in order to call it from outside of my main class? Or should I just instantiate it within the Main class and just use a getter? Sorry if these are stupid questions but I'm really new at modding and I'm trying to get a sense of how things work.
  20. Is it necessary to create a new KeyBinding object considering that minecraft already has one? This is what I did: ClientRegistry.registerKeyBinding(new KeyBinding("Initiate Teleport Sequence", 37, "modID"));
  21. dangit I was hoping to not have to use the registry stuff because I don't really know how to do all that to be honest. I usually just deal with code manipulation rather than actually implementing new features into the game. If you could help me out a little more with the registry stuff or give me a resource where I can learn it that would be awesome, otherwise I can continue trying to learn it myself.
  22. I wanna know how I would go about adding my own mod to the controls tab so that you can set the custom hotkeys for the mod from the controls menu as you would in vanilla mc
  23. Never mind I figured it out, you just have to instantiate the ITextComponent as a TextComponentString ITextComponent m = new TextComponentString(message); Minecraft.getMinecraft().player.sendMessage(m); (Still wanna know about the whole # thing though)
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.