本文整理匯總了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;
}
}
}