Jump to content

[DK] Headcrab [DK]

Members
  • Posts

    7
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

[DK] Headcrab [DK]'s Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. For other people coming across this thread, I found the solution. Minecraft.getInstance().options.keyInventory.getKey().getValue();
  2. Hello, I am trying to figure out how to get a clients key mappings, but currently without any luck. Specifically I want to know which key is bound to the "Open/Close Inventory" key mapping. I have searched the internet, and only found old references to previous versions of forge using a property called gameSettings. Minecraft.getInstance().gameSettings How would one go about doing this in 1.18? Any reading material on the matter would also be much appreciated 😄 Thanks in advance.
  3. Im not exactly sure how to do what you want, but the Item#onEntitySwing is executed whenever you left click with an item. From there you might be able to use the players look vector and do some ray tracing, but this is just me guessing. Remember the method is called many times, and will continue being called while holding down left click.
  4. The last argument for FontRenderer#drawString is the color as an integer. So for example: fontRenderer.drawString("My string to draw in RED", stringPosX, stringPosY, GuiHelper.RGBAToInt(255, 0, 0)); Same applies for FontRenderer#drawStringWithShadow
  5. I use the following class to get colors outside the predefined ones, it should be able to fit your case I belive. To understand how it works, it is simply that RGBA colors are encoded in a single integer, where each set of 2 bytes store a single color. 2 bytes can encode the values 0-255.Which is the reason that RGB is defined in that range. public class GuiHelper { private GuiHelper() { } public static int RGBAToInt(int R, int G, int B, int A) { // Make sure the values are between 0 and 255 R &= 255; G &= 255; B &= 255; A &= 255; // Convert return A << 24 | R << 16 | G << 8 | B; } public static int RGBAToInt(int RGB, int A) { return RGBAToInt(RGB, RGB, RGB, A); } public static int RGBAToInt(int RGB) { return RGBAToInt(RGB, RGB, RGB, 255); } public static int RGBAToInt(int R, int G, int B) { return RGBAToInt(R, G, B, 255); } }
  6. It seems both your "InfusionWandDiamond.java" and "InfusionWandIron.java" share the same registry key "diamond_infusion_wand". They should be unique.
  7. Hello, I were wondering if there were any recommendations on the use of many event handlers? My mod adds custom perks, and most perks trigger at different events. To make maintenance easier I would like to have all code related to the perk in its own class, so I was thinking about using the "@Mod.EventBusSubscriber" notation on each of the perk classes, and then use the "@SubscribeEvent" notation on the correct event to implement the functionality. If my mod addes 30 perks, it means I will be registering 30 new event handlers, and since im unsure of the actual inner workings of Forge, it made me wonder if having many EventHandlers could have an impact on performance? So, is it recommended to use a single EventHandler that subscribe to all relevant events, and call the correct methods in each perk, or is the performance impact negligable if any from using many handlers?
×
×
  • Create New...

Important Information

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