Java 类cpw.mods.fml.common.eventhandler.Event 实例源码

项目:ExtraUtilities    文件:ItemTemporalHoe.java   
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;
}
项目:ExtraUtilities    文件:EventHandlerSiege.java   
@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);
    }
}
项目:ExtraUtilities    文件:EventHandlerUnderdark.java   
@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);
            }
        }
    }
}
项目:4Space-5    文件:TileBaseUniversalElectrical.java   
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;
}
项目:4Space-5    文件:TileBaseUniversalConductor.java   
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();
        }
    }
}
项目:4Space-5    文件:MicdoodlePlugin.java   
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();
    }
}
项目:4Space-5    文件:MicdoodlePlugin.java   
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();
    }
}
项目:DualCraft    文件:WorldEventHandler.java   
@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);
            }
    }
}
项目:RFDrills    文件:ToolHelper.java   
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;
}
项目:Biota    文件:CommonEventHandler.java   
@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);
        }
    }
}
项目:Biota    文件:TerrainEventHandler.java   
@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);
            }
        }
    }
}
项目:MobInhibitor    文件:ServerEventHandler.java   
@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;
        }
    }
}
项目:MagicalRings    文件:BiomeDecorHandler.java   
@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);
                }
            }
        }
    }
}
项目:MyTown2    文件:ProtectionHandlers.java   
@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;
    }
}
项目:MyTown2    文件:ProtectionManager.java   
public static void checkBlockInteraction(Resident res, BlockPos bp, PlayerInteractEvent.Action action, Event ev) {
    if(!ev.isCancelable()) {
        return;
    }

    World world = MinecraftServer.getServer().worldServerForDimension(bp.getDim());
    Block block = world.getBlock(bp.getX(), bp.getY(), bp.getZ());

    // Bypass for SellSign
    if (block instanceof BlockSign) {
        TileEntity te = world.getTileEntity(bp.getX(), bp.getY(), bp.getZ());
        if(te instanceof TileEntitySign && SellSign.SellSignType.instance.isTileValid((TileEntitySign) te)) {
            return;
        }
    }

    for(SegmentBlock segment : segmentsBlock.get(block.getClass())) {
        if(!segment.shouldInteract(res, bp, action)) {
            ev.setCanceled(true);
        }
    }
}
项目:GardenCollection    文件:ForgeEventHandler.java   
@SubscribeEvent
public void applyEnrichedSoil (EnrichedSoilEvent event) {
    if (!GardenTrees.config.compostGrowsOrnamentalTrees)
        return;

    Item sapling = Item.getItemFromBlock(event.block);
    int saplingMeta = event.world.getBlockMetadata(event.x, event.y, event.z);
    if (sapling == null)
        return;

    WorldGenerator generator = (WorldGenerator) SaplingRegistry.instance().getExtendedData(sapling, saplingMeta, "sm_generator");
    if (generator == null)
        return;

    event.world.setBlockToAir(event.x, event.y, event.z);

    if (generator.generate(event.world, event.world.rand, event.x, event.y, event.z)) {
        event.setResult(Event.Result.ALLOW);
        return;
    }

    event.world.setBlock(event.x, event.y, event.z, event.block, saplingMeta, 0);
}
项目:GardenCollection    文件:ItemCompost.java   
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;
}
项目:Rubedo    文件:Rituals.java   
public static void performEffect(IMasterRitualStone ritualStone, String ritualID)
{
    String ownerName = ritualStone.getOwner();

    RitualRunEvent event = new RitualRunEvent(ritualStone, ownerName, ritualID);

    if(MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
    {
        return;
    }

    if (ritualMap.containsKey(event.ritualKey))
    {
        Rituals ritual = ritualMap.get(event.ritualKey);
        if (ritual != null && ritual.effect != null)
        {
            ritual.effect.performEffect(ritualStone);
        }
    }
}
项目:Atmatm6_Mods    文件:MicdoodlePlugin.java   
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();
    }
}
项目:Atmatm6_Mods    文件:MicdoodlePlugin.java   
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();
    }
}
项目:ModularArmour    文件:Rituals.java   
public static void performEffect(IMasterRitualStone ritualStone, String ritualID)
{
    String ownerName = ritualStone.getOwner();

    RitualRunEvent event = new RitualRunEvent(ritualStone, ownerName, ritualID);

    if(MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
    {
        return;
    }

    if (ritualMap.containsKey(event.ritualKey))
    {
        Rituals ritual = ritualMap.get(event.ritualKey);
        if (ritual != null && ritual.effect != null)
        {
            ritual.effect.performEffect(ritualStone);
        }
    }
}
项目:ClockworkPhase    文件:WorldGenHandler.java   
@SubscribeEvent
public void onSaplingGrow(SaplingGrowTreeEvent event)
{
    ExtractorAreas.ExtractorArea area = ExtractorAreas.getAreasFromWorld(event.world, Phases.EARTH).getValidArea(event.world, event.x, event.y, event.z);
    if(area != null)
    {
        TileEntity te = event.world.getTileEntity(area.extractorX, area.extractorY, area.extractorZ);
        if(te != null && te instanceof TileEntityExtractor)
        {
            if(((TileEntityExtractor) te).applyEffect(Phases.EARTH))
            {
                PacketHandler.INSTANCE.sendToAllAround(new MessageDoublePositionParticleSpawn(event.x + 0.5, event.y + 0.5, event.z + 0.5, area.extractorX + 0.5, area.extractorY + 0.5, area.extractorZ + 0.5, 0), new NetworkRegistry.TargetPoint(event.world.provider.dimensionId, event.x + 0.5, event.y + 0.5, event.z + 0.5, 64));
                event.setResult(Event.Result.DENY);
            }
        }
    }
}
项目:ClockworkPhase    文件:EntityHandler.java   
@SubscribeEvent
public void onEntitySpawn(LivingSpawnEvent.CheckSpawn event)
{
    if(!(event.entityLiving instanceof EntityPlayer))
    {
        ExtractorAreas.ExtractorArea area = ExtractorAreas.getAreasFromWorld(event.entity.worldObj, Phases.LIFE).getValidArea(event.entity.worldObj, (int)event.entity.posX, (int)event.entity.posY, (int)event.entity.posZ);
        if(area != null)
        {
            TileEntity te = event.entity.worldObj.getTileEntity(area.extractorX, area.extractorY, area.extractorZ);
            if(te != null && te instanceof TileEntityExtractor)
            {
                ((TileEntityExtractor) te).addTimeSand(MechanicTweaker.TIME_SAND_FROM_NATURAL_SPAWN);
                event.setResult(Event.Result.DENY);
            }
        }
    }
}
项目:CodeLyokoMod    文件:LyokoBaseChunkProvider.java   
public void replaceBlocksForBiome(int chunkX, int chunkZ, Block[] blocks, byte[] blockMeta, BiomeGenBase[] biomesForGeneration)
{
    ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, chunkX, chunkZ, blocks, blockMeta, biomesForGeneration);
    MinecraftForge.EVENT_BUS.post(event);
    if (event.getResult() == Event.Result.DENY) return;

    double d0 = 0.03125D;
    int posX = chunkX * 16;
    int posZ = chunkZ * 16;
    this.stoneNoise = this.noiseGen4.generateNoiseOctaves(this.stoneNoise, posX, posZ, 16, 16, d0 * 2.0D, d0 * 2.0D, 1.0D);

    for (int z = 0; z < 16; ++z) {
        for (int x = 0; x < 16; ++x) {
            BiomeGenBase biomegenbase = biomesForGeneration[x + z * 16];
            biomegenbase.genTerrainBlocks(this.world, this.rand, blocks, blockMeta, posX + z, posZ + x, this.stoneNoise[x + z * 16]);
        }
    }
}
项目:PneumaticCraft    文件:TileEntityUniversalSensor.java   
public void onEvent(Event event){
    ISensorSetting sensor = SensorHandler.instance().getSensorFromPath(sensorSetting);
    if(sensor != null && sensor instanceof IEventSensorSetting && getPressure(ForgeDirection.UNKNOWN) > PneumaticValues.MIN_PRESSURE_UNIVERSAL_SENSOR) {
        int newRedstoneStrength = ((IEventSensorSetting)sensor).emitRedstoneOnEvent(event, this, getRange(), sensorGuiText);
        if(newRedstoneStrength != 0) eventTimer = ((IEventSensorSetting)sensor).getRedstonePulseLength();
        if(invertedRedstone) newRedstoneStrength = 15 - newRedstoneStrength;
        if(eventTimer > 0 && ThirdPartyManager.computerCraftLoaded) {
            if(event instanceof PlayerInteractEvent) {
                PlayerInteractEvent e = (PlayerInteractEvent)event;
                notifyComputers(newRedstoneStrength, e.x, e.y, e.z);
            } else {
                notifyComputers(newRedstoneStrength);
            }
        }
        if(newRedstoneStrength != redstoneStrength) {
            redstoneStrength = newRedstoneStrength;
            updateNeighbours();
        }
    }
}
项目:bit-client    文件:Render2DEventDispatcher.java   
@Override
public void invoke(Event e) {
    RenderGameOverlayEvent.Post eve = (RenderGameOverlayEvent.Post) e;
    if (Wrapper.thePlayer() != null && Wrapper.theWorld() != null
            && eve.type.equals(RenderGameOverlayEvent.ElementType.TEXT)) {
        new Render2DEvent().call();
    }
}
项目:bit-client    文件:NametagRenderEventDispatcher.java   
@Override
public void invoke(Event e) {
    RenderLivingEvent.Specials.Pre format = (RenderLivingEvent.Specials.Pre) e;
    NametagRenderEvent event = new NametagRenderEvent(format.entity);
    event.call();
    format.setCanceled(event.isCancelled());
}
项目:bit-client    文件:KeypressEventDispatcher.java   
@Override
public void invoke(Event e) {
    InputEvent.KeyInputEvent event = (InputEvent.KeyInputEvent) e;
    if (!Keyboard.getEventKeyState()) return;
    if (Keyboard.getEventKey() == Keyboard.KEY_NONE) return;
    new KeypressEvent(Keyboard.getEventKey()).call();
}
项目:bit-client    文件:PlayerGetDamagedEventDispatcher.java   
@Override
public void invoke(Event e) {
    LivingHurtEvent event = (LivingHurtEvent) e;
    if (Wrapper.thePlayer() == null || Wrapper.theWorld() == null) return;
    if (event.entityLiving != null && event.entityLiving.func_70005_c_() == Wrapper.thePlayer().func_70005_c_())
        new PlayerGetDamagedEvent().call();
}
项目:bit-client    文件:TickEventDispatcher.java   
@Override
public void invoke(Event event) {
    if (event instanceof RenderTickEvent)
        new sl.steeldood.bit.client.event.impl.RenderTickEvent().call();
    else
        new ClientTickEvent().call();

}
项目:ExtraUtilities    文件:EventHandlerServer.java   
@SubscribeEvent
public void magnumTorchDenySpawn(final LivingSpawnEvent.CheckSpawn event) {
    if (event.getResult() == Event.Result.ALLOW) {
        return;
    }
    if (event.entityLiving.isCreatureType(EnumCreatureType.monster, false) && isInRangeOfTorch(event.entity)) {
        event.setResult(Event.Result.DENY);
    }
}
项目:ExtraUtilities    文件:EventHandlerUnderdark.java   
@SubscribeEvent
public void noDirt(final OreGenEvent.GenerateMinable event) {
    if (event.world.provider.dimensionId == ExtraUtils.underdarkDimID) {
        switch (event.type) {
            case DIRT:
            case GRAVEL: {
                event.setResult(Event.Result.DENY);
                break;
            }
        }
    }
}
项目:4Space-5    文件:TileBaseUniversalElectrical.java   
private void unloadTileIC2()
{
    if (this.isAddedToEnergyNet && this.worldObj != null)
    {
        if (EnergyConfigHandler.isIndustrialCraft2Loaded() && !this.worldObj.isRemote)
        {
            try
            {
                Class<?> tileLoadEvent = Class.forName("ic2.api.energy.event.EnergyTileUnloadEvent");
                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 = false;
    }
}
项目:4Space-5    文件:TileBaseUniversalConductor.java   
private void unloadTileIC2()
{
    if (this.isAddedToEnergyNet && this.worldObj != null)
    {
        if (!this.worldObj.isRemote && EnergyConfigHandler.isIndustrialCraft2Loaded())
        {
            try
            {
                Class<?> tileLoadEvent = Class.forName("ic2.api.energy.event.EnergyTileUnloadEvent");
                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 = false;
    }
}
项目:DartCraft2    文件:BucketHandler.java   
@SubscribeEvent
public void onBucketFill(FillBucketEvent event) {

    ItemStack result = fillCustomBucket(event.world, event.target);

    if (result == null)
        return;

    event.result = result;
    event.setResult(Event.Result.ALLOW);
}
项目:DartCraft2    文件:ItemForceMitts.java   
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int blockMeta, float blockX, float blockY, float blockZ) { //Taken from vanilla code
    if (!player.canPlayerEdit(x, y, z, blockMeta, itemstack)) {
        return false;
    }
    else {
        UseHoeEvent event = new UseHoeEvent(player, itemstack, world, x, y, z);
        if (MinecraftForge.EVENT_BUS.post(event)) {
            return false;
        }

        if (event.getResult() == Event.Result.ALLOW) {
            itemstack.damageItem(1, player);
            return true;
        }

        Block block = world.getBlock(x, y, z);

        if (blockMeta != 0 && world.getBlock(x, y + 1, z).isAir(world, x, y + 1, z) && (block == Blocks.grass || block == Blocks.dirt)) {
            Block block1 = Blocks.farmland;
            world.playSoundEffect((double)((float)x + 0.5F), (double)((float)y + 0.5F), (double)((float)z + 0.5F), block1.stepSound.getStepResourcePath(), (block1.stepSound.getVolume() + 1.0F) / 2.0F, block1.stepSound.getPitch() * 0.8F);

            if (world.isRemote) {
                return true;
            }
            else {
                world.setBlock(x, y, z, block1);
                itemstack.damageItem(1, player);
                return true;
            }
        }
        else {
            return false;
        }
    }
}
项目:NOVA-Core    文件:ForgeEventHandler.java   
@SubscribeEvent
public void playerInteractEvent(PlayerInteractEvent event) {
    nova.core.event.PlayerEvent.Interact evt = new nova.core.event.PlayerEvent.Interact(
        WorldConverter.instance().toNova(event.world),
        new Vector3D(event.x, event.y, event.z),
        EntityConverter.instance().toNova(event.entityPlayer),
        nova.core.event.PlayerEvent.Interact.Action.values()[event.action.ordinal()]
    );

    Game.events().publish(evt);

    event.useBlock = Event.Result.values()[evt.useBlock.ordinal()];
    event.useItem = Event.Result.values()[evt.useItem.ordinal()];
    event.setCanceled(evt.isCanceled());
}
项目:SteelSheep    文件:EventStuff.java   
@SubscribeEvent
public void attack(LivingAttackEvent event) {
    if (event.entityLiving instanceof EntityPlayer && event.source == EntitySteelSheep.tetanus) {
        event.setCanceled(false);
        event.setResult(Event.Result.ALLOW);
    }
}
项目:M4thThings    文件:BucketHandler.java   
@SubscribeEvent
public void onBucketFill(FillBucketEvent event) {

    ItemStack result = fillCustomBucket(event.world, event.target);

    if (result == null)
        return;

    event.result = result;
    event.setResult(Event.Result.ALLOW);
}
项目:Biota    文件:BlockNewGrass.java   
@Override
public void updateTick(World world, int x, int y, int z, Random random)
{
    Hooks.onPlantTick(this, world, x, y, z);
    if (!world.isRemote)
    {
        if (world.getBlockLightValue(x, y + 1, z) < 4 && world.getBlockLightOpacity(x, y + 1, z) > 2)
        {
            world.setBlock(x, y, z, Blocks.dirt);
        }
        else
        {
            Event.Result result = AppleCoreAPI.dispatcher.validatePlantGrowth(this, world, x, y, z, random);
            if (result == Event.Result.ALLOW || (result == Event.Result.DEFAULT && world.getBlockLightValue(x, y + 1, z) >= 9))
            {
                int meta = world.getBlockMetadata(x, y, z);
                if (meta == 0)
                {
                    for (int l = 0; l < 4; ++l)
                    {
                        int i1 = x + random.nextInt(3) - 1;
                        int j1 = y + random.nextInt(5) - 3;
                        int k1 = z + random.nextInt(3) - 1;

                        if (world.getBlock(i1, j1, k1) == Blocks.dirt && world.getBlockMetadata(i1, j1, k1) == 0 && world.getBlockLightValue(i1, j1 + 1, k1) >= 4 && world.getBlockLightOpacity(i1, j1 + 1, k1) <= 2)
                        {
                            world.setBlock(i1, j1, k1, Blocks.grass, 15, 3);
                            Hooks.onPlantGrowth(world, i1, j1, k1, this, 15);
                        }
                    }
                }
                else if (random.nextInt(Settings.GRASS_GROW_BACK_CHANCE) == 0)
                {
                    world.setBlockMetadataWithNotify(x, y, z, meta - 1, 3);
                    AppleCoreAPI.dispatcher.announcePlantGrowth(this, world, x, y, z, meta);
                }
            }
        }
    }
}