Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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

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 by V0idWa1k3r

  • 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

  • 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?

  • 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 by Oscarita25

  • 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)
 

 

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.

  • Author
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

 

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.

  • 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

  • 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?

  • 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 ?

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.