本文整理匯總了Java中net.minecraftforge.event.entity.living.LivingDeathEvent類的典型用法代碼示例。如果您正苦於以下問題:Java LivingDeathEvent類的具體用法?Java LivingDeathEvent怎麽用?Java LivingDeathEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LivingDeathEvent類屬於net.minecraftforge.event.entity.living包,在下文中一共展示了LivingDeathEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onLivingDeath
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void onLivingDeath(LivingDeathEvent event)
{
/*
* Update player experience when they kill a monster. Experience gained is determined from how much health/damage the monsters has.
*/
if (event.getSource().getTrueSource() instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
EntityLivingBase enemy = event.getEntityLiving();
PlayerInformation playerInfo = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
if (!player.getEntityWorld().isRemote && playerInfo != null)
{
addExperience(player, playerInfo, enemy);
}
}
}
示例2: PlayerDeath
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@HarshenEvent
public void PlayerDeath(LivingDeathEvent event)
{
EntityPlayer player = (EntityPlayer) event.getEntity();
event.setCanceled(true);
if (player instanceof EntityPlayerMP)
{
EntityPlayerMP entityplayermp = (EntityPlayerMP)player;
entityplayermp.addStat(StatList.getObjectUseStats(Items.TOTEM_OF_UNDYING));
CriteriaTriggers.USED_TOTEM.trigger(entityplayermp, HarshenUtils.getFirstOccuringItem(player, Items.TOTEM_OF_UNDYING));
}
HarshenUtils.setStackInSlot(player, Items.TOTEM_OF_UNDYING, ItemStack.EMPTY);
player.setHealth(1.0F);
player.clearActivePotions();
player.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 900, 1));
player.addPotionEffect(new PotionEffect(MobEffects.ABSORPTION, 100, 1));
player.world.setEntityState(player, (byte)35);
}
示例3: onEntityDeath
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public static void onEntityDeath(LivingDeathEvent event)
{
// if villager death drops are enabled, if the newly dead entity is a villager, and that villager was killed by a player...
if ((ModConfiguration.enableDeathDrops) && (event.getEntityLiving() instanceof EntityVillager) && (event.getSource().getTrueSource() instanceof EntityPlayerMP))
{
// iterate through the itemstacks in the villager's inventory
InventoryBasic inventory = ((EntityVillager)event.getEntityLiving()).getVillagerInventory();
for (int i = 0; i < inventory.getSizeInventory(); i++)
{
// remove the stack from the inventory and spawn it in the world
ItemStack stack = inventory.getStackInSlot(i);
if (stack != ItemStack.EMPTY)
{
event.getEntityLiving().entityDropItem(stack, 0.0F);
}
}
}
}
示例4: printChat
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
public void printChat(int ID, LivingDeathEvent event, String item) {
Entity killer = event.getSource().getEntity();
EntityLivingBase target = event.getEntityLiving();
// Thanks again 'SourceCoded' <3
// Add to statclock weapon
if (killer != null && killer instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) killer;
String name = killer.getName();
item = translate(item + ".name");
player.sendMessage(new TextComponentString( name + "'s " + item + " " + translate("statclock.translate.chat") + " §6[" + translate("strange." + ID) + "]"));
}
}
示例5: checkPlayerDeath
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void checkPlayerDeath(LivingDeathEvent event) {
if (event.getEntityLiving() != null && event.getEntityLiving() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer)event.getEntityLiving();
NBTTagCompound tag = player.getEntityData();
if (tag.hasKey("hasSacrificed") && !tag.getBoolean("hasSacrificed"))
{
EntityItem ei = new EntityItem(player.worldObj, player.posX + 0.5D, player.posY + 0.5D, player.posZ + 0.5D, new ItemStack(UCItems.heart));
tag.setBoolean("hasSacrificed", true);
if (!player.worldObj.isRemote)
player.worldObj.spawnEntityInWorld(ei);
return;
}
}
}
示例6: onDeath
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void onDeath(LivingDeathEvent event) {
World world = event.getEntity().getEntityWorld();
if (world.isRemote) {
return;
}
Entity slayer = event.getSource().getTrueSource();
if (event.getEntity() instanceof EntityPlayer && slayer instanceof EntityCreature) {
handlePlayerDeath((EntityPlayer) event.getEntity(), (EntityCreature) slayer);
return;
}
if (!(event.getEntity() instanceof EntityCreature)) {
return;
}
if (event.getEntity().getTags().contains(NemesisSystem.TAG_NEMESIS)) {
handleNemesisDeath((EntityCreature) event.getEntity(), slayer);
}
}
示例7: onLivingDeath
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void onLivingDeath(LivingDeathEvent event) {
if (event.getSource().getSourceOfDamage() != null && event.getSource().getSourceOfDamage() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getSource().getSourceOfDamage();
if (this.isActive(player) && event.getEntityLiving() instanceof EntityVillager) {
EntityVillager villager = (EntityVillager) event.getEntityLiving();
EntityZombie zombieVillager = new EntityZombie(player.worldObj);
zombieVillager.copyLocationAndAnglesFrom(villager);
player.worldObj.removeEntity(villager);
zombieVillager.onInitialSpawn(player.worldObj.getDifficultyForLocation(new BlockPos(zombieVillager)), null);
zombieVillager.setVillagerType(villager.getProfessionForge());
zombieVillager.setChild(villager.isChild());
zombieVillager.setNoAI(villager.isAIDisabled());
if (villager.hasCustomName()) {
zombieVillager.setCustomNameTag(villager.getCustomNameTag());
zombieVillager.setAlwaysRenderNameTag(villager.getAlwaysRenderNameTag());
}
player.worldObj.spawnEntityInWorld(zombieVillager);
player.worldObj.playEvent(null, 1026, zombieVillager.getPosition(), 0);
}
}
}
示例8: japaneseDeath
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST)
public void japaneseDeath(LivingDeathEvent event)
{
EntityLivingBase living = event.getEntityLiving();
World world = living.world;
if(!event.isCanceled() && !world.isRemote && living.hasCapability(JAPANESE_MOB_CAP,null))
{
JapaneseMob japaneseMob = living.getCapability(JAPANESE_MOB_CAP,null);
int i = japaneseMob.spirits;
while (i > 0)
{
int j = EntitySpirit.getSpiritSplit(i);
i -= j;
world.spawnEntity(new EntitySpirit(world, living.posX, living.posY, living.posZ, j));
}
}
}
示例9: onHunt
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void onHunt(LivingDeathEvent event) {
EntityPlayer player = null;
EntityLivingBase e = (EntityLivingBase) event.getEntity();
DamageSource source = event.getSource();
if (source.getTrueSource() instanceof EntityPlayer) {
player = (EntityPlayer) source.getTrueSource();
}
if (player == null) {
return;
}
IDailiesCapability dailies = getCapability(player);
if (dailies == null) {
return;
}
dailies.hunt(player, e);
}
示例10: reviveEffect
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void reviveEffect(LivingDeathEvent lde)
{
if ((Main.allowPFeather) && ((lde.entityLiving instanceof EntityPlayer)))
{
EntityPlayer ep = (EntityPlayer)lde.entityLiving;
if (((EntityLivingBase) ep).isPotionActive(ItemRegistry1.customPotion))
{
if (!ep.worldObj.isRemote)
{
ep.setHealth(17);
ep.worldObj.playSoundAtEntity(ep, "fireworks.launch", 5.0F, 1.0F);
ep.worldObj.playSoundAtEntity(ep, "assets.speedboost", 0.4F, 0.3F);
((EntityLivingBase) ep).removePotionEffect(ItemRegistry1.customPotion.id);
}
System.out.println("Potion types capacity: " + Potion.potionTypes.length);
lde.setCanceled(true);
}
}
}
示例11: onKill
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void onKill(LivingDeathEvent event) {
EntityPlayer player = null;
EntityLivingBase victim = (EntityLivingBase) event.getEntity();
DamageSource source = event.getSource();
if (source.getTrueSource() instanceof EntityPlayer) {
player = (EntityPlayer) source.getTrueSource();
}
if (player == null) {
return;
}
Province province = PlayerCivilizationCapabilityImpl.get(player).getInCivilization();
if (province == null || province.civilization == null) {
return;
}
handleKillMobsQuest(player, province, victim);
}
示例12: checkkills
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void checkkills(LivingDeathEvent event) {
EntityPlayer player = null;
EntityLivingBase victum = (EntityLivingBase) event.getEntity();
DamageSource source = event.getSource();
if (!victum.getTags().contains("encampment_quest")) {
return;
}
if (source.getTrueSource() instanceof EntityPlayer) {
player = (EntityPlayer) source.getTrueSource();
} else {
return;
}
Set<QuestData> quests = PlayerCivilizationCapabilityImpl.get(player).getCurrentQuests();
for (QuestData data : quests) {
if (ID == data.getQuestType() && victum.getTags().contains(data.getQuestId().toString())) {
incrementKills(data);
return;
}
}
}
示例13: checkKillsInCivilization
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void checkKillsInCivilization(LivingDeathEvent event) {
EntityPlayer player = null;
EntityLivingBase victim = (EntityLivingBase) event.getEntity();
DamageSource source = event.getSource();
if (source.getTrueSource() instanceof EntityPlayer) {
player = (EntityPlayer) source.getTrueSource();
}
if (player == null) {
return;
}
Province province = PlayerCivilizationCapabilityImpl.get(player).getInCivilization();
if (province == null || province.civilization == null) {
return;
}
PlayerCivilizationCapabilityImpl.get(player).adjustReputation(province.civilization, getRepuationAdjustmentFor(victim, province));
}
示例14: onEntityKill
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void onEntityKill(LivingDeathEvent e) {
BlockPos pos = e.getEntity().getPosition();
World w = e.getEntity().getEntityWorld();
if (!w.isRemote && e.getSource().getTrueSource() != null) {
if (e.getSource().getTrueSource() instanceof EntityPlayer && e.getEntity() instanceof EntityCreature) {
if (random.nextFloat() <= chance && TinkerUtil.hasTrait(TagUtil.getTagSafe(((EntityPlayer) e.getSource().getTrueSource()).getHeldItemMainhand()), identifier)) {
int id = e.getEntity().getEntityId();
Entity ent = EntityList.createEntityByID(id, w);
if (ent != null) {
ent.setPosition(pos.getX(), pos.getY(), pos.getZ());
w.spawnEntity(ent);
e.getSource().getTrueSource().playSound(SoundEvents.AMBIENT_CAVE, 1.0F, 1.0F);
}
}
}
}
}
示例15: onTargetKilled
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入依賴的package包/類
@SubscribeEvent
public void onTargetKilled(LivingDeathEvent event) {
if (event.getSource().getTrueSource() instanceof EntityPlayer && event.getEntity() instanceof EntityLiving) {
World w = event.getSource().getTrueSource().world;
ItemStack tool = ((EntityPlayer) event.getSource().getTrueSource()).getHeldItemMainhand();
if (!w.isRemote && TinkerUtil.hasTrait(TagUtil.getTagSafe(tool), identifier)) {
NBTTagCompound tag = TagUtil.getExtraTag(tool);
Utils.GeneralNBTData data = Utils.GeneralNBTData.read(tag);
float health = ((EntityLiving) event.getEntity()).getMaxHealth();
data.killcount += 1;
data.health = health;
float bonus = Math.round(random.nextFloat() * health * 100) / divisor;
data.bonus += bonus;
data.bonus = (float) Math.round(data.bonus * 100f) / 100f;
data.write(tag);
TagUtil.setExtraTag(tool, tag);
}
}
}