当前位置: 首页>>代码示例>>Java>>正文


Java Event类代码示例

本文整理汇总了Java中cpw.mods.fml.common.eventhandler.Event的典型用法代码示例。如果您正苦于以下问题:Java Event类的具体用法?Java Event怎么用?Java Event使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Event类属于cpw.mods.fml.common.eventhandler包,在下文中一共展示了Event类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyEnrichment

import cpw.mods.fml.common.eventhandler.Event; //导入依赖的package包/类
public boolean applyEnrichment (ItemStack itemStack, World world, int x, int y, int z, EntityPlayer player) {
    ConfigManager config = GardenCore.config;
    Block block = world.getBlock(x, y, z);

    EnrichedSoilEvent event = new EnrichedSoilEvent(player, world, block, x, y, z);
    if (MinecraftForge.EVENT_BUS.post(event))
        return false;

    if (!config.enableCompostBonemeal)
        return false;

    if (event.getResult() == Event.Result.ALLOW) {
        if (!world.isRemote)
            itemStack.stackSize--;
        return true;
    }

    int prob = (config.compostBonemealStrength == 0) ? 0 : (int)(1 / config.compostBonemealStrength);
    if (world.rand.nextInt(prob) == 0)
        return ItemDye.applyBonemeal(itemStack, world, x, y, z, player);
    else
        --itemStack.stackSize;

    return true;
}
 
开发者ID:jaquadro,项目名称:GardenCollection,代码行数:26,代码来源:ItemCompost.java

示例2: onItemUse

import cpw.mods.fml.common.eventhandler.Event; //导入依赖的package包/类
public boolean onItemUse(final ItemStack p_77648_1_, final EntityPlayer p_77648_2_, final World p_77648_3_, final int p_77648_4_, final int p_77648_5_, final int p_77648_6_, final int p_77648_7_, final float p_77648_8_, final float p_77648_9_, final float p_77648_10_) {
    if (!p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_)) {
        return false;
    }
    final UseHoeEvent event = new UseHoeEvent(p_77648_2_, p_77648_1_, p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_);
    if (MinecraftForge.EVENT_BUS.post((Event)event)) {
        return false;
    }
    if (event.getResult() == Event.Result.ALLOW) {
        return true;
    }
    final Block block = p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_);
    if (p_77648_7_ == 0 || !p_77648_3_.getBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_).isAir((IBlockAccess)p_77648_3_, p_77648_4_, p_77648_5_ + 1, p_77648_6_) || (block != Blocks.grass && block != Blocks.dirt)) {
        return false;
    }
    final Block block2 = Blocks.farmland;
    p_77648_3_.playSoundEffect((double)(p_77648_4_ + 0.5f), (double)(p_77648_5_ + 0.5f), (double)(p_77648_6_ + 0.5f), block2.stepSound.getStepResourcePath(), (block2.stepSound.getVolume() + 1.0f) / 2.0f, block2.stepSound.getPitch() * 0.8f);
    if (p_77648_3_.isRemote) {
        return true;
    }
    p_77648_3_.setBlock(p_77648_4_, p_77648_5_, p_77648_6_, block2);
    return true;
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:24,代码来源:ItemTemporalHoe.java

示例3: SiegeCheckSpawn

import cpw.mods.fml.common.eventhandler.Event; //导入依赖的package包/类
@SubscribeEvent
public void SiegeCheckSpawn(final LivingSpawnEvent.CheckSpawn event) {
    if (EventHandlerSiege.SiegeParticipants.isEmpty()) {
        return;
    }
    if (event.entity.worldObj.isRemote) {
        return;
    }
    if (event.world.provider.dimensionId != 1) {
        return;
    }
    if (event.entityLiving instanceof EntityMob && event.entityLiving.worldObj.checkNoEntityCollision(event.entityLiving.boundingBox) && event.entityLiving.worldObj.getCollidingBoundingBoxes((Entity)event.entityLiving, event.entityLiving.boundingBox).isEmpty() && !event.entityLiving.worldObj.isAnyLiquid(event.entityLiving.boundingBox)) {
        event.entityLiving.getEntityData().setBoolean("Siege", true);
        event.entityLiving.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 7200, 2));
        event.setResult(Event.Result.ALLOW);
    }
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:18,代码来源:EventHandlerSiege.java

示例4: noMobs

import cpw.mods.fml.common.eventhandler.Event; //导入依赖的package包/类
@SubscribeEvent
public void noMobs(final LivingSpawnEvent.CheckSpawn event) {
    if (event.getResult() == Event.Result.DEFAULT && event.world.provider.dimensionId == ExtraUtils.underdarkDimID && event.entity instanceof EntityMob) {
        if (EventHandlerUnderdark.rand.nextDouble() < Math.min(0.95, event.entity.posY / 80.0)) {
            event.setResult(Event.Result.DENY);
        }
        else {
            IAttributeInstance t = ((EntityMob)event.entity).getEntityAttribute(SharedMonsterAttributes.maxHealth);
            t.setBaseValue(t.getBaseValue() * 2.0);
            ((EntityMob)event.entity).heal((float)t.getAttributeValue());
            t = ((EntityMob)event.entity).getEntityAttribute(SharedMonsterAttributes.attackDamage);
            t.setBaseValue(t.getBaseValue() * 2.0);
            if (!EventHandlerServer.isInRangeOfTorch(event.entity) && event.entityLiving.worldObj.checkNoEntityCollision(event.entityLiving.boundingBox) && event.entityLiving.worldObj.getCollidingBoundingBoxes((Entity)event.entityLiving, event.entityLiving.boundingBox).isEmpty() && !event.entityLiving.worldObj.isAnyLiquid(event.entityLiving.boundingBox)) {
                event.setResult(Event.Result.ALLOW);
            }
        }
    }
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:19,代码来源:EventHandlerUnderdark.java

示例5: initIC

import cpw.mods.fml.common.eventhandler.Event; //导入依赖的package包/类
protected void initIC()
{
    if (EnergyConfigHandler.isIndustrialCraft2Loaded())
    {
        try
        {
            Class<?> tileLoadEvent = Class.forName("ic2.api.energy.event.EnergyTileLoadEvent");
            Class<?> energyTile = Class.forName("ic2.api.energy.tile.IEnergyTile");
            Constructor<?> constr = tileLoadEvent.getConstructor(energyTile);
            Object o = constr.newInstance(this);

            if (o != null && o instanceof Event)
            {
                MinecraftForge.EVENT_BUS.post((Event) o);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    this.isAddedToEnergyNet = true;
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:25,代码来源:TileBaseUniversalElectrical.java

示例6: initIC

import cpw.mods.fml.common.eventhandler.Event; //导入依赖的package包/类
protected void initIC()
{
    if (EnergyConfigHandler.isIndustrialCraft2Loaded() && !this.worldObj.isRemote)
    {
        try
        {
            Class<?> tileLoadEvent = Class.forName("ic2.api.energy.event.EnergyTileLoadEvent");
            Class<?> energyTile = Class.forName("ic2.api.energy.tile.IEnergyTile");
            Constructor<?> constr = tileLoadEvent.getConstructor(energyTile);
            Object o = constr.newInstance(this);

            if (o != null && o instanceof Event)
            {
                MinecraftForge.EVENT_BUS.post((Event) o);
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:23,代码来源:TileBaseUniversalConductor.java

示例7: onSleepCancelled

import cpw.mods.fml.common.eventhandler.Event; //导入依赖的package包/类
public static void onSleepCancelled()
{
	try
	{
		if (MicdoodlePlugin.sleepCancelledConstructor == null)
		{
			MicdoodlePlugin.sleepCancelledConstructor = Class.forName(MicdoodlePlugin.galacticraftCoreClass + "$SleepCancelledEvent").getConstructor();
		}

		MinecraftForge.EVENT_BUS.post((Event) MicdoodlePlugin.sleepCancelledConstructor.newInstance());
	}
	catch (Exception e)
	{
		e.printStackTrace();
	}
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:17,代码来源:MicdoodlePlugin.java

示例8: orientCamera

import cpw.mods.fml.common.eventhandler.Event; //导入依赖的package包/类
public static void orientCamera()
{
	try
	{
		if (MicdoodlePlugin.orientCameraConstructor == null)
		{
			MicdoodlePlugin.orientCameraConstructor = Class.forName(MicdoodlePlugin.galacticraftCoreClass + "$OrientCameraEvent").getConstructor();
		}

		MinecraftForge.EVENT_BUS.post((Event) MicdoodlePlugin.orientCameraConstructor.newInstance());
	}
	catch (Exception e)
	{
		e.printStackTrace();
	}
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:17,代码来源:MicdoodlePlugin.java

示例9: onPlayerInteract

import cpw.mods.fml.common.eventhandler.Event; //导入依赖的package包/类
@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event)
{
    EntityPlayer player = event.entityPlayer;
    World world = event.world;
    int x = event.x;
    int y = event.y;
    int z = event.z;

    if ((event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) && (!player.isSneaking()))
    {
        Block clickedBlock = world.getBlock(x, y, z);
        if (clickedBlock == Blocks.crafting_table)
            if (validMultiblock(world, x, y, z))
            {
                event.useBlock = Event.Result.DENY;
                player.openGui(DualCraft.instance, GUIs.DUAL_WORKBENCH.ordinal(), world, x, y, z);
            }
    }
}
 
开发者ID:SamRaven2,项目名称:DualCraft,代码行数:21,代码来源:WorldEventHandler.java

示例10: hoeBlock

import cpw.mods.fml.common.eventhandler.Event; //导入依赖的package包/类
public static boolean hoeBlock(ItemStack stack, World world, int x, int y, int z, int sideHit, EntityPlayer player){
    Block block = world.getBlock(x, y, z);

    UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z);
    if(MinecraftForge.EVENT_BUS.post(event)) //if the event got canceled
        return false;

    if (event.getResult() == Event.Result.ALLOW) //if another mod handled this block using the event
        return true;

    //vanilla hoe behaviour
    if (sideHit != 0 && world.isAirBlock(x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt) && player.canPlayerEdit(x, y, z, sideHit, stack)) {
        if (!world.isRemote)
            world.setBlock(x, y, z, Blocks.farmland);
        return true;
    }

    return false;
}
 
开发者ID:goldenapple3,项目名称:RFDrills,代码行数:20,代码来源:ToolHelper.java

示例11: allowPlantGrowth

import cpw.mods.fml.common.eventhandler.Event; //导入依赖的package包/类
@SubscribeEvent
public void allowPlantGrowth(PlantGrowthEvent.AllowGrowthTick event)
{
    Chunk chunk = event.world.getChunkFromBlockCoords(event.x, event.z);
    BioSystem bioSystem = BioSystemHandler.getBioSystem(event.world, chunk);

    if (bioSystem != null)
    {
        int meta = event.world.getBlockMetadata(event.x, event.y, event.z);
        float lowestNutrientPart = PlantConfig.getLowestNutrientPart(event.block, meta, bioSystem.getPhosphorus(), bioSystem.getPotassium(), bioSystem.getNitrogen());
        float nutrientGrowChance = MathLib.getFittedValue(lowestNutrientPart, Settings.NUTRIENT_AMOUNT_FOR_STOP_GROWTH, Settings.NUTRIENT_AMOUNT_FOR_NORMAL_GROWTH, Settings.NUTRIENT_AMOUNT_FOR_MAX_GROWTH);

        int lightValue = event.block.isOpaqueCube() ? WorldHelper.getLightValue(event.world, event.x, event.y + 1, event.z) : WorldHelper.getLightValue(event.world, event.x, event.y, event.z);
        float lightGrowChance = MathLib.getFittedValue(lightValue, Settings.LIGHT_VALUE_FOR_STOP_GROWTH, Settings.LIGHT_VALUE_FOR_NORMAL_GROWTH, Settings.LIGHT_VALUE_FOR_MAX_GROWTH);

        if (Math.min(nutrientGrowChance, lightGrowChance) < event.world.rand.nextFloat())
        {
            event.setResult(Event.Result.DENY);
        }
    }
}
 
开发者ID:Dynious,项目名称:Biota,代码行数:22,代码来源:CommonEventHandler.java

示例12: onBiomeDecoration

import cpw.mods.fml.common.eventhandler.Event; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onBiomeDecoration(DecorateBiomeEvent.Decorate event)
{
    if (event.type == DecorateBiomeEvent.Decorate.EventType.FLOWERS && (event.getResult() == Event.Result.ALLOW || event.getResult() == Event.Result.DEFAULT))
    {
        for (int i = 0; i < Settings.FLOWER_QUANTITY; i++)
        {
            int x = event.chunkX + event.rand.nextInt(16) + 8;
            int z = event.chunkZ + event.rand.nextInt(16) + 8;
            int y = event.world.getTopSolidOrLiquidBlock(x, z);
            Block randomPlant = ModBlocks.plants[event.rand.nextInt(ModBlocks.plants.length)];

            if (event.world.isAirBlock(x, y, z) && (!event.world.provider.hasNoSky || y < 255) && randomPlant.canBlockStay(event.world, x, y, z))
            {
                event.world.setBlock(x, y, z, randomPlant, 0, 2);
            }
        }
    }
}
 
开发者ID:Dynious,项目名称:Biota,代码行数:20,代码来源:TerrainEventHandler.java

示例13: BlockSpawnEvent

import cpw.mods.fml.common.eventhandler.Event; //导入依赖的package包/类
@SubscribeEvent
public void BlockSpawnEvent(LivingSpawnEvent.CheckSpawn event){
    List<MobInhibitorReference> RefList;
    if (event.getResult() != Event.Result.DEFAULT){ return;} // If the event is already forced Allow or Deny, let it through
    if (event.entity.isCreatureType(EnumCreatureType.monster,false)){ //decide which list to use.
        RefList = MobInhibitor.HostileInhibitors;
    } else if (event.entity.isCreatureType(EnumCreatureType.waterCreature,false)){
        RefList = MobInhibitor.AquaInhibitors;
    } else { // this will also catch ambient creatures like bats.
        if (!ConfigurationHandler.InhibitAmbient && event.entity.isCreatureType(EnumCreatureType.ambient,false)){
            return; //If the InhibitAmbient config is not set, and the creature type is ambient, don't do anything.
            //If the config is set, fall through. The remaining category is Creature, which includes passives.
        }
        RefList = MobInhibitor.PassiveInhibitors;
    }
    for (MobInhibitorReference Ref : RefList){
        if (TestRange(Ref, event.entity.posX, event.entity.posY, event.entity.posZ, event.world.provider.dimensionId)) {
            event.setResult(Event.Result.DENY);
            LogHelper.debug("Blocked a spawn based on inhibitor at:"+Ref.i+", "+Ref.j+", "+Ref.k);
            return;
        }
    }
}
 
开发者ID:yarrim,项目名称:MobInhibitor,代码行数:24,代码来源:ServerEventHandler.java

示例14: onWorldDecoration

import cpw.mods.fml.common.eventhandler.Event; //导入依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onWorldDecoration(DecorateBiomeEvent.Decorate event) {
    BiomeGenBase biome = event.world.getBiomeGenForCoords(event.chunkX, event.chunkZ);
    if (biome != null && isValidBiomeType(biome)) {
        if ((event.getResult() == Event.Result.ALLOW || event.getResult() == Event.Result.DEFAULT) && event.type == DecorateBiomeEvent.Decorate.EventType.FLOWERS) {
            for (int i = 0; i < ModLibs.manaFlowerQuantity; i++) {
                int x = event.chunkX + event.rand.nextInt(16) + 8;
                int z = event.chunkZ + event.rand.nextInt(16) + 8;
                int y = event.world.getTopSolidOrLiquidBlock(x, z);

                for (int j = 0; j < ModLibs.manaFlowerDensity; j++) {
                    int x1 = x + event.rand.nextInt(8) - event.rand.nextInt(8);
                    int y1 = y + event.rand.nextInt(4) - event.rand.nextInt(4);
                    int z1 = z + event.rand.nextInt(8) - event.rand.nextInt(8);

                    if (event.world.isAirBlock(x1, y1, z1) && (!event.world.provider.hasNoSky || y1 < 127) && ModBlocks.manaFlower.canBlockStay(event.world, x1, y1, z1))
                        event.world.setBlock(x1, y1, z1, ModBlocks.manaFlower, event.rand.nextInt(3), 2);
                }
            }
        }
    }
}
 
开发者ID:Lomeli12,项目名称:MagicalRings,代码行数:23,代码来源:BiomeDecorHandler.java

示例15: onPlayerInteract

import cpw.mods.fml.common.eventhandler.Event; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerInteract(PlayerInteractEvent ev) {
    if (ev.entityPlayer.worldObj.isRemote || ev.isCanceled()) {
        return;
    }

    Resident res = MyTownUniverse.instance.getOrMakeResident(ev.entityPlayer);
    if(ev.entityPlayer.getHeldItem() != null) {
        ProtectionManager.checkUsage(ev.entityPlayer.getHeldItem(), res, ev.action, createBlockPos(ev), ev.face, ev);
    }
    if (!ev.isCanceled()) {
        ProtectionManager.checkBlockInteraction(res, new BlockPos(ev.x, ev.y, ev.z, ev.world.provider.dimensionId), ev.action, ev);
    }

    // Some things (Autonomous Activator) only care about these. So always deny them if the event is canceled.
    if (ev.isCanceled()) {
        ev.useBlock = Event.Result.DENY;
        ev.useItem = Event.Result.DENY;
    }
}
 
开发者ID:MyEssentials,项目名称:MyTown2,代码行数:22,代码来源:ProtectionHandlers.java


注:本文中的cpw.mods.fml.common.eventhandler.Event类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。