Jump to content

scoob27

Members
  • Posts

    12
  • Joined

  • Last visited

Everything posted by scoob27

  1. Lol !!! Thank you
  2. Thanks Ernio, that was the problem. Everything is working perfectly now. Just a question though : According to your suggestion i add an if(!world.isRemote) statement around my armor = null so that will be executed on the server side but before i did that there was nothing to tell where the code should be executed. In that case shouldn't it been executed on both side and so worked like i wanted ? Anyway thanks
  3. Yes and it works but it is only temporary since when I quit the game and reconnect the armor is still in the slot as if it was never destroyed. In fact it looks like it's a little bit more complex. Here it's what happened : 1) My inventory is completely empty. I take one piece of the armor in creative and go back to survival 2) I right-click the armor to equip it so it gets in the armor slot and disappears from the hotter 3) I go over the authorized limit and the armor breaks 4) I fall on the ground but don't take any fall damage (which is strange) 5) I log out and reconnect -> The armor is both in the armor slot and the hot bar as if i've never used it... Do you have an idea of what can cause that ?
  4. The second line will cause a NPE. I haven't try it but i also think it would cause a NPE since null is not an itemStack even if you cast it. Well since it worked for crackedEgg I will try it but I am not very hopeful EDIT : As expected i got a nullPointerExeption... I guess you were lucky somehow
  5. Hi everyone, I'm trying to make an armor (chest plate) which destroys itself when the player wears it and goes over a certain distance from the ground. To do so i create a fonction which calculates the distance between the player and the ground (i don't think there is a in-game method() that already exists. Am I right ?) Then I tried to make the chest plate to destroy itself and that is where i got some difficulties. First I look for a method which destroys the armor but didn't find one. Then i tried to use the setDamage method from ItemStack : So when I tried and got too high the armor got fully damaged (its bar is completely empty) but the armor was still in its slot. I also tried to use this.getMaxDamage()+1 but the result was the same. Then I tried the hard way and replace player.inventory.armorItemInSlot(2).setItemDamage(this.getMaxDamage()); with player.inventory.armorInventory[2] = null; It actually worked and the armor disappeared when I went over the limit but when I tried to disconnect and reconnect the armor was back in its slot... I thought that the armor = null was only working in the client side and tried to send a packet to the server (using ByteBufUtils.writeItemStack() with the new value of the slot but I realized it was stupid because the server would only receive "null" and won't know what it refers to. So unless i can send the player with it it won't work. I saw in the ByteBufUtils that there is a method to convert NBTT tag. So if I use a tag to store the player variable and send this tag in that packet with the new value do you think it would work ? But with all that I feel like using a sledgehammer to crack a nut... Is there any ways to do it more easily ? Thank you
  6. I wanted to do the same as you. Diesieben07 helped me and i figured out how to make them spawn. Basically i used getMovingObjectPositionFromPlayer(...) that i copied in the class of my item, rename into getDistanceFromPlayer(...) and modified a bit in order to be able to adjust the distance the player can right-click (as diesieben07 suggested) and not the rayTrace(...) which is only client side. Then i test if the world is remote and if not i spawn the lightning. You can have a look at the solution i used at the end of this topic : http://www.minecraftforge.net/forum/index.php/topic,27030.0.html Hope it helps PS : i also think that you should learn Java before trying to create your mod. It will be easier to understand how everything work
  7. Ok it works great now, the entities take damages and are set to fire (the grass not but it's not a big deal) and i can adjust the distance ! Thank you very much For those who are interested, here is my final code to spawn lightning when that player right-clicks an item :
  8. Well for my code it's the same. I just replace the ray method with the one you gave me. By copy, you mean i override the getMovingObjectPositionFromPlayer method right ? I'll try that.
  9. Thanks, it looks like it works I have 2 (minor) questions thought : 1) It appears that in single player i can burn the grass but not in multiplayer. Is there a reason to that ? 2) With the getMovingObjectPositionFromPlayer method it works but only when i right-click near the player. Do you know if there is a way to extend the distance ? If not, no problem, i can still work with that !! Anyway, thank you
  10. Hi everyone, Like Jetfan16ladd i do have a problem when spawning lightnings. In my first try i have successfully spawned lightnings which dealt damages on other entities and put the ground on fire but that only works in single player. When i tried in multiplayer the server crashed. I looked in my code and found that rayTrace(double,float) is client side only. So i tried to use the isRemote() method. The lightning appears in the world but it looks like it's only on the client side so the lighting don't deal any damage or put things on fire. From what i've read the client renders the lightning but it's the server's job to handle the damages (which is logic ). So does someone know how to make the lightning deal damages without crashing the server ? Here is the code i'm using:
  11. Ok, i thought it will be more difficult than that ! Works perfectly ! Thank you very much
  12. Hi everyone, I have an item, which when in the armor slots, allows the player to fly. When the player removes the item he is not able to fly anymore so i disable the player.capabilities.allowFlying in the onLivingUpdateEvent(...) method. No problem with that. But when i do so the player can still fly as long as he doesn't touch the ground. So my question is how can i make the player to fall when he removes the item ? Just like the player falls when he goes from creative to survival while flying. Is there a method i can call or something like that ? Thanks for your help
×
×
  • Create New...

Important Information

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