本文整理匯總了Java中net.minecraftforge.event.entity.living.LivingDeathEvent.getEntity方法的典型用法代碼示例。如果您正苦於以下問題:Java LivingDeathEvent.getEntity方法的具體用法?Java LivingDeathEvent.getEntity怎麽用?Java LivingDeathEvent.getEntity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.event.entity.living.LivingDeathEvent
的用法示例。
在下文中一共展示了LivingDeathEvent.getEntity方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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);
}
示例2: 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);
}
}
示例3: 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);
}
示例4: 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);
}
示例5: 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;
}
}
}
示例6: 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));
}
示例7: 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);
}
}
}
}
}
示例8: 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);
}
}
}
示例9: onEntityKill
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityKill(LivingDeathEvent e) {
if (e.getSource().getTrueSource() instanceof EntityPlayer && !e.getSource().getTrueSource().world.isRemote && e.getEntity() instanceof EntityCreature) {
if (TinkerUtil.hasTrait(TagUtil.getTagSafe(((EntityPlayer) e.getSource().getTrueSource()).getHeldItemMainhand()), identifier)) {
ItemStack tool = ((EntityPlayer) e.getSource().getTrueSource()).getHeldItemMainhand();
String name = e.getEntity().getName();
NBTTagCompound tag = TagUtil.getExtraTag(tool);
Utils.GeneralNBTData data = Utils.GeneralNBTData.read(tag);
if (!data.name.isEmpty()) {
return;
}
data.name = name;
data.write(tag);
TagUtil.setExtraTag(tool, tag);
}
}
}
示例10: onLivingDeath
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onLivingDeath(LivingDeathEvent event) {
Entity entity = event.getEntity();
World world = entity.world;
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
if (world instanceof WorldServer && player instanceof EntityPlayerMP) {
Map<Integer, BlockSystem> blockSystems = BlockSystems.PROXY.getBlockSystemHandler(world).getBlockSystems();
for (Map.Entry<Integer, BlockSystem> entry : blockSystems.entrySet()) {
BlockSystem blockSystem = entry.getValue();
if (blockSystem instanceof BlockSystemServer) {
((BlockSystemServer) blockSystem).getChunkTracker().removePlayer((EntityPlayerMP) player);
}
}
}
}
}
示例11: entityDeathEvent
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority= EventPriority.LOW)
public void entityDeathEvent(LivingDeathEvent e){
if(e.getEntity() instanceof EntityPlayer
&& e.getResult() != Event.Result.DENY
&& !e.getEntity().getEntityWorld().isRemote) {
final EntityPlayer player = (EntityPlayer)e.getEntity();
if(player.isSpectator()) return;
Map<ItemStack,EntityEquipmentSlot> cache = equipmentCache.computeIfAbsent(player,(EntityPlayer p)->new HashMap<>());
for(EntityEquipmentSlot slot : EntityLootableBody.EQUIPMENT_SLOTS){
cache.put(player.getItemStackFromSlot(slot),slot);
}
if(player.getPrimaryHand() == EnumHandSide.LEFT){
// swap main and off hand items (easier than messing with the rendering code)
cache.put(player.getItemStackFromSlot(EntityEquipmentSlot.MAINHAND),EntityEquipmentSlot.OFFHAND);
cache.put(player.getItemStackFromSlot(EntityEquipmentSlot.OFFHAND),EntityEquipmentSlot.MAINHAND);
}
}
}
示例12: onLivingDeathEvent
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent
@SuppressWarnings("unused")
public void onLivingDeathEvent(LivingDeathEvent event) {
int moneyDropValue = EnderPay.settings.getPvpMoneyDrop();
if (moneyDropValue == 0) return;
Entity entity = event.getEntity();
if (!(entity instanceof EntityPlayer) || entity.world.isRemote) return;
Entity killer = event.getSource().getTrueSource();
if (!(killer instanceof EntityPlayerMP)) return;
Account account = Account.get((EntityPlayer) entity);
if (account.getBalance() <= 0) return;
long amountTaken = (moneyDropValue > 0) ?
(account.getBalance() * EnderPay.settings.getPvpMoneyDrop()) / 100 :
Math.max(Math.min(account.getBalance(), -EnderPay.settings.getPvpMoneyDrop()), 0);
account.addBalance(-amountTaken);
long balance = account.getBalance();
PacketDispatcher.sendTo(new MessageBalance(balance), (EntityPlayerMP) entity);
Account killerAccount = Account.get((EntityPlayer) killer);
killerAccount.addBalance(amountTaken);
long balance2 = killerAccount.getBalance();
PacketDispatcher.sendTo(new MessageBalance(balance2), (EntityPlayerMP) killer);
}
示例13: getXP
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent
public static void getXP(LivingDeathEvent event) {
if (!event.getEntity().world.isRemote && event.getEntity() instanceof EntityEnderman) {
if (event.getSource().getTrueSource() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
IDriveState DRIVE = player.getCapability(ModCapabilities.DRIVE_STATE, null);
if(DRIVE.getActiveDriveName().equals(Strings.Form_Final)) {
DRIVE.setDriveExp(DRIVE.getActiveDriveName(), DRIVE.getDriveExp(DRIVE.getActiveDriveName())+1);
int[] costs = DriveFormRegistry.get(DRIVE.getActiveDriveName()).getExpCosts();
int actualLevel = DRIVE.getDriveLevel(DRIVE.getActiveDriveName());
int actualExp = DRIVE.getDriveExp(DRIVE.getActiveDriveName());
if(costs.length == 7 && actualLevel < 7) {
if (actualExp >= costs[actualLevel]){
System.out.println("LEVEL UP");
DRIVE.setDriveLevel(DRIVE.getActiveDriveName(),actualLevel+1);
DRIVE.displayLevelUpMessage(player, DRIVE.getActiveDriveName());
}
}
PacketDispatcher.sendTo(new SyncDriveData(DRIVE), (EntityPlayerMP) player);
}
}
}
}
示例14: getXP
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent
public static void getXP(LivingDeathEvent event) {
if (!event.getEntity().world.isRemote && event.getEntity() instanceof IKHMob) {
if (event.getSource().getTrueSource() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) event.getSource().getTrueSource();
IDriveState DRIVE = player.getCapability(ModCapabilities.DRIVE_STATE, null);
if(DRIVE.getActiveDriveName().equals(Strings.Form_Wisdom)) {
DRIVE.setDriveExp(DRIVE.getActiveDriveName(), DRIVE.getDriveExp(DRIVE.getActiveDriveName())+1);
int[] costs = DriveFormRegistry.get(DRIVE.getActiveDriveName()).getExpCosts();
int actualLevel = DRIVE.getDriveLevel(DRIVE.getActiveDriveName());
int actualExp = DRIVE.getDriveExp(DRIVE.getActiveDriveName());
if(costs.length == 7 && actualLevel < 7) {
if (actualExp >= costs[actualLevel]){
System.out.println("LEVEL UP");
DRIVE.setDriveLevel(DRIVE.getActiveDriveName(),actualLevel+1);
DRIVE.displayLevelUpMessage(player, DRIVE.getActiveDriveName());
}
}
PacketDispatcher.sendTo(new SyncDriveData(DRIVE), (EntityPlayerMP) player);
}
}
}
}
示例15: onEntityKill
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onEntityKill(LivingDeathEvent event) {
if (event.getSource() == null) {
return;
}
if (event.getSource().getTrueSource() instanceof EntityPlayer && event.getEntity() instanceof EntityLivingBase) {
EntityPlayer attacker = (EntityPlayer) event.getSource().getTrueSource();
int level = getCurrentLevelTool(attacker);
if (level <= 0) {
return;
}
EntityLivingBase target = (EntityLivingBase) event.getEntity();
World world = attacker.getEntityWorld();
BlockPos pos = target.getPosition();
dropExp(world, pos, XP_PER_LVL * level);
}
}