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


  • Posts

  • Joined

  • Last visited


  • Gender
  • URL

ConsumerJunk's Achievements

Tree Puncher

Tree Puncher (2/8)



  1. Hi, thanks for taking the time to read my question. I'm trying to emulate a custom FontRenderer. I say emulate because I don't want to create a custom FontRenderer, I just want to parse text into sections, then render those with the default FontRenderer. Normally that would be no problem, but in my case it's complicated by the fact that a TextComponent includes no way to get style data that I can modify (Or at least that I know of, hopefully the answers will shed some light on this). To simplify my general problem with a single question; How could I get the string (including style codes) of a TextComponent? What I'm hoping to achieve is get the string of a TextComponent, say "Player has made the advancement [Hot Stuff]" as "Player has made the advancement [§aHot Stuff]" I've tried looking at the Style class, the problem here is I can't get the style for a specific part of a string Thanks for reading my question - ConsumerJunk
  2. Funny how life works sometimes. I spent 3 days stumped on this question, then within 10 minutes of asking it here I found the answer. To avoid being the person who says they found the answer but fails to mention it in case people in the future have the same question: Inside of the Gui class in the render function (known as func_230430_a_ right now) I run this check, see if the current screen is null, if it's not null see if the gui is an instance of the custom Gui class, and if it run Minecraft::displayGuiScreen(null). (It probably doesn't need the checks to see if the screen is null because it the code is running then that means the screen isn't, but I think it's important to have that edge case, no matter how inconceivable, covered. InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), someKeybinding.getKey().getKeyCode())
  3. Hello, thank you for taking the time to read my question. I have a GUI that I only want to display when a key is being pressed, a lot like a pie menu. I've tried using the Keybinding class and using the Keybinding ::isPressed() method, but when a GUI is open it stops registering as pressed. How can I go about detecting if a key is pressed inside of a Gui? Preferably a key that is defined by a registered Keybinding so it's configurable. Thank you.
  4. Hi, thanks for taking a look at my question. I've tried to explain it concisely while still elaborating. How I simulate moving an item in the inventory? When the player selects an inventory row, I need a way to actually move the items between the inventory and the hotbar. My first though would be to simulate a click for each slot of the hotbar with the corresponding slot in the selected row. I know of PlayerControllerMP::windowClick, but what I'm concerned about is the possibility that there is no slot open that could be used to swap the rows. If all slots are full on both the hotbar and selected row, an item would need to be 'held' by the curse. Thank you for taking the time to look at my question.
  5. Hello, thank you for taking time to look at my question. I'm working on a mod that allows you to quickly switch your hotbar out with other lines in your inventory. I need a way to create a GUI and display the items in the inventory without using itemstacks. My hesitation about itemstacks is if the player attempts to interact with any of the items the client will send a packet to the server that references items the server knows the player doesn't have. How should I go about this? Thank you for reading my question, I appreciate it.
  6. I've taken a look at it before, but after you mentioned it I decided to give it another go. I found EntityRenderer#renderName, but I'm having some issues figuring out what the matrixStackIn is. I can make an empty one, but can't see a way to add a MatrixStack.Entry to it. I assume that's where the location would be
  7. Hello, I'm working on a mod that displays the name of a shulkerbox in 3d text above the block. I've been stuck at this part for the last 3 days, and have gotten quite a few false starts. I've looked at renderLivingLabel, but in the sources it includes GameRenderer.drawNameplate, which can't be resolved. I've also looked into the Tessellator, but the key methods that I've seen used seem to not exist anymore. In addition I've looked through the GitHub's of mods that display text in-game (Healthbar mods, minimap mods). All of this to say, I've tried multiple approaches but haven't quite gotten where I need to. (TL;DR: I've tried a lot of things, and a lot of things haven't worked) So that (finally) brings me to the question: How should I go about rendering billboard text? One idea I had is to create a client-side entity with no physics or appearance, only a rendered name. If anyone things this is another false start, or has a different approach they've used to seen used, I'd love to hear. Thank you (I've mocked up the effect I'm going for using an armorstand. Ironically this is similar to the entity approach I mentioned ealier) (Also here is the code that will call the name rendering. It doesn't seem particularly pertinent, but if it helps it's here) EventSubscriver.java @SubscribeEvent public void onPlayerEvent(EntityEvent e) { if(Minecraft.getInstance().player == null) { return; } player = Minecraft.getInstance().player; world = Minecraft.getInstance().world; if(!hasMoved(player)) return; BlockPos bp = getCurrentBlock(); BlockState bs = world.getBlockState(bp); if (bs.getMaterial() == Material.SHULKER) { TileEntity te = world.getTileEntity(bp); ShulkerBoxTileEntity sbte = (ShulkerBoxTileEntity)te; System.out.println(sbte.getDisplayName().getFormattedText()); sb = sbte; hovering = true; } else hovering = false; } private BlockPos getCurrentBlock() { int maxdistance = 3; Vec3d vec = player.getPositionVector(); Vec3d vec3 = new Vec3d(vec.x,vec.y+player.getEyeHeight(),vec.z); Vec3d vec3a = player.getLook(1.0F); Vec3d vec3b = vec3.add(vec3a.getX() * maxdistance, vec3a.getY()* maxdistance, vec3a.getZ()* maxdistance); BlockRayTraceResult brtr = world.rayTraceBlocks(new RayTraceContext(vec3, vec3b,RayTraceContext.BlockMode.OUTLINE, RayTraceContext.FluidMode.ANY, player)); return brtr.getPos(); } private double x,y,z,p,w; private boolean hasMoved(PlayerEntity player) { double newX = player.getPosX(); double newY = player.getPosY(); double newZ = player.getPosZ(); double newP = player.rotationPitch; double newW = player.rotationYaw; if(x != newX || y != newY || z != newZ || p != newP || w != newW) { x = newX; y = newY; z = newZ; p = newP; w = newW; return true; } return false; }
  8. I fixed it. I thought the problem was the modified GUI class, when in all reality it was the GUI switching which was the problem.
  • Create New...

Important Information

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