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


Java PlayerInteractEvent.getResult方法代碼示例

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


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

示例1: onBlockPlaced

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBlockPlaced(PlayerInteractEvent event)
{
	if (event.entityPlayer.worldObj.isRemote)
		return;

	ItemStack itemInHand = event.entityPlayer.getCurrentEquippedItem();
	
	if(itemInHand == null)
		return;
	
	if(event.action == Action.RIGHT_CLICK_BLOCK && event.getResult() != Result.DENY)
	{
		if(Loader.isModLoaded("Steamcraft"))
		{
			if(event.entityPlayer.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(SteamcraftBlocks.boiler) && ConfigSettings.FSPBoilerWaterFix)
			{
				event.setCanceled(true);
				handleBlockPlacement(event.entityPlayer, event.entityLiving, event.world, TFPBlocks.tweakedboiler, event.x, event.y, event.z, event.face);
			}			
			else if(event.entityPlayer.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(SteamcraftBlocks.flashBoiler) && ConfigSettings.FSPFlashBoilerWaterFix)
			{
				event.setCanceled(true);
				switch(event.face)
				{
					case 0: PlaceBlock(event.entityLiving, event.world, event.x, event.y - 1, event.z, TFPBlocks.tweakedFlashBoiler, 0); break;
					case 1: PlaceBlock(event.entityLiving, event.world, event.x, event.y + 1, event.z, TFPBlocks.tweakedFlashBoiler, 0); break;
					case 2: PlaceBlock(event.entityLiving, event.world, event.x, event.y, event.z - 1, TFPBlocks.tweakedFlashBoiler, 0); break;
					case 3: PlaceBlock(event.entityLiving, event.world, event.x, event.y, event.z + 1, TFPBlocks.tweakedFlashBoiler, 0); break;
					case 4: PlaceBlock(event.entityLiving, event.world, event.x - 1, event.y, event.z, TFPBlocks.tweakedFlashBoiler, 0); break;
					case 5: PlaceBlock(event.entityLiving, event.world, event.x + 1, event.y, event.z, TFPBlocks.tweakedFlashBoiler, 0); break;
					default: break;
				}			
				
				if(event.entityPlayer.getCurrentEquippedItem().stackSize == 1)
					event.entityPlayer.setCurrentItemOrArmor(0, null);
				else
					event.entityPlayer.getCurrentEquippedItem().stackSize--;
			}
		}
		
		if(event.entityPlayer.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(Blocks.chest))
		{
			event.setCanceled(true);

			if(event.entityPlayer.getCurrentEquippedItem().stackSize == 1)
				event.entityPlayer.setCurrentItemOrArmor(0, null);
			else
				event.entityPlayer.getCurrentEquippedItem().stackSize--;
		}
	}
}
 
開發者ID:StrayWolfe,項目名稱:TerrafirmaPunk-Tweaks,代碼行數:53,代碼來源:PlayerInteractionHandler.java

示例2: onPlayerTriesToPlaceBucket

import net.minecraftforge.event.entity.player.PlayerInteractEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onPlayerTriesToPlaceBucket(PlayerInteractEvent e) {
	if (e.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK)
		return;
	if (e.entityPlayer.dimension != IaSFlags.dim_nyx_id || !e.entityPlayer.capabilities.isCreativeMode)
		return;
	if (e.entityPlayer.getEquipmentInSlot(0) == null)
		return;
	final Item itid = e.entityPlayer.getEquipmentInSlot(0).getItem();
	if (itid == Items.lava_bucket || itid == Items.water_bucket) {
		e.getResult();
		if (e.action != Action.RIGHT_CLICK_BLOCK)
			return;
		int x = e.x;
		int y = e.y;
		int z = e.z;
		switch (e.face) {
		case 0:
			--y;
			break;
		case 1:
			++y;
			break;
		case 2:
			--z;
			break;
		case 3:
			++z;
			break;
		case 4:
			--x;
			break;
		case 5:
			++x;
			break;
		default:
			break;
		}
		e.useItem = Result.DENY;
		e.entityPlayer.setCurrentItemOrArmor(0, new ItemStack(Items.bucket));
		if (itid == Items.lava_bucket) {
			e.entityPlayer.worldObj.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, "random.fizz", 0.5F, 2.6F
					+ (e.entityPlayer.worldObj.rand.nextFloat() - e.entityPlayer.worldObj.rand.nextFloat()) * 0.8F);
			e.entityPlayer.worldObj.setBlock(x, y, z, Blocks.obsidian, 0, 0x2);
		} else if (itid == Items.water_bucket) {
			e.entityPlayer.worldObj.setBlock(x, y, z, Blocks.ice, 0, 0x2);
		}
	}
}
 
開發者ID:TheDaemoness,項目名稱:IceAndShadow2,代碼行數:50,代碼來源:NyxEventHandlerCold.java


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