本文整理匯總了Java中net.minecraftforge.event.world.BlockEvent.BreakEvent.setCanceled方法的典型用法代碼示例。如果您正苦於以下問題:Java BreakEvent.setCanceled方法的具體用法?Java BreakEvent.setCanceled怎麽用?Java BreakEvent.setCanceled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.event.world.BlockEvent.BreakEvent
的用法示例。
在下文中一共展示了BreakEvent.setCanceled方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onBreakBlock
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
/**
* On break block event, we are checking whether player is breaking director
* block and it's not empty (has replays at least one replay). Thanks to
* Tom Soel for suggesting this.
*/
@SubscribeEvent
public void onBreakBlock(BreakEvent event)
{
World world = event.getWorld();
if (!world.isRemote && event.getState().getBlock() instanceof AbstractBlockDirector)
{
TileEntity tile = world.getTileEntity(event.getPos());
if (tile instanceof TileEntityDirector)
{
TileEntityDirector director = (TileEntityDirector) tile;
if (!director.replays.isEmpty())
{
event.setCanceled(true);
Dispatcher.sendTo(new PacketConfirmBreak(event.getPos(), director.replays.size()), (EntityPlayerMP) event.getPlayer());
}
}
}
}
示例2: onBlockBreakEvent
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBlockBreakEvent(BreakEvent event)
{
if (event.getWorld().isRemote) { return; }
Main.console("[TERRITORIAL DEALINGS] Block at x " + event.getPos().getX() + " / y " + event.getPos().getY() + " / z " + event.getPos().getZ() + " broken by player " + event.getPlayer().getName() + ".");
Chunk chunk = event.getPlayer().worldObj.getChunkFromBlockCoords(event.getPos());
if (TerritoryHandler.canPlayerEditChunk(event.getPlayer(), 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
}
}
示例3: onBlockBreakEvent
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBlockBreakEvent(BreakEvent event)
{
if (event.getWorld().isRemote) { return; } // Not doing this on client side
Main.console("Block at x" + event.getPos().getX() + " y" + event.getPos().getY() + " z" + event.getPos().getZ() + " broken by player " + event.getPlayer().getName() +
" (ID " + event.getPlayer().getGameProfile().getId() + ").");
Chunk chunk = event.getPlayer().worldObj.getChunkFromBlockCoords(event.getPos());
if (TerritoryHandler.canPlayerEditChunk(event.getPlayer().worldObj, event.getPlayer(), 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
}
}
示例4: apply
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@Override
public boolean apply(final BreakEvent evt) {
if(!evt.isCanceled() && (evt.block instanceof MachineVending || evt.block instanceof MachineVendingTop)) {
// Do the check only if player is non-OP
if(!evt.getPlayer().capabilities.isCreativeMode) {
int baseY = evt.y;
if(evt.block instanceof MachineVendingTop)
baseY--;
final TileEntity te = evt.world.getTileEntity(evt.x, baseY, evt.z);
if(te instanceof VendingTileEntity) {
final VendingTileEntity vending = (VendingTileEntity) te;
if(!vending.okToBreak(evt.getPlayer()))
evt.setCanceled(true);
}
}
}
return true;
}
示例5: onBlockBreak
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBlockBreak(BreakEvent event){
EntityPlayer player = event.getPlayer();
if (player != null) {
ItemStack stack = player.getHeldItemMainhand();
if (stack != null) {
Item item = stack.getItem();
if (item instanceof grappleBow || item instanceof multiBow) {
event.setCanceled(true);
return;
}
}
}
this.blockbreak(event);
}
示例6: onBlockBreak
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBlockBreak (BreakEvent event) {
if (PROTECTED.contains(event.getPos()))
event.setCanceled(true);
protectBlock(event.getPos());
}
示例7: enderPearlTeleport
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void enderPearlTeleport(BreakEvent ev) {
if(ev.getPlayer() == null || ev.getPlayer().isCreative()){
return;
}
if (ev.getState().getBlock() == BlockTeletoryPortal.INSTANCE || ev.getState().getBlock() == BlockLinkedTeletoryPortal.INSTANCE) {
ev.setCanceled(true);
}
}
示例8: onBlockBreak
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBlockBreak(BreakEvent e) {
if (!e.world.isRemote) {
TileEntity tileentity = e.world.getTileEntity(e.pos);
if (tileentity instanceof TileEntityStorageCore) {
TileEntityStorageCore core = (TileEntityStorageCore)tileentity;
if (core.inventory.getTotalCount() > 0) {
e.setCanceled(true);
}
}
}
}
示例9: onBlockBreak
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
/** Make sure that only empty systems can be broken */
@SubscribeEvent
public void onBlockBreak(BreakEvent e) {
if (!e.getWorld().isRemote) {
TileEntity tileentity = e.getWorld().getTileEntity(e.getPos());
if (tileentity instanceof TileEntityStorageCore) {
TileEntityStorageCore core = (TileEntityStorageCore) tileentity;
if (core.inventory.getTotalCount() > 0) {
e.setCanceled(true);
}
}
}
}
示例10: onHarvest
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
private void onHarvest(BreakEvent event)
{
if(!this.hasMinLvl(harvest)) return;
this.calculateGain(event.getPlayer(), harvest);
if(this.success == 0)
{
event.setCanceled(true);
}
}
示例11: onBreakEvent
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBreakEvent(BreakEvent event) {
EntityPlayer player = event.getPlayer();
if(CoreClaim.claimManager.checkEventCancel(event.getPlayer(), event.x, event.z)) {
Utils.messageToPlayer(player, EnumChatFormatting.RED + "Oh snap, you are not allowed to break this!");
event.setCanceled(true);
}
}
示例12: onEvent
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onEvent(BreakEvent event) {
Block block = event.getState().getBlock();
int meta = block.getMetaFromState(event.getState());
if (ProgressionAPI.registry.fireTrigger(event.getPlayer(), getProvider().getUnlocalisedName(), block, meta) == Result.DENY) {
event.setCanceled(true);
}
}
示例13: onBreakBlock
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBreakBlock(BreakEvent event) {
EntityPlayer player = event.getPlayer();
if (player != null) {
Block block = event.getState().getBlock();
int meta = block.getMetaFromState(event.getState());
if (ProgressionEvents.isEventCancelled(player, ActionType.BREAKBLOCKWITH, player.getHeldItemMainhand(), ActionType.BREAKBLOCK, BlockActionHelper.getStackFromBlockData(block, meta))) {
event.setCanceled(true);
}
}
}
示例14: onBlockBreak
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBlockBreak(BreakEvent parEvent)
{
if (parEvent.state.getBlock() instanceof BlockCrops)
{
ItemStack playerItem = parEvent.getPlayer().getCurrentEquippedItem();
if (playerItem != null && playerItem.getItem() == _Sickle.sickle)
{
if (!isFullGrownCrop(parEvent.world, parEvent.pos, parEvent.state))
{
parEvent.setCanceled(true);
}
}
}
}
示例15: breakBlockEvent
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void breakBlockEvent(BreakEvent event) {
boolean cancel = WorldHandler.breakBlockS(event);
if (cancel)
event.setCanceled(true);
}