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


Java RightClickBlock.getEntityPlayer方法代码示例

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


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

示例1: onRightClickBlock

import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
@SubscribeEvent
public void onRightClickBlock(RightClickBlock event)
{
	if(!(event.getWorld().getBlockState(event.getPos()).getBlock() instanceof XPBlock) || event.getHand() != EnumHand.MAIN_HAND)
		return;

	if(!event.getWorld().isRemote)
	{
		if(event.getEntityPlayer().isSneaking()) //sneaking = add all player XP to the block
		{
			((TileEntityXPBlock)event.getWorld().getTileEntity(event.getPos())).addXP(event.getEntityPlayer().experienceTotal);
			event.getEntityPlayer().addExperienceLevel(-event.getEntityPlayer().experienceLevel - 1); // set player XP to 0
		}
		else //not sneaking = remove exactly enough XP from the block to get player to the next level
		{
			TileEntityXPBlock te = ((TileEntityXPBlock)event.getWorld().getTileEntity(event.getPos()));
			EntityPlayer player = event.getEntityPlayer();
			int neededXP = player.xpBarCap() - (int)player.experience;
			int availableXP = te.removeXP(neededXP);
			
			player.addExperience(availableXP);
		}
	}
}
 
开发者ID:bl4ckscor3,项目名称:GlobalXP,代码行数:25,代码来源:EventHandler.java

示例2: checkBlockBannedEvent

import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
@SubscribeEvent
public void checkBlockBannedEvent(RightClickBlock event)
{
	EntityPlayer player = event.getEntityPlayer();
	ItemStack currentStack = event.getItemStack();

	if (player.dimension == AetherConfig.getAetherDimensionID())
	{
		if (currentStack != null && (currentStack.getItem() == Items.FLINT_AND_STEEL || currentStack.getItem() == Item.getItemFromBlock(Blocks.TORCH) || currentStack.getItem() == Items.FIRE_CHARGE))
		{
			for (int i = 0; i < 10; ++i)
			{
				event.getWorld().spawnParticle(EnumParticleTypes.SMOKE_LARGE, event.getHitVec().xCoord, event.getHitVec().yCoord, event.getHitVec().zCoord, 0.0D, 0.0D, 0.0D, new int [] {});
			}

			event.setCanceled(true);

		}
		else if (event.getWorld().getBlockState(event.getPos()).getBlock() == Blocks.BED)
		{
			event.setCanceled(true);
		}
	}
}
 
开发者ID:Modding-Legacy,项目名称:Aether-Legacy,代码行数:25,代码来源:AetherEventHandler.java

示例3: rightClick

import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
/** Makes portals if config. */
@SubscribeEvent
public void rightClick(RightClickBlock event) {

    EntityPlayer player = event.getEntityPlayer();
    World world = event.getWorld();
    ItemStack stack = event.getItemStack();
    Item item = stack.getItem();
    BlockPos pos = event.getPos();
    
    if (GeoConfig.compatibility.portals && item == GeoItems.FIREOPAL &&
            world instanceof WorldServer) {

        new Teleporter((WorldServer) world).makePortal(player);
        stack.shrink(1);
    }
    
    if (GeoConfig.compatibility.portals && item == GeoItems.AMETHYST) {
        
        Items.ENDER_EYE.onItemUse(player, world, pos,
                event.getHand(), event.getFace(), 0, 0, 0);
    }
}
 
开发者ID:JayAvery,项目名称:geomastery,代码行数:24,代码来源:BlockEvents.java

示例4: poisonousPotatoRightClick

import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
@SubscribeEvent
public void poisonousPotatoRightClick(RightClickBlock event)
{
	EntityPlayer player = event.getEntityPlayer();
	World world = event.getWorld();
	
	if((event.getEntityPlayer().getHeldItemMainhand()!=null)
	&&(player.getHeldItemMainhand().getItem()==Items.POISONOUS_POTATO)
	&&(event.getFace()==EnumFacing.UP)
	&&world.getBlockState(event.getPos()).getBlock().canSustainPlant(world.getBlockState(event.getPos()), world, event.getPos(), EnumFacing.UP, (IPlantable) Items.POTATO))
	{
		if(!world.isRemote)
		{
			if(!player.capabilities.isCreativeMode)
				{
					player.inventory.clearMatchingItems(Items.POISONOUS_POTATO, -1, 1, null);
				}
			if(world.getBlockState(event.getPos().up(+1)).getBlock()==Blocks.AIR)
			{
				world.setBlockState(event.getPos().up(+1),Blocks.POTATOES.getDefaultState());
			}
		}	
	}
}
 
开发者ID:theishiopian,项目名称:ForageCraft,代码行数:25,代码来源:PotatoPlanter.java

示例5: onPlayerRightClickBlock

import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
/**
 * Event listener for Action.INTERACT_BLOCK (when player right clicks on
 * a block)
 */
@SubscribeEvent
public void onPlayerRightClickBlock(RightClickBlock event)
{
    EntityPlayer player = event.getEntityPlayer();
    List<Action> events = CommonProxy.manager.getActions(player);

    if (!player.worldObj.isRemote && events != null)
    {
        events.add(new InteractBlockAction(event.getPos()));
    }
}
 
开发者ID:mchorse,项目名称:blockbuster,代码行数:16,代码来源:ActionHandler.java


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