
Thornack
Members-
Posts
629 -
Joined
-
Last visited
Everything posted by Thornack
-
this doesnt work... not sure what im missing maybe im not good enough at java to know but if youd like to help and know what the issue is then please do @SubscribeEvent public void OnItemPickup(ItemPickupEvent e){ NBTTagCompound caughtEntityNBT = itemStack.stackTagCompound.getCompoundTag("caughtEntity"); String playerName = itemStack.stackTagCompound.getString("playerName"); String mobName = caughtEntityNBT.getString("mobName"); if (!player.worldObj.isRemote){ tryToAddMobToParty(caughtEntityNBT); e.isCanceled(); itemStack = null; e.pickedUp.setDead(); } }
-
Im sorry but what skills might those be, the field is not obvious to me and i apologize for that, i think I have already shown that I know enough java to mod quite successfully. The stuff I am doing is complicated and even the best miss things... which field is the obvious one?
-
that doesnt exist inside EntityItemPickupEvent
-
I guess that is my issue Im not sure how to set it to dead, I have the itemstack and its NBT data and I have access to the player and his inventory but that is where I am stuck. I dont actually know how to get the exact item that I picked up and set it to dead (kinda my original question but i guess i worded it poorly up top). the event has three parameters e.Entity, e.EntityLiving and e.EntityPlayer is the entityItem the e.Entity?
-
Does anyone know how to get the EntityItem instance based off of the itemstack that was picked up?
-
im not sure how to get the EntityItem so that I can set it to dead
-
I get my data from the Itemstack in the following way public void tryToAddMobToParty(NBTTagCompound caughtEntityNBT){ PlayerParty ppp = PlayerParty.get(player); if(ppp.hasFreeSlot() == true){ this.displayChatMessage(EnumChatFormatting.GREEN + "Adding Mob To Party Slot: " + (ppp.getNextFreeSlot() + 1)); ppp.setPartyMember(ppp.getNextFreeSlot(), caughtEntityNBT); ppp.updatePlayerPartyServerToClient(); }else{ this.displayChatMessage(EnumChatFormatting.RED + "Your Party Is Currently Full!!"); } } then inside the pickup event if(e.item.getEntityItem().getItem().equals(CommonProxy.myItem)){ player = e.entityPlayer; ItemStack itemStack = e.item.getEntityItem(); PlayerParty ppp = PlayerParty.get(player); if(itemStack.stackTagCompound != null && itemStack.stackTagCompound.hasKey("caughtEntity")){ NBTTagCompound caughtEntityNBT = itemStack.stackTagCompound.getCompoundTag("caughtEntity"); String playerName = itemStack.stackTagCompound.getString("playerName"); String mobName = caughtEntityNBT.getString("mobName"); if (!player.worldObj.isRemote){ tryToAddMobToParty(caughtEntityNBT); } } }
-
how are you saving your NBT to your itemstack? My item has NBT data associated with it I use this factory method to grab my custom NBT data from my entity and save it to the itemstack public classItemStackFactory { public static ItemStack generateItemStack(EntityCustom caughtEntity, ItemClass itemType, String playerName){ ItemStack item = new ItemStack(itemType); if(itemstackTagCompound == null){ item.stackTagCompound = new NBTTagCompound(); } NBTTagCompound entityCustomNBTCompound = new NBTTagCompound(); caughtEntity.writeToNBT(entityCustomNBTCompound); item.stackTagCompound.setTag("caughtEntity", entityCustomNBTCompound); item.stackTagCompound.setString("playerName", playerName); return item; } }
-
I want the player to pick up my item, this item applies custom data to players IEEP but I want the item to cease to exist after the data has been applied
-
In my event the itemstack persists if i do this, dont know why @SubscribeEvent public void OnItemPickup(EntityItemPickupEvent e){ if(e.item.getEntityItem().getItem().equals(CommonProxy.myItem)){ System.out.println("Event fired"); player = e.entityPlayer; ItemStack itemStack = e.item.getEntityItem(); if (!player.worldObj.isRemote){ //my methods itemStack = null; } } }
-
When I try itemStack = null; the itemstack persists I dont know why
-
Hi everyone, this may be a stupid question but how do you set an itemstack to dead? I havent been able to figure out how to remove my item. I get the item using the item pickup event then I do stuff but I then need to remove the item from the game to clean up. I cant figure it out
-
I figured it out my packet was extending the wrong abstract message class
-
I did a System.out.println( "was pressed? " + wasPressed + "slot? " + slot1 + "slot? " + slot2); inside my constructor and all data appears to equal what it should but the process method isnt called at all in my packet overlord class I use this to send the packet containing my request that says this button was pressed and these were the results take those results. Then I try to validate on server and nothing /** * Send this message to the server. See * {@link SimpleNetworkWrapper#sendToServer(IMessage)} */ public static final void sendToServer(IMessage message) { PacketOverlord.dispatcher.sendToServer(message); }
-
Ok so I have the following public class PacketSyncSwapPartyMembers extends AbstractClientMessage<PacketSyncSwapPartyMembers> { int slot1; int slot2; boolean wasPressed; public PacketSyncSwapPartyMembers() {} public PacketSyncSwapPartyMembers(int slot1, int slot2, boolean wasPressed) { this.slot1 = slot1; this.slot2 = slot2; this.wasPressed =wasPressed; } @Override protected void read(PacketBuffer buffer) throws IOException { slot1 = buffer.readInt(); slot2 = buffer.readInt(); wasPressed = buffer.readBoolean(); } @Override protected void write(PacketBuffer buffer) throws IOException { buffer.writeInt(slot1); buffer.writeInt(slot2); buffer.writeBoolean(wasPressed); } @Override public void process(EntityPlayer player, Side side) { if(wasPressed == true && !player.worldObj.isRemote){ if(slot1 != -1 && slot2 !=-1){ PlayerParty ppp = PlayerParty.get(player); ppp.swapPartyMembers(slot1, slot2, wasPressed); PacketOverlord.sendTo(new PacketSyncPlayerParty((EntityPlayer) entityPlayer),(EntityPlayerMP) entityPlayer); } } }} and inside my GUI I have this code but the server doesnt seem to update the client, my process method doesnt get called not sure why (I have very little experience with packets) else if(button.id == BUTTON_SWITCH_ID){ if(switchBtnPressed == true && firstSelectedSlot != -1 && secondSelectedSlot !=-1){ this.switchSuccessful = true; ppp.swapPartyMembers(firstSelectedSlot, secondSelectedSlot,this.switchSuccessful); PacketOverlord.sendToServer(new PacketSyncSwapPartyMembers(firstSelectedSlot, secondSelectedSlot, switchSuccessful)); this.mc.displayGuiScreen((GuiScreen)null); this.mc.displayGuiScreen(battleMenuGuiPP); firstSelectedSlot = -1; secondSelectedSlot = -1; switchBtnPressed = false; this.switchSuccessful = false; } else if(switchBtnPressed == true && firstSelectedSlot == -1 && secondSelectedSlot ==-1){ }else if(switchBtnPressed == true && firstSelectedSlot != -1 && secondSelectedSlot ==-1){ }else{ switchBtnPressed = true; } pwButton.wasBtnPressed = switchBtnPressed; }
-
Ya ok now that I understand how this works I think then ya pretty easy but I havent found any good tutorials, I think it is part of the reason why people always ask these questions. I think Ill be able to get it maybe
-
Ah ok I assume that is for security purposes, Another question, how would I send the request you mentioned? And I am not sure how to do the deciding bit on the server as I would have to do the deciding bit inside my IEEP class and am not sure how to access the server side player there.
-
I need to be able to update the server player from client side and I am not sure how to do this
-
Hi everyone, I want to update my players IEEP from a gui when the player does something. Specifically, I want to update my players party when the player swaps the position of the party members in his party. Example if i have a party member in slot 1 and a party memeber in slot 2 I want to swap them so that they are reversed. For simplicity I currently use the onItemRightClick method of a generic item to call my swap party members method. If i call my swap method server side then using the following packet everything updates beautifully and is persistent. Now I am not sure what to do when updating the other direction client to server. the swap method in my IEEP class public void swapPartyMembers(int slotOne, int slotTwo){ NBTTagCompound tempSlot = partyNbt[slotOne]; partyNbt[slotOne] = partyNbt[slotTwo]; partyNbt[slotTwo] = tempSlot; PacketOverlord.sendTo(new PacketSyncPlayerParty((EntityPlayer) entityPlayer),(EntityPlayerMP) entityPlayer); } An example of my right click method (pseudo code) public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { //if I use server player and I update my GUI with my packet everything works beautifully if (!world.isRemote){ PlayerParty pp = PlayerParty.get(player); pp.swapPartyMembers(firstSelectedSlot, secondSelectedSlot); } //However I am unsure how to update from client to server (i get a crash) if I call the swapPartyMembers method as it is up top and the consol points to a problem with my packet if (world.isRemote){ PlayerParty pp = PlayerParty.get(Minecraft.GetMinecraft.thePlayer); pp.swapPartyMembers(firstSelectedSlot, secondSelectedSlot); } } My SyncPlayerParty PacketClass public class PacketSyncPlayerParty extends AbstractClientMessage<PacketSyncPlayerParty> { private NBTTagCompound data; public PacketSyncPlayerParty() {} public PacketSyncPlayerParty(EntityPlayer player) { System.out.println("Updating Player Party Sending a Packet"); data = new NBTTagCompound(); PlayerParty.get(player).saveNBTData(data); } @Override protected void read(PacketBuffer buffer) throws IOException { data = buffer.readNBTTagCompoundFromBuffer(); } @Override protected void write(PacketBuffer buffer) throws IOException { buffer.writeNBTTagCompoundToBuffer(data); } @Override public void process(EntityPlayer player, Side side) { PlayerParty.get(player).loadNBTData(data); } } For updating client player I use the following method in my PacketOverlord class I am not sure how to do the reverse of this /** * Sends message to the specified player's client-side counterpart. See * {@link SimpleNetworkWrapper#sendTo(IMessage, EntityPlayerMP)} */ public static final void sendTo(IMessage message, EntityPlayerMP player) { PacketOverlord.dispatcher.sendTo(message, player); }
-
[1.7.10] changing button texture - solved but have questions
Thornack replied to Thornack's topic in Modder Support
thanks alot Ernio your suggestion worked working class public class CustomGuiButton extends GuiButton { public ResourceLocation buttonTexture; public CustomGuiButton(int id, int width, int height, String displayString, String textureName) { super(id, width, height, displayString); buttonTexture = new ResourceLocation("yourmodsnamehere:textures/gui/" + textureName); } /** * Draws this button to the screen. */ @Override public void drawButton(Minecraft minecraft, int xCoord, int yCoord) { if (this.visible) { FontRenderer fontrenderer = minecraft.fontRenderer; minecraft.getTextureManager().bindTexture(buttonTexture); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); this.field_146123_n = xCoord >= this.xPosition && yCoord >= this.yPosition && xCoord < this.xPosition + this.width && yCoord < this.yPosition + this.height; int k = this.getHoverState(this.field_146123_n); GL11.glEnable(GL11.GL_BLEND); OpenGlHelper.glBlendFunc(770, 771, 1, 0); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); this.drawTexturedModalRect(this.xPosition, this.yPosition, 0, 46 + k * 20, this.width / 2, this.height); this.drawTexturedModalRect(this.xPosition + this.width / 2, this.yPosition, 200 - this.width / 2, 46 + k * 20, this.width / 2, this.height); this.mouseDragged(minecraft, xCoord, yCoord); int l = 14737632; if (packedFGColour != 0) { l = packedFGColour; } else if (!this.enabled) { l = 10526880; } else if (this.field_146123_n) { l = 16777120; } this.drawCenteredString(fontrenderer, this.displayString, this.xPosition + this.width / 2, this.yPosition + (this.height - / 2, l); } } } -
Hi everyone, so I have created my own button class where I override the draw button method to insert my own texture. It works but for some reason I cannot pass in a different texture using the constructor. I have to hard code the texture and then it works. I was wondering if anyone could tell me why. This is the constructor that I use inside my GUI class's initGui() method. If I try to pass in my texture name via a string as "Test.png" where my texture is located in my appropriate directory specified by custommod:textures/gui/Test.png then I get the pink/black missing texture texture. To actually change the texture if instead I replace this line then I get my custom texture rendering as the buttons texture. Can anyone explain why I cannot pass in my texture via a string in this way? any help is appreciated
-
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
Figured it out Thanks everybody that space was one issue and I had a type also and the client player being called on server was the main issue i think other than that it works beautifully now -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
in my load method I think the statement if(properties.hasKey("Slot"+i)){} never returns true -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
The tryToAddMobToParty is being called inside my holder entity class (this class has access to the player as it is passed the thrower that threw the previous entity) and I make sure to call tryToAddMobToParty on Server only and when I outprint it it only outprints on Server thread -
[1.7.10] NBT persistent saving issue - adding additional player data
Thornack replied to Thornack's topic in Modder Support
Before catching 1 entity all my slots are null which is expected After catching 1 entity all slots seem to be given data which is weird Id expect only slot 0 to get data and the rest to be null After catching second entity all slots are again given data but why does it outprint {Slot 0:{.....NBT Data...... shouldnt this be {Slot 1:{.....NBT Data...... since at this point we should be filling slot 1 and not slot 0 If I catch a third entity then the following weirdness happens. next to PROP 0 this gets printed {Slot 0:..., next to PROP 1 this gets printed {Slot 0:... but PROP 2,3,4, and 5 get {Slot 2:... if I catch a fourth entity then next to PROP 0 there is a {Slot 0:..., next to PROP 1 there is a {Slot 0:... next to PROP 2 this gets printed {Slot 2:... but next to PROP 3,4, and 5 {Slot 3:... gets printed. Its unexpected I would think that the data would only get placed into the first slot and the rest be null but apparently the entire array is populated each time starting at whichever slot was not populated last. Now for the loadNBTData stuff... After I relog then log back on after having caught 1 entity the consol shows the following but at this point when I hit escape to save again then everything becomes Null again and my entity is lost... even though my entity loaded it doesnt seem to get resaved... This is the code that was responsible for the outprints up top @Override public void saveNBTData(NBTTagCompound compound) { NBTTagCompound properties = new NBTTagCompound(); for(int i=0; i < NUM_SLOTS; i++){ System.out.println("Before setting tag "+ i + properties); if(partyNbt[i] != null){ properties.setTag("Slot "+ i, partyNbt[i]); System.out.println("After setting tag "+ i + properties); } System.out.println("PROP "+ i + properties); } compound.setTag(EXTENDED_ENTITY_PROPERTIES_TAGNAME, properties); } @Override public void loadNBTData(NBTTagCompound compound) { NBTTagCompound properties = (NBTTagCompound) compound.getTag(EXTENDED_ENTITY_PROPERTIES_TAGNAME); if(properties != null){ System.out.println("PROPERTIES before " + properties); for(int i=0; i < NUM_SLOTS; i++){ System.out.println("PROPERTIES slot " + i + properties); if(properties.hasKey("Slot"+i)){ partyNbt[i] = properties.getCompoundTag("Slot"+i); System.out.println("PROPERTIES after " + i + properties); // doesnt seem to be called not sure why } } } }