Registered Machine command

This commit is contained in:
Robert S 2014-05-28 19:54:37 -04:00
parent a0e1f50aee
commit a88bc11666
2 changed files with 107 additions and 94 deletions

View file

@ -106,6 +106,10 @@ public class CommandMachine extends CommandBase
sender.sendChatToPlayer(ChatMessageComponent.createFromText("Failed to set energy! Maybe try a different side?")); sender.sendChatToPlayer(ChatMessageComponent.createFromText("Failed to set energy! Maybe try a different side?"));
} }
} }
else
{
sender.sendChatToPlayer(ChatMessageComponent.createFromText("Invalid input value"));
}
} }
else else
{ {

View file

@ -4,6 +4,8 @@ import java.util.HashMap;
import java.util.logging.Logger; import java.util.logging.Logger;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.command.ICommandManager;
import net.minecraft.command.ServerCommandManager;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.MinecraftForge;
@ -29,6 +31,7 @@ import resonantinduction.core.resource.ResourceGenerator;
import resonantinduction.core.resource.TileDust; import resonantinduction.core.resource.TileDust;
import resonantinduction.core.resource.fluid.ItemOreResourceBucket; import resonantinduction.core.resource.fluid.ItemOreResourceBucket;
import resonantinduction.core.resource.fluid.TileFluidMixture; import resonantinduction.core.resource.fluid.TileFluidMixture;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler; 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.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent; 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.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
/** /** The core module of Resonant Induction
* The core module of Resonant Induction *
* * @author Calclavia */
* @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") @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) @NetworkMod(channels = Reference.CHANNEL, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketHandler.class)
@ModstatInfo(prefix = "resonantin") @ModstatInfo(prefix = "resonantin")
public class ResonantInduction public class ResonantInduction
{ {
/** /** Mod Information */
* Mod Information public static final String ID = "ResonantInduction|Core";
*/ public static final String NAME = Reference.NAME;
public static final String ID = "ResonantInduction|Core"; public static final Logger LOGGER = Logger.getLogger(Reference.NAME);
public static final String NAME = Reference.NAME; /** Packets */
public static final Logger LOGGER = Logger.getLogger(Reference.NAME); public static final PacketTile PACKET_TILE = new PacketTile(Reference.CHANNEL);
/** public static final PacketMultiPart PACKET_MULTIPART = new PacketMultiPart(Reference.CHANNEL);
* Packets public static final PacketAnnotation PACKET_ANNOTATION = new PacketAnnotation(Reference.CHANNEL);
*/ public static final HashMap<Integer, BlockFluidFinite> blockMixtureFluids = new HashMap<Integer, BlockFluidFinite>();
public static final PacketTile PACKET_TILE = new PacketTile(Reference.CHANNEL); public static final HashMap<Integer, BlockFluidFinite> blockMoltenFluid = new HashMap<Integer, BlockFluidFinite>();
public static final PacketMultiPart PACKET_MULTIPART = new PacketMultiPart(Reference.CHANNEL); public static final ContentRegistry contentRegistry = new ContentRegistry(Settings.CONFIGURATION, Settings.idManager, ID).setPrefix(Reference.PREFIX).setTab(TabRI.CORE);
public static final PacketAnnotation PACKET_ANNOTATION = new PacketAnnotation(Reference.CHANNEL); @Instance(ID)
public static final HashMap<Integer, BlockFluidFinite> blockMixtureFluids = new HashMap<Integer, BlockFluidFinite>(); public static ResonantInduction INSTANCE;
public static final HashMap<Integer, BlockFluidFinite> blockMoltenFluid = new HashMap<Integer, BlockFluidFinite>(); @SidedProxy(clientSide = "resonantinduction.core.ClientProxy", serverSide = "resonantinduction.core.CommonProxy")
public static final ContentRegistry contentRegistry = new ContentRegistry(Settings.CONFIGURATION, Settings.idManager, ID).setPrefix(Reference.PREFIX).setTab(TabRI.CORE); public static CommonProxy proxy;
@Instance(ID) @Mod.Metadata(ID)
public static ResonantInduction INSTANCE; public static ModMetadata metadata;
@SidedProxy(clientSide = "resonantinduction.core.ClientProxy", serverSide = "resonantinduction.core.CommonProxy") /** Blocks and Items */
public static CommonProxy proxy; public static Block blockOre;
@Mod.Metadata(ID) public static ItemOreResource itemRubble, itemDust, itemRefinedDust;
public static ModMetadata metadata; public static ItemOreResourceBucket itemBucketMixture, itemBucketMolten;
/** public static Item itemBiomass;
* Blocks and Items public static Block blockDust, blockRefinedDust;
*/ public static Block blockMachinePart;
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 @EventHandler
public void preInit(FMLPreInitializationEvent evt) public void preInit(FMLPreInitializationEvent evt)
{ {
ResonantInduction.LOGGER.setParent(FMLLog.getLogger()); ResonantInduction.LOGGER.setParent(FMLLog.getLogger());
NetworkRegistry.instance().registerGuiHandler(this, proxy); NetworkRegistry.instance().registerGuiHandler(this, proxy);
Modstats.instance().getReporter().registerMod(this); Modstats.instance().getReporter().registerMod(this);
Settings.CONFIGURATION.load(); Settings.CONFIGURATION.load();
// Register Forge Events // Register Forge Events
MinecraftForge.EVENT_BUS.register(ResourceGenerator.INSTANCE); MinecraftForge.EVENT_BUS.register(ResourceGenerator.INSTANCE);
MinecraftForge.EVENT_BUS.register(new TextureHookHandler()); MinecraftForge.EVENT_BUS.register(new TextureHookHandler());
blockMachinePart = contentRegistry.createBlock(BlockMachineMaterial.class, ItemBlockMetadata.class); blockMachinePart = contentRegistry.createBlock(BlockMachineMaterial.class, ItemBlockMetadata.class);
/** /** Melting dusts */
* Melting dusts blockDust = contentRegistry.createBlock("dust", BlockDust.class, null, TileDust.class).setCreativeTab(null);
*/ blockRefinedDust = contentRegistry.createBlock("refinedDust", BlockDust.class, null, TileDust.class).setCreativeTab(null);
blockDust = contentRegistry.createBlock("dust", BlockDust.class, null, TileDust.class).setCreativeTab(null);
blockRefinedDust = contentRegistry.createBlock("refinedDust", BlockDust.class, null, TileDust.class).setCreativeTab(null);
// Items // Items
itemRubble = new ItemOreResource(Settings.getNextItemID("oreRubble"), "oreRubble"); itemRubble = new ItemOreResource(Settings.getNextItemID("oreRubble"), "oreRubble");
itemDust = new ItemOreResource(Settings.getNextItemID("oreDust"), "oreDust"); itemDust = new ItemOreResource(Settings.getNextItemID("oreDust"), "oreDust");
itemRefinedDust = new ItemOreResource(Settings.getNextItemID("oreRefinedDust"), "oreRefinedDust"); itemRefinedDust = new ItemOreResource(Settings.getNextItemID("oreRefinedDust"), "oreRefinedDust");
itemBucketMixture = new ItemOreResourceBucket(Settings.getNextItemID("bucketMixture"), "bucketMixture", false); itemBucketMixture = new ItemOreResourceBucket(Settings.getNextItemID("bucketMixture"), "bucketMixture", false);
itemBucketMolten = new ItemOreResourceBucket(Settings.getNextItemID("bucketMolten"), "bucketMolten", true); itemBucketMolten = new ItemOreResourceBucket(Settings.getNextItemID("bucketMolten"), "bucketMolten", true);
itemBiomass = contentRegistry.createItem(ItemBiomass.class); itemBiomass = contentRegistry.createItem(ItemBiomass.class);
GameRegistry.registerItem(itemRubble, itemRubble.getUnlocalizedName()); GameRegistry.registerItem(itemRubble, itemRubble.getUnlocalizedName());
GameRegistry.registerItem(itemDust, itemDust.getUnlocalizedName()); GameRegistry.registerItem(itemDust, itemDust.getUnlocalizedName());
GameRegistry.registerItem(itemRefinedDust, itemRefinedDust.getUnlocalizedName()); GameRegistry.registerItem(itemRefinedDust, itemRefinedDust.getUnlocalizedName());
GameRegistry.registerItem(itemBucketMixture, itemBucketMixture.getUnlocalizedName()); GameRegistry.registerItem(itemBucketMixture, itemBucketMixture.getUnlocalizedName());
GameRegistry.registerItem(itemBucketMolten, itemBucketMolten.getUnlocalizedName()); GameRegistry.registerItem(itemBucketMolten, itemBucketMolten.getUnlocalizedName());
// Already registered with ContentRegistry // Already registered with ContentRegistry
// GameRegistry.registerTileEntity(TileMaterial.class, "ri_material"); // GameRegistry.registerTileEntity(TileMaterial.class, "ri_material");
GameRegistry.registerTileEntity(TileFluidMixture.class, "ri_fluid_mixture"); GameRegistry.registerTileEntity(TileFluidMixture.class, "ri_fluid_mixture");
proxy.preInit(); proxy.preInit();
TabRI.ITEMSTACK = new ItemStack(blockMachinePart); TabRI.ITEMSTACK = new ItemStack(blockMachinePart);
} }
@EventHandler @EventHandler
public void init(FMLInitializationEvent evt) public void init(FMLInitializationEvent evt)
{ {
// Load Languages // Load Languages
ResonantInduction.LOGGER.fine("Languages Loaded:" + LanguageUtility.loadLanguages(Reference.LANGUAGE_DIRECTORY, Reference.LANGUAGES)); ResonantInduction.LOGGER.fine("Languages Loaded:" + LanguageUtility.loadLanguages(Reference.LANGUAGE_DIRECTORY, Reference.LANGUAGES));
// Set Mod Metadata // Set Mod Metadata
Settings.setModMetadata(metadata, ID, NAME); Settings.setModMetadata(metadata, ID, NAME);
proxy.init(); proxy.init();
} }
@EventHandler @EventHandler
public void postInit(FMLPostInitializationEvent evt) public void postInit(FMLPostInitializationEvent evt)
{ {
ConfigHandler.configure(Settings.CONFIGURATION, "resonantinduction"); ConfigHandler.configure(Settings.CONFIGURATION, "resonantinduction");
// Generate Resources // Generate Resources
ResourceGenerator.generateOreResources(); ResourceGenerator.generateOreResources();
proxy.postInit(); proxy.postInit();
Settings.CONFIGURATION.save(); Settings.CONFIGURATION.save();
} }
/** @EventHandler
* Recipe Types public void serverStarting(FMLServerStartingEvent event)
*/ {
public static enum RecipeType // Setup command
{ CommandMachine commandSentry = new CommandMachine();
CRUSHER, GRINDER, MIXER, SMELTER, SAWMILL; 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;
}
} }