Jump to content

Recommended Posts

Posted

I want to drop an item when the player die. I know how it works with overriding the EntityPlayer Class.

But i need how it works without overriding the class.

 

How does it work? No random drop!

Posted

Make a class named:

 

EntityPlayer_Drops.class

 

Add this, tested working.

 

package YOUR.PACKAGE;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.World;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.PlayerDropsEvent;

public class EntityPlayer_Drops extends EntityPlayer
{
public final int dropCount = 2;
public final int item = Item.appleRed.itemID;

public EntityPlayer_Drops(World world, int i, int j)
{
	super(world);
	i = dropCount;
	j = item;
}

@ForgeSubscribe
public void onPlayerDeath(PlayerDropsEvent event)
{
	if (event.entityPlayer.getHealth() <= 0) //Checks if player is dead.
	{
        event.entityPlayer.dropItem(Item.appleRed.itemID, 2); //Field 1 : Item/Block, change above. Field 2: Drop Count, change above.
	}
}

@Override
public boolean canCommandSenderUseCommand(int i, String s) 
{
	return false;
} //Ignore, don't change.

@Override
public ChunkCoordinates getPlayerCoordinates() 
{	
	return null;
} //Ignore, don't change.

@Override
public void sendChatToPlayer(String s) 
{

} //Ignore, don't change.
}

Posted

omg why a class?? just use

@PreInit

public void preInit(FMLPreInitializationEvent e){

MinecraftForge.EVENT_BUS.register(this);

}

@ForgeSubscribe

public void onDeath(LivingDeathEvent e){

if(e.entity instanceof EntityPlayer && !e.entity.worldObj.isRemote){

EntityPlayer killed = e.entity;

Entity killer = e.damageSource.getEntity();//if u want to know what killed the player

//do stuff

killed.dropItem(Item.aplleRed.itemID,2);

}

}

Posted

Thanks for the answerring.

I see there is a problem.

Somebody made for this another class and someone said that its easier if you implement it in your modfile.

For myself i would use the extra class beacuse its more clean and i find everything faster.

So i hope that the code works xD.

Posted

both codes worked pretty good. I used the last one. Because its a little bit cleaner.

Thanks for the help. but now a hard question. Is it possible to make this drop based on time?

I want to get this drop only at night xD (so that people have to wait until they get the next rare drop xD.)

Posted

I got not enought time to explain it thats why the extra answer now.

 

 

I want a very rare item which is so powerful and a recipe is with

technik mods to easy to cheating (like ee3 with transmutation)

and i do not want a recipe which requier 9 diamond blocks.

 

Thats why i want to get this drop only that the player dies.

But than the player could make a suicide and get this item very often.

Thats why i think in a special time will prevent people from doing that.

But my drop is not rare enough for that.

I mean with this item you can make item/blocks turn into exp.

Thats why i think i want to detect it have to be a special day (the night where fullmoon is)

 

 

And that is my first question: Is it possible to make a player drops an item when the moon is a fullmoon and the time is (maybe 18 clock (ingametime))

 

 

secon question is: Is it possible to make that the player have also the exp (1000 or bigger?)?

 

And howw can i do it?

 

Posted

how would i go about dropping multiple items? because you cannot have two

 

public final int item = ashtonsmod.Manure.itemID;

 

and you cannot change the

 

event.entityPlayer.dropItem

 

???

 

 

Use examples, i have aspergers.

Examples make sense to me.

Posted

for the full moon time u will need to calculate manually the time (see in the render global at render sky method and render stars method) do some tests.

 

Nope, just use this:

worldInstance.getMoonPhase()

I didn't use this, but I think after looking at the code, it's returning a value between 0-7. You have to figure out which is the full moon.

 

how would i go about dropping multiple items? because you cannot have two

 

public final int item = ashtonsmod.Manure.itemID;

 

and you cannot change the

 

event.entityPlayer.dropItem

 

???

 

 

Don't ninja threads.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Posted

what? i have a question related this this thread.. would you rather i started my own? i thought my question was just an extension of this thread anyway and i thought someone else may look at this and have the same problem and not have to find the answer in a new place or start another thread and wait. sorry.

Use examples, i have aspergers.

Examples make sense to me.

Posted

what? i have a question related this this thread.. would you rather i started my own? i thought my question was just an extension of this thread anyway and i thought someone else may look at this and have the same problem and not have to find the answer in a new place or start another thread and wait. sorry.

 

I thought of something different, sorry.

 

Well, if you want to edit the drops, you need to have a LivingDropsEvent, check if the entity is an instanceof EntityPlayer and if so, add new EntityItems to the event.drops list which are holding ItemStacks with your Items.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

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.

Announcements



×
×
  • Create New...

Important Information

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