本文整理匯總了Java中net.minecraftforge.event.entity.living.LivingDeathEvent.getEntityLiving方法的典型用法代碼示例。如果您正苦於以下問題:Java LivingDeathEvent.getEntityLiving方法的具體用法?Java LivingDeathEvent.getEntityLiving怎麽用?Java LivingDeathEvent.getEntityLiving使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.event.entity.living.LivingDeathEvent
的用法示例。
在下文中一共展示了LivingDeathEvent.getEntityLiving方法的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: 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);
}
}
}
}
示例3: 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) + "]"));
}
}
示例4: 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;
}
}
}
示例5: 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);
}
}
}
示例6: 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));
}
}
}
示例7: onLivingDeath
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onLivingDeath(LivingDeathEvent event) {
if (Always.isServer()) {
EntityLivingBase living = event.getEntityLiving();
if (!living.isEntityUndead()) {
EntityLivingBase target = EntityAIFindEntityNearestHelper.findNearest(living,
EntityLivingBase.class, AABBHelper.getAABBFromEntity(living, RADIUS), this::isEquipmented);
float power = living.getMaxHealth() / 5;
if (target != null && power > 0) {
ItemStack alive = getFormLiving(target);
alive_power.set(alive, min(alive_power.get(alive) + power, MAX_POWER));
List<Double6IntArrayPackage> d6iaps = Lists.newLinkedList();
int update[] = FXUpdateHelper.getIntArrayByArgs(FX_KEY_FOLLOW, target.getEntityId());
for (int i = 0; i < 4; i++)
d6iaps.add(new Double6IntArrayPackage(
living.posX + living.rand.nextGaussian(),
living.posY + living.rand.nextFloat() * .5,
living.posZ + living.rand.nextGaussian(), 0, 0, 0, update));
AlchemyNetworkHandler.spawnParticle(FXWisp.Info.type,
AABBHelper.getAABBFromEntity(living, AlchemyNetworkHandler.getParticleRange()), living.world, d6iaps);
}
}
}
}
示例8: onPlayerDeathMessage
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent
@SideOnly(Side.CLIENT)
public void onPlayerDeathMessage(LivingDeathEvent e)
{
if (!Config.deathMessages
|| !(e.getEntityLiving() instanceof EntityPlayer)
|| e.getEntityLiving().getUniqueID() != Minecraft.getMinecraft().thePlayer.getUniqueID())
return;
// Getting discord and minecraft user
EntityPlayer player = (EntityPlayer) e.getEntityLiving();
User me = DiscordCE.client.getUserById(DiscordCE.client.getSelfInfo().getId());
// Getting death message
String deathMessage = e.getSource().getDeathMessage(e.getEntityLiving()).getUnformattedText();
// Replacing minecraft name with discord name
deathMessage = deathMessage.replaceAll(player.getDisplayNameString(), me.getAsMention());
// Sending death message
DiscordCE.client.getTextChannelById(Preferences.i.usingChannel).sendMessageAsync(deathMessage, null);
}
示例9: onPlayerDeath
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerDeath(LivingDeathEvent event)
{
if(!event.getEntityLiving().getEntityWorld().isRemote && event.getEntityLiving() instanceof EntityPlayer && !(event.getEntityLiving() instanceof FakePlayer))
{
EntityPlayerMP player = (EntityPlayerMP)event.getEntityLiving();
if(player.interactionManager.getGameType() == GameType.CREATIVE || player.interactionManager.getGameType() == GameType.SPECTATOR)
{
return;
}
NBTTagCompound tag = EntityHelper.getPlayerPersistentData(player, "LimitedLivesSave");
int prevDeaths = tag.getInteger("deathCount");
int liveCount = tag.getInteger("maxLives");
if(liveCount == 0)
{
liveCount = LimitedLives.maxLives;
}
tag.setDouble("healthOffset", event.getEntityLiving().getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).getBaseValue() - (20D - (20D * prevDeaths / (double)liveCount)));
tag.setInteger("deathCount", prevDeaths + 1);
tag.setInteger("maxLives", LimitedLives.maxLives);
}
}
示例10: livingDeathEvent
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void livingDeathEvent(LivingDeathEvent event)
{
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) return;
if (event.getSource() != DamageSource.OUT_OF_WORLD || !(event.getEntity() instanceof EntityPlayer)) return;
if (event.getEntityLiving().lastDamage >= (Float.MAX_VALUE / 2)) return; // try to ignore /kill command
for (int dim : voidRefundDimensions)
{
if (dim != event.getEntity().dimension) continue;
event.setCanceled(true);
//noinspection ConstantConditions
InventoryPlayer tempCopy = new InventoryPlayer(null);
tempCopy.copyInventory(((EntityPlayer) event.getEntity()).inventory);
map.put(event.getEntity().getPersistentID(), tempCopy);
}
}
示例11: onDeath
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent(receiveCanceled = true, priority = EventPriority.NORMAL)
public void onDeath(LivingDeathEvent event)
{
int amount = rand.nextInt(3) + 1;
EntityLivingBase entity = event.getEntityLiving();
if (!entity.world.isRemote)
{
if (entity instanceof EntityPlayer)
{
ItemStack playerFlesh = new ItemStack(ItemRegistry.playerFlesh);
setMeatName(playerFlesh, entity.getName() + "'s Flesh");
entity.entityDropItem(playerFlesh, amount);
if (event.getSource().getTrueSource() instanceof EntityPlayer)
possessKiller((EntityPlayer) event.getSource().getTrueSource(), CannibalismNBT.getNBT((EntityPlayer) entity));
}
if (entity instanceof EntityVillager)
{
entity.dropItem(ItemRegistry.villagerFlesh, amount);
}
}
}
示例12: onSkeletonDeath
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onSkeletonDeath(LivingDeathEvent event) {
EntityLivingBase entity = event.getEntityLiving();
Entity sourceOfDamage = event.getSource().getSourceOfDamage();
if (entity instanceof EntitySkeleton && sourceOfDamage instanceof EntityPlayer &&
entity.isServerWorld()) {
spawnWitherSkeleton(entity.getEntityWorld(), entity.getPosition());
destroyHeldTool((EntityPlayer) sourceOfDamage);
}
}
示例13: onPlayerDeath
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onPlayerDeath(LivingDeathEvent event)
{
if(event.getEntityLiving() instanceof EntityPlayer)
{
HarshenItemStackHandler handler = HarshenUtils.getHandler(event.getEntity().getEntityData());
stackMap.put(event.getEntity().getUniqueID(), handler);
}
}
示例14: statEvent
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void statEvent(LivingDeathEvent event) {
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;
// Attackers weapon
ItemStack stack = player.getHeldItemMainhand();
if (stack == null) { return; }
// Weapon NBT
NBTTagCompound nbt = stack.getTagCompound();
if (nbt == null || !nbt.hasKey("Kills")) { return; }
String name = target.getName();
name = name + "Kills";
name = name.replace(" ", "_");
if (nbt.hasKey(name)) {
int i = nbt.getInteger(name) + 1;
nbt.setInteger(name, i);
}
setStrange(stack, nbt, event);
}
}
示例15: onLivingDeath
import net.minecraftforge.event.entity.living.LivingDeathEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOW)
public static void onLivingDeath(LivingDeathEvent event) {
EntityLivingBase entityLiving = event.getEntityLiving();
if (entityLiving instanceof EntityPlayer && !(entityLiving instanceof FakePlayer)) {
PlayerDataManager.clearPlayer((EntityPlayer) entityLiving);
}
}