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


Java BreakEvent.getPlayer方法代碼示例

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


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

示例1: 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;
}
 
開發者ID:OreCruncher,項目名稱:ThermalRecycling,代碼行數:24,代碼來源:VendingMachineBreakHandler.java

示例2: onBreakEvent

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onBreakEvent(BreakEvent event) {
  World world = event.getWorld();
  EntityPlayer player = event.getPlayer();
  if (player == null) {
    return;
  }
  BlockPos pos = event.getPos();
  int level = this.getCurrentLevelTool(player);
  if (level <= 0) {
    return;
  }
  Block block = event.getState().getBlock();
  int xpDropped = block.getExpDrop(event.getState(), world, pos, 0);
  int bonus = xpDropped * XP_PER_LVL * level;
  UtilExperience.incrementExp(player, bonus);
  //    dropExp(world, pos, xpDropped * XP_PER_LVL * level);
}
 
開發者ID:PrinceOfAmber,項目名稱:Cyclic,代碼行數:19,代碼來源:EnchantXpBoost.java

示例3: onBreakEvent

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
/**
 * tile entity data saved to item stack
 * 
 * @param event
 */
@SubscribeEvent
public static void onBreakEvent(BreakEvent event) {
  if (event.getPlayer() != null && event.getPlayer().capabilities.isCreativeMode) {
    return;
  } // dont drop in creative https://github.com/PrinceOfAmber/Cyclic/issues/93
  World world = event.getWorld();
  BlockPos pos = event.getPos();
  IBlockState state = event.getState();
  TileEntity ent = world.getTileEntity(pos);
  if (ent != null && ent instanceof TileEntityWirelessTr) {
    TileEntityWirelessTr t = (TileEntityWirelessTr) ent;
    ItemStack stack = new ItemStack(state.getBlock());
    if (t.getTargetPos() != null)
      UtilNBT.setItemStackBlockPos(stack, t.getTargetPos());
    //      saveTileDataToStack(stack, t);
    UtilItemStack.dropItemStackInWorld(world, pos, stack);
  }
}
 
開發者ID:PrinceOfAmber,項目名稱:Cyclic,代碼行數:24,代碼來源:BlockRedstoneWireless.java

示例4: onBreakEvent

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBreakEvent(BreakEvent event) {
  if (event.getPlayer() != null && event.getPlayer().capabilities.isCreativeMode) {
    return;
  } // dont drop in creative https://github.com/PrinceOfAmber/Cyclic/issues/93
  World world = event.getWorld();
  BlockPos pos = event.getPos();
  IBlockState state = event.getState();
  TileEntity ent = world.getTileEntity(pos);
  if (ent != null && ent instanceof TileEntityVector) {
    TileEntityVector t = (TileEntityVector) ent;
    ItemStack stack = new ItemStack(state.getBlock());
    saveTileDataToStack(stack, t);
    UtilItemStack.dropItemStackInWorld(world, pos, stack);
  }
}
 
開發者ID:PrinceOfAmber,項目名稱:Cyclic,代碼行數:17,代碼來源:BlockVectorPlate.java

示例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);
}
 
開發者ID:yyon,項目名稱:grapplemod,代碼行數:17,代碼來源:CommonProxyClass.java

示例6: mineOutEverything

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
public void mineOutEverything(int[][] locations, BreakEvent event)
{
    EntityPlayer player = event.getPlayer();
    ItemStack current = player.getCurrentEquippedItem();

    for (int i = 0; i < locations.length; i++)
    {
        int curX = event.x + locations[i][0];
        int curY = event.y + locations[i][1];
        int curZ = event.z + locations[i][2];

        Block miningBlock = event.world.getBlock(curX, curY, curZ);
        int meta = event.world.getBlockMetadata(curX, curY, curZ);
        if (canHarvestBlock(player, event.block, miningBlock, meta, curX, curY, curZ))
        {
            if (!((ItemTool) current.getItem()).onBlockStartBreak(current, curX, curY, curZ, player))
            {
                mineBlock(event.world, curX, curY, curZ, meta, player, miningBlock);
                ((ItemTool) current.getItem()).onBlockDestroyed(current, event.world, miningBlock, curX, curY, curZ, player);
                player.addExhaustion((float) 0.025);
            }
        }
    }
}
 
開發者ID:Wolfofthenyght,項目名稱:M4Armory,代碼行數:25,代碼來源:AOEHandler.java

示例7: mineGrass

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
public void mineGrass(int[][] blocks, BreakEvent event)
{
    EntityPlayer player = event.getPlayer();
    ItemStack current = player.getCurrentEquippedItem();

    for (int i = 0; i < blocks.length; i++)
    {
        Block currentBlock = event.world.getBlock(event.x + blocks[i][0], event.y + blocks[i][1], event.z + blocks[i][2]);
        int currentMeta = event.world.getBlockMetadata(event.x + blocks[i][0], event.y + blocks[i][1], event.z + blocks[i][2]);
        if (canHoeHarvest(currentBlock))
        {
            mineBlock(event.world, event.x + blocks[i][0], event.y + blocks[i][1], event.z + blocks[i][2], currentMeta, player, currentBlock);
            current.damageItem(1, player);
            if (current.getItemDamage() >= current.getMaxDamage())
            {
                return;
            }
        }
    }
}
 
開發者ID:Wolfofthenyght,項目名稱:M4Armory,代碼行數:21,代碼來源:AOEHandler.java

示例8: onBreakEvent

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBreakEvent(BreakEvent event) {
	Side side = FMLCommonHandler.instance().getEffectiveSide();

	if (side != Side.SERVER) return;
	
	if (event.getPlayer() instanceof EntityPlayerMP) {
		EntityPlayerMP thePlayer = (EntityPlayerMP) event.getPlayer();
		List<MocapAction> aList = Mocap.instance
				.getActionListForPlayer(thePlayer);
		if (aList != null) {
			MocapAction ma = new MocapAction(
					MocapActionTypes.BREAKBLOCK);
			
			ma.xCoord = event.x;
			ma.yCoord = event.y;
			ma.zCoord = event.z;
			aList.add(ma);
		}
	}
	
}
 
開發者ID:EchebKeso,項目名稱:Mocap,代碼行數:23,代碼來源:MocapEventHandler.java

示例9: onHarvest

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onHarvest(BreakEvent event) {
	if (event.getPlayer() == null) {
		return;
	}

	Province provinceFarmedIn = loadProvince(event.getPlayer().world, event.getPos());

	if (provinceFarmedIn == null || provinceFarmedIn.civilization == null) {
		return;
	}

	handleFarmQuest(event.getPlayer(), provinceFarmedIn, event.getState().getBlock(), false);
}
 
開發者ID:ToroCraft,項目名稱:ToroQuest,代碼行數:15,代碼來源:QuestFarm.java

示例10: harvest

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void harvest(BreakEvent event) {
	if (!ToroQuestConfiguration.cropsAffectRep) {
		return;
	}
	if (event.getPlayer() == null) {
		return;
	}

	if (isCrop(event.getState().getBlock())) {
		BlockPos pos = event.getPos();
		adjustPlayerRep(event.getPlayer(), pos.getX() / 16, pos.getZ() / 16, -getFarmRepAmount(event.getWorld().rand));
	}
}
 
開發者ID:ToroCraft,項目名稱:ToroQuest,代碼行數:15,代碼來源:CivilizationHandlers.java

示例11: 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);
	}
}
 
開發者ID:ToroCraft,項目名稱:TeleToro,代碼行數:11,代碼來源:Teletory.java

示例12: onPlayerBreaksBlock

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
/**
 * Event listener for Action.BREAK_BLOCK
 */
@SubscribeEvent
public void onPlayerBreaksBlock(BreakEvent event)
{
    EntityPlayer player = event.getPlayer();
    List<Action> events = CommonProxy.manager.getActions(player);

    if (!player.worldObj.isRemote && events != null && player.isCreative())
    {
        events.add(new BreakBlockAction(event.getPos(), false));
    }
}
 
開發者ID:mchorse,項目名稱:blockbuster,代碼行數:15,代碼來源:ActionHandler.java

示例13: mineGooeyBlocks

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void mineGooeyBlocks(BreakEvent event) {
    if (processing.get() != null) return;
    EntityPlayer p = event.getPlayer();
    if (!(p instanceof EntityPlayerMP)) return;
    EntityPlayerMP player = (EntityPlayerMP) p;
    boolean creative = player.capabilities.isCreativeMode;
    ItemStack held = player.getHeldItem();
    if (held == null && !creative) return;
    MovingObjectPosition mop = getMovingObjectPositionFromPlayer(player.worldObj, player, false);
    if (mop == null) return;
    for (int slot = 0; slot < 9; slot++) {
        ItemStack is = ItemUtil.normalize(player.inventory.getStackInSlot(slot));
        if (is == null || is.getItem() != this) continue;
        GooData data = GooData.getNullGooData(is, player.worldObj);
        if (data == null) continue;
        for (int i = 0; i < data.coords.length; i += 3) {
            if (eq(data.coords, i, mop.getBlockPos())) {
                processing.set(true);
                try {
                    mineSelection(is, data, player.worldObj, mop, player, held);
                } finally {
                    processing.remove();
                }
                return;
            }
        }
    }
}
 
開發者ID:purpleposeidon,項目名稱:Factorization,代碼行數:30,代碼來源:ItemGoo.java

示例14: playerBreakBlock

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void playerBreakBlock(BreakEvent event) {
    if (event.world.isRemote)
        return;
    EntityPlayer player = event.getPlayer();
    if (isPlayerFake(player))
        return;
    int fortune = EnchantmentHelper.getFortuneModifier(player);
    String name = event.state.getBlock().getUnlocalizedName();
    boolean harvest = false;
    List<ItemStack> stacks = event.state.getBlock().getDrops(event.world, event.pos, event.state, fortune);
    if (stacks.size() == 1) {
        ItemStack stack = stacks.get(0);
        Item item = stack.getItem();
        if (item == null)
            ;
        else if (item instanceof ItemBlock) {
            ItemBlock ib = (ItemBlock) item;
            Block b = ib.block;
            harvest = b != event.state.getBlock();
        }
        else
            harvest = true;
    }
    else
        harvest = stacks.size() != 0;
    if (name.startsWith("tile."))
        name = name.substring(5);
    if (!harvest)
        PlayerResearchHelper.progressResearch(player, "block.break." + name, 1, true);
    else
        PlayerResearchHelper.progressResearch(player, "block.harvest." + name, 1, true);
}
 
開發者ID:AlexIIL,項目名稱:CivCraft,代碼行數:34,代碼來源:BeakerEarningListener.java

示例15: 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);
	}	
}
 
開發者ID:unitedworldminers,項目名稱:ClaimIO,代碼行數:10,代碼來源:EventBus.java


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