Jump to content

Aulig

Members
  • Posts

    42
  • Joined

  • Last visited

Everything posted by Aulig

  1. Oh. I was messing around with where i place the model creation to see if it makes any difference. Also my problem is that i want the sign (in this case) to be rendered normally as if my TESR didnt exist.
  2. Thats what i did (unless im misunderstanding you). shortened code: @Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float partialTick, int destroyStage) { //tKeybind is true when the Keybind is toggled if(KeyHandler.tKeybind){ ModelSign model = new ModelSign(); GL11.glPushMatrix(); ResourceLocation redBlock = (new ResourceLocation("mymod", "textures/blocks/redBlock.png")); Minecraft.getMinecraft().renderEngine.bindTexture(redBlock); model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); } } http://prnt.sc/b3q3ec (keybind not toggled; invisible) http://prnt.sc/b3q3t2 (keybind toggled; renders how i want it to render)
  3. Hello, is it possible to disable a TESR? Id like to use the TESR only if a Keybind is toggled, but the 2 ideas i had dont work: - i cant just temporarily "unregister" the TESR as its in init - if i put it inside of an if-statement, the TE will just be invisible Thanks in advance.
  4. Does no one know a solution? If its possible can i somehow export the vanilla sign model?
  5. Hello, Im trying to simply render the vanilla sign with a different texture if a variable is set to true. I only need help with the rendering, everything else is done the way i want it already. GL11.glPushMatrix(); GlStateManager.translate(x, y, z); ResourceLocation customSignResource = new ResourceLocation("mymod", "textures/blocks/sign.png"); (*) Minecraft.getMinecraft().renderEngine.bindTexture(customSignResource); (*) //I assume Im missing something here GL11.glPopMatrix(); In this state it doesnt render the texture, but the sign "exists" (i can see the hitbox when i hover over it). The same thing happens with all lines i marked with a "*" are removed. Do i have to create a custom model? It works if i use one, but id like to keep the standard one if possible. Thanks in advance
  6. good thing you pointed that out, ive been using 1.8.9 for a bit now but kept naming my questions 1.8.8 by habit. sorry about that . Does it make any difference in this case though? Also Im not using 1.9 as my mod is designed to help on minigame servers which mostly use 1.8 still. This feature is intended to make spotting servers that have a free slot available easier (If you have an easier idea than changing the signs color - Im open to suggestions )
  7. Hello, Id like to change the texture of the sign (either only if its on a wall or in both states) if it says a specified text in line 3. My mod is clientside only and id like to keep it that way; i know its possible to do it as "labymod"(a clientside mod) does it. if(world.getBlockState(BlockPosCurr).getBlock() == Blocks.standing_sign || world.getBlockState(BlockPosCurr).getBlock() == Blocks.wall_sign){ TileEntitySign sign = (TileEntitySign) world.getTileEntity(BlockPosCurr); IChatComponent text = sign.signText[2]; IChatComponent searched = new ChatComponentText("test"); if(text.equals(searched)){ //edit texture } }
  8. Hello, Id like to check if a block is a sign and if it is, save the second line of the sign in a string. Is this how you would check if its a sign (in the most practical way for this use)? BlockPos BlockPosition = new BlockPos(posX, posY, posZ); if(world.getBlockState(BlockPosition).getBlock() == Blocks.standing_sign || world.getBlockState(BlockPosition).getBlock() == Blocks.wall_sign){ String x = <2nd line of sign>; } What I dont know how to do is how i get the sign text. Ive seen people talk about using something like ".signText", but i have no clue how i would use that. Also I wonder if its possible to change the text clientside only? (or make the sign stand out somehow) Thanks in advance.
  9. Sorry for my nooby questions but how do i register a command and the commandhandler? this is what i found (by lexmanos): /** * The class that handles client-side chat commands. You should register any * commands that you want handled on the client with this command handler. * * If there is a command with the same name registered both on the server and * client, the client takes precedence! * */ public class ClientCommandHandler extends CommandHandler{ public static final ClientCommandHandler instance = new ClientCommandHandler(); public String[] latestAutoComplete = null; /** * @return 1 if successfully executed, -1 if no permission or wrong usage, * 0 if it doesn't exist or it was canceled (it's sent to the server) */ @Override public int executeCommand(ICommandSender sender, String message) { message = message.trim(); if (message.startsWith("/")) { message = message.substring(1); } String[] temp = message.split(" "); String[] args = new String[temp.length - 1]; String commandName = temp[0]; System.arraycopy(temp, 1, args, 0, args.length); ICommand icommand = (ICommand) getCommands().get(commandName); try { if (icommand == null) { return 0; } if(icommand.getCommandName() == "toggle"){ KeyHandler.tAutohit = true; } if (icommand.canCommandSenderUseCommand(sender)) { CommandEvent event = new CommandEvent(icommand, sender, args); if (MinecraftForge.EVENT_BUS.post(event)) { if (event.exception != null) { throw event.exception; } return 0; } icommand.processCommand(sender, args); return 1; } else { sender.addChatMessage(format(RED, "commands.generic.permission")); } } catch (WrongUsageException wue) { sender.addChatMessage(format(RED, "commands.generic.usage", format(RED, wue.getMessage(), wue.getErrorObjects()))); } catch (CommandException ce) { sender.addChatMessage(format(RED, ce.getMessage(), ce.getErrorObjects())); } catch (Throwable t) { sender.addChatMessage(format(RED, "commands.generic.exception")); t.printStackTrace(); } return -1; } //Couple of helpers because the mcp names are stupid and long... private ChatComponentTranslation format(EnumChatFormatting color, String str, Object... args) { ChatComponentTranslation ret = new ChatComponentTranslation(str, args); ret.getChatStyle().setColor(color); return ret; } public void autoComplete(String leftOfCursor, String full) { latestAutoComplete = null; if (leftOfCursor.charAt(0) == '/') { leftOfCursor = leftOfCursor.substring(1); Minecraft mc = FMLClientHandler.instance().getClient(); if (mc.currentScreen instanceof GuiChat) { List<String> commands = getTabCompletionOptions(mc.thePlayer, leftOfCursor, mc.thePlayer.getPosition()); if (commands != null && !commands.isEmpty()) { if (leftOfCursor.indexOf(' ') == -1) { for (int i = 0; i < commands.size(); i++) { commands.set(i, GRAY + "/" + commands.get(i) + RESET); } } else { for (int i = 0; i < commands.size(); i++) { commands.set(i, GRAY + commands.get(i) + RESET); } } latestAutoComplete = commands.toArray(new String[commands.size()]); } } } } } Yes, i know this is just copy-pasted but the documentation on forge is very "minimalistic"... Thanks in advance
  10. Hello, Im trying to adjust values in my mod via chat messages. For example: Player: "wandstrength set 1" -> mod sets int wandstrength to 1. I tried using the ServerChatEvent which works in singleplayer but not in multiplayer: public void onServerChatEvent(ServerChatEvent event){ Chat.printMsg("Canceled sending of message"); //this solely outputs the string to the chat (client only) event.setCanceled(true); } Note: currently im making a clientside only mod so i dont want the server to need the mod. Im open to any suggestion, as long as the server doesnt need the mod and the other players on the server wont see the message.
  11. Thanks, that worked! I guess the tutorial i watched wasnt very good. Thank you for the help.
  12. hmmm i still cant get it to work completely. This code works when the keybind for toggleTest is set to a key but not when set to a mouse button: public class Clienttick { public static boolean tTest; @SubscribeEvent public void onClientTickEvent(ClientTickEvent event){ if(Mymod.toggleTest.getKeyCode() < -85){ //check if keybind is set to a mouse button if(Mouse.isButtonDown(Mymod.toggleTest.getKeyCode())){ if(tTest){ Chat.printMsg("disabled"); tTest = false; } else{ Chat.printMsg("enabled"); tTest = true; } } } else{ if(Keyboard.isKeyDown(Mymod.toggleTest.getKeyCode())){ if(tTest){ Chat.printMsg("disabled"); tTest = false; } else{ Chat.printMsg("enabled"); tTest = true; } } } } }
  13. thanks for your answer, the weird thing is that sometimes it triggered even though it shouldnt (according to you). I will check out the solutions you provided, but is there a reason (eg performance) why clienttick should be preferred? Is this how youre supposed to do it? I assume i only need my keybinds now, but not the keyhandler right? @SubscribeEvent public void onClientTickEvent(ClientTickEvent event){ boolean mousepressed = Mouse.isButtonDown(-97); boolean keyboardpressed = Keyboard.isKeyDown(Keyboard.KEY_P); }
  14. Hello, when i try to use keybinds that are bound to buttons on my mouse forge doesnt always execute the code. The strange thing is that it works sometimes but i really have to "spam" the button to make it work. Also vanilla keybinds work with my mouse buttons, eg my sprint button is bound to "Button 5" and it works perfectly fine. NOTE: This is not about setting the standard key of a keybinding to a mouse button, in my case its "Button 4" with id "-97". It also doesnt work with "Button 3" (which is middle mouse click). Id appreciate it if you tell me if thats a common problem or somethings wrong with my code. My main file: public class Mymod { public static KeyBinding toggleTest = new KeyBinding("Toggle Test", -97, "Mymod"); public void preInit(FMLPreInitializationEvent event){ } @EventHandler public void init(FMLInitializationEvent event){ ClientRegistry.registerKeyBinding(toggleTest); FMLCommonHandler.instance().bus().register(new KeyHandler()); } public void postInit(FMLPostInitializationEvent event){ } } KeyHandler: public class KeyHandler { static boolean tTest; @SubscribeEvent public void onKeyInputEvent(KeyInputEvent event){ if(Antipathy.toggleTest.isKeyDown()){ if(tAutohit){ tAutohit = false; Chat.printMsg("Disabled Test"); //this solely outputs a chatmessage, nothing fancy } else{ tAutohit = true; Chat.printMsg("Enabled Test"); } } } }
  15. thanks for the answers, andavins tip worked the thread.sleep was the thing causing the lag and so i just had to replace that.
  16. Hello! As you can read in the topic im trying to code an autoclicker for minecraft using forge. I created a new keybind which gets triggered when i press the set key. Currently what it does when i press the keybind is: - cause lag! (main problem) - execute a leftclick (solely visible by looking at a mob and seeing that it becomes red) The lag freezes the game for half a second so that you cant see the attacking (swinging arm) animation and when trying to execute multiple clicks it freezes minecraft for a longer time. Although mc freezes, the autoclicker works outside of the game. Maybe someone knows a way to modify this code so the autoclicker only works in mc which would be convenient but not essential. Also i do NOT want to make this mod a cheat-mod which speeds up attacking and i also do NOT want to use Minecraft.getMinecraft().playerController.attackEntity(player, targetEntity); (Warning: Im new to java so it might be some really stupid mistake) public class KeyHandler { static boolean tHitmarker; static boolean tAutohit; @SubscribeEvent public void onKeyInputEvent(KeyInputEvent event){ if(MyMod.toggleAutohit.isKeyDown()){ EntityPlayer player = Minecraft.getMinecraft().thePlayer; if(tAutohit){ tAutohit = false; player.addChatComponentMessage(new ChatComponentText("Disabled Autohit")); } else{ tAutohit = true; Autoclick.leftclick(); player.addChatComponentMessage(new ChatComponentText("Enabled Autohit")); } } } } public class Autoclick extends Thread{ public static void leftclick(){ Robot bot; try { bot = new Robot(); bot.mousePress(InputEvent.BUTTON1_MASK); bot.mouseRelease(InputEvent.BUTTON1_MASK); } catch (AWTException e) { e.printStackTrace(); } try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } } Note: i posted a similar question recently but deleted it as it wasnt very clear.
×
×
  • Create New...

Important Information

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