本文整理汇总了Java中net.minecraftforge.event.world.BlockEvent.BreakEvent类的典型用法代码示例。如果您正苦于以下问题:Java BreakEvent类的具体用法?Java BreakEvent怎么用?Java BreakEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BreakEvent类属于net.minecraftforge.event.world.BlockEvent包,在下文中一共展示了BreakEvent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: onBlockBreak
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //导入依赖的package包/类
@SubscribeEvent
public void onBlockBreak(BreakEvent event)
{
Random rand = event.world.rand;
//Drop nuts from leaves
if(event.block == TFCBlocks.leaves && rand.nextInt(100) < 10)
{
Item nut = null;
switch(event.blockMetadata)
{
case 0: nut = CWTFCItems.acorn; break;
case 3: nut = CWTFCItems.chestnut; break;
case 5: nut = CWTFCItems.pecan; break;
case 8: nut = CWTFCItems.pineNut; break;
}
if(nut != null)
{
ItemStack is = ItemFoodTFC.createTag(new ItemStack(nut), CropIndex.getWeight(4, rand));
event.world.spawnEntityInWorld(new EntityItem(event.world, event.x + 0.5, event.y + 0.5, event.z + 0.5, is));
}
}
}
开发者ID:StrayWolfe,项目名称:Cooking-with-TFC,代码行数:26,代码来源:PlayerHandler.java
示例3: 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
示例4: 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
示例5: blockDestroy
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //导入依赖的package包/类
/**
* ブロックを破壊します
*
* @param world world
* @param x x座標
* @param y y座標
* @param z z座標
* @param player プレイヤー
* @param centerBlock 中心のブロック
* @param cX 中心のブロックのx座標
* @param cY 中心のブロックのy座標
* @param cZ 中心のブロックのz座標
* @param toolStack 破壊に使用したツールのItemStack
*/
private void blockDestroy(World world, int x, int y, int z, EntityPlayerMP player, Block centerBlock, int cX, int cY, int cZ, ItemStack toolStack) {
if (!world.isAirBlock(x, y, z)) {
Block block = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if (canDestroyBlock(toolStack, block, meta) && (centerBlock.getBlockHardness(world, cX, cY, cZ) - block.getBlockHardness(world, x, y, z)) <= 3F) {
BreakEvent event = ForgeHooks.onBlockBreakEvent(world, player.theItemInWorldManager.getGameType(), player, x, y, z);
if (!event.isCanceled()) {
block.onBlockHarvested(world, x, y, z, meta, player);
if (block.removedByPlayer(world, player, x, y, z, false)) {
block.onBlockDestroyedByPlayer(world, x, y, z, meta);
block.harvestBlock(world, player, x, y, z, meta);
}
if (!world.isRemote) {
player.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
}
}
}
}
}
开发者ID:Team-Antimatter-Mod,项目名称:AntiMatterMod,代码行数:35,代码来源:MiningHammer.java
示例6: 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
示例7: 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
示例8: 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
示例9: 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
示例10: 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
示例11: 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
示例12: 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
示例13: 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
示例14: 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
示例15: onBlockBreak
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //导入依赖的package包/类
@SubscribeEvent
public void onBlockBreak(BreakEvent event) {
// check if the block broken was a leaf block
if (event.block.getMaterial() == Material.leaves) {
// get a random number instance
Random random = new Random();
// calculate the percentage and continue if fortunate. Note that random.nextInt will return an int from 0-99
if ((random.nextInt(100)) < leafBrushwoodChance) {
// get the height of surface from where the leaf was destroyed
int y = event.world.getTopSolidOrLiquidBlock(event.x, event.z);
// get the surface block of where the leaf was destroyed as 'spawnCandidate'
Block spawnCandidate = event.world.getBlock(event.x, y, event.z);
// ensure that spawnCandidate is (a) an air block and (b) below the leaf block that was destroyed
if (spawnCandidate.isAir(event.world, event.x, y, event.z) && y < event.y) {
// spawnCandidate is valid, place Brushwood block!
event.world.setBlock(event.x, y, event.z, ModBlocks.brushwood);
}
}
}
}
开发者ID:CosmicDan-Minecraft,项目名称:Imperium,代码行数:21,代码来源:BlockEvents.java
示例16: do3x1Mine
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //导入依赖的package包/类
private void do3x1Mine(BreakEvent event)
{
MovingObjectPosition mop = DirectionHelper.raytraceFromEntity(event.world, event.getPlayer(), false, 4.5D);
if (mop == null) // something is NaN, bail out!
{
return;
}
if (mop.sideHit != 0 && mop.sideHit != 1)
{
int[][] mineArray = { { 0, 1, 0 }, { 0, -1, 0 } };
mineOutEverything(mineArray, event);
}
else //Hit the top or bottom.
{
int playerDir = DirectionHelper.getPlayerDirection(event.getPlayer());
mineOutEverything(DirectionHelper.get1x3MiningCoordinatesForTopAndBottom(playerDir), event);
}
}
开发者ID:wyldmods,项目名称:ToolUtilities,代码行数:21,代码来源:AOEHandler.java
示例17: 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
示例18: 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
示例19: onBlockBroken
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //导入依赖的package包/类
@SubscribeEvent
public void onBlockBroken(BreakEvent event){
if(!event.world.isRemote)
if(event.world.getTileEntity(event.pos) != null && event.world.getTileEntity(event.pos) instanceof CustomizableSCTE){
CustomizableSCTE te = (CustomizableSCTE) event.world.getTileEntity(event.pos);
for(int i = 0; i < te.getNumberOfCustomizableOptions(); i++)
if(te.itemStacks[i] != null){
ItemStack stack = te.itemStacks[i];
EntityItem item = new EntityItem(event.world, event.pos.getX(), event.pos.getY(), event.pos.getZ(), stack);
event.world.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((EnumFacing)te.getWorld().getBlockState(te.getPos()).getValue(BlockSecurityCamera.FACING), -1), te.getWorld().getBlockState(te.getPos()).getBlock());
}
}
}
开发者ID:Geforce132,项目名称:SecurityCraft,代码行数:21,代码来源:SCEventHandler.java
示例20: onBlockBroken
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //导入依赖的package包/类
@SubscribeEvent
public void onBlockBroken(BreakEvent event){
if(!event.world.isRemote)
if(event.world.getTileEntity(event.pos) != null && event.world.getTileEntity(event.pos) instanceof CustomizableSCTE){
CustomizableSCTE te = (CustomizableSCTE) event.world.getTileEntity(event.pos);
for(int i = 0; i < te.getNumberOfCustomizableOptions(); i++)
if(te.itemStacks[i] != null){
ItemStack stack = te.itemStacks[i];
EntityItem item = new EntityItem(event.world, event.pos.getX(), event.pos.getY(), event.pos.getZ(), stack);
event.world.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
注:本文中的net.minecraftforge.event.world.BlockEvent.BreakEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论