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


Java World.spawnEntity方法代码示例

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


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

示例1: performEffect

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void performEffect(RayTraceResult rtrace, EntityLivingBase caster, World world) {
	if (rtrace.typeOfHit == Type.ENTITY && rtrace.entityHit instanceof EntityLivingBase) {
		EntityLivingBase entity = (EntityLivingBase) rtrace.entityHit;
		EnumHand hand = null;
		if (!entity.getHeldItemMainhand().isEmpty()) hand = EnumHand.MAIN_HAND;
		else if (!entity.getHeldItemOffhand().isEmpty()) hand = EnumHand.OFF_HAND;
		if (hand != null) {
			ItemStack stack = entity.getHeldItem(hand).copy();
			entity.setHeldItem(hand, ItemStack.EMPTY);
			if (!(entity instanceof EntityPlayer) && stack.isItemStackDamageable() && stack.getItemDamage() == 0) {
				stack.setItemDamage((int) (stack.getMaxDamage() * (0.5D + 0.5D * Math.random())));
			}
			EntityItem ei = new EntityItem(world, entity.posX, entity.posY, entity.posZ, stack);
			ei.setPickupDelay(200);
			ei.setNoDespawn();
			if (!world.isRemote) world.spawnEntity(ei);
		}
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:21,代码来源:SpellDisarming.java

示例2: onItemRightClick

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
	public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
	{
		ItemStack stack = player.getHeldItem(hand);

		if (!player.capabilities.isCreativeMode)
		{
			stack.shrink(1);
		}

		world.playSound((EntityPlayer)null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

		if (!world.isRemote)
		{
			EntityCurseOrb entity = new EntityCurseOrb(world, player);
			entity.setHeadingFromThrower(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
			world.spawnEntity(entity);
		}

//		playerIn.addStat(StatList.getObjectUseStats(this));
		return new ActionResult(EnumActionResult.SUCCESS, stack);
	}
 
开发者ID:crazysnailboy,项目名称:Halloween,代码行数:23,代码来源:ItemCurseOrb.java

示例3: onBlockActivated

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand,
		EnumFacing side, float hitX, float hitY, float hitZ) {

	if (!world.isRemote && world.getTileEntity(pos) instanceof TilePedestal) {
		TilePedestal pedestal = (TilePedestal) world.getTileEntity(pos);
		if (pedestal.getStack().func_190926_b()) {
			if (!player.getHeldItem(hand).func_190926_b()) {
				pedestal.setStack(player.getHeldItem(hand));
				player.inventory.setInventorySlotContents(player.inventory.currentItem, ItemStack.field_190927_a);
				player.openContainer.detectAndSendChanges();
			}
		} else {
			ItemStack stack = pedestal.getStack();
			pedestal.setStack(ItemStack.field_190927_a);
			if (!player.inventory.addItemStackToInventory(stack)) {
				EntityItem entityItem = new EntityItem(world, pos.getX(), pos.getY() + 1, pos.getZ(), stack);
				world.spawnEntity(entityItem);
			} else {
				player.openContainer.detectAndSendChanges();
			}
		}
	}

	return true;
}
 
开发者ID:the-realest-stu,项目名称:Infernum,代码行数:27,代码来源:BlockPedestal.java

示例4: onItemUse

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    if (!worldIn.isRemote) {
        ItemStack stack = player.getHeldItem(hand);
        if (stack.getMetadata() == 1 && !(worldIn.getTileEntity(pos) instanceof TileFaerieHome)) {
            NBTTagCompound nbt = stack.getTagCompound();
            if (nbt == null) return EnumActionResult.FAIL;
            EntityFaerie faerie = new EntityFaerie(worldIn, nbt.getDouble("max_health"), nbt.getInteger("type"), nbt.getFloat("size"), nbt.getInteger("level"), nbt.getInteger("current_exp"));
            faerie.setPosition((double) pos.getX(), (double) pos.up().getY(), (double) pos.getZ());
            worldIn.spawnEntity(faerie);
            player.setHeldItem(hand, new ItemStack(GeneraItems.ItemGlassJar, 1, 0));
            return EnumActionResult.SUCCESS;
        }
    }
    return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
}
 
开发者ID:BenjaminSutter,项目名称:genera,代码行数:18,代码来源:ItemGlassJar.java

示例5: updateTick

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
    super.updateTick(worldIn, pos, state, rand);
    if (!worldIn.isRemote) {
        if (state.getValue(AGE) == 2) {
            EntityFaerie faerie = new EntityFaerie(worldIn, 4.0D, 0, 0.1F, 1);
            faerie.setPosition((double) pos.getX(), (double) pos.up().getY(), (double) pos.getZ());
            worldIn.spawnEntity(faerie);
        }
        if (!(worldIn.getBiome(pos) == Biomes.FOREST ||
                worldIn.getBiome(pos) == Biomes.FOREST_HILLS ||
                worldIn.getBiome(pos) == Biomes.TAIGA ||
                worldIn.getBiome(pos) == Biomes.TAIGA_HILLS) && state.getValue(AGE) >= 1) {
            worldIn.setBlockState(pos, state.withProperty(AGE, 0));
        }
    }

}
 
开发者ID:BenjaminSutter,项目名称:genera,代码行数:19,代码来源:BlockNightshadeCrop.java

示例6: throwProjectile

import net.minecraft.world.World; //导入方法依赖的package包/类
private void throwProjectile(EntityPlayer player, EnumHand hand, World world) {
    ItemStack heldItem = player.getHeldItem(hand);

    int charge = getCharge(heldItem);
    if (charge <= 0) {
        MeeCreepsMessages.INSTANCE.sendTo(new PacketShowBalloonToClient("message.meecreeps.gun_no_charge"), (EntityPlayerMP) player);
        return;
    }
    setCharge(heldItem, charge-1);

    List<TeleportDestination> destinations = getDestinations(heldItem);
    int current = getCurrentDestination(heldItem);
    if (current == -1) {
        MeeCreepsMessages.INSTANCE.sendTo(new PacketShowBalloonToClient("message.meecreeps.gun_no_destination"), (EntityPlayerMP) player);
    } else if (destinations.get(current) == null) {
        MeeCreepsMessages.INSTANCE.sendTo(new PacketShowBalloonToClient("message.meecreeps.gun_bad_destination"), (EntityPlayerMP) player);
    } else {
        EntityProjectile projectile = new EntityProjectile(world, player);
        projectile.setDestination(destinations.get(current));
        projectile.setPlayerId(player.getUniqueID());
        projectile.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, 1.5F, 1.0F);
        world.spawnEntity(projectile);
    }
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:25,代码来源:PortalGunItem.java

示例7: onItemRightClick

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand hand) {
	ItemStack itemstack = playerIn.getHeldItem(hand);
	ItemStack copy = playerIn.capabilities.isCreativeMode ? itemstack.copy() : itemstack.splitStack(1);
	playerIn.playSound(SoundEvents.ENTITY_LINGERINGPOTION_THROW, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

	if (!worldIn.isRemote) {
		EntityBrew brew = new EntityBrew(worldIn, playerIn, copy, EntityBrew.BrewDispersion.LINGER);

		brew.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, -20.0F, 0.5F, 1.0F);
		worldIn.spawnEntity(brew);
	}

	return ActionResult.newResult(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand));
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:16,代码来源:ItemBrewLinger.java

示例8: onItemUse

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (hand != EnumHand.MAIN_HAND) return EnumActionResult.PASS;

    if (!world.isRemote) {
        ItemStack iStack = player.getHeldItemMainhand();
        EntityDrone drone = new EntityDrone(world, player);

        BlockPos placePos = pos.offset(facing);
        drone.setPosition(placePos.getX() + 0.5, placePos.getY() + 0.5, placePos.getZ() + 0.5);
        world.spawnEntity(drone);

        NBTTagCompound stackTag = iStack.getTagCompound();
        NBTTagCompound entityTag = new NBTTagCompound();
        drone.writeEntityToNBT(entityTag);
        if (stackTag != null) {
            entityTag.setTag("widgets", stackTag.getTagList("widgets", 10).copy());
            entityTag.setFloat("currentAir", stackTag.getFloat("currentAir"));
            entityTag.setInteger("color", stackTag.getInteger("color"));
            entityTag.setTag(ChargeableItemHandler.NBT_UPGRADE_TAG, stackTag.getCompoundTag(ChargeableItemHandler.NBT_UPGRADE_TAG));
        }
        drone.readEntityFromNBT(entityTag);
        if (iStack.hasDisplayName()) drone.setCustomNameTag(iStack.getDisplayName());

        drone.naturallySpawned = false;
        //TODO 1.8 check if valid replacement drone.onSpawnWithEgg(null);
        drone.onInitialSpawn(world.getDifficultyForLocation(placePos), null);
        iStack.shrink(1);
    }
    return EnumActionResult.SUCCESS;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:32,代码来源:ItemDrone.java

示例9: onItemUse

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    ItemStack iStack = player.getHeldItem(hand);
    if (!world.isRemote) {
        EntityDrone drone = new EntityLogisticsDrone(world, player);

        BlockPos placePos = pos.offset(facing);
        drone.setPosition(placePos.getX() + 0.5, placePos.getY() + 0.5, placePos.getZ() + 0.5);
        world.spawnEntity(drone);

        NBTTagCompound stackTag = iStack.getTagCompound();
        NBTTagCompound entityTag = new NBTTagCompound();
        drone.writeEntityToNBT(entityTag);
        if (stackTag != null) {
            entityTag.setFloat("currentAir", stackTag.getFloat("currentAir"));
            entityTag.setInteger("color", stackTag.getInteger("color"));
            entityTag.setTag(ChargeableItemHandler.NBT_UPGRADE_TAG, stackTag.getCompoundTag(ChargeableItemHandler.NBT_UPGRADE_TAG));
        }
        drone.readEntityFromNBT(entityTag);
        addLogisticsProgram(pos, drone.progWidgets);
        if (iStack.hasDisplayName()) drone.setCustomNameTag(iStack.getDisplayName());

        drone.naturallySpawned = false;
        //TODO 1.8 check if valid replacement drone.onSpawnWithEgg(null);
        drone.onInitialSpawn(world.getDifficultyForLocation(placePos), null);
        iStack.shrink(1);
    }
    return EnumActionResult.SUCCESS;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:30,代码来源:ItemLogisticsDrone.java

示例10: apply

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void apply(World world, BlockPos pos, EntityLivingBase entity, int amplifier, int tick) {
	if (entity instanceof EntityMooshroom) {
		EntityCow cow = new EntityCow(world);
		cow.setPosition(pos.getX(), pos.getY(), pos.getZ());
		entity.setDead();
		world.spawnEntity(cow);
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:10,代码来源:GrassGrowBrew.java

示例11: drop

import net.minecraft.world.World; //导入方法依赖的package包/类
private static void drop(World world, BlockPos pos, BlockPos newPos) {
    EntityFallingBlock fallingBlock = new EntityFallingBlock(world, newPos.getX(), newPos.getY(), newPos.getZ(), world.getBlockState(pos));
    fallingBlock.setEntityBoundingBox(new AxisAlignedBB(newPos.add(0, 0, 0), newPos.add(1, 1, 1)));
    fallingBlock.fallTime = 1;
    world.spawnEntity(fallingBlock);
    world.setBlockState(pos, Blocks.AIR.getDefaultState());
}
 
开发者ID:ternsip,项目名称:ChopDown,代码行数:8,代码来源:ChopDown.java

示例12: addEntitiesToWorld

import net.minecraft.world.World; //导入方法依赖的package包/类
private void addEntitiesToWorld(World worldIn, BlockPos pos, Mirror mirrorIn, Rotation rotationIn, @Nullable StructureBoundingBox aabb)
{
    for (Template.EntityInfo template$entityinfo : this.entities)
    {
        BlockPos blockpos = transformedBlockPos(template$entityinfo.blockPos, mirrorIn, rotationIn).add(pos);

        if (aabb == null || aabb.isVecInside(blockpos))
        {
            NBTTagCompound nbttagcompound = template$entityinfo.entityData;
            Vec3d vec3d = transformedVec3d(template$entityinfo.pos, mirrorIn, rotationIn);
            Vec3d vec3d1 = vec3d.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ());
            NBTTagList nbttaglist = new NBTTagList();
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.x));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.y));
            nbttaglist.appendTag(new NBTTagDouble(vec3d1.z));
            nbttagcompound.setTag("Pos", nbttaglist);
            nbttagcompound.setUniqueId("UUID", UUID.randomUUID());
            Entity entity;

            try
            {
                entity = EntityList.createEntityFromNBT(nbttagcompound, worldIn);
            }
            catch (Exception var15)
            {
                entity = null;
            }

            if (entity != null)
            {
                float f = entity.getMirroredYaw(mirrorIn);
                f = f + (entity.rotationYaw - entity.getRotatedYaw(rotationIn));
                entity.setLocationAndAngles(vec3d1.x, vec3d1.y, vec3d1.z, f, entity.rotationPitch);
                worldIn.spawnEntity(entity);
            }
        }
    }
}
 
开发者ID:kenijey,项目名称:harshencastle,代码行数:39,代码来源:HarshenTemplate.java

示例13: onFinish

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void onFinish(EntityPlayer player, IRitualHandler tile, World world, BlockPos pos, NBTTagCompound data) {
	if (!world.isRemote) {
		EntityWitch witch = new EntityWitch(world);
		witch.setLocationAndAngles(pos.getX(), pos.getY(), pos.getZ(), (float) (Math.random() * 360), 0);
		witch.onInitialSpawn(world.getDifficultyForLocation(new BlockPos(witch)), (IEntityLivingData) null);
		world.spawnEntity(witch);
		if (Math.random() < 0.1)
			witch.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 6000, 2, false, false));
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:12,代码来源:RitualConjurationWitch.java

示例14: throwREP

import net.minecraft.world.World; //导入方法依赖的package包/类
public void throwREP(ItemStack itemstack, World world, EntityPlayer player) {
    if (REPThrowTimeout > 0) {
        return;
    }

    if (!player.capabilities.isCreativeMode) {
        itemstack.shrink(1);
    }
    world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ARROW_SHOOT, SoundCategory.NEUTRAL,  0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
    activeREP = new EntityREP(world, player);
    world.spawnEntity(activeREP);
    REPThrowTimeout = 40;
}
 
开发者ID:TheCBProject,项目名称:WirelessRedstone,代码行数:14,代码来源:RedstoneEtherClientAddons.java

示例15: onCastFinish

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public void onCastFinish(World world, EntityPlayer player, ItemStack stack) {
	if (!world.isRemote && consumePower(player)) {
		Vec3d lookVec = player.getLookVec();
		double x = player.posX + lookVec.xCoord;
		double y = player.posY + lookVec.yCoord + player.eyeHeight;
		double z = player.posZ + lookVec.zCoord;
		EntityWitheringBolt bolt = new EntityWitheringBolt(world, player, 1, x, y, z);
		bolt.setAim(player, player.rotationPitch, player.rotationYaw, 0.75F, 0.08F);
		world.spawnEntity(bolt);
	}
}
 
开发者ID:the-realest-stu,项目名称:Infernum,代码行数:13,代码来源:SpellWitheringBolt.java


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