本文整理汇总了Java中net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerInteractEvent.LeftClickBlock方法的具体用法?Java PlayerInteractEvent.LeftClickBlock怎么用?Java PlayerInteractEvent.LeftClickBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.player.PlayerInteractEvent
的用法示例。
在下文中一共展示了PlayerInteractEvent.LeftClickBlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: playerLeftClick
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void playerLeftClick(PlayerInteractEvent.LeftClickBlock event) {
if (!event.getEntityPlayer().capabilities.isCreativeMode && event.getWorld().getBlockState(event.getPos()).getBlock() instanceof BlockDoor && event.getWorld().getBlockState(event.getPos()).getMaterial() == Material.WOOD) {
event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1);
event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_WOOD_PLACE, SoundCategory.BLOCKS, 1, 1);
event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_WOOD_PLACE, SoundCategory.BLOCKS, 1, 1);
event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_WOOD_PLACE, SoundCategory.BLOCKS, 1, 1);
}
if (!event.getEntityPlayer().capabilities.isCreativeMode && event.getWorld().getBlockState(event.getPos()).getBlock() instanceof BlockDoor && event.getWorld().getBlockState(event.getPos()).getMaterial() == Material.IRON) {
event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1);
event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1);
event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1);
event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1);
event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1);
event.getWorld().playSound(null, event.getPos(), SoundEvents.BLOCK_METAL_PLACE, SoundCategory.BLOCKS, 1, 1);
}
}
示例2: interaction
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGH)
public void interaction(
final PlayerInteractEvent.LeftClickBlock event )
{
if (BitDrawers.config.debugTrace) {
Vec3d vec = event.getHitVec();
BDLogger.info("Left Click %s %s %f %f %f", resultToString(event.getUseItem()), resultToString(event.getUseBlock()), vec.xCoord, vec.yCoord, vec.zCoord);
}
if ( event.getEntityPlayer() != null && event.getUseItem() != Event.Result.DENY )
{
final ItemStack is = event.getItemStack();
if ( is != null && (is.getItem() instanceof ItemChiseledBit) && event.getWorld().isRemote)
{
Block target = event.getWorld().getBlockState(event.getPos()).getBlock();
if (target instanceof BlockBitDrawers) {
target.onBlockClicked(event.getWorld(), event.getPos(), event.getEntityPlayer());
}
if (BitDrawers.config.debugTrace)
BDLogger.info("Bit Left Click");
}
}
}
示例3: onHit
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHit(PlayerInteractEvent.LeftClickBlock event) {
EntityPlayer player = event.getEntityPlayer();
ItemStack held = player.getHeldItem(event.getHand());
if (held.getItem() == this) {
//did we turn it off? is the visible timer still going?
if (ActionType.getTimeout(held) > 0) {
return;
}
ActionType.setTimeout(held);
event.setCanceled(true);
UtilSound.playSound(player, player.getPosition(), SoundRegistry.dcoin, SoundCategory.PLAYERS, 0.1F);
if (!player.getEntityWorld().isRemote) { // server side
ActionType.toggle(held);
UtilChat.addChatMessage(player, UtilChat.lang(ActionType.getName(held)));
}
}
}
示例4: onHit
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHit(PlayerInteractEvent.LeftClickBlock event) {
EntityPlayer player = event.getEntityPlayer();
ItemStack held = player.getHeldItem(event.getHand());
if (held != null && held.getItem() == this) {
if (ActionType.getTimeout(held) > 0) {
//without a timeout, this fires every tick. so you 'hit once' and get this happening 6 times
return;
}
ActionType.setTimeout(held);
event.setCanceled(true);
UtilSound.playSound(player, player.getPosition(), SoundRegistry.dcoin, SoundCategory.PLAYERS);
if (!player.getEntityWorld().isRemote) { // server side
ActionType.toggle(held);
UtilChat.addChatMessage(player, UtilChat.lang(ActionType.getName(held)));
}
}
}
示例5: onHit
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHit(PlayerInteractEvent.LeftClickBlock event) {
EntityPlayer player = event.getEntityPlayer();
ItemStack held = player.getHeldItem(event.getHand());
if (held != null && held.getItem() == this) {
//did we turn it off? is the visible timer still going?
if (ActionType.getTimeout(held) > 0) {
return;
}
ActionType.setTimeout(held);
event.setCanceled(true);
UtilSound.playSound(player, player.getPosition(), SoundRegistry.dcoin, SoundCategory.PLAYERS, 0.3F);
if (!player.getEntityWorld().isRemote) { // server side
ActionType.toggle(held);
UtilChat.addChatMessage(player, UtilChat.lang(ActionType.getName(held)));
}
}
}
示例6: onHit
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onHit(PlayerInteractEvent.LeftClickBlock event) {
EntityPlayer player = event.getEntityPlayer();
ItemStack held = player.getHeldItem(event.getHand());
if (!held.isEmpty() && held.getItem() == this) {
if (ActionType.getTimeout(held) > 0) {
//without a timeout, this fires every tick. so you 'hit once' and get this happening 6 times
return;
}
ActionType.setTimeout(held);
event.setCanceled(true);
UtilSound.playSound(player, player.getPosition(), SoundRegistry.dcoin, SoundCategory.PLAYERS);
if (!player.getEntityWorld().isRemote) { // server side
ActionType.toggle(held);
UtilChat.addChatMessage(player, UtilChat.lang(ActionType.getName(held)));
}
}
}
示例7: onLeftClickBlock
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLeftClickBlock(PlayerInteractEvent.LeftClickBlock event) {
BlockPos pos = event.getPos();
World world = event.getWorld();
EntityPlayer player = event.getEntityPlayer();
ItemStack stack = event.getItemStack();// ItemStack stack = player.getHeldItem(event.getHand());
if (player.isSneaking() == false && world.getTileEntity(pos) instanceof TileEntityVector
&& stack != null && Block.getBlockFromItem(stack.getItem()) instanceof BlockVectorPlate) {
IBlockState iblockstate = world.getBlockState(pos);
Block block = iblockstate.getBlock();
TileEntityVector tile = (TileEntityVector) world.getTileEntity(pos);
if (stack.hasTagCompound()) {
((BlockVectorPlate) block).saveStackDataTotile(stack, tile);
if (world.isRemote)
UtilChat.addChatMessage(player, "tile.plate_vector.copied");
}
}
}
示例8: onLeftClickBlock
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void onLeftClickBlock(PlayerInteractEvent.LeftClickBlock event)
{
EntityPlayer player = event.getEntityPlayer();
if(player == null) return;
ItemStack stackIn = event.getItemStack();
if (stackIn == null || stackIn.isEmpty() || !(stackIn.getItem() instanceof PlacementItem)) return;
PlacementResult result = PlacementHandler.doLeftClickBlock(player, event.getPos(), event.getFace(), event.getHitVec(), stackIn);
if(!result.shouldInputEventsContinue())
{
result.apply(stackIn, player);
event.setCanceled(true);
}
}
示例9: onLeftClickBlock
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onLeftClickBlock(PlayerInteractEvent.LeftClickBlock event)
{
ItemStack is = ItemInstrument.getUsableInstrument(event.getEntityPlayer());
if(!is.isEmpty() && !(!event.getEntityPlayer().getHeldItemMainhand().isEmpty() && !event.getEntityPlayer().getHeldItemOffhand().isEmpty()))
{
stopPlayingTrack(event.getEntityPlayer());
}
}
示例10: stopUsing
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void stopUsing(PlayerInteractEvent.LeftClickBlock event) {
if (!TF2Util.canInteract(event.getEntityLiving())) {
event.setCanceled(true);
}
event.getEntityPlayer().removePotionEffect(TF2weapons.charging);
}
示例11: onInteractLeftClickBlock
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onInteractLeftClickBlock(PlayerInteractEvent.LeftClickBlock event)
{
if (event.getEntityPlayer() != null)
{
if (event.getEntityPlayer().isPotionActive(ExPPotions.stunned))
{
event.setCanceled(true);
}
}
}
示例12: cancelLeftClick
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void cancelLeftClick(final PlayerInteractEvent.LeftClickBlock event) {
if (EventHandler.blockClickEvent) {
EventHandler.blockClickEvent = false;
event.setUseBlock(Event.Result.DENY);
}
}
示例13: onPlayerInteract
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event)
{
// Disallow creating or destroying events in the player structure:
if (event instanceof PlayerInteractEvent.LeftClickBlock)
{
// Destroy block
if (blockInBounds(event.getPos(), this.sourceBounds))
event.setCanceled(true);
}
else if (event instanceof PlayerInteractEvent.RightClickBlock)
{
// Place block - need to work out *where* the block would be placed.
// This code was cribbed from ItemBlock.onItemUse()
IBlockState iblockstate = event.getWorld().getBlockState(event.getPos());
Block block = iblockstate.getBlock();
EnumFacing side = event.getFace();
BlockPos pos = event.getPos();
if (block == Blocks.SNOW_LAYER && ((Integer)iblockstate.getValue(BlockSnow.LAYERS)).intValue() < 1)
{
side = EnumFacing.UP;
}
else if (!block.isReplaceable(event.getWorld(), pos))
{
pos = pos.offset(side);
}
if (blockInBounds(pos, this.sourceBounds))
event.setCanceled(true);
}
}
示例14: onINteractOnAir
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onINteractOnAir(PlayerInteractEvent.LeftClickBlock e) {
if (e.getEntityLiving() instanceof EntityPlayer) {
if (!e.getEntityLiving().getCapability(ITrigger_item_Provider.TRIGGER_ITEM, null).getInteraction()) {
e.setCanceled(true);
e.setUseBlock(Event.Result.DENY);
e.setUseItem(Event.Result.DENY);
}
}
}
示例15: onPlayerInteract
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent.LeftClickBlock event){
EntityPlayer player = event.getEntityPlayer();
for(int i = 0; i < player.inventory.getSizeInventory(); i++){
ItemStack stack = player.inventory.getStackInSlot(i);
if(stack != null && stack.getItem() instanceof ItemToolbelt){
ItemToolbelt.selectBestTool(player, i);
return;
}
}
}