当前位置: 首页>>代码示例>>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;未经允许,请勿转载。