当前位置: 首页>>代码示例>>Java>>正文


Java EntityLivingBase.getEntityWorld方法代码示例

本文整理汇总了Java中net.minecraft.entity.EntityLivingBase.getEntityWorld方法的典型用法代码示例。如果您正苦于以下问题:Java EntityLivingBase.getEntityWorld方法的具体用法?Java EntityLivingBase.getEntityWorld怎么用?Java EntityLivingBase.getEntityWorld使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.EntityLivingBase的用法示例。


在下文中一共展示了EntityLivingBase.getEntityWorld方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dropClay

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
public void dropClay(LivingDropsEvent event) {
    EntityLivingBase deadEntity = event.getEntityLiving();
    World world = deadEntity.getEntityWorld();
    BlockPos position = deadEntity.getPosition();
    double x = position.getX();
    double y = position.getY();
    double z = position.getZ();
    if (deadEntity instanceof EntityWitherSkeleton) {
        if (world.rand.nextInt(10) == 5) {
            event.getDrops().add(new EntityItem(world, x, y, z, new ItemStack(Items.CLAY_BALL)));
        }
    } else if (deadEntity instanceof EntityDragon || deadEntity instanceof EntityWither) {
        event.getDrops().add(new EntityItem(world, x, y, z, new ItemStack(Items.CLAY_BALL)));
    }
}
 
开发者ID:elifoster,项目名称:MakeClayValuableAgain,代码行数:17,代码来源:ClayProgressionImprovements.java

示例2: onEntityJoinWorld

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
public void onEntityJoinWorld(EntityJoinWorldEvent event)
{
	if (event.getEntity() instanceof EntityLivingBase && !(event.getEntity() instanceof EntityPlayer))
	{
		EntityLivingBase entity = (EntityLivingBase) event.getEntity();
		World world = entity.getEntityWorld();
		IEnemyLevel enemyLevelCap = entity.getCapability(CapabilityEnemyLevel.ENEMY_LEVEL, null);
		IChunkLevelHolder chunkLevelHolder = world.getCapability(CapabilityChunkLevel.CHUNK_LEVEL, null);
		
		if (enemyLevelCap != null && chunkLevelHolder != null)
		{
			if (enemyLevelCap.getEnemyLevel() == 0)
			{
				IChunkLevel chunkLevel = chunkLevelHolder.getChunkLevel(new ChunkPos(entity.getPosition()));
				int level = chunkLevel.getChunkLevel();
				
				enemyLevelCap.setEnemyLevel(level);
				entity.setCustomNameTag("Level: " + enemyLevelCap.getEnemyLevel());
				
				if (level > 1) setAttributeModifiers(entity, level);
			}
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:26,代码来源:EventEntityJoinWorld.java

示例3: onEquipped

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onEquipped(ItemStack stack, EntityLivingBase entity) 
{
	if (entity.getEntityWorld().isRemote) entity.playSound(SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 0.1F, 1.3f);
	else
	{
		if (entity instanceof EntityPlayer)
		{
			EntityPlayer player = (EntityPlayer) entity;
			PlayerInformation info = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
			
			if (info != null && info.getPlayerLevel() >= NBTHelper.loadStackNBT(stack).getInteger("Level"))
			{
				EventPlayerTick.updateStats(player, info);
			}
			else player.sendMessage(new TextComponentString(TextFormatting.RED + "WARNING: You are using a high-leveled item. It will be useless and will not provide any bonuses."));
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:20,代码来源:ItemLEBauble.java

示例4: onUnequipped

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onUnequipped(ItemStack stack, EntityLivingBase entity) 
{
	if (!entity.getEntityWorld().isRemote)
	{
		if (entity instanceof EntityPlayer)
		{
			EntityPlayer player = (EntityPlayer) entity;
			PlayerInformation info = (PlayerInformation) player.getCapability(CapabilityPlayerInformation.PLAYER_INFORMATION, null);
			
			if (info != null)
			{
				EventPlayerTick.updateStats(player, info);
			}
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:18,代码来源:ItemLEBauble.java

示例5: itemInteractionForEntity

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target, EnumHand hand) {
    if (target.getEntityWorld().isRemote) return false;
    if (target instanceof EntityPlayer || !target.isNonBoss()) return false;
    if (containsEntity(stack)) return false;
    String entityID = EntityList.getKey(target).toString();
    if (isBlacklisted(entityID)) return false;
    NBTTagCompound nbt = new NBTTagCompound();
    nbt.setString("entity", entityID);
    nbt.setInteger("id", EntityList.getID(target.getClass()));
    target.writeToNBT(nbt);
    stack.setTagCompound(nbt);
    playerIn.swingArm(hand);
    playerIn.setHeldItem(hand, stack);
    target.setDead();
    return true;
}
 
开发者ID:Buuz135,项目名称:Industrial-Foregoing,代码行数:18,代码来源:MobImprisonmentToolItem.java

示例6: handleServerMessage

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public IMessage handleServerMessage(EntityPlayer player, MessageSyncAdd message, MessageContext ctx) {
	if ((player != null) && (message != null) && (ctx != null)) {
		EntityLivingBase en = (EntityLivingBase) player.getEntityWorld().getEntityByID(message.entityId);
		if (en != null) {
			if (player.getEntityId() == en.getEntityId() && en.getEntityWorld() != null && en.hasCapability(Currency.ACCOUNT_DATA, null)) {
				AccountCapability entityData = en.getCapability(Currency.ACCOUNT_DATA, null);
				for (ItemStack stack : CurrencyUtils.itemMoneyAmount(message.amount)) {
					if (stack != null && stack != ItemStack.EMPTY && en instanceof EntityPlayer) {
						EntityPlayer pl = (EntityPlayer) en;
						pl.inventory.addItemStackToInventory(stack);
					}
				}
			}
		}
	}
	return null;
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:19,代码来源:MessageSyncAdd.java

示例7: onWornTick

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
@Method(modid = MODID_BAUBLES)
public void onWornTick(ItemStack stack, EntityLivingBase player) {
	if (!player.getEntityWorld().isRemote) {
		doTick(player, stack);
	}
}
 
开发者ID:p455w0rd,项目名称:ToughExpansion,代码行数:8,代码来源:ItemTempRegulator.java

示例8: handleServerMessage

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public IMessage handleServerMessage(EntityPlayer player, MessageSyncDrops message, MessageContext ctx) {
	if ((player != null) && (message != null) && (ctx != null)) {
		EntityLivingBase en = (EntityLivingBase) player.getEntityWorld().getEntityByID(message.entityId);
		if (en != null) {
			if (player.getEntityId() == en.getEntityId() && en.getEntityWorld() != null && en.hasCapability(Currency.ACCOUNT_DATA, null)) {
				AccountCapability entityData = en.getCapability(Currency.ACCOUNT_DATA, null);
				CurrencyUtils.dropMoneyAmount(message.amount, en.getEntityWorld(), en.posX, en.posY, en.posZ);
			}
		}
	}
	return null;
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:14,代码来源:MessageSyncDrops.java

示例9: handleClientMessage

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public IMessage handleClientMessage(EntityPlayer player, MessageSyncAccount message, MessageContext ctx) {
	if ((player != null) && (message != null) && (ctx != null)) {
		EntityLivingBase en = (EntityLivingBase) player.getEntityWorld().getEntityByID(message.entityId);
		if (en != null) {
			if (en.getEntityWorld() != null && en.hasCapability(Currency.ACCOUNT_DATA, null)) {
				AccountCapability entityData = en.getCapability(Currency.ACCOUNT_DATA, null);
				entityData.setAmount(message.amount, false);
			}
		}
	}
	return null;
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:14,代码来源:MessageSyncAccount.java

示例10: handleClientMessage

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public IMessage handleClientMessage(EntityPlayer player, MessageSyncCart message, MessageContext ctx) {
	if ((player != null) && (message != null) && (ctx != null)) {
		EntityLivingBase en = (EntityLivingBase) player.getEntityWorld().getEntityByID(message.entityId);
		if (en != null) {
			if (en.getEntityWorld() != null && en.hasCapability(Currency.CART_DATA, null)) {
				CartCapability entityData = en.getCapability(Currency.CART_DATA, null);
				entityData.setCart(message.cart, false);
			}
		}
	}
	return null;
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:14,代码来源:MessageSyncCart.java

示例11: handleServerMessage

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public IMessage handleServerMessage(EntityPlayer player, MessageSyncServer message, MessageContext ctx) {
	if ((player != null) && (message != null) && (ctx != null)) {
		EntityLivingBase en = (EntityLivingBase) player.getEntityWorld().getEntityByID(message.entityId);
		if (en != null) {
			if (en.getEntityWorld() != null && en.hasCapability(Currency.ACCOUNT_DATA, null)) {
				AccountCapability entityData = en.getCapability(Currency.ACCOUNT_DATA, null);
				entityData.setAmount(message.amount, false);
			}
		}
	}
	return null;
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:14,代码来源:MessageSyncServer.java

示例12: handleClientMessage

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public IMessage handleClientMessage(EntityPlayer player, MessageSyncCartItem message, MessageContext ctx) {
	if ((player != null) && (message != null) && (ctx != null)) {
		EntityLivingBase en = (EntityLivingBase) player.getEntityWorld().getEntityByID(message.entityId);
		if (en != null) {
			if (en.getEntityWorld() != null && en.hasCapability(Currency.CART_DATA, null)) {
				CartCapability entityData = en.getCapability(Currency.CART_DATA, null);
				entityData.setStackInSlot(message.slot, message.stack, false);
			}
		}
	}
	return null;
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:14,代码来源:MessageSyncCartItem.java

示例13: handleClientMessage

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public IMessage handleClientMessage(EntityPlayer player, MessageSyncPrices message, MessageContext ctx) {
	if ((player != null) && (message != null) && (ctx != null)) {
		EntityLivingBase en = (EntityLivingBase) player.getEntityWorld().getEntityByID(message.entityId);
		if (en != null) {
			if (en.getEntityWorld() != null && en.hasCapability(Currency.CART_DATA, null)) {
				CartCapability entityData = en.getCapability(Currency.CART_DATA, null);
				entityData.setPrices(message.prices, false);
			}
		}
	}
	return null;
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:14,代码来源:MessageSyncPrices.java

示例14: somethingDied

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
public void somethingDied(LivingDropsEvent event)
{
	if (!"player".equals(event.getSource().damageType))
	{
		return;
	}

	EntityLivingBase entity = event.getEntityLiving();
	int looting = event.getLootingLevel();
	Random rng = entity.getEntityWorld().rand;

	ItemStack skull = null;

	if (entity instanceof EntityZombieVillager)
	{
		if (rng.nextFloat() < 0.025 + looting * 0.01)
		{
			skull = HEADS.get("minecraft:zombie_villager;" + ((EntityZombieVillager) entity).getForgeProfession().getRegistryName().toString());
		}
	}
	else if (entity instanceof EntityLlama)
	{
		if (rng.nextFloat() < 0.025 + looting * 0.01)
		{
			skull = HEADS.get("minecraft:llama;" + ((EntityLlama) entity).getVariant());
		}
	}
	else if (entity instanceof EntityOcelot)
	{
		if (rng.nextFloat() < 0.05 + looting * 0.02)
		{
			skull = HEADS.get("minecraft:ocelot;" + ((EntityOcelot) entity).getTameSkin());
		}
	}
	else if (entity instanceof EntityRabbit)
	{
		if (rng.nextFloat() < 0.1 + looting * 0.05)
		{
			if ("Toast".equals(entity.getCustomNameTag()))
			{
				skull = HEADS.get("minecraft:rabbit;Toast");
			}
			else
			{
				skull = HEADS.get("minecraft:rabbit;" + ((EntityRabbit) entity).getRabbitType());
			}
		}
	}
	else if (entity instanceof EntityParrot)
	{
		skull = HEADS.get("minecraft:parrot;" + ((EntityParrot) entity).getVariant());
	}
	else if (entity instanceof EntityHorse)
	{
		if (rng.nextFloat() < 0.2 + looting * 0.1)
		{
			skull = HEADS.get("minecraft:horse;" + ((EntityHorse) entity).getHorseVariant() % 256);
		}
	}
	else if (entity instanceof EntityWither)
	{
		skull = WITHER_HEADS.get(entity.getEntityWorld().rand.nextInt(WITHER_HEADS.size()));
	}

	if (skull != null)
	{
		event.getDrops().add(new EntityItem(entity.getEntityWorld(), entity.getPosition().getX(), entity.getPosition().getY(), entity.getPosition().getZ(), skull.copy()));
	}
}
 
开发者ID:DarkMorford,项目名称:BetterThanWeagles,代码行数:71,代码来源:EvenMoreMobHeads.java

示例15: onLivingHurt

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST) //so all other can modify their damage first, and we apply after that
public static void onLivingHurt(LivingHurtEvent event) {
    EntityLivingBase entity = event.getEntityLiving();
    float amountToDamage = event.getAmount();
    if (entity.getEntityWorld().isRemote || !(entity instanceof EntityPlayer))
        return;
    EntityPlayer player = (EntityPlayer) entity;
    AbstractPlayerDamageModel damageModel = PlayerDataManager.getDamageModel(player);
    DamageSource source = event.getSource();

    if (amountToDamage == Float.MAX_VALUE) {
        damageModel.forEach(damageablePart -> damageablePart.currentHealth = 0F);
        if (player instanceof EntityPlayerMP)
            Arrays.stream(EnumPlayerPart.VALUES).forEach(part -> FirstAid.NETWORKING.sendTo(new MessageReceiveDamage(part, Float.MAX_VALUE, 0F), (EntityPlayerMP) player));
        event.setCanceled(true);
        CommonUtils.killPlayer(player, source);
        return;
    }

    amountToDamage = ArmorUtils.applyGlobalPotionModifiers(player, source, amountToDamage);

    //VANILLA COPY - combat tracker and exhaustion
    if (amountToDamage != 0.0F) {
        player.addExhaustion(source.getHungerDamage());
        //2nd param is actually never queried, no need to worry about wrong values
        player.getCombatTracker().trackDamage(source, -1, amountToDamage);
    }

    boolean addStat = amountToDamage < 3.4028235E37F;
    IDamageDistribution damageDistribution = FirstAidRegistryImpl.INSTANCE.getDamageDistribution(source);

    if (source.isProjectile()) {
        Pair<Entity, RayTraceResult> rayTraceResult = hitList.remove(player);
        if (rayTraceResult != null) {
            Entity entityProjectile = rayTraceResult.getLeft();
            EntityEquipmentSlot slot = ProjectileHelper.getPartByPosition(entityProjectile, player);
            if (slot != null)
                damageDistribution = new PreferredDamageDistribution(slot);
        }
    }

    float left = damageDistribution.distributeDamage(amountToDamage, player, source, addStat);
    if (left > 0) {
        damageDistribution = RandomDamageDistribution.NEAREST_KILL;
        damageDistribution.distributeDamage(left, player, source, addStat);
    }

    event.setCanceled(true);
    if (damageModel.isDead(player))
        CommonUtils.killPlayer(player, source);

    hitList.remove(player);
}
 
开发者ID:ichttt,项目名称:FirstAid,代码行数:54,代码来源:EventHandler.java


注:本文中的net.minecraft.entity.EntityLivingBase.getEntityWorld方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。