Example usage for net.minecraftforge.common MinecraftForge EVENT_BUS

List of usage examples for net.minecraftforge.common MinecraftForge EVENT_BUS

Introduction

In this page you can find the example usage for net.minecraftforge.common MinecraftForge EVENT_BUS.

Prototype

IEventBus EVENT_BUS

To view the source code for net.minecraftforge.common MinecraftForge EVENT_BUS.

Click Source Link

Document

The core Forge EventBusses, all events for Forge will be fired on these, you should use this to register all your listeners.

Usage

From source file:abo.ABO.java

License:Open Source License

@EventHandler
public void preInitialize(FMLPreInitializationEvent evt) {

    aboLog.setParent(FMLLog.getLogger());
    aboLog.info("Starting Additional-Buildcraft-Objects #@BUILD_NUMBER@ " + VERSION
            + " (Built for Minecraft @MINECRAFT_VERSION@ with Buildcraft @BUILDCRAFT_VERSION@ and Forge @FORGE_VERSION@");
    aboLog.info("Copyright (c) Flow86, 2011-2013");

    aboConfiguration = new ABOConfiguration(new File(evt.getModConfigurationDirectory(), "abo/main.conf"));
    try {/*from   w w  w.j  a v  a 2  s.  c o  m*/
        aboConfiguration.load();

        itemGateSettingsDuplicator = createItem(itemGateSettingsDuplicatorID, ItemGateSettingsDuplicator.class,
                "Gate Settings Duplicator", BuildCraftCore.wrenchItem, BuildCraftTransport.pipeGateAutarchic,
                null);

        pipeFluidsValve = createPipe(pipeFluidsValveID, PipeFluidsValve.class, "Valve Pipe", 1,
                BuildCraftTransport.pipeFluidsWood, BuildCraftTransport.pipeGateAutarchic, null);

        pipeFluidsGoldenIron = createPipe(pipeFluidsGoldenIronID, PipeFluidsGoldenIron.class,
                "Golden Iron Waterproof Pipe", 1, BuildCraftTransport.pipeFluidsGold,
                BuildCraftTransport.pipeFluidsIron, null);

        pipeFluidsBalance = createPipe(pipeFluidsBalanceID, PipeFluidsBalance.class,
                "Balancing Waterproof Pipe", 1, BuildCraftTransport.pipeFluidsWood,
                new ItemStack(BuildCraftEnergy.engineBlock, 1, 0), BuildCraftTransport.pipeFluidsWood);

        pipeFluidsDiamond = createPipe(pipeFluidsDiamondID, PipeFluidsDistribution.class,
                "Diamond Waterproof Pipe", 1, BuildCraftTransport.pipeItemsDiamond,
                BuildCraftTransport.pipeWaterproof, null);

        if (GameRegistry.findItem("APUnofficial", "item.PipeFluidsWaterPump") == null) {
            pipeFluidsWaterPump = createPipe(pipeFluidsWaterPumpID, PipeFluidsPump.class, "Water Pump Pipe", 1,
                    false,
                    new Object[] { " L ", "rPr", " W ", 'r', Item.redstone, 'P', BuildCraftCore.ironGearItem,
                            'L', BuildCraftTransport.pipeFluidsGold, 'W', BuildCraftTransport.pipeFluidsWood });
        }

        pipeItemsRoundRobin = createPipe(pipeItemsRoundRobinID, PipeItemsRoundRobin.class,
                "RoundRobin Transport Pipe", 1, BuildCraftTransport.pipeItemsStone, Block.gravel, null);

        pipeItemsCompactor = createPipe(pipeItemsCompactorID, PipeItemsCompactor.class, "Compactor Pipe", 1,
                BuildCraftTransport.pipeItemsStone, Block.pistonBase, null);

        pipeItemsInsertion = createPipe(pipeItemsInsertionID, PipeItemsInsertion.class, "Insertion Pipe", 1,
                BuildCraftTransport.pipeItemsIron, new ItemStack(Item.dyePowder, 1, 2), null);

        pipeItemsExtraction = createPipe(pipeItemsExtractionID, PipeItemsExtraction.class,
                "Extraction Transport Pipe", 1, BuildCraftTransport.pipeItemsWood, Block.planks, null);

        pipeItemsBounce = createPipe(pipeItemsBounceID, PipeItemsBounce.class, "Bounce Transport Pipe", 1,
                BuildCraftTransport.pipeItemsStone, Block.cobblestone, null);

        pipeItemsCrossover = createPipe(pipeItemsCrossoverID, PipeItemsCrossover.class,
                "Crossover Transport Pipe", 1, BuildCraftTransport.pipeItemsStone,
                BuildCraftTransport.pipeItemsIron, null);

        pipeItemsStripes = createPipe(pipeItemsStripesID, PipeItemsStripes.class, "Stripes Transport Pipe", 8,
                new ItemStack(Item.dyePowder, 1, 0), Block.glass, new ItemStack(Item.dyePowder, 1, 11));

        pipePowerSwitch = createPipe(pipePowerSwitchID, PipePowerSwitch.class, "Power Switch Pipe", 1,
                BuildCraftTransport.pipePowerGold, Block.lever, null);

        pipePowerIron = createPipe(pipePowerIronID, PipePowerDirected.class, "Directed Kinesis Pipe", 1,
                new ItemStack(BuildCraftTransport.pipeGate, 1, 1), BuildCraftTransport.pipePowerGold, null);

        pipeDistributionConductive = createPipe(pipeDistributionConductiveID, PipePowerDistribution.class,
                "Distribution Conductive Pipe", 2, pipePowerIron, BuildCraftTransport.pipeItemsDiamond,
                pipePowerIron);

        triggerEngineSafe = new TriggerEngineSafe(triggerEngineSafeID);
        actionSwitchOnPipe = new ActionSwitchOnPipe(actionSwitchOnPipeID);
        actionToggleOnPipe = new ActionToggleOnPipe(actionToggleOnPipeID);
        actionToggleOffPipe = new ActionToggleOffPipe(actionToggleOffPipeID);

        ActionManager.registerActionProvider(new ABOActionProvider());
        ActionManager.registerTriggerProvider(new ABOTriggerProvider());

        BuildCraftCore.itemBptProps[pipeItemsExtraction.itemID] = new BptItemPipeWooden();
        BuildCraftCore.itemBptProps[pipeFluidsValve.itemID] = new BptItemPipeIron();
        BuildCraftCore.itemBptProps[pipeFluidsGoldenIron.itemID] = new BptItemPipeIron();
        BuildCraftCore.itemBptProps[pipeFluidsDiamond.itemID] = new BptItemPipeDiamond();
        BuildCraftCore.itemBptProps[pipePowerIron.itemID] = new BptItemPipeIron();

        MinecraftForge.EVENT_BUS.register(this);
    } finally {
        if (aboConfiguration.hasChanged())
            aboConfiguration.save();
    }
}

From source file:additionalpipes.AdditionalPipes.java

License:Minecraft Mod Public

@Mod.EventHandler
public void preInitialize(FMLPreInitializationEvent event) {
    logger.setParent(FMLLog.getLogger());

    configuration = new Configuration(event.getSuggestedConfigurationFile());
    try {/*from w  w  w.j a va2s . com*/
        configuration.load();

        enableRestoreRecipes = getProp(Configuration.CATEGORY_GENERAL, "enableRestoreRecipes",
                APDefaultProps.ENABLE_RESTORE_RECIPES,
                "Set to true to enable restoring Fluid/Kinesis/Structure Pipe recipes to Items Pipe.");
        distributorSplitsStack = getProp(Configuration.CATEGORY_GENERAL, "distributorSplitsStack",
                APDefaultProps.DISTRIBUTOR_SPLITS_STACK,
                "Set to true to distribute by the number of items instead of the number of stacks.");
        fakedUserName = getProp(Configuration.CATEGORY_GENERAL, "fakedUserName", APDefaultProps.FAKED_USER_NAME,
                "This user name is shown in the GUI on SSP.");
        showAllPersistentChunks = getProp(Configuration.CATEGORY_GENERAL, "showAllPersistentChunks",
                APDefaultProps.SHOW_ALL_PERSISTENT_CHUNKS,
                "Set to true to show chunks that is loaded by other mods when you press F9.");
        disablePermissions = getProp(Configuration.CATEGORY_GENERAL, "disablePermissions",
                APDefaultProps.DISABLE_PERMISSIONS, "Set to true to disable access restrictions.");

        disableEnergyUsage = getProp(CATEGORY_ENERGY, "disableEnergyUsage", APDefaultProps.DISABLE_ENERGY_USAGE,
                "Set to false to use energy with Teleport Manager when the item of pipe is teleporting. This function is for the masochists");
        disableLinkingUsage = getProp(CATEGORY_ENERGY, "disableLinkingUsage",
                APDefaultProps.DISABLE_LINKING_USAGE,
                "Set to false to link teleport pipes with Teleport Manager. This function is for the masochists");
        forcedEnergyFactor = getProp(CATEGORY_ENERGY, "forcedEnergyFactor", APDefaultProps.FORCED_ENERGY_FACTOR,
                1,
                "Teleport Pipe will use energy increased by this number if no Teleport Manager has linked pipes");
        unitLP = getProp(CATEGORY_ENERGY, "unit.LP", APDefaultProps.UNIT_LP, 1, null);
        unitItems = getProp(CATEGORY_ENERGY, "unit.items", APDefaultProps.UNIT_ITEMS, 1, null);
        unitFluids = getProp(CATEGORY_ENERGY, "unit.fluids", APDefaultProps.UNIT_FLUIDS, 1, null);
        unitPower = getProp(CATEGORY_ENERGY, "unit.power", APDefaultProps.UNIT_POWER, 1, null);
        managerCapacity = getProp(CATEGORY_ENERGY, "managerCapacity", APDefaultProps.MANAGER_CAPACITY, 0, null);

        pipeItemsTeleport = createPipe(APDefaultProps.PIPE_ITEMS_TELEPORT, PipeItemsTeleport.class,
                "Item Teleport Pipe", BuildCraftCore.diamondGearItem, Item.eyeOfEnder,
                BuildCraftCore.diamondGearItem);
        pipeFluidsTeleport = createPipe(APDefaultProps.PIPE_FLUIDS_TELEPORT, PipeFluidsTeleport.class,
                "Waterproof Teleport Pipe", BuildCraftTransport.pipeWaterproof, pipeItemsTeleport);
        pipePowerTeleport = createPipe(APDefaultProps.PIPE_POWER_TELEPORT, PipePowerTeleport.class,
                "Power Teleport Pipe", Item.redstone, pipeItemsTeleport);
        pipeStructureTeleport = createPipe(APDefaultProps.PIPE_STRUCTURE_TELEPORT, PipeStructureTeleport.class,
                "Structure Teleport Pipe", Block.gravel, pipeItemsTeleport);

        pipeItemsDistribution = createPipe(APDefaultProps.PIPE_ITEMS_DISTRIBUTION, PipeItemsDistributor.class,
                "Distribution Transport Pipe", Item.redstone, Item.ingotIron, Block.glass, Item.ingotIron);

        pipeItemsAdvancedWood = createPipe(APDefaultProps.PIPE_ITEMS_ADVANCED_WOOD, PipeItemsAdvancedWood.class,
                "Advanced Wooden Transport Pipe", Item.emerald, "plankWood", Block.glass, "plankWood");
        if (pipeItemsAdvancedWood != null) {
            PipeRecipe recipe = new PipeRecipe();
            recipe.result = new ItemStack(pipeItemsAdvancedWood, 2);
            recipe.input = new Object[] { " r ", "wgw", Character.valueOf('r'), Item.redstone,
                    Character.valueOf('w'), "plankWood", Character.valueOf('g'), Block.glass };
            pipeRecipes.add(recipe);
        }
        pipePowerAdvancedWood = createPipe(APDefaultProps.PIPE_POWER_ADVANCED_WOOD, PipePowerAdvancedWood.class,
                "Advanced Wooden Conductive Pipe", Item.redstone, pipeItemsAdvancedWood);

        pipeItemsAdvancedInsertion = createPipe(APDefaultProps.PIPE_ITEMS_ADVANCED_INSERTION,
                PipeItemsAdvancedInsertion.class, "Item Advanced Insertion Pipe", Item.redstone, Block.stone,
                Block.glass, Block.stone);
        pipeFluidsAdvancedInsertion = createPipe(APDefaultProps.PIPE_FLUIDS_ADVANCED_INSERTION,
                PipeFluidsAdvancedInsertion.class, "Advanced Insertion Waterproof Pipe",
                BuildCraftTransport.pipeWaterproof, pipeItemsAdvancedInsertion);

        pipeItemsRedstone = createPipe(APDefaultProps.PIPE_ITEMS_REDSTONE, PipeItemsRedstone.class,
                "Redstone Transport Pipe", Item.redstone, Block.glass, Item.redstone);
        pipeFluidsRedstone = createPipe(APDefaultProps.PIPE_FLUIDS_REDSTONE, PipeFluidsRedstone.class,
                "Redstone Waterproof Pipe", BuildCraftTransport.pipeWaterproof, pipeItemsRedstone);
        pipePowerRedstone = createPipe(APDefaultProps.PIPE_POWER_REDSTONE, PipePowerRedstone.class,
                "Redstone Conductive Pipe", Item.redstone, pipeItemsRedstone);

        triggerRemoteRedSignalActive = createTrigger(APDefaultProps.TRIGGER_REMOTE_RED_SIGNAL_ACTIVE, true,
                IPipe.WireColor.Red);
        triggerRemoteRedSignalInactive = createTrigger(APDefaultProps.TRIGGER_REMOTE_RED_SIGNAL_INACTIVE, false,
                IPipe.WireColor.Red);
        triggerRemoteBlueSignalActive = createTrigger(APDefaultProps.TRIGGER_REMOTE_BLUE_SIGNAL_ACTIVE, true,
                IPipe.WireColor.Blue);
        triggerRemoteBlueSignalInactive = createTrigger(APDefaultProps.TRIGGER_REMOTE_BLUE_SIGNAL_INACTIVE,
                false, IPipe.WireColor.Blue);
        triggerRemoteGreenSignalActive = createTrigger(APDefaultProps.TRIGGER_REMOTE_GREEN_SIGNAL_ACTIVE, true,
                IPipe.WireColor.Green);
        triggerRemoteGreenSignalInactive = createTrigger(APDefaultProps.TRIGGER_REMOTE_GREEN_SIGNAL_INACTIVE,
                false, IPipe.WireColor.Green);
        triggerRemoteYellowSignalActive = createTrigger(APDefaultProps.TRIGGER_REMOTE_YELLOW_SIGNAL_ACTIVE,
                true, IPipe.WireColor.Yellow);
        triggerRemoteYellowSignalInactive = createTrigger(APDefaultProps.TRIGGER_REMOTE_YELLOW_SIGNAL_INACTIVE,
                false, IPipe.WireColor.Yellow);

        Integer actionId = getDefinedProp(CATEGORY_TRIGGER, "actionDisableInsertion.id",
                APDefaultProps.ACTION_DISABLE_INSERTION);
        if (actionId == null || actionId.intValue() != 0) {
            actionDisableInsertion = new ActionDisableInsertion(
                    actionId != null ? actionId.intValue() : APDefaultProps.ACTION_DISABLE_INSERTION);
        }

        int tetherId = getBlockProp("teleportTether.id", APDefaultProps.BLOCK_TELEPORT_TETHER);
        enableTeleportTether = getProp(Configuration.CATEGORY_BLOCK, "teleportTether.enabled", true, null);
        if (tetherId != 0) {
            CoreProxy.proxy.registerTileEntity(TileTeleportTether.class, "Teleport Tether");

            blockTeleportTether = new BlockTeleportTether(tetherId);
            GameRegistry.registerBlock(blockTeleportTether.setUnlocalizedName("teleportTether"),
                    ItemTeleportTether.class, "teleportTether");
            CoreProxy.proxy.addName(blockTeleportTether, "Teleport Tether");
            net.kyprus.additionalpipes.AdditionalPipes.blockChunkLoader = blockTeleportTether;
        }

        int managerId = getBlockProp("teleportManager.id", APDefaultProps.BLOCK_TELEPORT_MANAGER);
        enableTeleportManager = getProp(Configuration.CATEGORY_BLOCK, "teleportManager.enabled", true, null);
        if (managerId != 0) {
            CoreProxy.proxy.registerTileEntity(
                    disableEnergyUsage ? TileTeleportManager.class : TileTeleportManagerEnergy.class,
                    "Teleport Manager");

            blockTeleportManager = new BlockTeleportManager(managerId);
            GameRegistry.registerBlock(blockTeleportManager.setUnlocalizedName("teleportManager"),
                    ItemTeleportManager.class, "teleportManager");
            CoreProxy.proxy.addName(blockTeleportManager, "Teleport Manager");
        }

        MinecraftForge.EVENT_BUS.register(this);
    } finally {
        if (configuration.hasChanged()) {
            configuration.save();
        }
    }

    BlockTeleportTether.maxChunkDepth = ForgeChunkManager.getMaxChunkDepthFor(APDefaultProps.ID);
    BlockTeleportTether.maxTicketLength = ForgeChunkManager.getMaxTicketLengthFor(APDefaultProps.ID);
}

From source file:additionalpipes.api.TeleportManager.java

License:Minecraft Mod Public

public static void addEnergyProvider(ITeleportEnergyProvider provider) {
    if (energyProviders.add(provider)) {
        MinecraftForge.EVENT_BUS.post(new EnergyProviderEvent.Add(provider));
    }/* ww  w . jav a2 s.c  om*/
}

From source file:additionalpipes.api.TeleportManager.java

License:Minecraft Mod Public

public static void removeEnergyProvider(ITeleportEnergyProvider provider) {
    if (energyProviders.remove(provider)) {
        MinecraftForge.EVENT_BUS.post(new EnergyProviderEvent.Remove(provider));
    }/*from ww  w .  j  a  va  2 s.  c o m*/
}

From source file:additionalpipes.api.TeleportManager.java

License:Minecraft Mod Public

public static void addTeleportPipe(ITeleportPipe pipe) {
    if (teleportPipes.add(pipe)) {
        MinecraftForge.EVENT_BUS.post(new TeleportPipeEvent.Add(pipe));
    }/*from   w ww. ja  v a 2 s  .com*/
}

From source file:additionalpipes.api.TeleportManager.java

License:Minecraft Mod Public

public static void removeTeleportPipe(ITeleportPipe pipe) {
    if (teleportPipes.remove(pipe)) {
        MinecraftForge.EVENT_BUS.post(new TeleportPipeEvent.Remove(pipe));
    }/*w w w. j  av  a 2  s.c o m*/
}

From source file:additionalpipes.chunk.ChunkManager.java

License:Minecraft Mod Public

private ChunkManager() {
    TickRegistry.registerTickHandler(this, Side.SERVER);
    ForgeChunkManager.setForcedChunkLoadingCallback(AdditionalPipes.instance, this);
    MinecraftForge.EVENT_BUS.register(this);
}

From source file:additionalpipes.inventory.ContainerTeleportManager.java

License:Minecraft Mod Public

public ContainerTeleportManager(IInventory playerInventory, TileTeleportManager manager) {
    super(manager, 0);
    this.manager = manager;

    if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
        rebuildPipeProps();/*from   w w w  .j  av a2s.  c  o  m*/
        MinecraftForge.EVENT_BUS.register(this);
    }

    propIsPublic = addPropertyToContainer(new PropertyBoolean());
    propForcedLink = addPropertyToContainer(new PropertyBoolean());
    propLP = addPropertyToContainer(new PropertyInteger());
    propMaps = addPropertyToContainer(new PropertyIntArray());
    propPipes = addPropertyToContainer(new PropertyMap());
    propViewClick = addPropertyToContainer(new PropertyIntArray());

    for (int l = 0; l < 3; l++) {
        for (int k1 = 0; k1 < 9; k1++) {
            addSlotToContainer(new Slot(playerInventory, k1 + l * 9 + 9, 8 + k1 * 18, 142 + l * 18));
        }
    }

    for (int i1 = 0; i1 < 9; i1++) {
        addSlotToContainer(new Slot(playerInventory, i1, 8 + i1 * 18, 200));
    }
}

From source file:additionalpipes.inventory.ContainerTeleportManager.java

License:Minecraft Mod Public

@Override
public void onContainerClosed(EntityPlayer par1EntityPlayer) {
    super.onContainerClosed(par1EntityPlayer);
    if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
        MinecraftForge.EVENT_BUS.unregister(this);
    }//from   www .ja v a2 s  .  c om
}

From source file:additionalpipes.inventory.ContainerTeleportManager.java

License:Minecraft Mod Public

private void rebuildPipeProps() {
    ListMultimap<PropertyInteger, ITeleportPipe> pipeMultimap = ArrayListMultimap.create();
    for (ITeleportPipe pipe : TeleportManager.getPipes()) {
        for (int map : manager.getMapsLinkTo(pipe)) {
            pipeMultimap.put(PropertyInteger.create(map), pipe);
        }// w  w w  .ja  v a2 s  .c o  m
    }
    pipes = Maps.newHashMap(Maps.transformEntries(pipeMultimap.asMap(),
            new EntryTransformer<PropertyInteger, Collection<ITeleportPipe>, PropertyIntArray>() {
                @Override
                public PropertyIntArray transformEntry(PropertyInteger key, Collection<ITeleportPipe> value) {
                    int[] result = new int[value.size() * 3];
                    int i = 0;
                    for (ITeleportPipe pipe : value) {
                        result[i++] = pipe.getType().ordinal();
                        ChunkCoordinates pos = pipe.getPosition();
                        MapData mapData = Item.map.getMapData(
                                APUtils.createMapStack(key.value, manager.worldObj), manager.worldObj);
                        int size = 1 << mapData.scale;
                        float var11 = (pos.posX - mapData.xCenter) / (float) size;
                        float var12 = (pos.posZ - mapData.zCenter) / (float) size;
                        result[i++] = (int) (var11 * 2.0F + 0.5D);
                        result[i++] = (int) (var12 * 2.0F + 0.5D);
                    }
                    return PropertyIntArray.create(result);
                }
            }));

    if (!needToRebuild) {
        MinecraftForge.EVENT_BUS.post(new ContainerModifyEvent(this, manager));
    }
}