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


Java World.playEvent方法代码示例

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


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

示例1: onItemUse

import net.minecraft.world.World; //导入方法依赖的package包/类
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(EntityPlayer stack, World playerIn, BlockPos worldIn, EnumHand pos, EnumFacing hand, float facing, float hitX, float hitY)
{
    IBlockState iblockstate = playerIn.getBlockState(worldIn);

    if (iblockstate.getBlock() == Blocks.JUKEBOX && !((Boolean)iblockstate.getValue(BlockJukebox.HAS_RECORD)).booleanValue())
    {
        if (!playerIn.isRemote)
        {
            ItemStack itemstack = stack.getHeldItem(pos);
            ((BlockJukebox)Blocks.JUKEBOX).insertRecord(playerIn, worldIn, iblockstate, itemstack);
            playerIn.playEvent((EntityPlayer)null, 1010, worldIn, Item.getIdFromItem(this));
            itemstack.func_190918_g(1);
            stack.addStat(StatList.RECORD_PLAYED);
        }

        return EnumActionResult.SUCCESS;
    }
    else
    {
        return EnumActionResult.PASS;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:26,代码来源:ItemRecord.java

示例2: onItemUse

import net.minecraft.world.World; //导入方法依赖的package包/类
/**
 * Called when a Block is right-clicked with this Item
 */
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (iblockstate.getBlock() == Blocks.JUKEBOX && !((Boolean)iblockstate.getValue(BlockJukebox.HAS_RECORD)).booleanValue())
    {
        if (!worldIn.isRemote)
        {
            ((BlockJukebox)Blocks.JUKEBOX).insertRecord(worldIn, pos, iblockstate, stack);
            worldIn.playEvent((EntityPlayer)null, 1010, pos, Item.getIdFromItem(this));
            --stack.stackSize;
            playerIn.addStat(StatList.RECORD_PLAYED);
        }

        return EnumActionResult.SUCCESS;
    }
    else
    {
        return EnumActionResult.PASS;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:25,代码来源:ItemRecord.java

示例3: dispense

import net.minecraft.world.World; //导入方法依赖的package包/类
protected void dispense(World worldIn, BlockPos pos)
{
    BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos);
    TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();

    if (tileentitydispenser != null)
    {
        int i = tileentitydispenser.getDispenseSlot();

        if (i < 0)
        {
            worldIn.playEvent(1001, pos, 0);
        }
        else
        {
            ItemStack itemstack = tileentitydispenser.getStackInSlot(i);
            IBehaviorDispenseItem ibehaviordispenseitem = this.getBehavior(itemstack);

            if (ibehaviordispenseitem != IBehaviorDispenseItem.DEFAULT_BEHAVIOR)
            {
                tileentitydispenser.setInventorySlotContents(i, ibehaviordispenseitem.dispense(blocksourceimpl, itemstack));
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:26,代码来源:BlockDispenser.java

示例4: onBlockActivated

import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    if (this.blockMaterial == Material.IRON)
    {
        return false;
    }
    else
    {
        BlockPos blockpos = state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
        IBlockState iblockstate = pos.equals(blockpos) ? state : worldIn.getBlockState(blockpos);

        if (iblockstate.getBlock() != this)
        {
            return false;
        }
        else
        {
            state = iblockstate.cycleProperty(OPEN);
            worldIn.setBlockState(blockpos, state, 10);
            worldIn.markBlockRangeForRenderUpdate(blockpos, pos);
            worldIn.playEvent(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? this.getOpenSound() : this.getCloseSound(), pos, 0);
            return true;
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:26,代码来源:BlockDoor.java

示例5: toggleDoor

import net.minecraft.world.World; //导入方法依赖的package包/类
public void toggleDoor(World worldIn, BlockPos pos, boolean open)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);

    if (iblockstate.getBlock() == this)
    {
        BlockPos blockpos = iblockstate.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
        IBlockState iblockstate1 = pos == blockpos ? iblockstate : worldIn.getBlockState(blockpos);

        if (iblockstate1.getBlock() == this && ((Boolean)iblockstate1.getValue(OPEN)).booleanValue() != open)
        {
            worldIn.setBlockState(blockpos, iblockstate1.withProperty(OPEN, Boolean.valueOf(open)), 10);
            worldIn.markBlockRangeForRenderUpdate(blockpos, pos);
            worldIn.playEvent((EntityPlayer)null, open ? this.getOpenSound() : this.getCloseSound(), pos, 0);
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:18,代码来源:BlockDoor.java

示例6: onBlockActivated

import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (this.blockMaterial == Material.IRON)
    {
        return false; //Allow items to interact with the door
    }
    else
    {
        BlockPos blockpos = state.getValue(HALF) == BlockDoor.EnumDoorHalf.LOWER ? pos : pos.down();
        IBlockState iblockstate = pos.equals(blockpos) ? state : worldIn.getBlockState(blockpos);

        if (iblockstate.getBlock() != this)
        {
            return false;
        }
        else
        {
            state = iblockstate.cycleProperty(OPEN);
            worldIn.setBlockState(blockpos, state, 10);
            worldIn.markBlockRangeForRenderUpdate(blockpos, pos);
            worldIn.playEvent(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? this.getOpenSound() : this.getCloseSound(), pos, 0);
            return true;
        }
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:26,代码来源:BlockDoor.java

示例7: neighborChanged

import net.minecraft.world.World; //导入方法依赖的package包/类
/**
 * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
 * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
 * block, etc.
 */
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos p_189540_5_)
{
    if (!worldIn.isRemote)
    {
        boolean flag = worldIn.isBlockPowered(pos);

        if (((Boolean)state.getValue(POWERED)).booleanValue() != flag)
        {
            worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(flag)).withProperty(OPEN, Boolean.valueOf(flag)), 2);

            if (((Boolean)state.getValue(OPEN)).booleanValue() != flag)
            {
                worldIn.playEvent((EntityPlayer)null, flag ? 1008 : 1014, pos, 0);
            }
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:23,代码来源:BlockFenceGate.java

示例8: onBlockActivated

import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (((Boolean)state.getValue(OPEN)).booleanValue())
    {
        state = state.withProperty(OPEN, Boolean.valueOf(false));
        worldIn.setBlockState(pos, state, 10);
    }
    else
    {
        EnumFacing enumfacing = EnumFacing.fromAngle((double)playerIn.rotationYaw);

        if (state.getValue(FACING) == enumfacing.getOpposite())
        {
            state = state.withProperty(FACING, enumfacing);
        }

        state = state.withProperty(OPEN, Boolean.valueOf(true));
        worldIn.setBlockState(pos, state, 10);
    }

    worldIn.playEvent(playerIn, ((Boolean)state.getValue(OPEN)).booleanValue() ? 1008 : 1014, pos, 0);
    return true;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:24,代码来源:BlockFenceGate.java

示例9: updateTask

import net.minecraft.world.World; //导入方法依赖的package包/类
/**
 * Updates the task
 */
public void updateTask()
{
    EntityLivingBase entitylivingbase = this.parentEntity.getAttackTarget();
    if (entitylivingbase.getDistanceSqToEntity(this.parentEntity) < 4096.0D && this.parentEntity.canEntityBeSeen(entitylivingbase))
    {
        World world = this.parentEntity.worldObj;
        ++this.attackTimer;

        if (this.attackTimer == 10)
        {
            world.playEvent((EntityPlayer)null, 1015, new BlockPos(this.parentEntity), 0);
        }

        if (this.attackTimer == 20)
        {
            Vec3d vec3d = this.parentEntity.getLook(1.0F);
            double d2 = entitylivingbase.posX - (this.parentEntity.posX + vec3d.xCoord * 4.0D);
            double d3 = entitylivingbase.getEntityBoundingBox().minY + (double)(entitylivingbase.height / 2.0F) - (0.5D + this.parentEntity.posY + (double)(this.parentEntity.height / 2.0F));
            double d4 = entitylivingbase.posZ - (this.parentEntity.posZ + vec3d.zCoord * 4.0D);
            world.playEvent((EntityPlayer)null, 1016, new BlockPos(this.parentEntity), 0);
            EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.parentEntity, d2, d3, d4);
            entitylargefireball.explosionPower = this.parentEntity.getFireballStrength();
            entitylargefireball.posX = this.parentEntity.posX + vec3d.xCoord * 4.0D;
            entitylargefireball.posY = this.parentEntity.posY + (double)(this.parentEntity.height / 2.0F) + 0.5D;
            entitylargefireball.posZ = this.parentEntity.posZ + vec3d.zCoord * 4.0D;
            world.spawnEntityInWorld(entitylargefireball);
            this.attackTimer = -40;
        }
    }
    else if (this.attackTimer > 0)
    {
        --this.attackTimer;
    }

    this.parentEntity.setAttacking(this.attackTimer > 10);
}
 
开发者ID:Herobone,项目名称:HeroUtils,代码行数:40,代码来源:EntityDummy.java

示例10: updateTask

import net.minecraft.world.World; //导入方法依赖的package包/类
/**
 * Updates the task
 */
public void updateTask()
{
    EntityLivingBase entitylivingbase = this.parentEntity.getAttackTarget();
    double d0 = 64.0D;

    if (entitylivingbase.getDistanceSqToEntity(this.parentEntity) < 4096.0D && this.parentEntity.canEntityBeSeen(entitylivingbase))
    {
        World world = this.parentEntity.worldObj;
        ++this.attackTimer;

        if (this.attackTimer == 10)
        {
            world.playEvent((EntityPlayer)null, 1015, new BlockPos(this.parentEntity), 0);
        }

        if (this.attackTimer == 20)
        {
            double d1 = 4.0D;
            Vec3d vec3d = this.parentEntity.getLook(1.0F);
            double d2 = entitylivingbase.posX - (this.parentEntity.posX + vec3d.xCoord * 4.0D);
            double d3 = entitylivingbase.getEntityBoundingBox().minY + (double)(entitylivingbase.height / 2.0F) - (0.5D + this.parentEntity.posY + (double)(this.parentEntity.height / 2.0F));
            double d4 = entitylivingbase.posZ - (this.parentEntity.posZ + vec3d.zCoord * 4.0D);
            world.playEvent((EntityPlayer)null, 1016, new BlockPos(this.parentEntity), 0);
            EntityLargeFireball entitylargefireball = new EntityLargeFireball(world, this.parentEntity, d2, d3, d4);
            entitylargefireball.explosionPower = this.parentEntity.getFireballStrength();
            entitylargefireball.posX = this.parentEntity.posX + vec3d.xCoord * 4.0D;
            entitylargefireball.posY = this.parentEntity.posY + (double)(this.parentEntity.height / 2.0F) + 0.5D;
            entitylargefireball.posZ = this.parentEntity.posZ + vec3d.zCoord * 4.0D;
            world.spawnEntityInWorld(entitylargefireball);
            this.attackTimer = -40;
        }
    }
    else if (this.attackTimer > 0)
    {
        --this.attackTimer;
    }

    this.parentEntity.setAttacking(this.attackTimer > 10);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:43,代码来源:EntityGhast.java

示例11: extinguishFire

import net.minecraft.world.World; //导入方法依赖的package包/类
public boolean extinguishFire(@Nullable EntityPlayer player, BlockPos pos, EnumFacing side, World world) {
	pos = pos.offset(side);
	if (world.getBlockState(pos).getBlock() == BlockRegistry.specialfire) {
		world.playEvent(player, 1009, pos, 0);
		world.setBlockToAir(pos);
		return true;
	}
	return false;
}
 
开发者ID:MinecraftModDevelopmentMods,项目名称:Got-Wood,代码行数:10,代码来源:FireHandler.java

示例12: onItemRightClick

import net.minecraft.world.World; //导入方法依赖的package包/类
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = worldIn.getHeldItem(playerIn);
    RayTraceResult raytraceresult = this.rayTrace(itemStackIn, worldIn, false);

    if (raytraceresult != null && raytraceresult.typeOfHit == RayTraceResult.Type.BLOCK && itemStackIn.getBlockState(raytraceresult.getBlockPos()).getBlock() == Blocks.END_PORTAL_FRAME)
    {
        return new ActionResult(EnumActionResult.PASS, itemstack);
    }
    else
    {
        worldIn.setActiveHand(playerIn);

        if (!itemStackIn.isRemote)
        {
            BlockPos blockpos = ((WorldServer)itemStackIn).getChunkProvider().getStrongholdGen(itemStackIn, "Stronghold", new BlockPos(worldIn), false);

            if (blockpos != null)
            {
                EntityEnderEye entityendereye = new EntityEnderEye(itemStackIn, worldIn.posX, worldIn.posY + (double)(worldIn.height / 2.0F), worldIn.posZ);
                entityendereye.moveTowards(blockpos);
                itemStackIn.spawnEntityInWorld(entityendereye);
                itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_ENDEREYE_LAUNCH, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
                itemStackIn.playEvent((EntityPlayer)null, 1003, new BlockPos(worldIn), 0);

                if (!worldIn.capabilities.isCreativeMode)
                {
                    itemstack.func_190918_g(1);
                }

                worldIn.addStat(StatList.getObjectUseStats(this));
                return new ActionResult(EnumActionResult.SUCCESS, itemstack);
            }
        }

        return new ActionResult(EnumActionResult.SUCCESS, itemstack);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:39,代码来源:ItemEnderEye.java

示例13: placeDeadFlower

import net.minecraft.world.World; //导入方法依赖的package包/类
private void placeDeadFlower(World p_185605_1_, BlockPos p_185605_2_)
{
    p_185605_1_.setBlockState(p_185605_2_, this.getDefaultState().withProperty(AGE, Integer.valueOf(5)), 2);
    p_185605_1_.playEvent(1034, p_185605_2_, 0);
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:6,代码来源:BlockChorusFlower.java

示例14: onBlockStartBreak

import net.minecraft.world.World; //导入方法依赖的package包/类
@Override
public boolean onBlockStartBreak(ItemStack itemstack, BlockPos pos, EntityPlayer player) {
	World world = player.getEntityWorld();

	if (!world.isRemote && player instanceof EntityPlayerMP) {

		RayTraceResult rt = this.rayTrace(world, player, false);
		if (rt.typeOfHit == RayTraceResult.Type.BLOCK) {
			EnumFacing side = rt.sideHit;

			List<BlockPos> extraBlocks = getExtraBlocks(world, rt, player);

			for (BlockPos pos2 : extraBlocks) {

				IBlockState state = world.getBlockState(pos2);

				if (!world.isBlockLoaded(pos2) || !player.canPlayerEdit(pos2, side, itemstack) || !(state.getBlock().canHarvestBlock(world, pos2, player))) {
					continue;
				}

				if (player.capabilities.isCreativeMode) {
					state.getBlock().onBlockHarvested(world, pos2, state, player);
					if (state.getBlock().removedByPlayer(state, world, pos2, player, false)) {
						state.getBlock().onBlockDestroyedByPlayer(world, pos2, state);
					}
				} else {
					int xp = ForgeHooks.onBlockBreakEvent(world, ((EntityPlayerMP) player).interactionManager.getGameType(), (EntityPlayerMP) player, pos2);

					state.getBlock().onBlockHarvested(world, pos2, state, player);
					this.onBlockDestroyed(itemstack, world, state, pos2, player);
					if (state.getBlock().removedByPlayer(state, world, pos2, player, true)) {
						state.getBlock().onBlockDestroyedByPlayer(world, pos2, state);
						state.getBlock().harvestBlock(world, player, pos2, state, world.getTileEntity(pos2), itemstack);
						state.getBlock().dropXpOnBlockBreak(world, pos2, xp);
					}
				}

				world.playEvent(2001, pos, Block.getStateId(state));
				((EntityPlayerMP) player).connection.sendPacket(new SPacketBlockChange(world, pos));

			}

		}

	}

	return false;
}
 
开发者ID:the-realest-stu,项目名称:Adventurers-Toolbox,代码行数:49,代码来源:ItemATHammer.java

示例15: auxHarvestBlock

import net.minecraft.world.World; //导入方法依赖的package包/类
/**
 * Destroys and tries to harvest a block with the currently active tool, except that instead of calling
 * onBlockDestroyed, it calls onBlockAuxDestroyed on the tool, preventing infinite loops.
 */
public static boolean auxHarvestBlock(World world, BlockPos pos, EntityPlayerMP player) {
	if (world.isRemote) return false; //Shouldn't even be possible if we have an EntityPlayerMP!
	
	GameType gameType = player.interactionManager.getGameType();
	
	int exp = net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(world, gameType, player, pos);
       if (exp == -1) {
           return false;
       } else {
           IBlockState iblockstate = world.getBlockState(pos);
           if (iblockstate.getBlockHardness(world, pos)<0) return false;
           TileEntity tileentity = world.getTileEntity(pos);
           Block block = iblockstate.getBlock();

           if ((block instanceof BlockCommandBlock || block instanceof BlockStructure) && !player.canUseCommandBlock()) {
               world.notifyBlockUpdate(pos, iblockstate, iblockstate, 3);
               return false;
           } else {
               ItemStack stack = player.getHeldItemMainhand();
               if (!stack.isEmpty() && stack.getItem().onBlockStartBreak(stack, pos, player)) return false;

               world.playEvent(player, 2001, pos, Block.getStateId(iblockstate));
               boolean removed = false;

               if (gameType==GameType.CREATIVE) {
                   removed = removeBlock(world, pos, player, false);
                   player.connection.sendPacket(new SPacketBlockChange(world, pos));
               } else {
                   ItemStack itemstack1 = player.getHeldItemMainhand();
                   ItemStack itemstack2 = itemstack1.isEmpty() ? ItemStack.EMPTY : itemstack1.copy();
                   boolean canHarvest = iblockstate.getBlock().canHarvestBlock(world, pos, player);

                   if (!itemstack1.isEmpty()) {
                   //    itemstack1.onBlockDestroyed(world, iblockstate, pos, player);
                    if (itemstack1.getItem() instanceof IAuxDestroyBlock) {
                    	((IAuxDestroyBlock)itemstack1.getItem()).onBlockAuxDestroyed(world, iblockstate, pos, player);
                    }
                   }
                   
                   removed = removeBlock(world, pos, player, canHarvest);
                   if (removed && canHarvest) {
                       iblockstate.getBlock().harvestBlock(world, player, pos, iblockstate, tileentity, itemstack2);
                   }
               }

               // Drop experience
               if (gameType!=GameType.CREATIVE && removed && exp > 0) {
                   iblockstate.getBlock().dropXpOnBlockBreak(world, pos, exp);
               }
               return removed;
           }
       }
}
 
开发者ID:elytra,项目名称:Thermionics,代码行数:58,代码来源:ToolHelper.java


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