Jump to content

Recommended Posts

Posted

Hello, I created a custom chestplate and i'd like to make the chestplate provide a special effect when a certain button is pressed, I'm not sure how could i do this..

 

KeyBindings Class:

package phonixe.phoenixcraft.network;

import org.lwjgl.input.Keyboard;

import net.minecraft.client.settings.KeyBinding;
import net.minecraftforge.fml.client.registry.ClientRegistry;

public class PhoenixCraftKeyBindings {
    public static KeyBinding flyWings;
    public static void init() {
    flyWings = new KeyBinding("key.flyWings", Keyboard.KEY_R, "key.categories.phoenixcraft");
    ClientRegistry.registerKeyBinding(flyWings);
    }
}

 

InputHandler:

package phonixe.phoenixcraft.network;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemArmor;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import phonixe.phoenixcraft.items.RedFirePhoenix_Chestplate;

public class PhoenixCraftKeyInputHandler {
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
	if(PhoenixCraftKeyBindings.flyWings.isPressed()) {
	}
}
}

Posted

There are two things that much be true for your keybind to do anything.

 

1) The key needs to be pressed

2) The player needs to be wearing the armor

3) the server needs to know about it

 

You've got #1 at the moment, now do #2 and #3.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

You could also try a method more like this. It works with items, but I don't know about armor.

 

 

@Override

public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5){

super.onUpdate(stack, world, entity, par4, par5);

{

 

EntityPlayer player = (EntityPlayer) entity;

ItemStack equipped = player.getCurrentEquippedItem();

 

 

 

if (Keyboard.isKeyDown(Keyboard.KEY_F)) {

 

player.supercoolthingyouwantyourarmortodo;

   

 

}

 

Posted

You could also try a method more like this. It works with items, but I don't know about armor.

 

 

@Override

public void onUpdate (ItemStack stack, World world, Entity entity, int par4, boolean par5){

super.onUpdate(stack, world, entity, par4, par5);

{

 

EntityPlayer player = (EntityPlayer) entity;

ItemStack equipped = player.getCurrentEquippedItem();

 

 

 

if (Keyboard.isKeyDown(Keyboard.KEY_F)) {

 

player.supercoolthingyouwantyourarmortodo;

   

 

}

 

 

This will not work on the dedicated server.  The server doesn't necessarily know what a "keyboard" is, much less which player is pressing it.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Well here's my current InputHandler, I'm pretty sure i'm messing this up royally as i'm not sure how to do this. Also how could i let the server know of this?

 

package phonixe.phoenixcraft.network;

import javax.annotation.Nullable;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
import phonixe.phoenixcraft.init.PhoenixCraftItems;
import phonixe.phoenixcraft.items.RedFirePhoenix_Chestplate;

public class PhoenixCraftKeyInputHandler {
private ItemStack ItemStack;
@SubscribeEvent
public void onKeyInput(InputEvent.KeyInputEvent event) {
	ItemStack itemstack = this.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
	if(PhoenixCraftKeyBindings.flyWings.isPressed()) {
		if (itemstack.getItem() == PhoenixCraftItems.redfirephoenix_chestplate){

		}
	}
}

public ItemStack getItemStackFromSlot(EntityEquipmentSlot slotIn) {
	return ItemStack;
}

public void setItemStackToSlot(EntityEquipmentSlot slotIn, @Nullable ItemStack stack) {
}
}

Posted

private ItemStack ItemStack;

The fuck?

	public ItemStack getItemStackFromSlot(EntityEquipmentSlot slotIn) {
	return ItemStack;
}

Double da-fuck?

 

Also how could i let the server know of this?

 

The magic of packets.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

When the key is pressed: tell the server

The server then checks if the player is wearing the armor.

And if so, activates the effect.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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've tried the java version you linked to and got a new exit code of 127 Here is the new console log I also tried making sure that I had Java 8 selected with the version of Java 8 I already had installed and got the same exit code Here is the console log with that installation in case it has any differences I do notice both say 'Java checker returned some invalid data we don't understand:' followed by 'Minecraft might not start properly.' which could be some issues.  
    • Looking for unbeatable savings on Temu in 2025? Our exclusive Temu code [ald244107] is your key to unlocking a $100 OFF discount, plus much more! This verified promo code works for both new and existing customers, giving you up to 50% off your next order and even bigger savings on clearance items. With Temu coupon code [ald244107], you'll get a flat $100 discount on top of existing sales. First-time users can enjoy an extra 100% off select items, while returning shoppers automatically qualify for the $100 OFF when applying the code at checkout. Imagine saving up to 90% on your favorite products across the USA, Canada, UK, and many other countries! 🔥 Temu Coupon Highlights with Code [ald244107]:  * Temu New User Offer: Use ald244107 for 50% off your first order + $100 OFF.  * Temu Existing Customer Promo: Apply ald244107 to get an instant $100 OFF.  * Global Reach: Valid in the USA, UK, Canada, Germany, France, Japan, Chile, Colombia, Malaysia, Mexico, South Korea, Philippines, Saudi Arabia, Qatar, Pakistan, and more.  * Top 2025 Deal: Secure $200 OFF plus 100% bonus discounts with ald244107. Maximize Your Savings: Top Temu Deals for 2025 (Code: ald244107)  * ✅ Temu Memorial Day Sale: Save $100 with ald244107  * ✅ Temu First Order Special: Use ald244107 for 50% + $100 OFF  * ✅ Temu USA Exclusive: Get $100 off instantly with ald244107  * ✅ International Temu Codes: ald244107 works in Japan, Germany, Chile, and many others.  * ✅ Temu Reddit Discount: Enjoy $100 OFF for both new and old users.  * ✅ Temu Coupon Bundle 2025: Combine $100 OFF with up to 50% slash deals.  * ✅ 100% OFF Free Gift Code: Use ald244107 – no invitation needed!  * ✅ Temu Sign-Up Bonus: Instantly get a welcome $100 OFF.  * ✅ Free Temu Code for New Users: Apply ald244107 – no referral required.  * ✅ Temu Clearance Codes 2025: Use ald244107 for 85–100% discounts. This Temu code [ald244107] is more than just a discount; it's your ticket to free shipping, exclusive first-order deals, and stackable coupon bundles across electronics, fashion, home goods, and beauty products. You can truly unlock up to 90% OFF plus an additional $100 OFF on qualified orders. 💡 Pro Tip: Don't forget to apply ald244107 during checkout on the Temu app or website to activate your instant $100 discount, even if you’re a returning customer! Temu $100 OFF Code by Country (All Use ald244107):  * 🇺🇸 Temu USA – ald244107  * 🇯🇵 Temu Japan – ald244107  * 🇲🇽 Temu Mexico – ald244107  * 🇨🇱 Temu Chile – ald244107  * 🇨🇴 Temu Colombia – ald244107  * 🇲🇾 Temu Malaysia – ald244107  * 🇵🇭 Temu Philippines – ald244107  * 🇰🇷 Temu Korea – ald244107  * 🇵🇰 Temu Pakistan – ald244107  * 🇫🇮 Temu Finland – ald244107  * 🇸🇦 Temu Saudi Arabia – ald244107  * 🇶🇦 Temu Qatar – ald244107  * 🇫🇷 Temu France – ald244107  * 🇩🇪 Temu Germany – ald244107 Real Shoppers, Real Savings: User Reviews We love hearing about your experiences! Here’s what some happy shoppers are saying about using the Temu code [ald244107]:  * Alice W., USA ⭐️⭐️⭐️⭐️⭐️ (5/5) "Great experience! Temu's promo code {ald244107} saved me a lot on my first order. Highly recommend this offer!"  * James T., UK ⭐️⭐️⭐️⭐️ (4/5) "Very happy with the quality and prices on Temu. The $100 credits offer was a nice bonus using {ald244107}. Will shop again."  * Sara M., Canada ⭐️⭐️⭐️ (3/5) "Got some decent deals with the {ald244107} code, though shipping took a bit longer than expected. Overall satisfied with the credits."
    • Thank you so much! I didnt see it in the log😭😭  
    • So im completely new to modding in general, i have some experience in Behavior packs in minecraft bedrock and i would like to modify entities stats and attributes like in a behavior pack (health, damage, speed, xp drop...). The problem is that i cant find any information online on how to do that, and I have no clue on what to do and where to start. I am currently modding in 1.20.4 with IntelliJ if that helps. My final objective is to buff mobs health and damage (double it for exemple), but since there is no entity file anywhere i don't know how to change it... 😢
    • Hey there, nothing to do with the code, I am just suggesting you use Intelij IDEA. Trust me, it is the best.
  • Topics

×
×
  • Create New...

Important Information

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