Jump to content

Recommended Posts

Posted

Hey, i want to create a new bar above the armor that displays the players armor weight. I cant find any good tutorials on this at all, and would really appreciate some help, examples encouraged. Heres my current code for applying armor weight and such:

 

package MinecraftRPGOverhaul.items;

import java.awt.List;
import java.util.ArrayList;
import java.util.Arrays;

import cpw.mods.fml.common.ObfuscationReflectionHelper;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerCapabilities;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.world.World;

public class ModArmor extends ItemArmor{

//set the different weight classes
private static final float DIAMOND = 6.25f;
private static final float IRON = 5.00f;
private static final float GOLD = 3.75f;
private static final float CHAIN = 2.50f;
private static final float LEATHER = 1.25f;

//weight for each armor piece
private static float bootWeight = 0.0f;
private static float chestplateWeight = 0.0f;
private static float helmetWeight = 0.0f;
private static float leggingWeight = 0.0f;

//total armor weight
public static float totalWeight = 0.0f;

public static Item diamondArmor[] = new Item[] { 
	Items.diamond_boots, 
	Items.diamond_chestplate, 
	Items.diamond_leggings, 
	Items.diamond_helmet };

public static Item ironArmor[] = new Item[] { 
	Items.iron_boots, 
	Items.iron_chestplate, 
	Items.iron_leggings, 
	Items.iron_helmet };

public static Item goldArmor[] = new Item[] { 
	Items.golden_boots, 
	Items.golden_chestplate, 
	Items.golden_leggings, 
	Items.golden_helmet };

public static Item chainArmor[] = new Item[] { 
	Items.chainmail_boots, 
	Items.chainmail_chestplate, 
	Items.chainmail_leggings, 
	Items.chainmail_helmet };
public static Item leatherArmor[] = new Item[] { 
	Items.leather_boots, 
	Items.leather_chestplate, 
	Items.leather_leggings, 
	Items.leather_helmet };

public String textureName; //The texture name, the name is passed in via the 'ModArmor' method

public ModArmor(String unlocalizedName, ArmorMaterial material, String textureName, int type){ //ModArmor method, passes in all pertinent information to create a piece of armor
    
	super(material, 0, type);
    this.textureName = textureName;
    this.setTextureName(unlocalizedName);
}

@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type){ //getArmorTexture method, uses previous information passed in to assure you have the right texture

	return "rpgmod" + ":armor/" + this.textureName + "_" + (this.armorType == 2 ? "2" : "1") + ".png";

}

public static float armorCall(EntityPlayer player) {

	totalWeight = setCurrentArmorWeight(player);

    return (((100f - totalWeight) / 1000));
    

}

public static float setCurrentArmorWeight(EntityPlayer player) {

	player.capabilities.setFlySpeed(0);

		if (player.getCurrentArmor(0) != null) {
			for(int x = 0; x < 4; x = x+1) {
				if (player.getCurrentArmor(0).getItem().equals(diamondArmor[x])) {					
					bootWeight = DIAMOND;			
				}
				if (player.getCurrentArmor(0).getItem().equals(ironArmor[x])) {					
					bootWeight = IRON;			
				}
				if (player.getCurrentArmor(0).getItem().equals(goldArmor[x])) {					
					bootWeight = GOLD;			
				}
				if (player.getCurrentArmor(0).getItem().equals(chainArmor[x])) {					
					bootWeight = CHAIN;			
				}
				if (player.getCurrentArmor(0).getItem().equals(leatherArmor[x])) {					
					bootWeight = LEATHER;			
				}
			}
		}

		else {
			bootWeight = 0;
		}
		if (player.getCurrentArmor(1) != null) {
			for(int x = 0; x < 4; x = x+1) {
				if (player.getCurrentArmor(1).getItem().equals(diamondArmor[x])) {					
					leggingWeight = DIAMOND;			
				}
				if (player.getCurrentArmor(1).getItem().equals(ironArmor[x])) {					
					leggingWeight = IRON;			
				}
				if (player.getCurrentArmor(1).getItem().equals(goldArmor[x])) {					
					leggingWeight = GOLD;			
				}
				if (player.getCurrentArmor(1).getItem().equals(chainArmor[x])) {					
					leggingWeight = CHAIN;			
				}
				if (player.getCurrentArmor(1).getItem().equals(leatherArmor[x])) {					
					leggingWeight = LEATHER;			
				}
			}
		}
			else {
				leggingWeight = 0;

		}
		if (player.getCurrentArmor(2) != null) {
			for(int x = 0; x < 4; x = x+1) {
				if (player.getCurrentArmor(2).getItem().equals(diamondArmor[x])) {					
					chestplateWeight = DIAMOND;			
				}
				if (player.getCurrentArmor(2).getItem().equals(ironArmor[x])) {					
					chestplateWeight = IRON;			
				}
				if (player.getCurrentArmor(2).getItem().equals(goldArmor[x])) {					
					chestplateWeight = GOLD;			
				}
				if (player.getCurrentArmor(2).getItem().equals(chainArmor[x])) {					
					chestplateWeight = CHAIN;			
				}
				if (player.getCurrentArmor(2).getItem().equals(leatherArmor[x])) {					
					chestplateWeight = LEATHER;			
				}
			}
		}
			else {
				chestplateWeight = 0;

		}
		if (player.getCurrentArmor(3) != null) {
			for(int x = 0; x < 4; x = x+1) {
				if (player.getCurrentArmor(3).getItem().equals(diamondArmor[x])) {					
					helmetWeight = DIAMOND;			
				}
				if (player.getCurrentArmor(3).getItem().equals(ironArmor[x])) {					
					helmetWeight = IRON;			
				}
				if (player.getCurrentArmor(3).getItem().equals(goldArmor[x])) {					
					helmetWeight = GOLD;			
				}
				if (player.getCurrentArmor(3).getItem().equals(chainArmor[x])) {					
					helmetWeight = CHAIN;			
				}
				if (player.getCurrentArmor(3).getItem().equals(leatherArmor[x])) {					
					helmetWeight = LEATHER;			
				}
			}
		}
			else {
				helmetWeight = 0;

		}

		return bootWeight + helmetWeight + chestplateWeight
				+ leggingWeight;

}

}

 

And heres the event that modifies the players speed and a little test GUI i did:

 

package MinecraftRPGOverhaul.events;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.PlayerCapabilities;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import MinecraftRPGOverhaul.ModGUI.ModGUI;
import MinecraftRPGOverhaul.items.ModArmor;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.common.ObfuscationReflectionHelper;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;

public class ModEventHandler {

@SubscribeEvent
public void onEntityUpdate(PlayerTickEvent event) {

	event.player.capabilities.setPlayerWalkSpeed(ModArmor.armorCall(event.player));
	System.out.println((ModArmor.armorCall(event.player)));

}

@SubscribeEvent
public void onOverlayRender(RenderGameOverlayEvent event) {

	if (event.type == RenderGameOverlayEvent.ElementType.ALL) {
		FMLClientHandler.instance().getClient().fontRenderer.drawStringWithShadow("Armor Weight(Speed): " + String.format("%.2f", (100 - ModArmor.totalWeight)) + " Percent", 0, 0,16777215);
	}
}

}

 

I know its not the best code but im still figuring things out, I believe currently it wouldn't work with SMP but thats okay for now! Basically i want to have a bar that has 10 little weights, and for ever 2.5 "weight" (The totalWeight variable), i would like to display half a GUI weight as a visual representation! If someone could help me figure this out or point me to a tutorial that is more relevant to this, then that would be great!

 

Thanks in advance as i know its quite the big question/undertaking.

Posted

That only seems to be events, which i do know how to use. I need help with how to render and such! Thanks though, I bookmarked it in-case i ever need it!

 

Edit: By know how to use events, i mean i know how to use the render event and such, I just don't know how to create a functioning bar akin to the armor bar.

Posted

That only seems to be events, which i do know how to use. I need help with how to render and such! Thanks though, I bookmarked it in-case i ever need it!

 

Edit: By know how to use events, i mean i know how to use the render event and such, I just don't know how to create a functioning bar akin to the armor bar.

You didn't read the post did you?

 

The post has the extended properties tutorial below it and how to make the gui overlay.

I'm back from being gone for... I think its been about a year. I'm pretty sure nobody remembers me, but hello anybody who does!

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

    • ⚠️ DON'T CLICK THIS LINK OR ANYTHING RELATED TO THIS, IT HAS MALWARE IN THE LINK AND IT'S LIKELY A SCAM. ⚠️
    • ⚠️ DON'T CLICK THIS LINK OR ANYTHING RELATED TO THIS, IT HAS MALWARE IN THE LINK AND IT'S LIKELY A SCAM. ⚠️
    • I fight fires for a living, it's in my blood as a volunteer firefighter. But nothing could have prepared me for the fire that almost reduced my family's future to ashes. I had secretly accumulated $150,000 worth of Bitcoin over the years, intending to lock up my children's education and provide my wife with some leeway from our constant shift-work life. That was until a phishing attack struck me while I was out fighting a wildfire. The call had been on a hot afternoon. We were dashing to contain wildfires tearing across parched scrub lands. At such frantic moments, my phone pulsed with a security alert message from what looked like my Bitcoin wallet operator. Drenched with sweat, fatigue, and hyper adrenaline, I had clicked on the link and input my log-ins without questioning anything. I was tricked by hackers during my most vulnerable time. Hours later, returning to the station, I emptied my wallet. The harsh reality hit me with more force than any fire could ever have. My carefully saved safety net had vanished. My heart beat faster than the sirens. I felt as though I had failed my family. I explained my terror of burgers at our favorite local diner that evening to my friend. He leaned in close and whispered a single word: Digital Hack Recovery. He swore by their effectiveness, stating they worked miracles when his cousin had crypto stolen from him in a scam. I was skeptical old-school and desperate, so I called them. From the first call, their team treated me like family. They didn't only view figures; they viewed a husband and a father attempting to rectify a horrific error. They labored day and night, following stolen money through blockchain transactions like l detectives. Progress was made every day, translating intricate tech into fireman-speak. Ten days later, I got the call. “We recovered your Bitcoin.” I cried. Right there in the station, surrounded by smoke-stained gear, I let it all out. Relief. Gratitude. Hope they don't stop there. Knowing I worked in emergency services, Digital Hack Recovery offered to run an online security workshop for my entire fire department. They turned my disaster into a lesson that safeguarded my team. These folks don’t just recover wallets; they rebuild lives. They rebuilt mine. I fight fires for a living, it's in my blood as a volunteer firefighter. But nothing could have prepared me for the fire that almost reduced my family's future to ashes. I had secretly accumulated $150,000 worth of Bitcoin over the years, intending to lock up my children's education and provide my wife with some leeway from our constant shift-work life. That was until a phishing attack struck me while I was out fighting a wildfire. The call had been on a hot afternoon. We were dashing to contain wildfires tearing across parched scrub lands. At such frantic moments, my phone pulsed with a security alert message from what looked like my Bitcoin wallet operator. Drenched with sweat, fatigue, and hyper adrenaline, I had clicked on the link and input my log-ins without questioning anything. I was tricked by hackers during my most vulnerable time. Hours later, returning to the station, I emptied my wallet. The harsh reality hit me with more force than any fire could ever have. My carefully saved safety net had vanished. My heart beat faster than the sirens. I felt as though I had failed my family. I explained my terror of burgers at our favorite local diner that evening to my friend. He leaned in close and whispered a single word: Digital Hack Recovery. He swore by their effectiveness, stating they worked miracles when his cousin had crypto stolen from him in a scam. I was skeptical old-school and desperate, so I called them. From the first call, their team treated me like family. They didn't only view figures; they viewed a husband and a father attempting to rectify a horrific error. They labored day and night, following stolen money through blockchain transactions like l detectives. Progress was made every day, translating intricate tech into fireman-speak. Ten days later, I got the call. “We recovered your Bitcoin.” I cried. Right there in the station, surrounded by smoke-stained gear, I let it all out. Relief. Gratitude. Hope they don't stop there. Knowing I worked in emergency services, Digital Hack Recovery offered to run an online security workshop for my entire fire department. They turned my disaster into a lesson that safeguarded my team. These folks don’t just recover wallets; they rebuild lives. They rebuilt mine. Contact : Whats...App : +.1 .4 7.4.3 5.3.7 7..1.9 Website : https://       digitalhackrecovery.com     Mail:            digitalhackrecovery         @techie.       com 
    • I fight fires for a living, it's in my blood as a volunteer firefighter. But nothing could have prepared me for the fire that almost reduced my family's future to ashes. I had secretly accumulated $150,000 worth of Bitcoin over the years, intending to lock up my children's education and provide my wife with some leeway from our constant shift-work life. That was until a phishing attack struck me while I was out fighting a wildfire. The call had been on a hot afternoon. We were dashing to contain wildfires tearing across parched scrub lands. At such frantic moments, my phone pulsed with a security alert message from what looked like my Bitcoin wallet operator. Drenched with sweat, fatigue, and hyper adrenaline, I had clicked on the link and input my log-ins without questioning anything. I was tricked by hackers during my most vulnerable time. Hours later, returning to the station, I emptied my wallet. The harsh reality hit me with more force than any fire could ever have. My carefully saved safety net had vanished. My heart beat faster than the sirens. I felt as though I had failed my family. I explained my terror of burgers at our favorite local diner that evening to my friend. He leaned in close and whispered a single word: Digital Hack Recovery. He swore by their effectiveness, stating they worked miracles when his cousin had crypto stolen from him in a scam. I was skeptical old-school and desperate, so I called them. From the first call, their team treated me like family. They didn't only view figures; they viewed a husband and a father attempting to rectify a horrific error. They labored day and night, following stolen money through blockchain transactions like l detectives. Progress was made every day, translating intricate tech into fireman-speak. Ten days later, I got the call. “We recovered your Bitcoin.” I cried. Right there in the station, surrounded by smoke-stained gear, I let it all out. Relief. Gratitude. Hope they don't stop there. Knowing I worked in emergency services, Digital Hack Recovery offered to run an online security workshop for my entire fire department. They turned my disaster into a lesson that safeguarded my team. These folks don’t just recover wallets; they rebuild lives. They rebuilt mine. I fight fires for a living, it's in my blood as a volunteer firefighter. But nothing could have prepared me for the fire that almost reduced my family's future to ashes. I had secretly accumulated $150,000 worth of Bitcoin over the years, intending to lock up my children's education and provide my wife with some leeway from our constant shift-work life. That was until a phishing attack struck me while I was out fighting a wildfire. The call had been on a hot afternoon. We were dashing to contain wildfires tearing across parched scrub lands. At such frantic moments, my phone pulsed with a security alert message from what looked like my Bitcoin wallet operator. Drenched with sweat, fatigue, and hyper adrenaline, I had clicked on the link and input my log-ins without questioning anything. I was tricked by hackers during my most vulnerable time. Hours later, returning to the station, I emptied my wallet. The harsh reality hit me with more force than any fire could ever have. My carefully saved safety net had vanished. My heart beat faster than the sirens. I felt as though I had failed my family. I explained my terror of burgers at our favorite local diner that evening to my friend. He leaned in close and whispered a single word: Digital Hack Recovery. He swore by their effectiveness, stating they worked miracles when his cousin had crypto stolen from him in a scam. I was skeptical old-school and desperate, so I called them. From the first call, their team treated me like family. They didn't only view figures; they viewed a husband and a father attempting to rectify a horrific error. They labored day and night, following stolen money through blockchain transactions like l detectives. Progress was made every day, translating intricate tech into fireman-speak. Ten days later, I got the call. “We recovered your Bitcoin.” I cried. Right there in the station, surrounded by smoke-stained gear, I let it all out. Relief. Gratitude. Hope they don't stop there. Knowing I worked in emergency services, Digital Hack Recovery offered to run an online security workshop for my entire fire department. They turned my disaster into a lesson that safeguarded my team. These folks don’t just recover wallets; they rebuild lives. They rebuilt mine. Contact : Wh.ats.Ap.p : +1 .4 .7  4 3. 5  3  .7 7.1.9 Website : https://     digitalhackrecovery.   com Mail:       digitalhackrecovery     @         techie.                     com  
    • Ran it one more time just to check, and there's no errors this time on the log??? Log : https://mclo.gs/LnuaAiu I tried allocating more memory to the modpack, around 8000MB and it's still the same; stopping at "LOAD_REGISTRIES". Are some of the mods clashing, maybe? I have no clue what to do LOL
  • Topics

×
×
  • Create New...

Important Information

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