本文整理汇总了Java中net.minecraftforge.event.entity.player.PlayerDropsEvent类的典型用法代码示例。如果您正苦于以下问题:Java PlayerDropsEvent类的具体用法?Java PlayerDropsEvent怎么用?Java PlayerDropsEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PlayerDropsEvent类属于net.minecraftforge.event.entity.player包,在下文中一共展示了PlayerDropsEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemDrop
import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void onItemDrop(PlayerDropsEvent event)
{
if(!event.getEntityPlayer().getEntityWorld().isRemote)
{
for(EntityItem item : event.getDrops())
{
if(item.getItem().getItem() == Clef.itemInstrument)
{
NBTTagCompound tag = item.getItem().getTagCompound();
if(tag != null)
{
String instName = tag.getString("itemName");
Instrument is = InstrumentLibrary.getInstrumentByName(instName);
if(is == null) //request the item then?
{
InstrumentLibrary.requestInstrument(instName, event.getEntityPlayer());
}
}
}
}
}
}
示例2: onPlayerDeath
import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerDeath(PlayerDropsEvent event)
{
if (event.entityLiving instanceof EntityPlayerMP)
{
GCPlayerStats stats = GCPlayerStats.get((EntityPlayerMP) event.entityLiving);
if (!event.entityLiving.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory"))
{
event.entityLiving.captureDrops = true;
for (int i = stats.extendedInventory.getSizeInventory() - 1; i >= 0; i--)
{
ItemStack stack = stats.extendedInventory.getStackInSlot(i);
if (stack != null)
{
((EntityPlayerMP) event.entityLiving).func_146097_a(stack, true, false);
stats.extendedInventory.setInventorySlotContents(i, null);
}
}
event.entityLiving.captureDrops = false;
}
}
}
示例3: addPlayerHeads
import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入依赖的package包/类
public void addPlayerHeads(PlayerDropsEvent event){
EntityPlayer player = event.getEntityPlayer();
DamageSource source = event.getSource();
Entity attacker = source.getSourceOfDamage();
if(Config.playerHeadType == ItemDropType.NONE)return;
if(player == null || player.getEntityWorld() == null)return;
int rand = player.getEntityWorld().rand.nextInt(Math.max(Config.playerHeadDropChance / fixLooting(event.getLootingLevel()), 1));
if(Config.playerHeadDropChance < 0 || rand !=0)
return;
if(Config.playerHeadType == ItemDropType.KILLED){
if(attacker == null || !(attacker instanceof EntityPlayer) || attacker instanceof FakePlayer)
return;
}
ItemStack skull = PlayerUtil.createPlayerHead(player);
event.getDrops().add(ItemUtil.dropFromPlayer(player, skull, true));
}
示例4: onPlayerDeath
import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerDeath(PlayerDropsEvent event)
{
EntityPlayer player = event.getEntityPlayer();
Item item;
for (int i = 0; i < event.getDrops().size(); i++)
{
item = event.getDrops().get(i).getEntityItem().getItem();
if (item != null && (item instanceof ItemSword || item instanceof ItemShield || item instanceof ItemArmor || item instanceof ItemBow))
{
ItemStack stack = event.getDrops().get(i).getEntityItem();
NBTTagCompound nbt = NBTHelper.loadStackNBT(stack);
if (nbt != null)
{
if (WeaponAttribute.SOUL_BOUND.hasAttribute(nbt) || ArmorAttribute.SOUL_BOUND.hasAttribute(nbt) || BowAttribute.SOUL_BOUND.hasAttribute(nbt) || ShieldAttribute.SOUL_BOUND.hasAttribute(nbt))
{
event.getDrops().remove(i);
player.inventory.addItemStackToInventory(stack);
}
}
}
}
}
示例5: onPlayerDeath
import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerDeath(PlayerDropsEvent evt) {
if (evt.getEntityPlayer() == null || evt.getEntityPlayer() instanceof FakePlayer || evt.isCanceled()) {
return;
}
if(evt.getEntityPlayer().world.getGameRules().getBoolean("keepInventory")) {
return;
}
ListIterator<EntityItem> iter = evt.getDrops().listIterator();
while (iter.hasNext()) {
EntityItem ei = iter.next();
ItemStack item = ei.getEntityItem();
if(isSoulBound(item)) {
if (addToPlayerInventory(evt.getEntityPlayer(), item)) {
Bagginses.analytics.eventDesign("playerDied:Soulbound", Bagginses.analytics.userPrefix());
iter.remove();
}
}
}
}
示例6: onPlayerDeath
import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入依赖的package包/类
/**
* Stores cybernetic implants for a specific player in a hashmap on death
* TODO this equips implants that aren't currently equipped as armor. Fot it so that it only stores implants equipped as armor
* @param e the PlayersDropsEvent event
*/
@SubscribeEvent
public void onPlayerDeath(PlayerDropsEvent e) {
//the arraylist that will store all of the player's implants
ArrayList<EntityItem> savedDrops = new ArrayList<EntityItem>();
//iterate through all of the player drops (the items in the player's inventory) and save all the implants
for (EntityItem i : e.drops) {
if (i.getEntityItem().getItem() instanceof Implant) {
savedDrops.add(i);
}
}
//remove all of the found implants from the drops list so they don't spawn in world
e.drops.removeAll(savedDrops);
savedImplants.put(e.entityPlayer.getDisplayName(), savedDrops);
}
示例7: deathEvent
import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void deathEvent(PlayerDropsEvent event)
{
try
{
if (D3Core.isDebug())
perks = new JsonParser().parse(IOUtils.toString(new URL(CoreConstants.PERKS_URL), Charset.forName("UTF-8"))).getAsJsonObject();
if (perks.has(event.getEntityPlayer().getName()))
{
JsonObject perk = perks.getAsJsonObject(event.getEntityPlayer().getName());
if (perk.has("drop"))
{
ItemStack stack = getItemStackFromJson(perk.getAsJsonObject("drop"), 0, 1);
if (stack == ItemStack.EMPTY) return;
event.getDrops().add(new EntityItem(event.getEntityPlayer().getEntityWorld(), event.getEntityPlayer().posX, event.getEntityPlayer().posY, event.getEntityPlayer().posZ, stack));
}
}
}
catch (Exception e)
{
if (D3Core.isDebug()) e.printStackTrace();
}
}
示例8: onPlayerDeathLate
import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerDeathLate(PlayerDropsEvent evt) {
if (evt.getEntityPlayer() == null || evt.getEntityPlayer() instanceof FakePlayer || evt.isCanceled()) {
return;
}
if (evt.getEntityPlayer().world.getGameRules().getBoolean("keepInventory")) {
return;
}
Log.debug("Running onPlayerDeathLate logic for " + evt.getEntityPlayer().getName());
ListIterator<EntityItem> iter = evt.getDrops().listIterator();
while (iter.hasNext()) {
EntityItem ei = iter.next();
ItemStack item = ei.getEntityItem();
if (isSoulBound(item)) {
if (addToPlayerInventory(evt.getEntityPlayer(), item)) {
iter.remove();
}
}
}
}
示例9: dropFakeItems
import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOW)
public void dropFakeItems(PlayerDropsEvent event) {
InventoryWearables inv = event.getEntityLiving().getCapability(TF2weapons.INVENTORY_CAP, null);
for (int i = 3; i < 13; i++)
if (inv.getStackInSlot(i) != null) {
event.getEntityPlayer().dropItem(inv.getStackInSlot(i), true, false);
}
if(WeaponsCapability.get(event.getEntity()).isFeign())
for(EntityItem item:event.getDrops()) {
item.getEntityData().setBoolean("Fake", true);
item.setAgeToCreativeDespawnTime();
}
}
示例10: onPlayerDrops
import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入依赖的package包/类
public static void onPlayerDrops(EntityPlayer player, DamageSource cause, List<EntityItem> capturedDrops, boolean recentlyHit)
{
PlayerDropsEvent event = new PlayerDropsEvent(player, cause, capturedDrops, recentlyHit);
if (!MinecraftForge.EVENT_BUS.post(event))
{
for (EntityItem item : capturedDrops)
{
player.dropItemAndGetStack(item);
}
}
}
示例11: captureGoldenBagDrop
import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void captureGoldenBagDrop(final PlayerDropsEvent event) {
if (ExtraUtils.goldenBag == null) {
return;
}
if (event.entity.getEntityData().getCompoundTag("PlayerPersisted").hasKey("XU|GoldenBags")) {
return;
}
int j = 0;
final NBTTagCompound t = new NBTTagCompound();
for (int i = 0; i < event.drops.size(); ++i) {
final ItemStack item = event.drops.get(i).getEntityItem();
if (item != null && item.getItem() == ExtraUtils.goldenBag && ItemGoldenBag.isMagic(item)) {
final NBTTagCompound tags = new NBTTagCompound();
item.writeToNBT(tags);
t.setTag("item_" + j, (NBTBase)tags);
++j;
event.drops.remove(i);
--i;
}
}
t.setInteger("no_items", j);
NBTTagCompound e;
if (event.entityPlayer.getEntityData().hasKey("PlayerPersisted")) {
e = event.entityPlayer.getEntityData().getCompoundTag("PlayerPersisted");
}
else {
e = new NBTTagCompound();
event.entityPlayer.getEntityData().setTag("PlayerPersisted", (NBTBase)e);
}
e.setTag("XU|GoldenBags", (NBTBase)t);
}
示例12: onPlayerDeath
import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerDeath(PlayerDropsEvent e)
{
EntityPlayer player = e.getEntityPlayer();
int x = (int) player.posX;
int y = (int) player.posY;
int z = (int) player.posZ;
int dim = player.dimension;
player.addChatComponentMessage(new TextComponentTranslation("message.littlethings.deathCoords", x, y, z));
player.addChatComponentMessage(ITextComponent.Serializer.jsonToComponent(I18n.translateToLocal("message.littlethings.deathLinks")
.replaceAll("%w%", String.valueOf(dim))
.replaceAll("%x%", String.valueOf(x))
.replaceAll("%y%", String.valueOf(y))
.replaceAll("%z%", String.valueOf(z))));
}
示例13: onDeath
import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入依赖的package包/类
public void onDeath(DamageSource p_70645_1_)
{
if (ForgeHooks.onLivingDeath(this, p_70645_1_)) {
return;
}
super.onDeath(p_70645_1_);
setSize(0.2F, 0.2F);
setPosition(this.posX, this.posY, this.posZ);
this.motionY = 0.1000000014901161D;
this.captureDrops = true;
this.capturedDrops.clear();
if (getCommandSenderName().equals("Notch")) {
func_146097_a(new ItemStack(Items.apple, 1), true, false);
}
if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory")) {
this.inventory.dropAllItems();
}
this.captureDrops = false;
if (!this.worldObj.isRemote)
{
PlayerDropsEvent event = new PlayerDropsEvent(this, p_70645_1_, this.capturedDrops, this.recentlyHit > 0);
if (!MinecraftForge.EVENT_BUS.post(event)) {
for (EntityItem item : this.capturedDrops) {
joinEntityItemWithWorld(item);
}
}
}
if (p_70645_1_ != null)
{
this.motionX = (-MathHelper.cos((this.attackedAtYaw + this.rotationYaw) * 3.141593F / 180.0F) * 0.1F);
this.motionZ = (-MathHelper.sin((this.attackedAtYaw + this.rotationYaw) * 3.141593F / 180.0F) * 0.1F);
}
else
{
this.motionX = (this.motionZ = 0.0D);
}
this.yOffset = 0.1F;
addStat(StatList.deathsStat, 1);
}
示例14: itemDrop
import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入依赖的package包/类
@SubscribeEvent
public void itemDrop(PlayerDropsEvent event)
{
List<EntityItem> items = event.getDrops();
for (EntityItem item : items)
{
if (item.getEntityItem().getItem() == ModItems.itemDeathList)
{
item.setDead();
}
}
}
示例15: onPlayerDrops
import net.minecraftforge.event.entity.player.PlayerDropsEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerDrops(PlayerDropsEvent event) {
EntityPlayer player = event.getEntityPlayer();
if (!player.world.getGameRules().getBoolean("keepInventory")) {
IInventory inventory = player.getCapability(AlchemyCapabilityLoader.bauble, null);
if (inventory != null)
for (int i = 0, len = inventory.getSizeInventory(); i < len; i++) {
ItemStack item = inventory.removeStackFromSlot(i);
if (!item.isEmpty())
event.getDrops().add(InventoryHelper.getEntityItem(player, item));
}
}
}