Jump to content

Alex_Richard

Members
  • Posts

    17
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Alex_Richard's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I know how to code a solid bar GUI to represent a value, but how do i use multiple textures like the vanilla health and armor bars? Is it just a lot of this? if (value > number && value1 < number { render one image else if (value > number && value1 < number { render one image next to other image
  2. Thanks a ton, I'm reading it right now!
  3. It's clear you don't know what you are doing currently, I REALLY encourage you to look at these tutorials, and possibly some basic java tutorials on things such as: Methods, classes and objects ETC. Heres some good tutorials on minecraft modding: http://bedrockminer.jimdo.com/modding-tutorials/
  4. 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.
  5. 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.
  6. Hmm, it still won't update at all in game... public class ModEventHandler { public float weight; @SubscribeEvent public void onEntityUpdate(PlayerTickEvent event) { weight = ModArmor.armorCall(event.player); event.player.capabilities.setPlayerWalkSpeed(weight); System.out.println((ModArmor.armorCall(event.player))); } @SubscribeEvent public void onOverlayRender(RenderGameOverlayEvent event) { if (event.type == RenderGameOverlayEvent.ElementType.ALL) { FMLClientHandler.instance().getClient().fontRenderer.drawStringWithShadow(String.format("%.2f", weight), 0, 0,16777215); } } } Edit: Nvm i got it working!
  7. So how do check the phase? is it just Phase.START? When i use: if(event.type == RenderGameOverlayEvent.ElementType.EXPERIENCE) It just replaced the experience bar...
  8. This is what i have under the Render event: FMLClientHandler.instance().getClient().fontRenderer.drawStringWithShadow(String.format("%.2f", weight), 0, 0, 16777215); NOW, its my understanding i need to only render at a certain phase, because currently it does not display the value of weight, which is for sure being set because my debug shows it! So something not right, whats the setupup for a phase, i know so far its "event.getPhase() == something" but im not sure about the something! Any tips or links to lead me in the right direction?
  9. That worked thanks a ton! How would i go about updating it when I need to/every tick? Its going to display my armor weight value.
  10. Registered it with: FMLCommonHandler.instance().bus().register(new ModEventHandler()); Check the element type? I'm a bit new to the minecraft source, can you give me a quick dirty rundown on that? I'm running 1.7.10 btw.
  11. It seems my RenderGameOverlayEvent isn't rendering, I basically just wanna render a string once the player enters the game: @SubscribeEvent public void onOverlayRender(RenderGameOverlayEvent.Post event) { FMLClientHandler.instance().getClient().fontRenderer.drawStringWithShadow("Yooooooo", 0, 0, 16777215); } It should be working, but it doesn't, hmm.
  12. Hey, I've done a little looking around on AttributeModifier, and i don't quite understand how to use it. I'm commonly seeing these three lines pop up in descriptions: AttributeModifier attributemodifier = (AttributeModifier)entry.getValue(); attributeinstance.func_111124_b(attributemodifier); attributeinstance.func_111121_a(new AttributeModifier(attributemodifier.func_111167_a(), this.getName() + " " + par3, this.func_111183_a(par3, attributemodifier), attributemodifier.func_111169_c())); Also what are all the func_#####? I know what they /are/ but not what specific ones are, or where to find out what they all are, it always takes me forever to dig around enough to figure it out. Also bonus points if you can explain why the hell functions are called numbers and not by a name that told people what they do, like what is the advantage to that?
  13. Thanks for the advice! Do you have any links or tips for getting started with NBT's, they sound kind of intimidating ahaha.
  14. Hmm, I was told that could cause problems down the road when handling server side and such. EDIT: Ok well that seems to have solved that error, any idea on why we're getting an error on ticking the player? EDIT2: appears to be saying player is null, but i cant figure out why... A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at MinecraftRPGOverhaul.events.ModEventHandler.onEntityUpdate(ModEventHandler.java:17) at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_ModEventHandler_onEntityUpdate_PlayerTickEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:138) at cpw.mods.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:345) at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:259) -- Player being ticked -- Details: Entity Type: null (net.minecraft.entity.player.EntityPlayerMP) Entity ID: 193 Entity Name: Player163 Entity's Exact location: -118.09, 72.00, 251.67 Entity's Block location: World: (-119,72,251), Chunk: (at 9,4,11 in -8,15; contains blocks -128,0,240 to -113,255,255), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Entity's Momentum: 0.00, -0.08, 0.00 Stacktrace: at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:330) at net.minecraft.network.NetHandlerPlayServer.processPlayer(NetHandlerPlayServer.java:329) at net.minecraft.network.play.client.C03PacketPlayer.processPacket(C03PacketPlayer.java:37) at net.minecraft.network.play.client.C03PacketPlayer$C06PacketPlayerPosLook.processPacket(C03PacketPlayer.java:271) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) -- Ticking connection -- Details: Connection: net.minecraft.network.NetworkManager@5cb42fdf Stacktrace: at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
×
×
  • Create New...

Important Information

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