Jump to content

Explosion spawning based on the rotation?


Oscarita25

Recommended Posts

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 by Oscarita25
taking out useless stuff
Link to comment
Share on other sites

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 by Oscarita25
Link to comment
Share on other sites

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)
 

Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

1 hour ago, V0idWa1k3r said:

Why are you using lastTickPos insread of pos?

oh  that was just me trying .. i should change that.. :P

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

@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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • In the ever-evolving landscape of cryptocurrency, the challenge of recovering lost or stolen digital assets has long been a pressing concern. However, a pioneering company known as Washington Recovery Pro has emerged as a trailblazer in this domain, offering a revolutionary approach to the recovery of Bitcoin and other cryptocurrencies. Leveraging their deep expertise in blockchain technology and digital forensics, Washington Recovery Pro has developed a suite of innovative tools and techniques that empower individuals and organizations to track, trace, and reclaim their rightful digital holdings, even in the face of sophisticated theft and obfuscation tactics employed by cybercriminals. By tapping into the transparency and immutability of the blockchain, Washington Recovery Pro analysts are able to meticulously follow the digital breadcrumbs left behind by illicit transactions, unraveling complex money-laundering schemes and identifying the ultimate destinations of stolen funds. Through their tireless efforts and cutting-edge investigative methods, Washington Recovery Pro has successfully recovered millions of dollars' worth of cryptocurrency, restoring peace of mind and financial stability to countless victims of crypto-related crimes. As the adoption of digital assets continues to soar, the importance of Washington Recovery Pro work cannot be overstated, as they stand as a bulwark against the growing threat of cryptocurrency theft and a beacon of hope for those seeking to reclaim their rightful digital wealth. For more information, contact:          
    • Ive tried to disable all the mods and repair the installation in curseforge but that didnt change anything sadly.
    • Ive been trying to run some datapacks from vanilla tweaks like multiplayer sleep and Anti Creeper grief, but i cant seem to get them working on CurseForge while they work completely fine in Vanilla on the same version. They are loaded according to the game but they don´t work at all, ive tried using openloader but that doesnt change anything either.   Any ideas on what could be causing this?    Thank you in advance, Nap
    • I am having the same issue when I try to launch the modpack from the launcher. I am on Windows, running 32gb RAM, I have plenty of RAM dedicated to the modpack, but every time I try to launch the game, I get a message saying "Game Crashed - Exit Code: 1" For reference, I have 18.5k MB dedicated to running the game, and it still crashes. I am not sure what the issue is. Any help is appreciated!
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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