
Thornack
Members-
Posts
629 -
Joined
-
Last visited
Everything posted by Thornack
-
[1.7.10]How would I check if the players inventory is open?
Thornack replied to starwarsmace's topic in Modder Support
I guess to clarify how would you check whether or not a specific slot in the players HUD inventory bar does not contain an item. And -- if and only if this specific slot doesnt contain an itemstack (ie is empty where itemstack is null) then add an item to that specific slot. Ive been stumped by this for a while. -
I have an event that gives the player a series of items on player log in but I want each item to go into its own unique and specific slot in the player HUD inventory if and only if the specified slot is empty and if there is a different item already in that slot then I dont want to give the player my item. What is weird is that for the code below kind of works but the first item adds to slot 1 no problem but the other 2 are not added at all. Does anyone know why? And is there a way to achieve this that works? My PlayerLoggedInEvent
-
[1.7.10]How would I check if the players inventory is open?
Thornack replied to starwarsmace's topic in Modder Support
I played around with this and was wondering, how would you check for the players HUD inventory bar being open in survival mode and specifically check for a slot number and whether or not it contains an item -
I want to give the player in survival mode a series of items when the player logs in and when he spawns after death. So far I have tried the following but it doesnt do anything @SubscribeEvent public void onJoinWorld(EntityJoinWorldEvent event) { if (event.entity instanceof EntityPlayer && !event.entity.worldObj.isRemote) { PacketOverlord.sendTo(new PacketSyncPlayerStamina((EntityPlayer) event.entity), (EntityPlayerMP) event.entity); //System.out.println("This is called # 1"); if(Minecraft.getMinecraft().thePlayer != null && Minecraft.getMinecraft().currentScreen instanceof GuiInventory){ //System.out.println("This is not called"); Minecraft.getMinecraft().thePlayer.inventory.addItemStackToInventory(new ItemStack(CommonProxy.itemCustom1)); }} } Not sure what Im doing wrong
-
Hi, I have a custom HUD stamina bar and i want to make it stay in place. By stay in place I mean like the Health bar stays in place no matter what size the screen is, no matter what your computers resolution the health bar stays in place relative to the minecraft window. How would you achieve this. I know how to position it using the width and height but I want this position to adjust itself when the user resizes the minecraft window when not in full screen and when going to full screen also so that it looks as if the HUD is in the same place relative to everything else.
-
Ok I figured out how to add it back in works well now and the food event is cancelled @SideOnly(Side.CLIENT) public class GUIStaminaBar extends Gui { private Minecraft mc; private static final ResourceLocation texture = new ResourceLocation("staminamod:textures/gui/BasicLockBackground.png"); public GUIStaminaBar(Minecraft mc) { super(); this.mc = mc; //System.out.println("this is called"); } @SubscribeEvent(priority=EventPriority.NORMAL) public void onRenderFoodBar(RenderGameOverlayEvent.Pre event) { if (event.type == ElementType.FOOD) { event.setCanceled(true); return; } if (event.type != ElementType.FOOD) { return; } } @SubscribeEvent(priority=EventPriority.NORMAL) public void onRenderExperienceBar(RenderGameOverlayEvent.Post event) { if (event.type != ElementType.EXPERIENCE) { return; } // render the custom HUD }
-
This worked it got rid of the food Hud @SubscribeEvent(priority=EventPriority.NORMAL) public void onRenderFoodBar(RenderGameOverlayEvent.Pre event) { if (event.type == ElementType.FOOD) { event.setCanceled(true); return; } if (event.type != ElementType.FOOD) { return; } [EDIT] BUUT Now it cancelled my Stamina Bar also. Im not sure how to fix this
-
How would I go about doign that I have tried @SubscribeEvent(priority=EventPriority.NORMAL) public void onRenderFoodLevelBar(RenderGameOverlayEvent.Pre event) { if(event.type.equals(ElementType.FOOD)) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); } and it doesnt turn the elements invisible and I still get the health bar changing to the weird symbols along with the other bars
-
When I try @SubscribeEvent(priority=EventPriority.NORMAL) public void onRenderFoodLevelBar(RenderGameOverlayEvent.Pre event) { if (event.type.equals(RenderGameOverlayEvent.ElementType.FOOD)) { event.setCanceled(true); return; } } to cancel the food GUI bar it also cancels the health bar and replaces them with glitchy looking textures a green one on top of weird white one
-
ok i kind of went a different route im abandoning the food stats route. But i do have a question how would you cancel the render player food gui event
-
Yes I know what youre trying to achieve I have read your threads. I suggest you go through his tutorials from the beginning to the end. He talks about renderers and how to register them properly and how to register entities and what not
-
Hi Everybody, Thanks to everyone who helped achieve the effect. But I want to take this further and will end up posting all working code after it is finished since this seems like excellent functionality that is very versatile for combat/mining/other minecraft activities First off I have figured out a way to increase the players "stamina" past Vanilla max food level of 20 by using saturation. This is a workaround that I am trying out. I do have a question. I have zero experience using RenderGameOverlayEvent. Is it possible to use this event to render a custom GUI that would represent a live picture of the players current and max (Food Level + Saturation Level) which would be used to represent the players stamina? In the code below I set (Food Level + Saturation Level) = (20 + 100) = 120 total possible stamina. My goal is to render a GUI stamina bar that makes this value the max stamina but I want this to be dynamic so that if I change the total possible stamina the gui also changes its max. Does anyone have any tutorials on replacing vanilla GUI's using RenderGameOverlayEvent? Second, I wish to eventually make it so that the stamina bar can be upgraded through some action in game by levelling up the player. I am still working on the stat system for this but was wondering if anyone has any suggestions as to a good system for achieving this upgrade ability. I was thinking of maybe using a list of boolean values such as the "staminaLevel(whatever)Reached" boolean values seen in my class below and just having a long list of cascading if statements that determine how much saturation you get to have as a max value per level you reach and somehow use packets to set these booleans to true when each level is reached. But this seemed tedious, repetitive coding and poorly designed since I would have one if statement per level containing the same code with the exception of containing a int maxAllowedSaturationLevel = that varies per level. so I dont think I am going to use that route. Im not sure how to implement this upgrade feature of the stamina bar. if you have any suggestions/ ideas please post them below. Any ideas/suggestions will be greatly appreciated! The console displays the following (I have added comments to the console output after the fact to describe what was occurring at each point in time [Note**these comments are preceded by /** and end with a */])
-
It seems to work perfectly now public class EventPlayerHungerUpdate { private int tick ; @SubscribeEvent public void incrimentHungerBar(PlayerTickEvent event) { tick = event.player.ticksExisted ++; int divisor = 20; World world = event.player.worldObj; if ((tick % divisor == 0 && event.phase == event.phase.END && !world.isRemote)) { System.out.println("Adding Food Each Tick"); if ((!(event.player == null)) && (event.player.getFoodStats().getFoodLevel() < 20)) { event.player.getFoodStats().setFoodLevel(event.player.getFoodStats().getFoodLevel() + 1); } } } }
-
Look up Neale Gaming on Youtube. His series should teach you what you need. Id recommend watching all of his videos though. https://www.youtube.com/user/nealegaming
-
This seems to work buut the ticking doesnt happen often, I want it to update the hunger bar once/sec and it doesnt since the server ticks dont seem to almost ever occur. Is this frame rate dependant the way it is. And how could I get the correct ticks public class EventPlayerHungerUpdate { private static int tick = 0; @SubscribeEvent public void incrimentHungerBar(PlayerTickEvent event) { tick++; int divisor = 20; World world = event.player.worldObj; if ((tick % divisor == 0 && event.phase == event.phase.END && !world.isRemote)) { System.out.println("Adding Food Each Tick"); if ((!(event.player == null)) && (event.player.getFoodStats().getFoodLevel() < 20)) { event.player.getFoodStats().setFoodLevel(event.player.getFoodStats().getFoodLevel() + 1); } } } }
-
@SubscribeEvent public void incrimentHungerBar(PlayerTickEvent event) { tick++; int divisor = 20; if ((tick % divisor == 0)) { // System.out.println("Adding Food Each Tick"); if ((!(event.player == null)) && (event.player.getFoodStats().getFoodLevel() < 20)) { event.player.getFoodStats().setFoodLevel(event.player.getFoodStats().getFoodLevel() + 1); } } } } Seems to work but there is a weird issue, when I switch from creative mode to survival mode in game the hunger bar saves. when I log out while in survival mode and log back in the saving breaks. Does anyone know why. [EDIT] Also sometimes it saves properly and other times it does not
-
When I try @SubscribeEvent public void incrimentHungerBar(PlayerTickEvent event) { tick++; int divisor = 20; if ((tick % divisor == 0) && !event.player.worldObj.isRemote) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; // System.out.println("Adding Food Each Tick"); if ((!(player == null)) && (player.getFoodStats().getFoodLevel() < 20)) { player.getFoodStats().setFoodLevel(player.getFoodStats().getFoodLevel() + 1); } } } The same thing happens and if i add @SideOnly(Side.SERVER) and remove the && !event.player.worldObj.isRemote bit the method doesnt seem to be called at all
-
Hi Everyone, I am trying to implement a stamina bar that replenishes over time and is used up while using an item (I have the item part figured out where on right click the item adds exhaustion to the player using the player.addExhaustion(); method). I have decided to use Minecraft's Default Hunger Bar to achieve this stamina bar effect but have run into problems. My event class updates the bar each tick increasing the food level (you can see the gui update more meat stick things are added each tick until it is full) but this isnt saved for some reason where the next tick the hunger level goes back to the level it was before. This is made apparent when hunger reaches 0 and the bar updates until it shows it is full and then becomes 0 the next tick. Question 1) does anyone know what my mistake is and why the food level doesnt seem to be saved? The class is below My event class Question 2) Is there a way to change the maximum hunger level that is allowed (currently this is 20) but lets say I want to increase it to 21 or 22 or 23 depending on the players exp for example.and If so How would you do it? Question 3) Is there a way to change the default Hunger GUI? and If so How? Question 4) If it isnt possible to change the maximum amount of hunger level or the GUI texture for the hunger level does anyone know how to create a custom hunger bar and could you point me in the direction to create one. Any help/input is appreciated
-
Hi Everyone, I am looking at adding functionality to minecraft that would allow the player to become an entity that exists in the world. I have an EntityCustomZombie that has custom stats (custom HP,Attack,defence,speed etc etc... Where each object of the EntityCustomZombie has a unique combination of these stats. I want to create an item that if the player right clicks on the zombie object the player becomes that zombie and inherits all particular stats that are associated with that instance of the EntityCustomZombie, while leaving the player model behind in a stationary spot at the location where you clicked on the zombie. I want this to be reversible so that as a zombie you can click on the players body and leave the zombies body and enter your own again leaving the zombie entity intact. Essentially I want the Zombie to keep all of its particular attributes throughout the entire process where just its movement/controls/cameraview are changed to those of the entity player. Does anyone think this could be achieved and if so any ideas as to where to start? I know that you can replace the player model but I want more than just a simple model replace essentially I want to turn the player into a being that can mind control other entities at will and end the mind control to return them into their original state.
-
[1.7.10] spawining an entity at precise world coordinates
Thornack replied to Thornack's topic in Modder Support
Ya The ray trace problem you mentioned seems to be my issue. Im not sure your method is precise enough either -
Hi everyone, I am looking to spawn an entity at precise world coordinates on top of a block to within (xCoord +or- 0.1, yCoord +or- 0.1,zCoord +or- 0.1) where xCoord is the world coordinate of each block. currently I do my spawning like this but it is pretty inaccurate as the entity doesnt spawn where the + on the screen (that represents the mouse) points. is there a more accurate way of doing this using the mouse position maybe and running the same sort of checks as found in my if statement. My goal is to only spawn my entity if a non air block is selected, and the raytrace hits a block or entity and isnt null. Also it is important for the raytrace to have a changeableRange that can be altered to represent a max distance away from the player at which the entity can be spawned. Does anyone know of a more accurate way that this could be done so that I could spawn an entity at block coordinates of example (xCoord =312.1, yCoord = 1, zCoord = 454.3) or more generically(xxx.u, 1, zzz.v) where xxx and zzz represent the integer block coordinate and u and v represent the decimal places and can have a value of 0-9 so you can spawn the entity at (xCoord = 312.1 or 312.2 or 312.3...and so on up to... 313.0, yCoord = 1, and zCoord =454.1 or 454.2 or 454.3...and so on up to... 455.0) as determined by where the + on the screen (that represents the mouse) points so that if (for example) it points 0.4 position units along the x axis of a block and 0.2 units along the z axis of a block that is where the entity will spawn (1 block above this point on the x/z plane). (hopefully I have clearly described the functionality i am searching for)
-
[1.7.10] Spawning Custom Particle Crashes the game
Thornack replied to Thornack's topic in Modder Support
it was a registering issue, now solved Thanks everyone! and yes it works now -
[1.7.10] Spawning Custom Particle Crashes the game
Thornack replied to Thornack's topic in Modder Support
I am truly stumped by why the ,method is not being called when I provide an if(worldObj.isRemote) check arent showing up. Any ideas are appreciated