Jump to content

Recommended Posts

Posted

Hello modders,

I have a problem with spawning EnitityLightningBolts in the world. When they spawn you can hear them, but not see them.. They didn´t do any damage!

Here is my class(The event is registered and the code gets executed in the right way)

 

  Reveal hidden contents

 

Posted

I tested it and it had the same effect like world.joinjoinEntityInSurroundings(entity). You can hear the lightnings but they are still invisible and do no damage

Posted

Why i have to test this? The method is performed in the world and if it´s on a server the method doesn´t change. Or did I unterstand world.isRemote() wrong?

Posted

Oh, forgot that the singleplayer has an integrated server too. Thanks for your help. But the problem I described above isn´t solved yet!

Posted

Updated code:

 

  Reveal hidden contents

 

I don´t need a test for the world for the method after

if(!blitz_velocity.isEmpty())

because blitz_velocity will be always empty if the world isn´t remote.

Posted

@brandon3055

  Quote
your using setVelocity where you should be using setPosition

I don´t want to that the position of the lightning to the player! I just want that the lightnings travel to the player with setting the velocity from the player to the lightnings.

@diesieben07

  Quote
Also: You are accessing the collections from both threads (client & server). You cannot do that! If they are static fields they will be shared between the two. You have to check with world.isRemote.

Forgot what I said.. Now I updated the code. If there is something in blitz_velocity and world.isRemote return true (==singleplayer) the Hashmap will be cleared. Otherwise the code will be performed.

 

  Reveal hidden contents

 

But the problem still exists.

Posted

I updated all

 

  Reveal hidden contents

 

I now formatted the next by myself instant of the eclipse one. I also added

if(!world.isRemote())

(I think that´s now right!).

I now changed the Objects to other Objects. Before I thought that was a problem with the Hashmap and that it doesn´t can save EntityPlayer or EntityLightningBolts...

You can hear the lightnings but you can´t see them and they do no damage!

Thanks for your patience diesieben07! Today it isn´t my day...

EDIT: I pasted the old code....

Posted

@diesieben07

I am trying to spawn lightnings in the world around the player who has bad karma. The spawnpoints of the lightnings are randomly setted by the class called BlitzGewitter near the player. On the event Tickevent.WorldTick it gets the list and checks if it isn´t empty. Then it spawns the last EntityLightningBolt in the ArrayList<EntityLightningBolt>  in the world, deletes the entity from the list and adds him to another HashMap calles blitz_velocity. Next it checks if blitz_velocity is empty. If not it gets all the EntityLightningBolts in the Map and check if they are dead. If yes they will be removed from the list (I used iterator.remove() to prevent a java.util.ConcurrentModificationError). Else the velocity is setted to the EntityPlayer which is stored as value for the EntityLightningBolt (I want that the lightnings go straight to the player or near him). That´s all!

Posted

Is this right?

 

  Reveal hidden contents

 

I change the 2 for-loops later to another method.

Posted

I have already .lang files but I don´t know how to make that for chat messages. I also need to know if the player´s language is german or whatever(I have .lang files for german and english).

About this I looked in the Internet and found nothing. So can you explain how to get the player´s language and then send him the right translation (server side without minecraft code)?

Posted

Thanks for your help. But now i have another problem:

event.player.addChatMessage(new ChatComponentTranslation("msg.badkarma.txt", new Object[0]));

works, but it isn´t colored anymore.

In the .lang file:

msg.badkarma.txt=You got §1Zeus §fangry! §4NOW FEEL HIS PAYBACK!

§1 = DARK_BLUE; §f = WHITE; §4 = DARK_RED.

In the chat is written:

You got ?1Zeus ?fangry! ?4NOW FEEL HIS PAYBACK!

 

EDIT: Solved the problem. Thread can be locked now!

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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