本文整理汇总了Java中net.minecraftforge.event.world.BlockEvent.BreakEvent方法的典型用法代码示例。如果您正苦于以下问题:Java BlockEvent.BreakEvent方法的具体用法?Java BlockEvent.BreakEvent怎么用?Java BlockEvent.BreakEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.world.BlockEvent
的用法示例。
在下文中一共展示了BlockEvent.BreakEvent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fireBlockBreak
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
/**
* 激活方块破坏事件
* <p>
* 此方法应该在方块被真实的放置到世界<i><b>之前</b></i>调用
* </p>
*
* @param pSnapshot
* 被破坏的方块
* @param pSimulate
* 是否为模拟
* @return 事件是否被允许
*/
public boolean fireBlockBreak(BlockSnapshot pSnapshot,boolean pSimulate){
if(!this.mEnable||this.isChecked(pSnapshot.world,pSnapshot.x,pSnapshot.y,pSnapshot.z,pSimulate))
return true;
if(!this.mAllow) return false;
this.mEnable=false; // 设置未false,防止BlockEvent中添加检查过方块
BlockEvent tEvent=new BlockEvent.BreakEvent(pSnapshot.x,pSnapshot.y,pSnapshot.z,pSnapshot.world,
pSnapshot.getReplacedBlock(),pSnapshot.meta,this.mCapturePlayer);
MinecraftForge.EVENT_BUS.post(tEvent);
this.mEnable=true;
if(!pSimulate){
this.mergeBlockChangeResult(!tEvent.isCanceled());
}
return !tEvent.isCanceled();
}
示例2: blockBreakEvent
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void blockBreakEvent(BlockEvent.BreakEvent event)
{
EntityPlayer player = event.getPlayer();
ItemStack OmniItem = null;
if(EnchantmentHelper.getEnchantmentLevel(ModEnchantment.runicenchantment, player.getHeldItem(EnumHand.MAIN_HAND) )>0)
OmniItem = player.getHeldItem(EnumHand.MAIN_HAND);
else if(EnchantmentHelper.getEnchantmentLevel(ModEnchantment.runicenchantment, player.getHeldItem(EnumHand.OFF_HAND) )>0)
OmniItem = player.getHeldItem(EnumHand.OFF_HAND);
else return;
CompiledSymbol[] script = ModDust.getScriptFromItem(OmniItem);
if(script==null)return;
new ScriptExecutor(script, player, OmniItem, ScriptExecutor.StartPoint.BLOCK_BREAK, event.getPos());
}
示例3: stopBreak
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void stopBreak(BlockEvent.BreakEvent event) {
if (event.getPlayer().getHeldItem(EnumHand.MAIN_HAND) != null && event.getPlayer().getHeldItem(EnumHand.MAIN_HAND).getItem() instanceof ItemUsable) {
event.setCanceled(true);
}
if (event.getPlayer().getActivePotionEffect(TF2weapons.bonk) != null) {
event.setCanceled(true);
}
if (event.getPlayer().getCapability(TF2weapons.WEAPONS_CAP, null).invisTicks > 0) {
event.setCanceled(true);
}
if (event.getPlayer().getActivePotionEffect(TF2weapons.stun) != null) {
event.setCanceled(true);
}
if (WeaponsCapability.get(event.getPlayer()).isDisguised()) {
disguise(event.getPlayer(), false);
}
}
示例4: eventBreakEvent
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void eventBreakEvent(BlockEvent.BreakEvent event) {
World world = event.world;
int x = event.x;
int y = event.y;
int z = event.z;
EntityPlayer player = event.getPlayer();
if (player != null && player.getHeldItem() != null && player.getHeldItem().getItem() == Items.stick) {
if (TOConfig.debugEnable && TOConfig.debugRemover && !world.isRemote
&& player.capabilities.isCreativeMode) {
int radius = TOConfig.debugRemoverScannerRadius;
for (int xx = x - radius; xx < x + radius; xx++)
for (int zz = z - radius; zz < z + radius; zz++)
for (int yy = 0; yy < 257; yy++)
if (!(world.getBlock(xx, yy, zz) instanceof BlockInfusedBlockOre))
world.setBlock(xx, yy, zz, Blocks.air, 0, 2);
String text = "[DEBUG " + ThaumOresMod.NAME + "] Removed blocks at " + x + ";" + z + " with radius "
+ radius;
player.addChatMessage(new ChatComponentText(text));
ThaumOresMod.log.info(text);
}
}
}
示例5: playerTick
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void playerTick(BlockEvent.BreakEvent breakEvent)
{
World world = breakEvent.getWorld();
BlockPos pos = breakEvent.getPos();
IBlockState state = world.getBlockState(pos);
Block block = state.getBlock();
if(block instanceof BlockWorldScaleOre)
{
if(state.getValue(BlockWorldScaleOre.CRACKED) < 5) {
((BlockWorldScaleOre)block).addCracks(world,pos,state,1);
breakEvent.setCanceled(true);
}
}
}
示例6: onBlockBreak
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent e)
{
IBlockState state = e.getState();
World world = e.getWorld();
BlockPos pos = e.getPos();
EntityPlayer player = e.getPlayer();
ItemStack heldItem = player.getHeldItem(EnumHand.MAIN_HAND);
if (state.getBlock() == Blocks.mob_spawner) {
Map<Enchantment, Integer> enchants = EnchantmentHelper.getEnchantments(heldItem);
if (enchants.containsKey(Enchantments.silkTouch)) {
ItemStack stack = new ItemStack(Blocks.mob_spawner, 1, 0);
NBTTagCompound nbttagcompound = new NBTTagCompound();
world.getTileEntity(pos).writeToNBT(nbttagcompound);
stack.setTagInfo("BlockEntityTag", nbttagcompound);
e.setExpToDrop(0);
e.getWorld().spawnEntityInWorld(new EntityItem(world, pos.getX(), pos.getY(), pos.getZ(), stack));
}
}
}
示例7: breakE
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void breakE(BlockEvent.BreakEvent event)
{
if(event.getWorld() !=null && !event.getWorld().isRemote && event.getWorld().provider.getDimension() == ModDimensions.CUBE_ID){
PlayerCube cube = CubeManager.getInstance().getPlayerCubeFromPos(event.getWorld(), event.getPos());
if(cube !=null){
for(TileEntityPlayerCubePortal portal : cube.watchers){
if (portal.mobileChunk.addBlockWithState(event.getPos(), Blocks.AIR.getDefaultState())) {
portal.mobileChunk.removeChunkBlockTileEntity(event.getPos());
}
portal.mobileChunk.setChunkModified();
portal.mobileChunk.onChunkLoad();
}
}
}
}
示例8: onBlockBreak
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent event){
EntityPlayer player = event.getPlayer();
if(player.isInsideOfMaterial(Material.WATER)) {
//Player is inside water, check for lanolin
if (player.getHeldItemMainhand().hasTagCompound() && player.getHeldItemMainhand().getTagCompound().hasKey("lanolin")) {
int newLanolin = player.getHeldItemMainhand().getTagCompound().getInteger("lanolin") - 1;
if (newLanolin <= 0)
player.getHeldItemMainhand().getTagCompound().removeTag("lanolin");
else
player.getHeldItemMainhand().getTagCompound().setInteger("lanolin", newLanolin);
}
}
}
示例9: onBlockBreak
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public static void onBlockBreak(BlockEvent.BreakEvent event) {
if (event.getState().getBlock() == Blocks.TALLGRASS) {
float randomValue = event.getWorld().rand.nextFloat();
if (randomValue >= 0.9) {
event.getWorld().spawnEntity(new EntityItem(event.getWorld(),
event.getPos().getX(),
event.getPos().getY(),
event.getPos().getZ(),
new ItemStack(GeneraItems.ItemSeedNightshade, 1)));
}
}
}
示例10: onBlockBreak
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent evt) {
/*
if (evt.block instanceof LobbyBlock) {
// RESETS DATA AND CANCELS EVENT
LobbyTileEntity t = (LobbyTileEntity) evt.world.getTileEntity(evt.x, evt.y, evt.z);
if (t != null) {
PlayerData data;
for (EntityPlayer p : UUIDUtil.getPlayersFromProfileUUIDs(evt.world, t.players)) {
data = PlayerData.get(p);
data.setReady(false);
data.setInLobby(false);
if (evt.world.isRemote)
data.sendToServer();
t.removePlayer(p);
//PAYDAY.INSTANCE.sendToServer(new LobbyPlayerActionPacket(evt.x, evt.y, evt.z, true));
}
}
//evt.setCanceled(true);
}*/
}
示例11: onBlockBreak
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
@SuppressWarnings({"ConstantConditions"})
public void onBlockBreak(BlockEvent.BreakEvent event) {
if ( event.getPlayer().getHeldItemMainhand() != null &&
new UItem(event.getPlayer().getHeldItemMainhand().getItem()).getId() == UItems.WOODEN_HOE.getId() &&
event.getPlayer().isCreative()) {
event.setCanceled(true);
Evaluator.touchBlock(event.getPlayer(), new UBlockPos(event.getPos()));
}
}
示例12: onBlockBreak
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
@SuppressWarnings({"ConstantConditions"})
public void onBlockBreak(BlockEvent.BreakEvent event) {
if ( event.getPlayer().getHeldItem() != null &&
new UItem(event.getPlayer().getHeldItem().getItem()).getId() == UItems.WOODEN_HOE.getId() &&
event.getPlayer().capabilities.isCreativeMode) {
event.setCanceled(true);
Evaluator.touchBlock(event.getPlayer(), new UBlockPos(event.x, event.y, event.z));
}
}
示例13: onBlockBreak
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent event) {
World world = event.getWorld();
IBlockState state = world.getBlockState(event.getPos());
BlockPos pos = event.getPos();
if (!state.getBlock().isWood(world, pos)) {
return;
}
int radius = 16;
int dirX = Math.max(-1, Math.min(1, pos.getX() - (int)Math.round(event.getPlayer().posX - 0.5)));
int dirZ = Math.max(-1, Math.min(1, pos.getZ() - (int)Math.round(event.getPlayer().posZ - 0.5)));
LinkedList<BlockPos> queue = new LinkedList<BlockPos>();
HashMap<BlockPos, Integer> used = new HashMap<BlockPos, Integer>();
queue.add(pos);
int leaf = 5;
used.put(pos, leaf);
while (!queue.isEmpty()) {
BlockPos top = queue.pollFirst();
for (int dx = -1; dx <= 1; ++dx) {
for (int dy = -1; dy <= 1; ++dy) {
for (int dz = -1; dz <= 1; ++dz) {
BlockPos nPos = top.add(dx, dy, dz);
int step = used.get(top);
if (step <= 0 || nPos.distanceSq(pos) > radius * radius) {
continue;
}
IBlockState nState = world.getBlockState(nPos);
boolean log = nState.getBlock().isWood(world, nPos);
boolean leaves = nState.getBlock().isLeaves(nState, world, nPos);
if ((dy >= 0 && step == leaf && log) || leaves) {
step = step - (leaves ? 1 : 0);
if (!used.containsKey(nPos) || used.get(nPos) < step) {
used.put(nPos, step);
queue.push(nPos);
}
}
}
}
}
}
for (Map.Entry<BlockPos, Integer> entry : used.entrySet()) {
BlockPos blockPos = entry.getKey();
if (!pos.equals(blockPos) && isDraggable(world, blockPos.add(0, -1, 0))) {
int oy = blockPos.getY() - pos.getY();
drop(world, blockPos, blockPos.add(oy * dirX, 0, oy * dirZ));
}
}
}
示例14: doMining
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
void doMining(World world, EntityPlayerMP player, int x, int y, int z) // Calling this 27 times, to blast mine a 3x3x3 area
{
Block toBeBroken = world.getBlock(x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if (toBeBroken.getBlockHardness(world, x, y, z) == -1) { return; } // Unbreakable
if (toBeBroken.getHarvestLevel(meta) > 1) { return; }
if (toBeBroken.getMaterial() == Material.water) { return; }
if (toBeBroken.getMaterial() == Material.lava) { return; }
if (toBeBroken.getMaterial() == Material.air) { return; }
if (toBeBroken.getMaterial() == Material.portal) { return; }
// Need to do checks here against invalid blocks
if (toBeBroken == Blocks.water) { return; }
if (toBeBroken == Blocks.flowing_water) { return; }
if (toBeBroken == Blocks.lava) { return; }
if (toBeBroken == Blocks.flowing_lava) { return; }
if (toBeBroken == Blocks.obsidian) { return; }
if (toBeBroken == Blocks.mob_spawner) { return; }
// Crashing blocks: Redstone Lamp, Extended Piston
// They're likely trying to drop things that cannot be dropped (active states of themselves)
//WorldSettings.GameType gametype = WorldSettings.GameType.getByName("survival");
WorldSettings.GameType gametype = world.getWorldInfo().getGameType();
BlockEvent.BreakEvent event = ForgeHooks.onBlockBreakEvent(world, gametype, player, x, y, z);
if (event.isCanceled()) { return; } // Not allowed to do this
//toBeBroken.dropBlockAsItem(world, x, x, z, meta, 0); // The last one is Fortune
boolean removalSuccess = world.setBlockToAir(x, y, z);
if (removalSuccess) { toBeBroken.onBlockDestroyedByPlayer(world, x, y, z, meta); }
Item preBlockItem = toBeBroken.getItemDropped(meta, player.getRNG(), 0);
if (preBlockItem == null) { return; } // Item doesn't exist
ItemStack blockItem = new ItemStack(preBlockItem);
blockItem.setItemDamage(meta);
EntityItem entityItem = new EntityItem(world, x, y + 0.5d, z, blockItem);
entityItem.delayBeforeCanPickup = 10;
world.spawnEntityInWorld(entityItem);
}
示例15: removeBanner
import net.minecraftforge.event.world.BlockEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void removeBanner(BlockEvent.BreakEvent event) {
TileEntity banner = event.getWorld().getTileEntity(event.getPos());
if(banner != null && banner instanceof TileEntityBanner){
if(getPatterns((TileEntityBanner) banner).contains(TF2weapons.redPattern)){
event.getWorld().getCapability(TF2weapons.WORLD_CAP, null).banners.remove(event.getPos());
}
}
}