Posted June 23, 20187 yr Well i try to spawn a explosion on the coardinates of the player.. that works pretty well with this: player.world.createExplosion(player, player.getPosition().getX(), player.getPosition().getY() + 1, player.getPosition().getZ(), (float) (level * 0.1), true); *i am spawning it with a keybind* but that wont change if the player rotates ... what i want it to do .. i want it to be always spawned at the right side of the player inside of his right hand .. Edited June 23, 20187 yr by Oscarita25 taking out useless stuff
June 23, 20187 yr Yaw and pitch are angles for rotation. Use Entity#getLookVec to get the vector of where the player is looking to then rotate and translate it until you get the desired result. Edited June 23, 20187 yr by V0idWa1k3r
June 23, 20187 yr Author 2 minutes ago, V0idWa1k3r said: Yaw and pitch are angles for rotation. Use Entity#getLookVec to get the vector of where the player is looking to then rotate and translate it until you get the desired result. thanks i will try that
June 23, 20187 yr Author ahh nooo :I .. i think this would not be any releated to this anymore but i noticed i am spawning the explosion client side and not server side .. how would spawn it server sided?
June 23, 20187 yr Detect the key press client-side then send a packet to the server and spawn the explosion.
June 23, 20187 yr Author thanks .. funny enough i already have a packets .. but i forgot that i could use them to do that
June 25, 20187 yr Author i got the packets working.. now everything or the explosions is server sided what is great.. but the explosion does not do damage... serverPlayer.getServerWorld().createExplosion(serverPlayer, serverPlayer.lastTickPosX + serverPlayer.getLookVec().x , serverPlayer.lastTickPosY + 1, serverPlayer.lastTickPosZ + serverPlayer.getLookVec().z , (float) (amount), true); is this the right way to do it? (this is in my packet handler class... the packet will send the amount of power that is being used) Edited June 25, 20187 yr by Oscarita25
June 25, 20187 yr Author 9 hours ago, Oscarita25 said: is this the right way to do it? (this is in my packet handler class... the packet will send the amount of power that is being used) still not sure about that .. also my explosion still does no damage .... (it should do damage to the entities not the player)
June 26, 20187 yr 21 hours ago, Oscarita25 said: serverPlayer.lastTickPosX Why are you using lastTickPos insread of pos? 21 hours ago, Oscarita25 said: is this the right way to do it? (this is in my packet handler class... the packet will send the amount of power that is being used) As long as you pass your actions to a server thread this is the correct way to do this. Show more of your code preferrably as a git repository so I can debug it myself.
June 26, 20187 yr Author 1 hour ago, V0idWa1k3r said: Why are you using lastTickPos insread of pos? oh that was just me trying .. i should change that.. 1 hour ago, V0idWa1k3r said: As long as you pass your actions to a server thread this is the correct way to do this. Show more of your code preferrably as a git repository so I can debug it myself. i think i am doing that ... and i don't run a git on it right now :I .. but i can give you some more code Here some more code: Message Handler: public class MyMessageHandler implements IMessageHandler<MessageExplosion, IMessage> { @Override public IMessage onMessage(MessageExplosion message, MessageContext ctx) { EntityPlayerMP serverPlayer = ctx.getServerHandler().player; float amount = message.power; serverPlayer.getServerWorld().addScheduledTask(() -> { serverPlayer.getServerWorld().createExplosion(serverPlayer, serverPlayer.lastTickPosX + serverPlayer.getLookVec().x , serverPlayer.lastTickPosY + 1, serverPlayer.lastTickPosZ + serverPlayer.getLookVec().z , (float) (amount), true); }); return null; } } Message: public class MessageExplosion implements IMessage { public MessageExplosion() {} public MessageExplosion(float power) { this.power = power; } float power; EntityPlayer player; @Override public void toBytes(ByteBuf buf) { buf.writeFloat(power); } @Override public void fromBytes(ByteBuf buf) { power = buf.readFloat(); } public float getamount() { return power; } } Here is what class i am using to spawn the explosion public class QuirkExplosive extends Quirk { private static EntityPlayer p; public QuirkExplosive() { super("explosive"); setMaxCooldown(2000); setLevelMinimum(100); setLevelFactor(5); setMaxActivatedTime(1); setLevelUp(new LevelUp(0, 0.99)); setXpPerTick(1/20); } @Override public void onPlayerUse(EntityPlayer player) { p = player; if(aviable) { BnHA.proxy.simpleNetworkWrapper.sendToServer(new MessageExplosion(level * 0.1F)); aviable = false; xp += level * 2.75; } } @SubscribeEvent public static void tick(ServerTickEvent event) { if(!aviable) { cooldown++; if(cooldown >= maxCooldown) { aviable = true; cooldown = 0; } } if(xp >= nextXp) { level++; nextXp = xp * levelFactor; if(p != null) { p.sendMessage(new TextComponentString(TextFormatting.AQUA + "Level Up")); p.sendMessage(new TextComponentString(TextFormatting.AQUA + "Your now level " + level)); } maxCooldown *= levelUp.getCooldownMultiplier(); } } } @V0idWa1k3r if the superclass is relevant i can send it too
June 26, 20187 yr 6 minutes ago, Oscarita25 said: (float) (amount) You do not need to cast a float to a float. 6 minutes ago, Oscarita25 said: BnHA.proxy.simpleNetworkWrapper Why is your networkwrapper in your proxy? And this looks like a Code-style Issue #1 to me. 9 minutes ago, Oscarita25 said: level * 0.1F I think that your issue is here. Explosions with a very low power value will not damage entities.
June 26, 20187 yr Author @V0idWa1k3r ... well i have overtaken the mod i am working on but i knew such thing as a "common" proxy should not exist aka. that what i were doing is wrong.. but just ignored that because it worked fine for now (right now i just want something running good XD) i will fix that in a second .. 3 minutes ago, V0idWa1k3r said: I think that your issue is here. Explosions with a very low power value will not damage entities. i wasn't sure about that .. but this actually could it be XD.. i will now debug my code and write another reply .. if changing the power worked
June 26, 20187 yr Author 16 minutes ago, V0idWa1k3r said: I think that your issue is here. Explosions with a very low power value will not damage entities. yup .. that was it .. now just out of curiousity ... is there a way to turn off explosion damage and just do damage to entities?
June 26, 20187 yr The last parameter of World#createExplosion is a boolean controlling whether the explosion damages terrain.
June 26, 20187 yr Author 1 minute ago, V0idWa1k3r said: The last parameter of World#createExplosion is a boolean controlling whether the explosion damages terrain. i thought that was for smoke ?
June 26, 20187 yr Author 1 minute ago, Oscarita25 said: i thought that was for smoke ? seems like it was for both...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.