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


Java FillBucketEvent.setCanceled方法代碼示例

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


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

示例1: onFillBucket

import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onFillBucket(FillBucketEvent event) {
	if(event.getEntityPlayer().isSneaking()) {
		return;
	}

	if(event.getTarget() == null) {
		return;
	}

	BlockPos pos = event.getTarget().getBlockPos();

	if(!isPartOfTank(event.getWorld(), pos)) {
		return;
	}

	event.setCanceled(true);
}
 
開發者ID:Lordmau5,項目名稱:FFS,代碼行數:19,代碼來源:TankManager.java

示例2: onFillBucket

import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
/**
 * Troll user if they attempt to put volcanic lava in a bucket.
 */
@SubscribeEvent(priority = EventPriority.HIGH) 
public static void onFillBucket(FillBucketEvent event)
{
    if(event.getEntityPlayer() != null && !event.getWorld().isRemote)
    {
        RayTraceResult target = event.getTarget();
        if(target != null && target.typeOfHit == RayTraceResult.Type.BLOCK)
        {
            if(target.getBlockPos() != null)
            {
                IBlockState state = event.getWorld().getBlockState(target.getBlockPos());
                if(state.getBlock() instanceof LavaBlock)
                {
                    event.getEntityPlayer().sendMessage(new TextComponentString(DENIALS[ThreadLocalRandom.current().nextInt(DENIALS.length)]));
                    event.setCanceled(true);
                }
            }
        }
    }
}
 
開發者ID:grondag,項目名稱:Hard-Science,代碼行數:24,代碼來源:CommonEventHandler.java

示例3: onBucketFillAttempt

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

	if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(event.entityPlayer, PermissionsMutex.USE_ITEMS, event.target.func_178782_a().getX(), event.target.func_178782_a().getY(), event.target.func_178782_a().getZ()))
		event.setCanceled(true);
	else
		GriefGuardian._dal.logAction(
				(EntityPlayerMP)event.entityPlayer, 
				Actions.ITEM_USE, 
				(int)Math.floor(event.entity.posX), 
				(int)Math.floor(event.entity.posY), 
				(int)Math.floor(event.entity.posZ), 
				event.entityPlayer.getCurrentEquippedItem(), 
				"");
}
 
開發者ID:Mithion,項目名稱:GriefGuardian,代碼行數:18,代碼來源:ClaimGuardEventHandler.java

示例4: onBucketUse

import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBucketUse(FillBucketEvent event)
{
	if (event.getWorld().isRemote) { return; }

	RayTraceResult target = event.getTarget();

	if (target == null) { return; }	// Nevermind?

	BlockPos pos = target.getBlockPos();

	if (pos == null) { return; }	// Nevermind?

	Main.console("[TERRITORIAL DEALINGS] Bucket used by player " + event.getEntityPlayer().getName() + " at x " + pos.getX() + " / y " + pos.getY() + " / z " + pos.getZ() + ".");

	Chunk chunk = event.getEntityPlayer().worldObj.getChunkFromBlockCoords(pos);

	if (TerritoryHandler.canPlayerEditChunk(event.getEntityPlayer(), chunk))	// Checks out
	{
		Main.console("[TERRITORIAL DEALINGS] Player is allowed to edit this chunk. Doing nothing.");
	}
	else
	{
		Main.console("[TERRITORIAL DEALINGS] Player is not allowed to edit this chunk. Cancelling.");
		event.setCanceled(true);	// Not having it
	}
}
 
開發者ID:Domochevsky,項目名稱:minecraft-territorialdealings,代碼行數:28,代碼來源:EventListener.java

示例5: onBucketUse

import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBucketUse(FillBucketEvent event)
{
	if (event.getWorld().isRemote) { return; }	// Not doing this on client side

	RayTraceResult target = event.getTarget();

	if (target == null) { return; }	// Nevermind?

	BlockPos pos = target.getBlockPos();

	if (pos == null) { return; }	// Nevermind?

	Main.console("Bucket used by player " + event.getEntityPlayer().getName() + " (ID " + event.getEntityPlayer().getGameProfile().getId() + ") at x" + pos.getX() + " y" + pos.getY() + " z" + pos.getZ() + ".");

	Chunk chunk = event.getEntityPlayer().worldObj.getChunkFromBlockCoords(pos);

	if (TerritoryHandler.canPlayerEditChunk(event.getEntityPlayer().worldObj, event.getEntityPlayer(), chunk))	// Checks out
	{
		Main.console("Player is allowed to edit this chunk. Doing nothing.");
	}
	else
	{
		Main.console("Player is not allowed to edit this chunk. Cancelling.");
		event.setCanceled(true);	// Not having it
	}
}
 
開發者ID:Domochevsky,項目名稱:minecraft-territorialdealings,代碼行數:28,代碼來源:EventListener.java

示例6: onFillBucket

import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOW) // low priority so other mods can handle their stuff first
public void onFillBucket(FillBucketEvent event)
{
    if (event.getResult() != Event.Result.DEFAULT)
    {
        // event was already handled
        return;
    }

    // not for us to handle
    ItemStack emptyBucket = event.getEmptyBucket();
    if (emptyBucket == null ||
            !emptyBucket.isItemEqual(getEmpty()) ||
            (isNbtSensitive() && ItemStack.areItemStackTagsEqual(emptyBucket, getEmpty())))
    {
        return;
    }

    // needs to target a block
    RayTraceResult target = event.getTarget();
    if (target == null || target.typeOfHit != RayTraceResult.Type.BLOCK)
    {
        return;
    }

    World world = event.getWorld();
    BlockPos pos = target.getBlockPos();

    ItemStack singleBucket = emptyBucket.copy();
    singleBucket.stackSize = 1;

    ItemStack filledBucket = FluidUtil.tryPickUpFluid(singleBucket, event.getEntityPlayer(), world, pos, target.sideHit);
    if (filledBucket != null)
    {
        event.setResult(Event.Result.ALLOW);
        event.setFilledBucket(filledBucket);
    }
    else
    {
        // cancel event, otherwise the vanilla minecraft ItemBucket would
        // convert it into a water/lava bucket depending on the blocks material
        event.setCanceled(true);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:45,代碼來源:UniversalBucket.java

示例7: stopBucket

import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void stopBucket(FillBucketEvent evt){
	if(evt.world.getBlock(evt.target.blockX, evt.target.blockY, evt.target.blockZ) == ROCBlocks.water_portal)evt.setCanceled(true);
}
 
開發者ID:Eternaldoom,項目名稱:Realms-of-Chaos,代碼行數:5,代碼來源:PortalFixEvent.java


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