Jump to content

Thornack

Members
  • Posts

    629
  • Joined

  • Last visited

Everything posted by Thornack

  1. I am pretty much stuck. Im not sure how to get my Inventory to show up in the player HUD. Any ideas? My classes are posted just above this post
  2. Im trying something out here. Although Im having some trouble atm. Im trying to just add my inventory in with the hotbar rendering being cancelled out. The Inventory Class The Container Class The Gui Class Im not sure if I set everything up correctly but those are my classes. Now, How would I get the Inventory to be open as a hotbar. Im not sure how to do this. I know it will probably require use of the RenderGameOverlayEvent.Pre and .Post I think but I am unsure how to get it to work. I cancel the default Hotbar but I am unsure how to insert mine in.
  3. If I do @SubscribeEvent public void guiOpened(GuiOpenEvent event) { if(event.gui==null) return; if(event.gui instanceof GuiContainer){ System.out.println("FIRED GUI INVETORY OPEN" + Minecraft.getMinecraft().thePlayer); if(!Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode){ event.setCanceled(true); return; //open custom GuiInventory } } } also if I try to replace event.gui instanceof GuiContainer with event.gui instanceof GuiChest or event.gui instanceof GuiCrafting I get crashes also. There has to be a better way to disable the players inventory than this. this is very hacky and basically requires you to do the following ridiculous if statement-> But this crashes the ridiculous if statement @SubscribeEvent public void guiOpened(GuiOpenEvent event) { if(event.gui==null) return; if(event.gui instanceof GuiInventory || event.gui instanceof GuiFurnace || event.gui instanceof GuiCrafting|| event.gui instanceof GuiChest ||event.gui instanceof GuiBeacon || event.gui instanceof GuiBrewingStand || event.gui instanceof GuiDispenser || event.gui instanceof GuiScreenHorseInventory ){ System.out.println("FIRED GUI INVETORY OPEN" + Minecraft.getMinecraft().thePlayer); if(!Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode){ event.setCanceled(true); return; //open custom GuiInventory } } } I get this crash for container, chest, crafting table, enderchest seems to work for cancelling the gui for furnace, dispenser, dropper, main inventory, and beacon but crashes on chest, crafting table, enderchest.. etc
  4. Any idea how to disable use of the items in your HUD Inventory. I know how to stop the inventory from rendering but you can still use the items in the hotbar. I need to disable this functionality and pair the hotbar keys to access my custom HUD Inventory.
  5. Im not sure if this is going to work for me. It cancels opening of the inventory throgh use of the E key but it still allows access to the items I am holding/using and I need to block that also. I think it also has the issue of if I click on any container my inventory wills till show up and I need that blocked aswell. Can you use the onInteract Event to block the inventory in all of the cases where if the player clicks on a container or a chest or a furnace etc etc it will block the inventory as well as if the player tries to open it witht he E key? @SubscribeEvent public void guiOpened(GuiOpenEvent event) { if(event.gui==null) return; if(event.gui instanceof GuiInventory){ if(!Minecraft.getMinecraft().thePlayer.capabilities.isCreativeMode){ event.setCanceled(true); return; //open custom GuiInventory } } }
  6. Hmm Ok, I will do be researching this for the next little bit, ill post if I find something better. If anyone else has any ideas Id love to hear about em.
  7. hmm, I like your idea with checking for the instanceof Gui Inventory. I dont want my mod compatible with other mods, its a stand alone mod and it already isnt compatible due to its complexity at this point haha so I just want as easy of a solution as i can get.
  8. This cancels the rendering of the hotbar, which is what I already know how to do, but I need to disable access to it completely (I need all access to the players normal inventory blocked off when a certain condition is true and only allow access to my custom inventory at this time/ render it at this time). But if my condition is false I need the player to only have access to his original inventory (with all behind the scenes item mechanics and everything preserved in both cases). @SubscribeEvent(priority=EventPriority.NORMAL) public void onRenderPre(RenderGameOverlayEvent.Pre event) { if (event.type == ElementType.HOTBAR) { event.setCanceled(true); return; } }
  9. Ok, Ill try that, Im just not sure how to cancel access to the players main inventory (the one that displayes when you hit E btn in survival mode) or how to then add my custom one to the player. I havent ever worked with inventories so all of this is a bit new to me.
  10. Hi Everyone, I Want to change the HUD inventory Element temporarily based on a condition (whether or not my player is morphed into his party member or not). So that when my condition is true the player gets a new inventory with a reduced # of slots and a custom gui for it, and when it is false he gets hic original inventory back. I also want to disable access to the players main inventory when my condition is true. Basically if(x == true) { Temporarily disable access to players current inventory and give player new custom inventory } else if (x == false){ Temporarily re-enable access to players original inventory and disable access to custom inventory } I know how to disable the HUD but im not sure how to disable access to the main inventory for the player. Also Im not sure how to add a custom inventory to the player. So far I have the following. Inventory Class Container Class Basically I want to do this so that in the case demoed by the left image player has access to all his items. In case demoed by the right image player only can use the items in the 4 new slots that are displayed. and I want the two cases to be swappable so that when my condition changes the inventories are swapped out
  11. Ive been looking into this also and it isnt easy, when you come up with a solution id love to hear about it. I dont think camera movements are easy
  12. My code above works except for speed. I know I ave to set it on client side but whenever my player sprints the speed is reset. I need a way to fix this. player.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(myCalculatedValue); <- works but it resets itself when you sprint
  13. So far I have written an inventory class. Im not sure how to add it to my entities in a way so that it becomes transferrable between my player and the entity because I have a method that swaps the player and entity so that the player becomes the entity and the entity becomes the player. Their models swap, positions swap, textures swap, and stats will also swap. But i need to be able to get the inventory from my entity that is full of items and give it to the player upon morph so that he can use it during morph. If he picks up an item while morphed and then morphs back i want the entity to get the inventory from the player containing the new items and i want it to be able to use them. unsure where to go next. public class InventoryCustom implements IInventory{ private final String inventoryName = "customInventory"; public static final int INV_SIZE = 4; ItemStack[] inventory = new ItemStack[iNV_SIZE]; public InventoryCustom(){ } @Override public int getSizeInventory() { return inventory.length; } @Override public ItemStack getStackInSlot(int slot) { return inventory[slot]; } @Override public ItemStack decrStackSize(int slot, int amount) { ItemStack stack = getStackInSlot(slot); if (stack != null){ if (stack.stackSize > amount){ stack = stack.splitStack(amount); if (stack.stackSize == 0){ setInventorySlotContents(slot, null); } }else{ setInventorySlotContents(slot, null); } this.markDirty(); } return stack; } @Override public ItemStack getStackInSlotOnClosing(int slot) { ItemStack stack = getStackInSlot(slot); if (stack != null){ setInventorySlotContents(slot, null); } return stack; } @Override public void setInventorySlotContents(int slot, ItemStack itemStack) { this.inventory[slot] = itemStack; if (itemStack != null && itemStack.stackSize > this.getInventoryStackLimit()){ itemStack.stackSize = this.getInventoryStackLimit(); } this.markDirty(); } @Override public String getInventoryName() { return inventoryName; } @Override public boolean hasCustomInventoryName() { return inventoryName.length() > 0; } @Override public int getInventoryStackLimit() { return 1; } @Override public void markDirty() { for (int i = 0; i < this.getSizeInventory(); ++i){ if (this.getStackInSlot(i) != null && this.getStackInSlot(i).stackSize == 0){ this.setInventorySlotContents(i, null); } } } @Override public boolean isUseableByPlayer(EntityPlayer player) { return true; } @Override public void openInventory() { } @Override public void closeInventory() { } @Override public boolean isItemValidForSlot(int slot, ItemStack itemStack) { return false; } public void loadInventoryFromPlayer(EntityPlayer player){ NBTTagCompound nbtCompound = player.getEntityData(); if(nbtCompound != null){ NBTTagList nbtTagList = nbtCompound.getTagList("customInventory", 10); this.loadInventoryFromNBT(nbtTagList); } } //save the player's PC inventory to NBT public void saveInventoryToPlayer(EntityPlayer player){ NBTTagCompound nbtCompound = player.getEntityData(); NBTTagList nbtTagList = this.saveInventoryToNBT(); nbtCompound.setTag("customInventory", nbtTagList); } //load,save to NBT copied from minecraft chest code public void loadInventoryFromNBT(NBTTagList par1NBTTagList) { int i; for (i = 0; i < this.getSizeInventory(); ++i) { this.setInventorySlotContents(i, (ItemStack)null); } for (i = 0; i < par1NBTTagList.tagCount(); ++i) { NBTTagCompound nbttagcompound = par1NBTTagList.getCompoundTagAt(i); int j = nbttagcompound.getByte("Slot") & 255; if (j >= 0 && j < this.getSizeInventory()) { this.setInventorySlotContents(j, ItemStack.loadItemStackFromNBT(nbttagcompound)); } } } //load,save to NBT copied from minecraft chest code public NBTTagList saveInventoryToNBT() { NBTTagList nbttaglist = new NBTTagList(); for (int i = 0; i < this.getSizeInventory(); ++i) { ItemStack itemstack = this.getStackInSlot(i); if (itemstack != null) { NBTTagCompound nbttagcompound = new NBTTagCompound(); nbttagcompound.setByte("Slot", (byte)i); itemstack.writeToNBT(nbttagcompound); nbttaglist.appendTag(nbttagcompound); } } return nbttaglist; } }
  14. Hi everyone, Does anyone know how you would go about giving a custom mob a usable storage? By usable i mean if this mob picks up a sword, an axe and a bow/arrows it can use its ai to switch weapons at whim and attack the player using those items. Im not sure where to start with this one. I will be researching this/ trying to accomplish it for the next little while and will post any progress I make Any input/ideas/tutorials/info is appreciated thanks
  15. lol i guess that was my bad, in my case the player is always you, so it works from client side. Maybe thats why iI didnt notice #2 thanks for the tip
  16. Hi everyone, I have noticed that some people have been having trouble with sending chat messages. These are the methods I use, they are pretty simple SERVER SIDE ONLY - works both on integrated and dedicated server String message = EnumChatFormatting.RED + "CUSTOM MESSAGE"; sendMessageToPlayer(player,message); public void sendMessageToPlayer (EntityPlayer player, String message){ if(message != null && !player.worldObj.isRemote){ player.addChatMessage(new ChatComponentText(message)); } } CLIENT SIDE only simple remove the !player.worldObj.isRemote //bit in the above public void method and the rest is the same and this would work inside a gui for example --------------------> Thank you btn is that a way and up ish
  17. Some more info, I have a player and he has a party from which he can spawn entities in his party and swap places with them (literally he morphs into the entity and the entity morphs into him) The models swap, the positions swap, and everything works great on dedicated server and client and integrated server where other players can see the swap occur and the player essentially becomes the party member he chose to morph into. Now I need their stats to be set properly and then I need to trigger their swapping correctly inside my morph method (that part will be easy once I set them properly). so far I tried setting my stats for the player when he morphs in the following way. Pseudocode as my morph function is complicated but essentially I do the following ... if(shouldBeMorphed){ player.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(morphEntity.stats.maxHP); player.setHealth(morphEntity.stats.currentHP); player.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(morphEntity.stats.currentAtt); //then I send a packet so that the speed can be changed client side only as all of the above occurs server side only } ... Is this the proper way to do this or should I use attribute modifiers and if so how do you go about using those correctly.
  18. post the java code you have so far and give a more specific question. No one will do the work for you. So what does your ai look like, have you started writing one? etc etc
  19. Hi everyone, So I have a system of stats where I calculate them when an entity is spawned into the world. Then these stats are persistent afterwards but differ from one instance of my entity to another (i introduce randomness to simulate genetic diversity basically). For my stats I have attack, defense, maxHp, currentHP, maxSpeed, and currentSpeed. Now I know that Minecraft has SharedMonsterAttributes.attackDamage SharedMonsterAttributes.followRange SharedMonsterAttributes.knockbackResistence SharedMonsterAttributes.maxHealth and SharedMonsterAttributes.movementSpeed I need to set my stats to be the same as minecrafts stats. ie if i calculate HP to be = 10 then minecraft HP should also be 10 or 5 full hearts since from what I understand 1 heart = 2HP? My stats should determine what the minecraft stats are. What would be the best way of doing this, Ive heard of using attribute modifiers but im not really sure I understand the concept of how to use them. Does anyone have any useful info on this concept, This may seem trivial but i want to make sure i do it properly so I dont get any weird behaviours where my entity calculated stats differ from minecraft stats some of the time in unpredictable ways. Also, as a side how do you set armour amount i havent been able to find that out yet.
  20. ya it seems to only occur on my laptop. Im not sure why but on my desktop i never get this error.
  21. Hi everyone, I get this error occurring randomly during gameplay. i havent been able to pinpoint a cause for it and dont know what/when it gets triggered. Any ideas what would cause this/ How to fix? Ive heard that reinstalling the graphics card drivers fixes this error since I am on a laptop but I am unsure about this
  22. I think I know what the issue is. How would you add a pickup delay for an EntityItem. I think this will fix the issue
  23. Anyone know what would cause this here is the error log. I keep getting this exception when running a dedicated server and it happens sometimes during gameplay. I cannot seem to get it to occur on a consistent basis
  24. Hi everyone, I have an entity which changes its model to become the player when my player becomes this entity. Essentially swapping places where the entity gets the players model and the player gets the entities model (among other things). All of this works fine and the entity knows when to morph into the player based on a boolean that is updated by the player. This boolean is true when my entity is in its morphed state (it is the player). I want to make the entity invincible while this boolean is true and not invincible when the boolean is false. Seems pretty simple but I am not sure what a good way to go about this would be. Any ideas. Thornack
×
×
  • Create New...

Important Information

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