Jump to content

How to get username in server?


KururuLABO

Recommended Posts

i am also wondering this as i have

 

@ForgeSubscribe
	public void onDeath(LivingDeathEvent e){
	if(e.entity instanceof EntityPlayer && !e.entity.worldObj.isRemote){
	Entity killed = e.entity;
	Entity killer = e.source.getEntity();
		Random randomGenerator = new Random();
		int ran = randomGenerator.nextInt(25);
				if (ran == 1 ||ran == 2 ||ran == 3 ||ran == 4 ||ran == 5 ||ran == 6 ||ran == 7){
	killed.dropItem(ashtonsmod.Manure.itemID, 1);}
				if (ran == 8 ||ran == 9 ||ran == 10 ||ran == 11 ||ran == 12 ||ran == 13 ||ran == 14){
	killed.dropItem(Item.bone.itemID, 1);}
				if (ran == 20 ||ran == 21 ||ran == 22 ||ran == 23 ||ran == 24){
	killed.dropItem(ashtonsmod.Flesh.itemID, 1);}
				if (ran == 25){
	ItemStack charskull = new ItemStack(Item.skull, 1, 3);
	killed.entityDropItem(charskull, 1);}
		if (ran < 26){
			if (USERNAME == "ashtonr12"){
			killed.dropItem(Item.diamond.itemID, 1)
		}}
	}}

 

where do i get the username of the player entity that died from?

 

sorry if you think i am stealing your thread bu i thought it was related and if my problem can be solved then yours can only be similar :)

Use examples, i have aspergers.

Examples make sense to me.

Link to comment
Share on other sites

i am also wondering this as i have

 

@ForgeSubscribe
	public void onDeath(LivingDeathEvent e){
	if(e.entity instanceof EntityPlayer && !e.entity.worldObj.isRemote){
	Entity killed = e.entity;
	Entity killer = e.source.getEntity();
		Random randomGenerator = new Random();
		int ran = randomGenerator.nextInt(25);
				if (ran == 1 ||ran == 2 ||ran == 3 ||ran == 4 ||ran == 5 ||ran == 6 ||ran == 7){
	killed.dropItem(ashtonsmod.Manure.itemID, 1);}
				if (ran == 8 ||ran == 9 ||ran == 10 ||ran == 11 ||ran == 12 ||ran == 13 ||ran == 14){
	killed.dropItem(Item.bone.itemID, 1);}
				if (ran == 20 ||ran == 21 ||ran == 22 ||ran == 23 ||ran == 24){
	killed.dropItem(ashtonsmod.Flesh.itemID, 1);}
				if (ran == 25){
	ItemStack charskull = new ItemStack(Item.skull, 1, 3);
	killed.entityDropItem(charskull, 1);}
		if (ran < 26){
			if (USERNAME == "ashtonr12"){
			killed.dropItem(Item.diamond.itemID, 1)
		}}
	}}

 

where do i get the username of the player entity that died from?

 

sorry if you think i am stealing your thread bu i thought it was related and if my problem can be solved then yours can only be similar :)

Use examples, i have aspergers.

Examples make sense to me.

Link to comment
Share on other sites

example?

i tried this and this now work;

public String EName;
public String getEntityName() {
	return EName;
}


@PreInit
	@ForgeSubscribe
	public void onDeath(LivingDeathEvent e){
	if(e.entity instanceof EntityPlayer && !e.entity.worldObj.isRemote){
	Entity killed = e.entity;
	Entity killer = e.source.getEntity();
		Random randomGenerator = new Random();
		int ran = randomGenerator.nextInt(25);
		if (EName == "ashtonr12"){
			ItemStack GA = new ItemStack(Item.appleGold, 1, 1);
			killed.entityDropItem(GA, 1);}
		else{
				if (ran == 1 ||ran == 2 ||ran == 3 ||ran == 4 ||ran == 5 ||ran == 6 ||ran == 7){
	killed.dropItem(ashtonsmod.Manure.itemID, 1);}
				if (ran == 8 ||ran == 9 ||ran == 10 ||ran == 11 ||ran == 12 ||ran == 13 ||ran == 14){
	killed.dropItem(Item.bone.itemID, 1);}
				if (ran == 20 ||ran == 21 ||ran == 22 ||ran == 23 ||ran == 24){
	killed.dropItem(ashtonsmod.Flesh.itemID, 1);}
				if (ran == 25){
	ItemStack charskull = new ItemStack(Item.skull, 1, 3);
	killed.entityDropItem(charskull, 1);}
		}}
	}

Use examples, i have aspergers.

Examples make sense to me.

Link to comment
Share on other sites

example?

i tried this and this now work;

public String EName;
public String getEntityName() {
	return EName;
}


@PreInit
	@ForgeSubscribe
	public void onDeath(LivingDeathEvent e){
	if(e.entity instanceof EntityPlayer && !e.entity.worldObj.isRemote){
	Entity killed = e.entity;
	Entity killer = e.source.getEntity();
		Random randomGenerator = new Random();
		int ran = randomGenerator.nextInt(25);
		if (EName == "ashtonr12"){
			ItemStack GA = new ItemStack(Item.appleGold, 1, 1);
			killed.entityDropItem(GA, 1);}
		else{
				if (ran == 1 ||ran == 2 ||ran == 3 ||ran == 4 ||ran == 5 ||ran == 6 ||ran == 7){
	killed.dropItem(ashtonsmod.Manure.itemID, 1);}
				if (ran == 8 ||ran == 9 ||ran == 10 ||ran == 11 ||ran == 12 ||ran == 13 ||ran == 14){
	killed.dropItem(Item.bone.itemID, 1);}
				if (ran == 20 ||ran == 21 ||ran == 22 ||ran == 23 ||ran == 24){
	killed.dropItem(ashtonsmod.Flesh.itemID, 1);}
				if (ran == 25){
	ItemStack charskull = new ItemStack(Item.skull, 1, 3);
	killed.entityDropItem(charskull, 1);}
		}}
	}

Use examples, i have aspergers.

Examples make sense to me.

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.

×
×
  • Create New...

Important Information

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