本文整理汇总了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);
}