當前位置: 首頁>>代碼示例>>Java>>正文


Java Action.RIGHT_CLICK_BLOCK屬性代碼示例

本文整理匯總了Java中net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK屬性的典型用法代碼示例。如果您正苦於以下問題:Java Action.RIGHT_CLICK_BLOCK屬性的具體用法?Java Action.RIGHT_CLICK_BLOCK怎麽用?Java Action.RIGHT_CLICK_BLOCK使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在net.minecraftforge.event.entity.player.PlayerInteractEvent.Action的用法示例。


在下文中一共展示了Action.RIGHT_CLICK_BLOCK屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPlayerInteract

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,代碼行數:16,代碼來源:GrassPath.java

示例2: handleCropRightClick

@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,代碼行數:22,代碼來源:RightClickCropHandler.java

示例3: onPlayerInteract

@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,代碼行數:26,代碼來源:PlayerInteractHandler.java

示例4: onInteract

@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,代碼行數:17,代碼來源:ForgeEventHandler.java

示例5: onPlayerInteractEvent

@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,代碼行數:22,代碼來源:ItemBlockManipulator.java

示例6: onPlayerInteract

@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,代碼行數:18,代碼來源:CoordTrackUpgradeHandler.java

示例7: getInteractionType

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,代碼行數:14,代碼來源:PlayerInteractEventHandler.java

示例8: onWrenchBlock

@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,代碼行數:13,代碼來源:WrenchEvent.java

示例9: placeBlockEvent

@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,代碼行數:35,代碼來源:HandlerEvents.java

示例10: blockPlaceEvent

@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,代碼行數:28,代碼來源:PlanetEventHandler.java

示例11: PlayerRightClickEvent

@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,代碼行數:28,代碼來源:CropEvent.java

示例12: onPlayerRightClickBlock

@SubscribeEvent
public void onPlayerRightClickBlock(PlayerInteractEvent event) {
	if (!event.entity.worldObj.isRemote && event.action == Action.RIGHT_CLICK_BLOCK) {
		AtlasAPI.getTileAPI().putCustomGlobalTile(event.entity.worldObj,
				customTileName, event.x >> 4, event.z >> 4);
	}
}
 
開發者ID:Hunternif,項目名稱:AntiqueAtlasApiExample,代碼行數:7,代碼來源:CustomTilePlacer.java

示例13: onPlayerInteract

@SubscribeEvent(priority=EventPriority.LOW)
public void onPlayerInteract(PlayerInteractEvent event) {
	BlockDoor door = (BlockDoor)Blocks.wooden_door;
	BlockLocation loc = BlockLocation.get(event.world, event.x, event.y, event.z);
	
	if ((event.action != Action.RIGHT_CLICK_BLOCK) ||
	    event.entityPlayer.isSneaking() ||
	    !(loc.getBlock() == door)) return;
	
	int direction = getDoorOrientation(door, loc);
	boolean isOpen = isDoorOpen(door, loc);
	boolean isMirrored = isDoorMirrored(door, loc);
	
	int i = (isMirrored ? -1 : 1);
	switch (direction) {
		case 0: loc = loc.relative(0, 0,  i); break;
		case 1: loc = loc.relative(-i, 0, 0); break;
		case 2: loc = loc.relative(0, 0, -i); break;
		case 3: loc = loc.relative( i, 0, 0); break;
	}
	
	if ((loc.getBlock() == door) &&
	    (getDoorOrientation(door, loc) == direction) &&
	    (isDoorOpen(door, loc) == isOpen) &&
	    (isDoorMirrored(door, loc) != isMirrored))
		door.onBlockActivated(loc.world, loc.x, loc.y, loc.z, event.entityPlayer, event.face, 0, 0, 0);
}
 
開發者ID:copygirl,項目名稱:copycore,代碼行數:27,代碼來源:TweakDoubleDoorInteraction.java

示例14: playerInteract

@SubscribeEvent
public void playerInteract(PlayerInteractEvent event) {
    if (event.action == Action.RIGHT_CLICK_BLOCK && event.entityPlayer.worldObj.isRemote) {
        if (placing.get() != null)
            return;//for mods that do dumb stuff and call this event like MFR
        placing.set(event);
        if (place(event.entityPlayer, event.entityPlayer.worldObj))
            event.setCanceled(true);
        placing.set(null);
    }
}
 
開發者ID:delta534,項目名稱:Chisel,代碼行數:11,代碼來源:ChiselEventHandler.java

示例15: playerInteract

@ForgeSubscribe
public void playerInteract(PlayerInteractEvent event) {
	if (event.action == Action.RIGHT_CLICK_BLOCK) {
		int id = event.entityPlayer.worldObj.getBlockId(event.x, event.y, event.z);
		if (id == TeamConfig.teamSelectionId) {
			int meta = event.entityPlayer.worldObj.getBlockMetadata(event.x, event.y, event.z);
			if (listener != null) {
				listener.interact(event.entityPlayer, meta, event.x, event.y, event.z);
			}
		}
	}
}
 
開發者ID:becelot,項目名稱:TeamCore,代碼行數:12,代碼來源:PlayerEvent.java


注:本文中的net.minecraftforge.event.entity.player.PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。