cpw.mods.fml.common.FMLCommonHandler Java Examples
The following examples show how to use
cpw.mods.fml.common.FMLCommonHandler.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WRAddonProxy.java From WirelessRedstone with MIT License | 6 votes |
public void init() { WRCoreSPH.delegates.add(new WRAddonSPH()); FMLCommonHandler.instance().bus().register(new WRAddonEventHandler()); triangulator = register(new ItemWirelessTriangulator(), "triangulator"); remote = register(new ItemWirelessRemote(), "remote"); sniffer = register(new ItemWirelessSniffer(), "sniffer"); emptyWirelessMap = register(new ItemEmptyWirelessMap(), "empty_map"); wirelessMap = register(new ItemWirelessMap(), "map"); tracker = register(new ItemWirelessTracker(), "tracker"); rep = register(new ItemREP(), "rep"); psniffer = register(new ItemPrivateSniffer(), "psniffer"); CommonUtils.registerHandledEntity(EntityWirelessTracker.class, "WRTracker"); addRecipes(); }
Example #2
Source File: ClientBlockUpdate.java From MyTown2 with The Unlicense | 6 votes |
public void send(BlockPos center, EntityPlayerMP player, ForgeDirection face) { World world = MinecraftServer.getServer().worldServerForDimension(center.getDim()); int x, y, z; Volume updateVolume = relativeCoords.translate(face); for (int i = updateVolume.getMinX(); i <= updateVolume.getMaxX(); i++) { for (int j = updateVolume.getMinY(); j <= updateVolume.getMaxY(); j++) { for (int k = updateVolume.getMinZ(); k <= updateVolume.getMaxZ(); k++) { x = center.getX() + i; y = center.getY() + j; z = center.getZ() + k; S23PacketBlockChange packet = new S23PacketBlockChange(x, y, z, world); FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().sendPacketToAllPlayers(packet); } } } }
Example #3
Source File: FWBlock.java From NOVA-Core with GNU Lesser General Public License v3.0 | 6 votes |
public FWBlock(BlockFactory factory) { //TODO: Hack build() method super(getMcMaterial(factory)); this.factory = factory; this.dummy = factory.build(); if (dummy.components.has(BlockProperty.BlockSound.class)) { this.stepSound = new FWBlockSound(dummy.components.get(BlockProperty.BlockSound.class)); } else { BlockProperty.BlockSound properties = dummy.components.add(new BlockProperty.BlockSound()); properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.BREAK, new Sound("", soundTypeStone.getBreakSound())); properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.PLACE, new Sound("", soundTypeStone.func_150496_b())); properties.setBlockSound(BlockProperty.BlockSound.BlockSoundTrigger.WALK, new Sound("", soundTypeStone.getStepResourcePath())); this.stepSound = soundTypeStone; } this.blockClass = dummy.getClass(); // Recalculate super constructor things after loading the block properly this.opaque = isOpaqueCube(); this.lightOpacity = isOpaqueCube() ? 255 : 0; if (FMLCommonHandler.instance().getSide().isClient()) { blockRenderingID = RenderingRegistry.getNextAvailableRenderId(); } }
Example #4
Source File: MyTown.java From MyTown2 with The Unlicense | 6 votes |
@EventHandler public void preInit(FMLPreInitializationEvent ev) { // Setup Loggers LOG = ev.getModLog(); Constants.CONFIG_FOLDER = ev.getModConfigurationDirectory().getPath() + "/MyTown/"; // Read Configs Config.instance.init(Constants.CONFIG_FOLDER + "/MyTown.cfg", Constants.MODID); LOCAL = new Local(Constants.CONFIG_FOLDER+"/localization/", Config.instance.localization.get(), "/mytown/localization/", MyTown.class); LocalManager.register(LOCAL, "mytown"); registerHandlers(); // Register ICrashCallable's FMLCommonHandler.instance().registerCrashCallable(new DatasourceCrashCallable()); }
Example #5
Source File: PacketPipeline.java From NBTEdit with GNU General Public License v3.0 | 6 votes |
@Override protected void decode(ChannelHandlerContext ctx, FMLProxyPacket msg, List<Object> out) throws Exception { ByteBuf payload = msg.payload(); byte discriminator = payload.readByte(); Class<? extends AbstractPacket> clazz = this.packets.get(discriminator); AbstractPacket pkt = clazz.newInstance(); pkt.decodeInto(ctx, payload.slice()); switch (FMLCommonHandler.instance().getEffectiveSide()) { case CLIENT: pkt.handleClientSide(this.getClientPlayer()); break; case SERVER: INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); pkt.handleServerSide(((NetHandlerPlayServer) netHandler).playerEntity); break; default: break; } out.add(pkt); }
Example #6
Source File: TranslocatorClientProxy.java From Translocators with MIT License | 6 votes |
public void init() { if(config.getTag("checkUpdates").getBooleanValue(true)) CCUpdateChecker.updateCheck("Translocator"); ClientUtils.enhanceSupportersList("Translocator"); super.init(); ClientRegistry.bindTileEntitySpecialRenderer(TileItemTranslocator.class, new TileTranslocatorRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileLiquidTranslocator.class, new TileTranslocatorRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileCraftingGrid.class, new TileCraftingGridRenderer()); PacketCustom.assignHandler(TranslocatorCPH.channel, new TranslocatorCPH()); MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(blockTranslocator), new ItemTranslocatorRenderer()); FMLCommonHandler.instance().bus().register(CraftingGridKeyHandler.instance); ClientRegistry.registerKeyBinding(CraftingGridKeyHandler.instance); }
Example #7
Source File: MCPacketHandler.java From NOVA-Core with GNU Lesser General Public License v3.0 | 6 votes |
@Override protected void channelRead0(ChannelHandlerContext ctx, PacketAbstract packet) throws Exception { INetHandler netHandler = ctx.channel().attr(NetworkRegistry.NET_HANDLER).get(); switch (FMLCommonHandler.instance().getEffectiveSide()) { case CLIENT: packet.handleClientSide(NovaMinecraft.proxy.getClientPlayer()); break; case SERVER: packet.handleServerSide(((NetHandlerPlayServer) netHandler).playerEntity); break; default: break; } }
Example #8
Source File: Thermos.java From Thermos with GNU General Public License v3.0 | 6 votes |
public static int lookupForgeRevision() { if (sForgeRevision != 0) return sForgeRevision; int revision = Integer.parseInt(System.getProperty("thermos.forgeRevision", "0")); if (revision != 0) return sForgeRevision = revision; try { Properties p = new Properties(); p.load(Thermos.class .getResourceAsStream("/fmlversion.properties")); revision = Integer.parseInt(String.valueOf(p.getProperty( "fmlbuild.build.number", "0"))); } catch (Exception e) { } if (revision == 0) { TLog.get().warning("Thermos: could not parse forge revision, critical error"); FMLCommonHandler.instance().exitJava(1, false); } return sForgeRevision = revision; }
Example #9
Source File: Chisel.java From Chisel-2 with GNU General Public License v2.0 | 6 votes |
@EventHandler public void init(FMLInitializationEvent event) { Features.init(); NetworkRegistry.INSTANCE.registerGuiHandler(this, new ChiselGuiHandler()); addWorldgen(Features.MARBLE, ChiselBlocks.marble, Configurations.marbleAmount); addWorldgen(Features.LIMESTONE, ChiselBlocks.limestone, Configurations.limestoneAmount); addWorldgen(Features.ANDESITE, ChiselBlocks.andesite, Configurations.andesiteAmount, 40, 100, 0.5); addWorldgen(Features.GRANITE, ChiselBlocks.granite, Configurations.graniteAmount, 40, 100, 0.5); addWorldgen(Features.DIORITE, ChiselBlocks.diorite, Configurations.dioriteAmount, 40, 100, 0.5); GameRegistry.registerWorldGenerator(GeneratorChisel.INSTANCE, 1000); EntityRegistry.registerModEntity(EntityChiselSnowman.class, "snowman", 0, this, 80, 1, true); proxy.init(); MinecraftForge.EVENT_BUS.register(this); FMLCommonHandler.instance().bus().register(instance); FMLInterModComms.sendMessage("Waila", "register", "com.cricketcraft.chisel.compat.WailaCompat.register"); }
Example #10
Source File: OvenGlove.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 6 votes |
@Override public String getUnlocalizedName( ItemStack stack ) { if( FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT ) { long curTime = System.currentTimeMillis(); if( curTime - prevTime > 1000L || curRand == -1) { curRand = _mRnd.nextInt( 4 ); } prevTime = curTime; return String.format( "%s_%d_%d", getUnlocalizedName(), stack.getItemDamage(), curRand ); } else { return super.getUnlocalizedName(stack); } // return this.getUnlocalizedName() + "_" + stack.getItemDamage(); }
Example #11
Source File: AdvancedMod.java From AdvancedMod with GNU General Public License v3.0 | 6 votes |
@Mod.EventHandler public void preInit(FMLPreInitializationEvent event){ ModBlocks.init(); ModTileEntities.init(); proxy.preInit(); GameRegistry.registerWorldGenerator(new WorldGeneratorFlag(), 0); NetworkHandler.init(); DescriptionHandler.init(); NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler()); MinecraftForge.EVENT_BUS.register(new AdvancedModEventHandler());//For registering events from the net.miencraftforge.event package. FMLCommonHandler.instance().bus().register(new AdvancedModEventHandler());//For registering events from the cpw.mods.fml.gameevent package. FMLInterModComms.sendMessage(Reference.MOD_ID, "camoMineBlacklist", new ItemStack(Blocks.stone)); FMLInterModComms.sendMessage("Waila", "register", "com.minemaarten.advancedmod.thirdparty.waila.Waila.onWailaCall"); Log.info("Pre Initialization Complete!"); if(Loader.isModLoaded("Thaumcraft")) { loadThaumcraft(); } }
Example #12
Source File: QuantumBread.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 6 votes |
@Override public String getUnlocalizedName(ItemStack stack) { if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) { long curTime = System.currentTimeMillis(); if (curTime - prevTime > 250L || curRand == -1) { curRand = MainRegistry.Rnd.nextInt(2); } prevTime = curTime; return String.format("%s_%d", getUnlocalizedName(), curRand); } else { return super.getUnlocalizedName(stack); } }
Example #13
Source File: CommonProxy.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
public void initalize() { NetworkRegistry.INSTANCE.registerGuiHandler(Gadomancy.instance, this); MinecraftForge.EVENT_BUS.register(EVENT_HANDLER_GOLEM); FMLCommonHandler.instance().bus().register(new EventHandlerNetwork()); EventHandlerWorld worldEventHandler = new EventHandlerWorld(); MinecraftForge.EVENT_BUS.register(worldEventHandler); FMLCommonHandler.instance().bus().register(worldEventHandler); MinecraftForge.EVENT_BUS.register(new EventHandlerEntity()); RegisteredEnchantments.init(); RegisteredRecipes.init(); SyncDataHolder.initialize(); ModSubstitutions.init(); RegisteredEntities.init(); DimensionManager.registerProviderType(ModConfig.dimOuterId, WorldProviderTCEldrich.class, true); DimensionManager.registerDimension(ModConfig.dimOuterId, ModConfig.dimOuterId); }
Example #14
Source File: TickDynamicMod.java From TickDynamic with MIT License | 6 votes |
@Subscribe public void init(FMLInitializationEvent event) { FMLCommonHandler.instance().bus().register(this); timedObjects = new HashMap<String, ITimed>(); entityGroups = new HashMap<String, EntityGroup>(); loadConfig(true); root = new TimeManager(this, null, "root", null); root.init(); root.setTimeMax(defaultTickTime * TimeManager.timeMilisecond); //Other group accounts the time used in a tick, but not for Entities or TileEntities TimedGroup otherTimed = new TimedGroup(this, null, "other", "other"); otherTimed.setSliceMax(0); //Make it get unlimited time root.addChild(otherTimed); //External group accounts the time used between ticks due to external load TimedGroup externalTimed = new TimedGroup(this, null, "external", "external"); externalTimed.setSliceMax(0); root.addChild(externalTimed); eventHandler = new WorldEventHandler(this); MinecraftForge.EVENT_BUS.register(eventHandler); FMLCommonHandler.instance().bus().register(eventHandler); }
Example #15
Source File: BlockSpikes.java From Chisel with GNU General Public License v2.0 | 5 votes |
@Override public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { if(FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) return; double dy = entity.posY - entity.prevPosY; GeneralChiselClient.speedupPlayer(world, entity, Configurations.concreteVelocity); }
Example #16
Source File: BasicSource.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
/** * Notification that the base TileEntity finished loading, for advanced uses. * Either updateEntity or onLoaded have to be used. */ public void onLoaded() { if (!addedToEnet && !FMLCommonHandler.instance().getEffectiveSide().isClient() && Info.isIc2Available()) { worldObj = parent.getWorldObj(); xCoord = parent.xCoord; yCoord = parent.yCoord; zCoord = parent.zCoord; MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); addedToEnet = true; } }
Example #17
Source File: BasicSink.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
/** * Use the specified amount of energy, if available. * * @param amount amount to use * @return true if the amount was available */ public boolean useEnergy(double amount) { if (canUseEnergy(amount) && !FMLCommonHandler.instance().getEffectiveSide().isClient()) { energyStored -= amount; return true; } return false; }
Example #18
Source File: Forbidden.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 5 votes |
@EventHandler public void crescendo(FMLInitializationEvent event) { events = new FMEventHandler(); MinecraftForge.EVENT_BUS.register(events); FMLCommonHandler.instance().bus().register(events); VillagerRegistry.instance().registerVillagerId(Config.hereticID); VillagerRegistry.instance().registerVillageTradeHandler(Config.hereticID, new VillagerHereticManager()); }
Example #19
Source File: ElectroMagicTools.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
@EventHandler public void preInit(FMLPreInitializationEvent event) { ElectroMagicTools.logger.info(localize("console.EMT.preInit.begin")); ConfigHandler.init(event.getSuggestedConfigurationFile()); FMLCommonHandler.instance().bus().register(new EventHandlerEMT()); ModuleRegistry.registerModules(); EssentiasOutputs.addPrimalOutputs(); EssentiasOutputs.addOutputs(); ElectroMagicTools.logger.info(localize("console.EMT.preInit.end")); }
Example #20
Source File: ChunkLoaderProxy.java From ChickenChunks with MIT License | 5 votes |
public void init() { blockChunkLoader = new BlockChunkLoader(); blockChunkLoader.setBlockName("chickenChunkLoader").setCreativeTab(CreativeTabs.tabMisc); GameRegistry.registerBlock(blockChunkLoader, ItemChunkLoader.class, "chickenChunkLoader"); GameRegistry.registerTileEntity(TileChunkLoader.class, "ChickenChunkLoader"); GameRegistry.registerTileEntity(TileSpotLoader.class, "ChickenSpotLoader"); PacketCustom.assignHandler(ChunkLoaderSPH.channel, new ChunkLoaderSPH()); ChunkLoaderManager.initConfig(config); MinecraftForge.EVENT_BUS.register(new ChunkLoaderEventHandler()); FMLCommonHandler.instance().bus().register(new ChunkLoaderEventHandler()); ChunkLoaderManager.registerMod(instance); GameRegistry.addRecipe(new ItemStack(blockChunkLoader, 1, 0), " p ", "ggg", "gEg", 'p', Items.ender_pearl, 'g', Items.gold_ingot, 'd', Items.diamond, 'E', Blocks.enchanting_table ); GameRegistry.addRecipe(new ItemStack(blockChunkLoader, 10, 1), "ppp", "pcp", "ppp", 'p', Items.ender_pearl, 'c', new ItemStack(blockChunkLoader, 1, 0) ); }
Example #21
Source File: BlockConcrete.java From Chisel with GNU General Public License v2.0 | 5 votes |
@Override public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { if(FMLCommonHandler.instance().getEffectiveSide() != Side.CLIENT) return; if(Configurations.concreteVelocity == 0) return; GeneralChiselClient.speedupPlayer(world, entity, Configurations.concreteVelocity); }
Example #22
Source File: BasicSink.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
/** * Notification that the base TileEntity finished loaded, for advanced uses. * Either updateEntity or onLoaded have to be used. */ public void onLoaded() { if (!addedToEnet && !FMLCommonHandler.instance().getEffectiveSide().isClient() && Info.isIc2Available()) { worldObj = parent.getWorldObj(); xCoord = parent.xCoord; yCoord = parent.yCoord; zCoord = parent.zCoord; MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); addedToEnet = true; } }
Example #23
Source File: BasicSource.java From Electro-Magic-Tools with GNU General Public License v3.0 | 5 votes |
/** * Add some energy to the output buffer. * * @param amount maximum amount of energy to add * @return amount added/used, NOT remaining */ public double addEnergy(double amount) { if (FMLCommonHandler.instance().getEffectiveSide().isClient()) return 0; if (amount > capacity - energyStored) amount = capacity - energyStored; energyStored += amount; return amount; }
Example #24
Source File: GardenTrees.java From GardenCollection with MIT License | 5 votes |
@Mod.EventHandler public void init (FMLInitializationEvent event) { proxy.registerRenderers(); integration.init(); MinecraftForge.EVENT_BUS.register(new ForgeEventHandler()); FMLCommonHandler.instance().bus().register(new ForgeEventHandler()); GameRegistry.registerFuelHandler(new FuelHandler()); if (config.generateCandelilla) GameRegistry.registerWorldGenerator(new WorldGenCandelilla(ModBlocks.candelilla), 10); }
Example #25
Source File: TileCraftingGrid.java From Translocators with MIT License | 5 votes |
private void doCraft(ItemStack mresult, InventoryCrafting craftMatrix, EntityPlayer player) { giveOrDropItem(mresult, player); FMLCommonHandler.instance().firePlayerCraftingEvent(player, mresult, craftMatrix); mresult.onCrafting(worldObj, player, mresult.stackSize); for (int slot = 0; slot < 9; ++slot) { ItemStack stack = craftMatrix.getStackInSlot(slot); if (stack == null) continue; craftMatrix.decrStackSize(slot, 1); if (stack.getItem().hasContainerItem(stack)) { ItemStack container = stack.getItem().getContainerItem(stack); if (container != null) { if (container.isItemStackDamageable() && container.getItemDamage() > container.getMaxDamage()) container = null; craftMatrix.setInventorySlotContents(slot, container); } } } for (int i = 0; i < 9; i++) items[i] = craftMatrix.getStackInSlot(i); }
Example #26
Source File: BlockConcrete.java From Chisel-2 with GNU General Public License v2.0 | 5 votes |
@Override public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { if (FMLCommonHandler.instance().getEffectiveSide() != Side.CLIENT) return; if (Configurations.concreteVelocity == 0) return; GeneralChiselClient.speedupPlayer(world, entity, Configurations.concreteVelocity); }
Example #27
Source File: CarvableHelper.java From Chisel-2 with GNU General Public License v2.0 | 5 votes |
public void addVariation(String description, int metadata, String texture, Block block, int blockMeta, String modid, ISubmapManager customManager, int order) { if (infoList.size() >= 16) return; IVariationInfo info = FMLCommonHandler.instance().getSide().isClient() ? getClientInfo(modid, texture, description, metadata, block, blockMeta, customManager, order) : getServerInfo(modid, texture, description, metadata, block, blockMeta, customManager, order); infoList.add(info); infoMap[metadata] = info; }
Example #28
Source File: Framez.java From Framez with GNU General Public License v3.0 | 5 votes |
@EventHandler public void postInit(FMLPostInitializationEvent event) { CompatibilityUtils.postInit(event); try { GuiHax.doGuiHax(); } catch (Exception e) { e.printStackTrace(); FMLCommonHandler.instance().exitJava(-1, true); } }
Example #29
Source File: ChunkLoaderManager.java From ChickenChunks with MIT License | 5 votes |
public static void initConfig(ConfigFile config) { config.getTag("players").setPosition(0).useBraces().setComment("Per player chunk limiting. Values ignored if 0.:Simply add <username>=<value>"); config.getTag("players.DEFAULT").setComment("Forge gives everyone 12500 by default").getIntValue(5000); config.getTag("players.OP").setComment("For server op's only.").getIntValue(5000); config.getTag("allowoffline").setPosition(1).useBraces().setComment("If set to false, players will have to be logged in for their chunkloaders to work.:Simply add <username>=<true|false>"); config.getTag("allowoffline.DEFAULT").getBooleanValue(true); config.getTag("allowoffline.OP").getBooleanValue(true); config.getTag("allowchunkviewer").setPosition(2).useBraces().setComment("Set to false to deny a player access to the chunk viewer"); config.getTag("allowchunkviewer.DEFAULT").getBooleanValue(true); config.getTag("allowchunkviewer.OP").getBooleanValue(true); if (!FMLCommonHandler.instance().getModName().contains("mcpc")) cleanupTicks = config.getTag("cleanuptime") .setComment("The number of ticks to wait between attempting to unload orphaned chunks") .getIntValue(1200); reloadDimensions = config.getTag("reload-dimensions") .setComment("Set to false to disable the automatic reloading of mystcraft dimensions on server restart") .getBooleanValue(true); opInteract = config.getTag("op-interact") .setComment("Enabling this lets OPs alter other player's chunkloaders. WARNING: If you change a chunkloader, you have no idea what may break/explode by not being chunkloaded.") .getBooleanValue(false); maxChunks = config.getTag("maxchunks") .setComment("The maximum number of chunks per chunkloader") .getIntValue(400); awayTimeout = config.getTag("awayTimeout") .setComment("The number of minutes since last login within which chunks from a player will remain active, 0 for infinite.") .getIntValue(0); }
Example #30
Source File: EnderStorageProxy.java From EnderStorage with MIT License | 5 votes |
public void preInit() { MinecraftForge.EVENT_BUS.register(new EnderStorageRecipe()); FMLCommonHandler.instance().bus().register(new EnderStorageSaveHandler()); MinecraftForge.EVENT_BUS.register(new EnderStorageSaveHandler()); FMLCommonHandler.instance().bus().register(new TankSynchroniser()); MinecraftForge.EVENT_BUS.register(new TankSynchroniser()); if(disableVanillaEnderChest) EnderStorageRecipe.removeVanillaChest(); }