From a88bc11666339e9c055c23160af6f55c8c296146 Mon Sep 17 00:00:00 2001 From: Robert S Date: Wed, 28 May 2014 19:54:37 -0400 Subject: [PATCH] Registered Machine command --- .../core/CommandMachine.java | 4 + .../core/ResonantInduction.java | 197 +++++++++--------- 2 files changed, 107 insertions(+), 94 deletions(-) diff --git a/src/main/scala/resonantinduction/core/CommandMachine.java b/src/main/scala/resonantinduction/core/CommandMachine.java index cf2e8263a..72875a7c5 100644 --- a/src/main/scala/resonantinduction/core/CommandMachine.java +++ b/src/main/scala/resonantinduction/core/CommandMachine.java @@ -106,6 +106,10 @@ public class CommandMachine extends CommandBase sender.sendChatToPlayer(ChatMessageComponent.createFromText("Failed to set energy! Maybe try a different side?")); } } + else + { + sender.sendChatToPlayer(ChatMessageComponent.createFromText("Invalid input value")); + } } else { diff --git a/src/main/scala/resonantinduction/core/ResonantInduction.java b/src/main/scala/resonantinduction/core/ResonantInduction.java index 926d14459..9954d3745 100644 --- a/src/main/scala/resonantinduction/core/ResonantInduction.java +++ b/src/main/scala/resonantinduction/core/ResonantInduction.java @@ -4,6 +4,8 @@ import java.util.HashMap; import java.util.logging.Logger; import net.minecraft.block.Block; +import net.minecraft.command.ICommandManager; +import net.minecraft.command.ServerCommandManager; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; @@ -29,6 +31,7 @@ import resonantinduction.core.resource.ResourceGenerator; import resonantinduction.core.resource.TileDust; import resonantinduction.core.resource.fluid.ItemOreResourceBucket; import resonantinduction.core.resource.fluid.TileFluidMixture; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; @@ -38,119 +41,125 @@ import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.registry.GameRegistry; -/** - * The core module of Resonant Induction - * - * @author Calclavia - */ +/** The core module of Resonant Induction + * + * @author Calclavia */ @Mod(modid = ResonantInduction.ID, name = ResonantInduction.NAME, version = Reference.VERSION, dependencies = "required-after:ForgeMultipart@[1.0.0.244,);required-after:ResonantEngine;before:ThermalExpansion;before:Mekanism") @NetworkMod(channels = Reference.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class) @ModstatInfo(prefix = "resonantin") public class ResonantInduction { - /** - * Mod Information - */ - public static final String ID = "ResonantInduction|Core"; - public static final String NAME = Reference.NAME; - public static final Logger LOGGER = Logger.getLogger(Reference.NAME); - /** - * Packets - */ - public static final PacketTile PACKET_TILE = new PacketTile(Reference.CHANNEL); - public static final PacketMultiPart PACKET_MULTIPART = new PacketMultiPart(Reference.CHANNEL); - public static final PacketAnnotation PACKET_ANNOTATION = new PacketAnnotation(Reference.CHANNEL); - public static final HashMap blockMixtureFluids = new HashMap(); - public static final HashMap blockMoltenFluid = new HashMap(); - public static final ContentRegistry contentRegistry = new ContentRegistry(Settings.CONFIGURATION, Settings.idManager, ID).setPrefix(Reference.PREFIX).setTab(TabRI.CORE); - @Instance(ID) - public static ResonantInduction INSTANCE; - @SidedProxy(clientSide = "resonantinduction.core.ClientProxy", serverSide = "resonantinduction.core.CommonProxy") - public static CommonProxy proxy; - @Mod.Metadata(ID) - public static ModMetadata metadata; - /** - * Blocks and Items - */ - public static Block blockOre; - public static ItemOreResource itemRubble, itemDust, itemRefinedDust; - public static ItemOreResourceBucket itemBucketMixture, itemBucketMolten; - public static Item itemBiomass; - public static Block blockDust, blockRefinedDust; - public static Block blockMachinePart; + /** Mod Information */ + public static final String ID = "ResonantInduction|Core"; + public static final String NAME = Reference.NAME; + public static final Logger LOGGER = Logger.getLogger(Reference.NAME); + /** Packets */ + public static final PacketTile PACKET_TILE = new PacketTile(Reference.CHANNEL); + public static final PacketMultiPart PACKET_MULTIPART = new PacketMultiPart(Reference.CHANNEL); + public static final PacketAnnotation PACKET_ANNOTATION = new PacketAnnotation(Reference.CHANNEL); + public static final HashMap blockMixtureFluids = new HashMap(); + public static final HashMap blockMoltenFluid = new HashMap(); + public static final ContentRegistry contentRegistry = new ContentRegistry(Settings.CONFIGURATION, Settings.idManager, ID).setPrefix(Reference.PREFIX).setTab(TabRI.CORE); + @Instance(ID) + public static ResonantInduction INSTANCE; + @SidedProxy(clientSide = "resonantinduction.core.ClientProxy", serverSide = "resonantinduction.core.CommonProxy") + public static CommonProxy proxy; + @Mod.Metadata(ID) + public static ModMetadata metadata; + /** Blocks and Items */ + public static Block blockOre; + public static ItemOreResource itemRubble, itemDust, itemRefinedDust; + public static ItemOreResourceBucket itemBucketMixture, itemBucketMolten; + public static Item itemBiomass; + public static Block blockDust, blockRefinedDust; + public static Block blockMachinePart; - @EventHandler - public void preInit(FMLPreInitializationEvent evt) - { - ResonantInduction.LOGGER.setParent(FMLLog.getLogger()); - NetworkRegistry.instance().registerGuiHandler(this, proxy); - Modstats.instance().getReporter().registerMod(this); - Settings.CONFIGURATION.load(); - // Register Forge Events - MinecraftForge.EVENT_BUS.register(ResourceGenerator.INSTANCE); - MinecraftForge.EVENT_BUS.register(new TextureHookHandler()); + @EventHandler + public void preInit(FMLPreInitializationEvent evt) + { + ResonantInduction.LOGGER.setParent(FMLLog.getLogger()); + NetworkRegistry.instance().registerGuiHandler(this, proxy); + Modstats.instance().getReporter().registerMod(this); + Settings.CONFIGURATION.load(); + // Register Forge Events + MinecraftForge.EVENT_BUS.register(ResourceGenerator.INSTANCE); + MinecraftForge.EVENT_BUS.register(new TextureHookHandler()); - blockMachinePart = contentRegistry.createBlock(BlockMachineMaterial.class, ItemBlockMetadata.class); + blockMachinePart = contentRegistry.createBlock(BlockMachineMaterial.class, ItemBlockMetadata.class); - /** - * Melting dusts - */ - blockDust = contentRegistry.createBlock("dust", BlockDust.class, null, TileDust.class).setCreativeTab(null); - blockRefinedDust = contentRegistry.createBlock("refinedDust", BlockDust.class, null, TileDust.class).setCreativeTab(null); + /** Melting dusts */ + blockDust = contentRegistry.createBlock("dust", BlockDust.class, null, TileDust.class).setCreativeTab(null); + blockRefinedDust = contentRegistry.createBlock("refinedDust", BlockDust.class, null, TileDust.class).setCreativeTab(null); - // Items - itemRubble = new ItemOreResource(Settings.getNextItemID("oreRubble"), "oreRubble"); - itemDust = new ItemOreResource(Settings.getNextItemID("oreDust"), "oreDust"); - itemRefinedDust = new ItemOreResource(Settings.getNextItemID("oreRefinedDust"), "oreRefinedDust"); - itemBucketMixture = new ItemOreResourceBucket(Settings.getNextItemID("bucketMixture"), "bucketMixture", false); - itemBucketMolten = new ItemOreResourceBucket(Settings.getNextItemID("bucketMolten"), "bucketMolten", true); - itemBiomass = contentRegistry.createItem(ItemBiomass.class); + // Items + itemRubble = new ItemOreResource(Settings.getNextItemID("oreRubble"), "oreRubble"); + itemDust = new ItemOreResource(Settings.getNextItemID("oreDust"), "oreDust"); + itemRefinedDust = new ItemOreResource(Settings.getNextItemID("oreRefinedDust"), "oreRefinedDust"); + itemBucketMixture = new ItemOreResourceBucket(Settings.getNextItemID("bucketMixture"), "bucketMixture", false); + itemBucketMolten = new ItemOreResourceBucket(Settings.getNextItemID("bucketMolten"), "bucketMolten", true); + itemBiomass = contentRegistry.createItem(ItemBiomass.class); - GameRegistry.registerItem(itemRubble, itemRubble.getUnlocalizedName()); - GameRegistry.registerItem(itemDust, itemDust.getUnlocalizedName()); - GameRegistry.registerItem(itemRefinedDust, itemRefinedDust.getUnlocalizedName()); - GameRegistry.registerItem(itemBucketMixture, itemBucketMixture.getUnlocalizedName()); - GameRegistry.registerItem(itemBucketMolten, itemBucketMolten.getUnlocalizedName()); + GameRegistry.registerItem(itemRubble, itemRubble.getUnlocalizedName()); + GameRegistry.registerItem(itemDust, itemDust.getUnlocalizedName()); + GameRegistry.registerItem(itemRefinedDust, itemRefinedDust.getUnlocalizedName()); + GameRegistry.registerItem(itemBucketMixture, itemBucketMixture.getUnlocalizedName()); + GameRegistry.registerItem(itemBucketMolten, itemBucketMolten.getUnlocalizedName()); - // Already registered with ContentRegistry - // GameRegistry.registerTileEntity(TileMaterial.class, "ri_material"); - GameRegistry.registerTileEntity(TileFluidMixture.class, "ri_fluid_mixture"); + // Already registered with ContentRegistry + // GameRegistry.registerTileEntity(TileMaterial.class, "ri_material"); + GameRegistry.registerTileEntity(TileFluidMixture.class, "ri_fluid_mixture"); - proxy.preInit(); - TabRI.ITEMSTACK = new ItemStack(blockMachinePart); - } + proxy.preInit(); + TabRI.ITEMSTACK = new ItemStack(blockMachinePart); + } - @EventHandler - public void init(FMLInitializationEvent evt) - { - // Load Languages - ResonantInduction.LOGGER.fine("Languages Loaded:" + LanguageUtility.loadLanguages(Reference.LANGUAGE_DIRECTORY, Reference.LANGUAGES)); - // Set Mod Metadata - Settings.setModMetadata(metadata, ID, NAME); - proxy.init(); - } + @EventHandler + public void init(FMLInitializationEvent evt) + { + // Load Languages + ResonantInduction.LOGGER.fine("Languages Loaded:" + LanguageUtility.loadLanguages(Reference.LANGUAGE_DIRECTORY, Reference.LANGUAGES)); + // Set Mod Metadata + Settings.setModMetadata(metadata, ID, NAME); + proxy.init(); + } - @EventHandler - public void postInit(FMLPostInitializationEvent evt) - { - ConfigHandler.configure(Settings.CONFIGURATION, "resonantinduction"); + @EventHandler + public void postInit(FMLPostInitializationEvent evt) + { + ConfigHandler.configure(Settings.CONFIGURATION, "resonantinduction"); - // Generate Resources - ResourceGenerator.generateOreResources(); - proxy.postInit(); - Settings.CONFIGURATION.save(); - } + // Generate Resources + ResourceGenerator.generateOreResources(); + proxy.postInit(); + Settings.CONFIGURATION.save(); + } - /** - * Recipe Types - */ - public static enum RecipeType - { - CRUSHER, GRINDER, MIXER, SMELTER, SAWMILL; - } + @EventHandler + public void serverStarting(FMLServerStartingEvent event) + { + // Setup command + CommandMachine commandSentry = new CommandMachine(); + MinecraftForge.EVENT_BUS.register(commandSentry); + + ICommandManager commandManager = FMLCommonHandler.instance().getMinecraftServerInstance().getCommandManager(); + ServerCommandManager serverCommandManager = ((ServerCommandManager) commandManager); + serverCommandManager.registerCommand(commandSentry); + + } + + /** Recipe Types */ + public static enum RecipeType + { + CRUSHER, + GRINDER, + MIXER, + SMELTER, + SAWMILL; + } }