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


Java BreakEvent.getWorld方法代碼示例

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


在下文中一共展示了BreakEvent.getWorld方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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());
            }
        }
    }
}
 
開發者ID:mchorse,項目名稱:blockbuster,代碼行數:28,代碼來源:EventHandler.java

示例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
	}
}
 
開發者ID:Domochevsky,項目名稱:minecraft-territorialdealings,代碼行數:20,代碼來源:EventListener.java

示例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
	}
}
 
開發者ID:Domochevsky,項目名稱:minecraft-territorialdealings,代碼行數:21,代碼來源:EventListener.java

示例4: onBreakEvent

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

	World world = event.getWorld();
	BlockPos pos = event.getPos();
	IBlockState state = event.getState();
	TileEntity ent = world.getTileEntity(pos);

	// TODO; check tool/pickaxe? if notHarvestable or whatever, drop the
	// buckets and the ..glass?

	if(ent != null && ent instanceof TileEntityBucketStorage){
		TileEntityBucketStorage t = (TileEntityBucketStorage) ent;
		ItemStack stack = new ItemStack(state.getBlock());

		setItemStackNBT(stack, BlockBucketStorage.NBTBUCKETS, t.getBuckets());

		dropItemStackInWorld(world, pos, stack);

		t.setBuckets(0);
	}
}
 
開發者ID:LothrazarMinecraftMods,項目名稱:BucketBlocks,代碼行數:23,代碼來源:ModBucketBlocks.java

示例5: 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

示例6: 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

示例7: 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

示例8: onBlockBroken

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBlockBroken(BreakEvent event){
	if(!event.getWorld().isRemote)
		if(event.getWorld().getTileEntity(event.getPos()) != null && event.getWorld().getTileEntity(event.getPos()) instanceof CustomizableSCTE){
			CustomizableSCTE te = (CustomizableSCTE) event.getWorld().getTileEntity(event.getPos());

			for(int i = 0; i < te.getNumberOfCustomizableOptions(); i++)
				if(te.itemStacks[i] != null){
					ItemStack stack = te.itemStacks[i];
					EntityItem item = new EntityItem(event.getWorld(), event.getPos().getX(), event.getPos().getY(), event.getPos().getZ(), stack);
					WorldUtils.addScheduledTask(event.getWorld(), () -> event.getWorld().spawnEntityInWorld(item));

					te.onModuleRemoved(stack, ((ItemModule) stack.getItem()).getModule());
					te.createLinkedBlockAction(EnumLinkedAction.MODULE_REMOVED, new Object[]{ stack, ((ItemModule) stack.getItem()).getModule() }, te);

					if(te instanceof TileEntitySecurityCamera)
						te.getWorld().notifyNeighborsOfStateChange(te.getPos().offset(te.getWorld().getBlockState(te.getPos()).getValue(BlockSecurityCamera.FACING), -1), te.getWorld().getBlockState(te.getPos()).getBlock());
				}
		}
}
 
開發者ID:Geforce132,項目名稱:SecurityCraft,代碼行數:21,代碼來源:SCEventHandler.java

示例9: onBlockBroken

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBlockBroken(BreakEvent event){
	if(!event.getWorld().isRemote)
		if(event.getWorld().getTileEntity(event.getPos()) != null && event.getWorld().getTileEntity(event.getPos()) instanceof CustomizableSCTE){
			CustomizableSCTE te = (CustomizableSCTE) event.getWorld().getTileEntity(event.getPos());

			for(int i = 0; i < te.getNumberOfCustomizableOptions(); i++)
				if(!te.modules.get(i).isEmpty()){
					ItemStack stack = te.modules.get(i);
					EntityItem item = new EntityItem(event.getWorld(), event.getPos().getX(), event.getPos().getY(), event.getPos().getZ(), stack);
					WorldUtils.addScheduledTask(event.getWorld(), () -> event.getWorld().spawnEntity(item));

					te.onModuleRemoved(stack, ((ItemModule) stack.getItem()).getModule());
					te.createLinkedBlockAction(EnumLinkedAction.MODULE_REMOVED, new Object[]{ stack, ((ItemModule) stack.getItem()).getModule() }, te);

					if(te instanceof TileEntitySecurityCamera)
						te.getWorld().notifyNeighborsOfStateChange(te.getPos().offset(te.getWorld().getBlockState(te.getPos()).getValue(BlockSecurityCamera.FACING), -1), te.getWorld().getBlockState(te.getPos()).getBlock(), true);
				}
		}
}
 
開發者ID:Geforce132,項目名稱:SecurityCraft,代碼行數:21,代碼來源:SCEventHandler.java

示例10: breakBlock

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
/** Fells trees according to player facing. */
@SubscribeEvent
public void breakBlock(BreakEvent event) {
    
    IBlockState state = event.getState();
    Block block = state.getBlock();
    World world = event.getWorld();
    BlockPos pos = event.getPos();
    
    if (block instanceof BlockLog) {

        TreeFallUtils.fellTree(world, pos, event.getPlayer()
                .getHorizontalFacing().rotateY());
    }
}
 
開發者ID:JayAvery,項目名稱:geomastery,代碼行數:16,代碼來源:BlockEvents.java

示例11: onBlockBroken

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
/** If the block can't be harvested, remove its drops */
@SubscribeEvent
public void onBlockBroken(BreakEvent e) {
	Block b = e.getState().getBlock();
	if(!e.getWorld().isRemote && b instanceof IBlockEverything) {
		if(!b.canHarvestBlock(e.getWorld(), e.getPos(), e.getPlayer())) {
			TileEntityBlockEverything tile = (TileEntityBlockEverything)e.getWorld().getTileEntity(e.getPos());
			tile.contains = null;
		}
	}
}
 
開發者ID:sblectric,項目名稱:EverythingBlocks,代碼行數:12,代碼來源:BlockEvents.java

示例12: onUpgradedTileBreak

import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
/** Spawn the lightning upgrade when an upgraded tile is broken */
@SubscribeEvent
public void onUpgradedTileBreak(BreakEvent e) {
	if(!e.getWorld().isRemote) {
		TileEntity t = e.getWorld().getTileEntity(e.getPos());
		if(t != null && t.hasCapability(LCCapabilities.LIGHTNING_UPGRADABLE, null) && 
				t.getCapability(LCCapabilities.LIGHTNING_UPGRADABLE, null).isUpgraded()) {
			Block.spawnAsEntity(e.getWorld(), e.getPos(), new ItemStack(LCItems.material, 1, Material.UPGRADE));
		}
	}
}
 
開發者ID:sblectric,項目名稱:LightningCraft,代碼行數:12,代碼來源:EntityItemEvents.java

示例13: 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);
			}
		}
	}
}
 
開發者ID:zerofall,項目名稱:EZStorage2,代碼行數:14,代碼來源:CoreEvents.java


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