本文整理匯總了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);
}
示例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);
}
}
}
}
}
示例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(),
"");
}
示例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
}
}
示例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
}
}
示例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);
}
}
示例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);
}