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


Java Action类代码示例

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


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

示例1: onPlayerInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; //导入依赖的package包/类
public static void onPlayerInteract(PlayerInteractEvent event) {
	if (EtFuturum.enableGrassPath)
		if (event.entityPlayer != null) {
			World world = event.entityPlayer.worldObj;
			if (event.action == Action.RIGHT_CLICK_BLOCK)
				if (world.getBlock(event.x, event.y, event.z) == Blocks.grass) {
					ItemStack stack = event.entityPlayer.getCurrentEquippedItem();
					if (stack != null && (stack.getItem() instanceof ItemSpade || isTinkersShovel(stack))) {
						world.setBlock(event.x, event.y, event.z, ModBlocks.grass_path);
						event.entityPlayer.swingItem();
						stack.damageItem(1, event.entityPlayer);
						world.playSoundEffect(event.x + 0.5F, event.y + 0.5F, event.z + 0.5F, Block.soundTypeGravel.getStepResourcePath(), 1.0F, 0.8F);
					}
				}
		}
}
 
开发者ID:jm-organization,项目名称:connor41-etfuturum2,代码行数:17,代码来源:GrassPath.java

示例2: handleCropRightClick

import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; //导入依赖的package包/类
@SubscribeEvent
public void handleCropRightClick(PlayerInteractEvent event) {
  int x = event.x, y = event.y, z = event.z;
  Block block = event.world.getBlock(x, y, z);
  int meta = event.world.getBlockMetadata(x, y, z);
  if (ConfigHandler.allowCropRC && event.action == Action.RIGHT_CLICK_BLOCK && (event.entityPlayer.getHeldItem() == null || !event.entityPlayer.isSneaking())) {
    for (PlantInfo info : plants) {
      if (info.blockInst == block && meta == info.meta) {
        if (event.world.isRemote) {
          event.entityPlayer.swingItem();
        } else {
          currentPlant = info;
          block.dropBlockAsItem(event.world, x, y, z, meta, 0);
          currentPlant = null;
          event.world.setBlockMetadataWithNotify(x, y, z, info.resetMeta, 3);
          event.setCanceled(true);
        }
        break;
      }
    }
  }
}
 
开发者ID:SleepyTrousers,项目名称:EnderCore,代码行数:23,代码来源:RightClickCropHandler.java

示例3: onPlayerInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event)
{
	if (event.entityPlayer.worldObj.isRemote)
		return;
	
	ItemStack itemInHand = event.entityPlayer.getCurrentEquippedItem();
	if (itemInHand == null) {
		return;
	}
	//Disable interaction between Mek and OpenBlock tanks and TFC Barrels or Vessels **Dupe bug***
	boolean validAction = event.action == Action.RIGHT_CLICK_BLOCK;
			
	if(validAction) {
		Block target = event.world.getBlock(event.x, event.y, event.z);
		if (target == TFCBlocks.barrel || target == TFCBlocks.vessel) {
			String name = itemInHand.getUnlocalizedName();
			if (name.contains("tile.openblocks.tank") || name.contains("tile.MachineBlock2.PortableTank") ||
					name.contains("ImmersiveEngineering.drill") || name.contains("ImmersiveEngineering.chemthrower")
					|| name.contains("ImmersiveEngineering.jerrycan") || name.contains("MachineBlock2")){
				event.setCanceled(true);
				return;
			}
		}
	}
}
 
开发者ID:AnodeCathode,项目名称:TechNodefirmacraftMod,代码行数:27,代码来源:PlayerInteractHandler.java

示例4: onEntitySwing

import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; //导入依赖的package包/类
/**
 * Called when the player left-clicks
 */
@Override
public boolean onEntitySwing( final EntityLivingBase entity, final ItemStack wandStack )
{
	// Is the entity a player?
	if( entity instanceof EntityPlayer )
	{
		// Cast to player
		EntityPlayer player = (EntityPlayer)entity;

		// Ray trace
		MovingObjectPosition position = this.getMovingObjectPositionFromPlayer( player.worldObj, player, true );

		// Was a block hit?
		if( ( position != null ) && ( position.typeOfHit == MovingObjectType.BLOCK ) )
		{
			// Use the focus
			return this.onUse( player.worldObj, player, position, wandStack, Action.LEFT_CLICK_BLOCK );
		}
	}

	return false;

}
 
开发者ID:Nividica,项目名称:ThaumicEnergistics,代码行数:27,代码来源:ItemFocusAEWrench.java

示例5: onEntityInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; //导入依赖的package包/类
@SubscribeEvent
public void onEntityInteract(EntityInteractEvent ev) {
    if(ev.entity.worldObj.isRemote || ev.isCanceled()) {
        return;
    }
    int x = (int) Math.floor(ev.target.posX);
    int y = (int) Math.floor(ev.target.posY);
    int z = (int) Math.floor(ev.target.posZ);

    Resident res = MyTownUniverse.instance.getOrMakeResident(ev.entityPlayer);
    ProtectionManager.checkInteraction(ev.target, res, ev);
    if(!ev.isCanceled() && ev.entityPlayer.getHeldItem() != null) {
        BlockPos bp = new BlockPos(x, y, z, ev.target.dimension);
        ProtectionManager.checkUsage(ev.entityPlayer.getHeldItem(), res, PlayerInteractEvent.Action.RIGHT_CLICK_AIR, bp, -1, ev);
    }
}
 
开发者ID:MyEssentials,项目名称:MyTown2,代码行数:17,代码来源:ProtectionHandlers.java

示例6: onInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; //导入依赖的package包/类
@SubscribeEvent
public void onInteract(PlayerInteractEvent pie){
	if(pie.action==Action.RIGHT_CLICK_BLOCK) {
		ItemStack i=pie.entityPlayer.getCurrentEquippedItem();
		
		if(i!=null && i.getItem().equals(Items.flint_and_steel)){
			PortalHandler.establishPortal(pie.world, pie.x, pie.y, pie.z, pie.face);
		}
		
		if(Properties.enableSimpleSetSpawn 
				&& pie.world instanceof WorldServer
				&& pie.world.getBlock(pie.x, pie.y, pie.z)==Blocks.bed) {
			ChunkCoordinates bedPosition=new ChunkCoordinates(pie.x, pie.y, pie.z);
			pie.entityPlayer.setSpawnChunk(bedPosition, false);
			pie.entityPlayer.addChatComponentMessage(new ChatComponentText("Spawn reset to ("+pie.x+", "+pie.y+", "+pie.z+")"));			}
	}
}
 
开发者ID:planetguy32,项目名称:Gizmos,代码行数:18,代码来源:ForgeEventHandler.java

示例7: onPlayerInteractEvent

import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerInteractEvent(PlayerInteractEvent event) {
  if (Util.isClientSide()) {
    if (event.action != Action.RIGHT_CLICK_BLOCK) {
      return;
    }
    EntityPlayer player = event.entityPlayer;
    if (player == null) {
      return;
    }
    if (player.getHeldItem() == null || !(player.getHeldItem().getItem() instanceof ItemBlockManipulator) || player.getHeldItem().stackTagCompound == null || !(player.getHeldItem().getItem() instanceof OEItemInterface)) {
      return;
    }
    NBTTagCompound nbt = new NBTTagCompound();
    nbt.setInteger("x", event.x);
    nbt.setInteger("y", event.y);
    nbt.setInteger("z", event.z);
    nbt.setInteger("face", event.face);// Bottom = 0, Top = 1, Sides = 2-5
    NetworkUtil.sendToServer(Channel.BlockManipulater, nbt);
    event.setCanceled(true);
  }
}
 
开发者ID:ictrobot,项目名称:Open-Exchange,代码行数:23,代码来源:ItemBlockManipulator.java

示例8: onPlayerInteract

import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; //导入依赖的package包/类
@SubscribeEvent
public boolean onPlayerInteract(PlayerInteractEvent event){
    if(event.action == Action.RIGHT_CLICK_BLOCK && isListeningToCoordTrackerSetting) {
        isListeningToCoordTrackerSetting = false;
        ForgeDirection dir = ForgeDirection.getOrientation(event.face);
        reset();
        ItemStack stack = event.entityPlayer.getCurrentArmor(3);
        if(stack != null) {
            NBTTagCompound tag = NBTUtil.getCompoundTag(stack, "CoordTracker");
            tag.setInteger("dimID", event.entity.worldObj.provider.dimensionId);
            tag.setInteger("x", event.x + dir.offsetX);
            tag.setInteger("y", event.y + dir.offsetY);
            tag.setInteger("z", event.z + dir.offsetZ);
        }
        NetworkHandler.sendToServer(new PacketCoordTrackUpdate(event.entity.worldObj, event.x + dir.offsetX, event.y + dir.offsetY, event.z + dir.offsetZ));
    }
    return false;
}
 
开发者ID:MineMaarten,项目名称:PneumaticCraft,代码行数:19,代码来源:CoordTrackUpgradeHandler.java

示例9: eventPlayerInteractEvent

import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; //导入依赖的package包/类
@SubscribeEvent
public void eventPlayerInteractEvent(PlayerInteractEvent event) {
	World world = event.world;
	int x = event.x;
	int y = event.y;
	int z = event.z;
	EntityPlayer player = event.entityPlayer;
	if (player != null && player.getHeldItem() != null && player.getHeldItem().getItem() == Items.stick) {
		if (TOConfig.debugEnable && TOConfig.debugScanner && !world.isRemote
				&& event.action.equals(Action.RIGHT_CLICK_BLOCK) && player.capabilities.isCreativeMode) {
			int radius = TOConfig.debugRemoverScannerRadius;
			int[] counter = new int[] { 0, 0, 0, 0, 0, 0 };
			for (int xx = x - radius; xx < x + radius; xx++)
				for (int zz = z - radius; zz < z + radius; zz++)
					for (int yy = 0; yy < 257; yy++)
						if ((world.getBlock(xx, yy, zz) instanceof BlockInfusedBlockOre)
								&& world.getBlockMetadata(xx, yy, zz) < 6)
							counter[world.getBlockMetadata(xx, yy, zz)]++;
			String text = "[DEBUG " + ThaumOresMod.NAME + "] Scanned blocks at " + x + ";" + z + " with radius "
					+ radius;
			for (int meta = 0; meta < 6; meta++)
				text += "\n Count ores with meta " + meta + " = " + counter[meta];
			for (String string : text.split("\n")) {
				ThaumOresMod.log.info(string);
				player.addChatMessage(new ChatComponentText(string));
			}
		}
	}
}
 
开发者ID:MJaroslav,项目名称:ThaumOres,代码行数:30,代码来源:TOEvents.java

示例10: getInteractionType

import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; //导入依赖的package包/类
public static InteractionType getInteractionType(final PlayerInteractEvent event) {

			if (event.action != Action.RIGHT_CLICK_BLOCK)
				return Nothing;

			if(event.entityPlayer.capabilities.isCreativeMode) {
				final ItemStack held = event.entityPlayer.getHeldItem();
				if(held != null && held.getItem() == CONFIGURE_ITEM) {
					return Configure;
				}
			}
			
			return Use;
		}
 
开发者ID:OreCruncher,项目名称:Pathways,代码行数:15,代码来源:PlayerInteractEventHandler.java

示例11: playerInteractEventHandler

import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; //导入依赖的package包/类
@SubscribeEvent
    public void playerInteractEventHandler(PlayerInteractEvent event)
    {
//    	if(event.world.isRemote)
//    	{
    		//generate the json file
//    		generateJson();
    		// get players held item
        	ItemStack heldItem = event.entityPlayer.inventory.getCurrentItem();
        	//Toggle mode on key press
        	if(event.world.isRemote)
        	{
        		if (event.action == Action.RIGHT_CLICK_AIR && key.config.isPressed())
        		{
        			//Load the json file
//        			load();
        			if(clientSetting != 3)
        				clientSetting++;
        			if(clientSetting >= 3)
        				clientSetting = 0;
        			event.entityPlayer.addChatMessage(new ChatComponentText(StatCollector.translateToLocal("torchieeeeness_key" + clientSetting)));
        			// Save the json file
//        			save();
                    PacketHandler.INSTANCE.sendToServer(new MessageSettings(clientSetting));
        		}
//        	}
    	}

        if(serverSetting != 0 && !(event.world.getTileEntity(event.x, event.y, event.z) instanceof TileEntity))
        {
        	if(serverSetting == 1)
        		placeAnything(event);
        	if(serverSetting == 2)
        		placeOnlyTorchs(event);
        }
    }
 
开发者ID:gigabit101,项目名称:Torchieeeeness,代码行数:37,代码来源:TorchEventHandler.java

示例12: onWrenchBlock

import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; //导入依赖的package包/类
@SubscribeEvent
public void onWrenchBlock(PlayerInteractEvent event) {

	if (!event.world.isRemote && event.action == Action.RIGHT_CLICK_BLOCK) {

		EntityPlayer player = event.entityPlayer;
		ItemStack itemInHand = player.getCurrentEquippedItem();

		if (player.isSneaking() && itemInHand != null && itemInHand.getItem() == InitItems.wrench) {
			wrenchBlock(new Location(event.world, event.x, event.y, event.z), player);
		}
	}
}
 
开发者ID:TeamMonumental,项目名称:FusionWarfare,代码行数:14,代码来源:WrenchEvent.java

示例13: placeBlockEvent

import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; //导入依赖的package包/类
@SubscribeEvent
public void placeBlockEvent(PlayerInteractEvent event) {
	EntityPlayer p = event.entityPlayer;
    if(event.action == Action.RIGHT_CLICK_BLOCK) {
    	Block clickedBlock = HelperActions.getBlock(event.x, event.y, event.z);
    	if (HelperActions.blockIsOneOf(clickedBlock, HelperActions.unbreakableBlocks) && event.y < p.posY) {
    		List<HelperPos> blockPoss = new ArrayList<HelperPos>();
    		blockPoss.add(new HelperPos(event.x, event.y + 1, event.z));
    		blockPoss.add(new HelperPos(event.x, event.y, event.z + 1));
    		blockPoss.add(new HelperPos(event.x, event.y, event.z - 1));
    		blockPoss.add(new HelperPos(event.x + 1, event.y, event.z));
    		blockPoss.add(new HelperPos(event.x - 1, event.y, event.z));
    		
    		for (HelperPos pos : blockPoss) {
    			String key = pos.x + "," + pos.y + "," + pos.z;
    			if (HelperActions.blockIsOneOf(HelperActions.getBlock(pos), HelperActions.mineableBlocks) && 
    					!MinecraftStateGeneratorHelper.blockNameMap.containsKey(key)) {
    				int blockID = HelperActions.getBlockId(pos.x, pos.y, pos.z);
    				ArrayList<String> blockNames = MinecraftStateGeneratorHelper.invBlockNameMap.get(blockID);
    				if (blockNames != null && blockNames.size() == 1) {
    					MinecraftStateGeneratorHelper.blockNameMap.put(key, blockNames.get(0));
    					MinecraftStateGeneratorHelper.invBlockNameMap.remove(blockID);
    				}
    				else {
						if(blockNames != null) {
							MinecraftStateGeneratorHelper.blockNameMap.put(key, blockNames.get(0));
							blockNames.remove(0);
						}
    				}
    				break;
    			}
    		}
    	}
    }
}
 
开发者ID:h2r,项目名称:burlapcraft,代码行数:36,代码来源:HandlerEvents.java

示例14: blockPlaceEvent

import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; //导入依赖的package包/类
@SubscribeEvent
public void blockPlaceEvent(PlayerInteractEvent event) {
	ForgeDirection direction = ForgeDirection.getOrientation(event.face);
	if(!event.world.isRemote && Action.RIGHT_CLICK_BLOCK == event.action && event.entityPlayer != null  && AtmosphereHandler.getOxygenHandler(event.world.provider.dimensionId) != null &&
			!AtmosphereHandler.getOxygenHandler(event.world.provider.dimensionId).getAtmosphereType(event.x + direction.offsetX, event.y + direction.offsetY, event.z + direction.offsetZ).allowsCombustion()) {

		if(event.entityPlayer.getCurrentEquippedItem() != null) {
			if(event.entityPlayer.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(Blocks.torch) && 
					event.world.getBlock(event.x, event.y, event.z).isSideSolid(event.world, event.x, event.y, event.z, direction)) {
				event.setCanceled(true);
				event.world.setBlock(event.x + direction.offsetX, event.y + direction.offsetY, event.z + direction.offsetZ, AdvancedRocketryBlocks.blockUnlitTorch);
			}
			else if(zmaster587.advancedRocketry.api.Configuration.torchBlocks.contains(Block.getBlockFromItem(event.entityPlayer.getCurrentEquippedItem().getItem())) )
				event.setCanceled(true);
			else if(event.entityPlayer.getCurrentEquippedItem().getItem() == Items.flint_and_steel || event.entityPlayer.getCurrentEquippedItem().getItem() == Items.fire_charge || event.entityPlayer.getCurrentEquippedItem().getItem() == Items.blaze_powder || event.entityPlayer.getCurrentEquippedItem().getItem() == Items.blaze_rod || event.entityPlayer.getCurrentEquippedItem().getItem() == Items.lava_bucket)
				event.setCanceled(true);
		}
	}

	if(!event.world.isRemote && event.entityPlayer != null && event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK && event.entityPlayer.getCurrentEquippedItem() != null && event.entityPlayer.getCurrentEquippedItem().getItem() == Items.bed && event.world.provider instanceof WorldProviderPlanet) {
		AdvancedRocketryItems.itemAstroBed.onItemUse( event.entityPlayer.getCurrentEquippedItem(),  event.entityPlayer,  event.entityPlayer.worldObj, event.x, event.y, event.z, event.face, 0, 0, 0);
		event.setCanceled(true);
	}

	if(!event.world.isRemote && event.entityPlayer != null && event.entityPlayer.getCurrentEquippedItem() != null && event.entityPlayer.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(AdvancedRocketryBlocks.blockGenericSeat) && event.world.getBlock(event.x, event.y, event.z) == Blocks.tnt) {
		event.entityPlayer.triggerAchievement(ARAchivements.beerOnTheSun);
	}
}
 
开发者ID:zmaster587,项目名称:AdvancedRocketry,代码行数:29,代码来源:PlanetEventHandler.java

示例15: PlayerRightClickEvent

import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; //导入依赖的package包/类
@SubscribeEvent
public void PlayerRightClickEvent(PlayerInteractEvent event)
{
	if(ConfigHandler.allowCropFeature)
	{
		EntityPlayer player = event.entityPlayer;
		World world = event.world;
		Block crop = world.getBlock(event.x, event.y, event.z);
		int cropMeta = world.getBlockMetadata(event.x, event.y, event.z);
		int dropRate = event.world.rand.nextInt(3) + 1;
		ItemStack drops = new ItemStack(crop.getItemDropped(cropMeta, event.world.rand, Short.MAX_VALUE), dropRate);
		
		
		if(player.getCurrentEquippedItem() == null && event.action == Action.RIGHT_CLICK_BLOCK && crop != null)
		{	
			if(crop instanceof BlockCrops && cropMeta >= 7)
			{
				event.entityPlayer.swingItem();
				if(!world.isRemote)
				{
					EntityItem droppedItem = new EntityItem(world, event.x, event.y, event.z, drops);
					world.setBlockMetadataWithNotify(event.x, event.y, event.z, 0, 3);
					world.spawnEntityInWorld(droppedItem);
				}
			}
		}
	}
}
 
开发者ID:oitsjustjose,项目名称:GlassWorks,代码行数:29,代码来源:CropEvent.java


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