
Zer0HD2
Members-
Posts
127 -
Joined
-
Last visited
Everything posted by Zer0HD2
-
Regarding custom HUD elements (replacing vanilla)
Zer0HD2 replied to Zer0HD2's topic in Modder Support
@SideOnly(Side.CLIENT) public class GuiHealthBar extends Gui { private Minecraft mc; private static final ResourceLocation texLoc = new ResourceLocation("mchardcore", "textures/gui/health_bar.png"); public GuiHealthBar(Minecraft mc) { super(); this.mc = mc; } @SubscribeEvent public void onRenderHealthBar(RenderGameOverlayEvent.Pre event) { if(event.type == ElementType.HEALTH) { event.setCanceled(true); EntityPlayer player = this.mc.thePlayer; float health = player.getHealth(); float maxHealth = player.getMaxHealth(); int healthBarWidth = (int)(((float)health/maxHealth)*79); int xPos = event.resolution.getScaledWidth() / 2 - 91; int yPos = event.resolution.getScaledHeight() - 40; GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); this.mc.getTextureManager().bindTexture(texLoc); this.drawTexturedModalRect(xPos, yPos, 0, 0, 81, 9); this.drawTexturedModalRect(xPos+1, yPos+1, 0, 9, healthBarWidth, 7); } } } -
Regarding custom HUD elements (replacing vanilla)
Zer0HD2 replied to Zer0HD2's topic in Modder Support
Ah, I did not use the .PRE event. That would be why it was cancelling everything rendered after the health bar. Thanks, I'll give that a try. EDIT: Nope. Still cancels the rendering of everything after the health bar: https://www.dropbox.com/s/r4324mcvd8n2mgw/javaw%202014-06-20%2021-48-19-069.png -
Regarding custom HUD elements (replacing vanilla)
Zer0HD2 replied to Zer0HD2's topic in Modder Support
I am fully aware of that. What I am asking is how to NOT cancel the food bar when you cancel the health bar. I have tried setting canceled to false when the event.type is FOOD, but the food bar is still not rendered. -
Regarding custom HUD elements (replacing vanilla)
Zer0HD2 replied to Zer0HD2's topic in Modder Support
Thanks, but my problem is not cancelling the rendering of the health bar - it's stopping that from cancelling the rendering of the hunger bar. Right now if I stop the health bar from rendering, the hunger bar doesn't render either. I would prefer to implement a custom hunger bar, but I've been unable to get it to display the correct value. What I wanted to know was how to stop the event from cancelling when it renders the hunger bar. -
Regarding custom HUD elements (replacing vanilla)
Zer0HD2 replied to Zer0HD2's topic in Modder Support
That is precisely what I said in my first post. I had it there for testing. I've got the positioning sorted now, anyway. -
Launch fireworks from player's location (and one other small question)
Zer0HD2 replied to Zer0HD2's topic in Modder Support
Yep, I just got this working, thanks. I was being dumb and trying to set the tag compound AFTER creating the EntityFireworkRocket, rather than setting the tag compound to the ItemStack itself. -
Regarding custom HUD elements (replacing vanilla)
Zer0HD2 replied to Zer0HD2's topic in Modder Support
Update: I've figured out the positioning thing. X position from center, Y position from bottom. -
I'm currently working on a mod which will eventually modify a player's maximum health depending on a level, and replace the default GUI element with a custom health bar. I currently have the following working; - Vanilla health bar no longer renders - My custom health bar is rendering (in the center of the screen, this is one of my questions) - My custom health bar is displaying the correct amount of health ((current health / max health) * bar width) However, I have a few problems/questions: Firstly, the hunger bar no longer renders. This is not a huge issue, as I can just make it render manually, but I'd rather not cancel that particular part of the RenderGameOverlayEvent. Is there any way to only cancel the rendering of the health bar, not the hunger bar? Second, how would I go about finding the X and Y coords of the top-left corner of the VANILLA health (and hunger) bar? As in, the location on the screen where it will render. I currently am using event.resolution.getScaledHeight() / 2 (and width for the x position) to get the center of the screen, but thanks to the helpful variable naming in Minecraft's code, I haven't been able to figure out how they get the position on the screen. Lastly, how exactly would I go about updating the player's maximum health, and do I need to store this in their extended properties (and use packets to sync between client and server)? I already have extended properties set up for the levelling system, and can grab the user's properties (level, exp, etc) at any time. Thanks, Zer0
-
I was trying to avoid this response as long as possible, but I really think you should read up more on Java before you try something like this.
-
When you say you only changed that, you did remove the if statement, right? If not, then the setFire() code will only be executed when the mob has a fireModifier of more than 0. Which is never.
-
Try actually setting the fireModifier to a number. Right now you're just getting the fire aspect modifier of the mob which, unless you're adding that to it somewhere in your code that you're not showing us, will be 0.
-
Ah, I didn't realise he was talking about setting the environment on fire, you're right, that would require the onUpdate() method. And Soulas, as I said above, remove the second argument from your attackEntityAsMob() method. You are not overriding the method created in EntityMob.
-
Probably because the method attackEntityAsMob() in the EntityMob class does not have the second argument that you supplied. In other words, you have created a new method, not overridden the existing one.
-
Can he not directly get the target from attackEntityAsMob(), and set fire to that entity? That is, after overriding it properly.
-
That is not how you override a method.
-
Unless you give us the code of what you tried, we can't tell you where you're going wrong.
-
Launch fireworks from player's location (and one other small question)
Zer0HD2 replied to Zer0HD2's topic in Modder Support
I've spent a while looking at this, and I've figured out what some of the NBT tags are (mostly by comparing the code in RecipeFireworks to the crafting recipes on the wiki), but I've still been unable to add them to the firework itself. Does anyone know how this is done? -
You're on the right track, you do have to use the interact method. However, there are a few things you need to do to make this work. First, you need to make it sit on the server side, by checking if the world is remote. Second, you need to add the AI task for sitting. Then you just toggle whether or not it's sitting by using setSitting(!this.isSitting()).
-
Launch fireworks from player's location (and one other small question)
Zer0HD2 replied to Zer0HD2's topic in Modder Support
Thanks, that got the fireworks to spawn. One more thing, do you know how you add the information to the rocket entity for explosion type, flight length, etc? I'm assuming it's something to do with the addInformation() method. -
Launch fireworks from player's location (and one other small question)
Zer0HD2 replied to Zer0HD2's topic in Modder Support
Ah, sorry, I posted the version where I had removed the code. I tried this: EntityFireworkRocket firework = new EntityFireworkRocket(this.player.worldObj); firework.setPosition(this.player.posX, this.player.posY, this.player.posZ); this.player.worldObj.spawnEntityInWorld(firework); By not working, I mean literally nothing happened. -
Launch fireworks from player's location (and one other small question)
Zer0HD2 replied to Zer0HD2's topic in Modder Support
This is the code I use for handling players' levels, exp, etc: And the class which adds exp to players, handles display name changes, etc: -
So I'm making a small levelling system. My original plan was to have fireworks launch when a player levels up, but after a couple of days of code-diving, I've been unable to figure this out. I've narrowed it down (I think) to creating a new EntityFireworkRocket and putting it into the world at the player's location, but have been unable to get it to work. Does anyone know how to do this? Also, as a sidenote, I've also been fairly unsuccessful in getting a mob to spawn only in villages. If anyone has any pointers on that, it would be much appreciated.
-
I have created an abomination (custom entity model)
Zer0HD2 replied to Zer0HD2's topic in Modder Support
Now this I did not know. Thanks so much for that, just adjusted the rotation points of the arms and it's fixed it. LAST UPDATE: Yup. Fixed now, thanks to Jabelar. Just a thought, you might want to put that thing about offsetting the rotation point relative to that of the parents in your tutorial if it's not already on there (not sure, was 3am when I read it). Anyway, the final, less possessed/deformed product: -
I have created an abomination (custom entity model)
Zer0HD2 replied to Zer0HD2's topic in Modder Support
Alright, I'm putting this on a back burner for now and focusing on other things - I just tried a very simple model, just adding one cube to the head of a biped and adding it as a child, but every time I add a child it messes it up in-game -
I have created an abomination (custom entity model)
Zer0HD2 replied to Zer0HD2's topic in Modder Support
Removing the part which rendered each of the children stopped the duplication, but the positions are still all messed up. I'll try what Delpi suggested and see what happens. EDIT: Changing the order in which I create the child parts made no difference: https://www.dropbox.com/s/gfyuvs33ti2c011/javaw%202014-06-13%2018-37-10-886.png