本文整理汇总了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);
}
}
}
示例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);
}
}
}
示例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);
}
}
示例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());
}
}
}
}
示例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()));
}
}