Jump to content

Recommended Posts

Posted

Hey, so all I want to do is add a slider (like minecraft does for the FOV and such) to my Gui and use it for my own purpose. I just can't figure out what to do. xD

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

Actually, I can't use THAT one because it relays on GameSettings to work. I did find the GuiSlider class but, don't really know how to use it. See, I need it to set a value (like lets say 10) then take that value to be able to purchase 10 of that item.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Posted

Actually, I can't use THAT one because it relays on GameSettings to work. I did find the GuiSlider class but, don't really know how to use it. See, I need it to set a value (like lets say 10) then take that value to be able to purchase 10 of that item.

 

I'm not saying to use them exactly, but rather copy the code to make your own version.  So if you copied the GuiOptionsSlider class then instead of passing a GameSettings.Options enum you can make your own enum (or if you only have one slider, maybe none at all).

 

But GuiSlider can also be a reference.

 

The first thing to do when trying to copy similar code is to change the field names to something meaningful -- you'll have to do some detective work to figure that out sometimes.  For example, in GuiSlider the constuctor parameters have names like p_i45536_2_ but if you match things to the call with the super constructor to GuiButton you'll see that these parameters represent the button id, x, y, width, height, name, etc.  So rename all the fields in your class so that they are easy to read and understand.  For example, I think field_175227_p represents the slider positions (from 0.0 to 1.0).

 

This slider needs to be put on a GUI, so you'll need a custom GuiScreen where you add the button.  Then, in the actionPerformed() method of that GUIScreen you would react when your slider button is acted on.

 

When the slider is acted on, you're going to want to change a value somewhere that the rest of your code can process.  Since most processing needs to happen on the server, you generally should send a packet.  So if someone selected 10 on the slider and you wanted that to mean buy 10 diamonds, then you would send a custom packet that when received by the server would put 10 diamonds into the player inventory.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

It's kinda funny because cpw made a GuiSlider class so you can easily implement it. xD Thanks for the explanation though. :P

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I can't understand the logs, so I'm hoping someone could tell me what's causing the issues. https://pastebin.com/d1XPxCes
    • Hello I'm currently making an Item that thrusts you to viewing direction, and I referenced riptide code of trident for my item. @Override public InteractionResultHolder<ItemStack> use(Level pLevel, Player pPlayer, InteractionHand pUsedHand) { if(!pLevel.isClientSide() && pUsedHand == InteractionHand.MAIN_HAND && pPlayer.isOnGround()){ Impale(pPlayer, pUsedHand); pPlayer.getCooldowns().addCooldown(this, 40); } return super.use(pLevel, pPlayer, pUsedHand); } public void Impale(Player pPlayer, InteractionHand pUsedHand) { float playerYRot = pPlayer.getYRot(); float xForce = -Mth.sin(playerYRot * ((float)Math.PI / 180F)) * Mth.cos((float)Math.PI / 180F); float yForce = 100.6F; float zForce = Mth.cos(playerYRot * ((float)Math.PI / 180F)) * Mth.cos((float)Math.PI / 180F); float stabilizedForce = Mth.sqrt(xForce * xForce + zForce * zForce); xForce /= stabilizedForce; zForce /= stabilizedForce; pPlayer.push((double)xForce, (double)yForce, (double)zForce); pPlayer.sendSystemMessage(Component.literal(playerYRot + " " + xForce + " " + yForce + " " + zForce + " " + stabilizedForce + "shoo")); } I sure edited a lot from source code but this isn't working somehow? the sendSystemMessage works correctly. It prints value of variables and string, but the force isn't applying to player. how can I make this to work? Thanks.
    • i tried putting a modpack together and cant get this working no matter what i have tried log: https://pastebin.com/uqz1aKiY
    • We have an event for an Entity being struck by lighting, but doesn't look like we have one for Blocks. And unfortunately, looking at it, the LightingBolt entity doesn't have any context on why it was registered, so you wouldn't be able to get the source context. What are you trying to accomplish with this event?
    • Hey guys, I'm trying to use the simple planes mod https://www.curseforge.com/minecraft/mc-mods/simple-planes with a nuclear bombs mod https://www.curseforge.com/minecraft/mc-mods/nuclear-bombs . The simple planes mod has a cargo plane that can drop tnt, and i want it to work with the nuclear bombs. I added this JSON file from chatGPT to the payloads folder in simple planes (because the nukes couldn't even get stored in the plane in the first place), but this only allows the nuke to drop but doesn't explode: https://mclo.gs/3uEQIX2 . This nuke mod requires a redstone signal and then manual activation, which makes this tougher i imagine. If someone could write me a code for the payload folder for simpleplanes, something that even tampers with the nuke mod, or any general suggestions that would be great!  Many Thanks
  • Topics

×
×
  • Create New...

Important Information

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