本文整理汇总了Java中net.minecraftforge.event.world.BlockEvent类的典型用法代码示例。如果您正苦于以下问题:Java BlockEvent类的具体用法?Java BlockEvent怎么用?Java BlockEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlockEvent类属于net.minecraftforge.event.world包,在下文中一共展示了BlockEvent类的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: onWitherBoneHarvestEvent
import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onWitherBoneHarvestEvent(BlockEvent.HarvestDropsEvent event) {
if (event.getHarvester() == null) {
return;
}
EntityPlayer player = event.getHarvester();
ItemStack stack = player.getHeldItemMainhand();
boolean flag = false;
if (stack.getItem() instanceof IHaftTool) {
if (IHaftTool.getHaftMat(stack) == ModMaterials.HAFT_WITHER_BONE) {
flag = true;
}
}
if (flag) {
if (player.dimension != DimensionType.NETHER.getId()) {
stack.damageItem(7, player);
}
}
}
示例4: canCreateFluidSource
import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent
public static void canCreateFluidSource(BlockEvent.CreateFluidSourceEvent event)
{
if (event.getResult() != Event.Result.DEFAULT)
return;
if (applyModifiers(event))
return;
Block block = event.getState().getBlock();
if (block instanceof CSBlock)
{
ContentBlockBase content = ((CSBlock) block).getContent();
if (content instanceof ContentBlockFluid)
{
ContentBlockFluid fluid = (ContentBlockFluid) content;
event.setResult(fluid.canCreateSource ? Event.Result.ALLOW : Event.Result.DENY);
}
}
}
示例5: applyModifiers
import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
private static boolean applyModifiers(BlockEvent.CreateFluidSourceEvent event)
{
Block block = event.getState().getBlock();
for (FluidModifier modifier : FluidModifier.getModifiers())
{
if (block.getRegistryName() != null && block.getRegistryName().equals(modifier.block))
{
if (modifier.canCreateSource != null)
{
event.setResult(modifier.canCreateSource ? Event.Result.ALLOW : Event.Result.DENY);
return true;
}
}
}
return false;
}
示例6: 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);
}
}
示例7: 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);
}
}
}
示例8: 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);
}
}
}
示例9: recordBlock
import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST) // Act after any cancellations
public void recordBlock(BlockEvent.PlaceEvent event) {
IBlockState bs = event.placedBlock;
Block block = bs.getBlock();
if (event.player == null) return;
if (event.world.isRemote) return;
if (event.player instanceof FakePlayer) return;
if (block.getBlockHardness(event.world, event.pos) <= 0F) return;
if (PlayerUtil.isPlayerCreative(event.player)) return;
int idmd = hash(bs);
final ItemStack theItem = toItem(block, event.world, event.pos, bs);
final PlacedBlock at = new PlacedBlock(FzUtil.getWorldDimension(event.world), event.pos, idmd, theItem);
markPlacement(event.player, at);
if (event.player instanceof EntityPlayerMP) {
send(event.player, at);
}
}
示例10: redstoneUpdate
import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent
public void redstoneUpdate(BlockEvent.NeighborNotifyEvent event)
{
World world = event.getWorld();
BlockPos pos = event.getPos();
IBlockState state = event.getState();
if(state.getBlock() != Blocks.REDSTONE_WIRE)
return;
if(!willRedstoneBoil(world,pos))
return;
if(state.getValue(BlockRedstoneWire.POWER) > 0)
return;
scheduleRedstone(world,pos,9);
}
示例11: onSnitchBreak
import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent
public void onSnitchBreak(BlockEvent.BreakEvent event)
{
BlockPos pos = event.getPos();
Location loc = new Location(pos.getX(), pos.getY(), pos.getZ(), snitchMaster.getCurrentWorld());
Snitch snitch = manager.getSnitches().remove(loc);
if (snitch != null)
{
snitchMaster.individualJourneyMapUpdate(snitch);
manager.saveSnitches();
SnitchMaster.SendMessageToPlayer("Removed snitch at " + loc.toString());
}
}
示例12: 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();
}
}
}
}
示例13: onBlockPlace
import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent
public void onBlockPlace(BlockEvent.PlaceEvent e) {
if (!e.getWorld().isRemote) {
for (EnumFacing facing : EnumFacing.VALUES) {
TileEntity tile = e.getWorld().getTileEntity(e.getBlockSnapshot().getPos().offset(facing));
if (tile != null && TileEntityPipeEStorage.isNetworkTile(tile)) {
EStorageNetwork network = TileEntityPipeEStorage.getTileNetwork(tile);
if (network != null && !network.hasAbility(e.getPlayer(), NetworkAbility.BUILD)) {
ChatUtil.sendNoSpam(e.getPlayer(), Lang.localize("gui.networkability."+NetworkAbility.BUILD.getId()));
e.setCanceled(true);
return;
}
}
}
}
}
示例14: onBlockBreak
import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent
public void onBlockBreak(BlockEvent.BreakEvent e) {
if (!e.getWorld().isRemote) {
TileEntity tile = e.getWorld().getTileEntity(e.getPos());
if (tile != null && TileEntityPipeEStorage.isNetworkTile(tile)) {
EStorageNetwork network = TileEntityPipeEStorage.getTileNetwork(tile);
if (network != null && !network.hasAbility(e.getPlayer(), NetworkAbility.BUILD)) {
ChatUtil.sendNoSpam(e.getPlayer(), Lang.localize("gui.networkability."+NetworkAbility.BUILD.getId()));
e.setCanceled(true);
}
}
}
}
示例15: placeBlock
import net.minecraftforge.event.world.BlockEvent; //导入依赖的package包/类
@SubscribeEvent
public void placeBlock(BlockEvent.PlaceEvent event) {
for (Arena arena : arenas) {
if (!arena.getPlayers().contains(event.getPlayer().getUniqueID()) || arena.getWorld() != event.getWorld())
continue;
if (!event.getWorld().isRemote && arena.getBoss() instanceof EntityZachriel)
((EntityZachriel) arena.getBoss()).nemezDrive.trackBlock(event.getPos(), event.getWorld().getBlockState(event.getPos()));
//if (!event.getWorld().isRemote)
// for (ZachTimeManager timeManager : zachHourGlasses) {
// if (timeManager.getEntityZachriel().getEntityId() == arena.getBossID()) {
// timeManager.trackBlock(Blocks.AIR.getDefaultState(), event.getPos());
// }
// }
}
}