v4.2.2 Beta #4
*Upgraded versioning. *Added MachineryManager to open up future opportunities. *Bumped version to 4.2.2, I forgot to on last commit.
This commit is contained in:
parent
cd6f1a4cae
commit
25a47a34c1
3 changed files with 104 additions and 10 deletions
85
src/common/net/uberkat/obsidian/common/MachineryManager.java
Normal file
85
src/common/net/uberkat/obsidian/common/MachineryManager.java
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
package net.uberkat.obsidian.common;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.src.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A simple way of managing all machines -- MachineryManager! Contains an ArrayList of
|
||||||
|
* basic machines that all machines are added to on placement.
|
||||||
|
* @author AidanBrady
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class MachineryManager
|
||||||
|
{
|
||||||
|
/** The list of machines used */
|
||||||
|
public List<TileEntityBasicMachine> machines = new ArrayList<TileEntityBasicMachine>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MachineryManager -- the easiest way of managing machines.
|
||||||
|
*/
|
||||||
|
public MachineryManager()
|
||||||
|
{
|
||||||
|
reset();
|
||||||
|
System.out.println("[ObsidianIngots] Successfully initialized Machinery Manager.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a machine with the manager.
|
||||||
|
* @param machine - to be added
|
||||||
|
*/
|
||||||
|
public void register(TileEntityBasicMachine machine)
|
||||||
|
{
|
||||||
|
if(!machines.contains(machine))
|
||||||
|
{
|
||||||
|
machines.add(machine);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("[ObsidianIngots] Attempted to add machine to manager that already exists.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove a machine from the manager.
|
||||||
|
* @param machine - to be removed
|
||||||
|
*/
|
||||||
|
public void remove(TileEntityBasicMachine machine)
|
||||||
|
{
|
||||||
|
if(machines.contains(machine))
|
||||||
|
{
|
||||||
|
machines.remove(machine);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("[ObsidianIngots] Attempted to remove machine from manager that doesn't exist.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Grabs a machine from the manager.
|
||||||
|
* @param world - to be grabbed
|
||||||
|
* @param x - block coord
|
||||||
|
* @param y - block coord
|
||||||
|
* @param z - block coord
|
||||||
|
* @return machine grabbed from the manager
|
||||||
|
*/
|
||||||
|
public TileEntityBasicMachine getMachine(World world, int x, int y, int z)
|
||||||
|
{
|
||||||
|
if(machines.contains((TileEntityBasicMachine)world.getBlockTileEntity(x, y, z)))
|
||||||
|
{
|
||||||
|
return (TileEntityBasicMachine)world.getBlockTileEntity(x, y, z);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
System.out.println("[ObsidianIngots] Attempted to grab machine from manager that doesn't exist.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the manager -- removing all machines from the ArrayList
|
||||||
|
*/
|
||||||
|
public void reset()
|
||||||
|
{
|
||||||
|
machines.clear();
|
||||||
|
}
|
||||||
|
}
|
|
@ -60,7 +60,7 @@ public class ObsidianIngots
|
||||||
public static Configuration configuration;
|
public static Configuration configuration;
|
||||||
|
|
||||||
/** Obsidian Ingots version number */
|
/** Obsidian Ingots version number */
|
||||||
public static Version versionNumber = new Version(4, 2, 1);
|
public static Version versionNumber = new Version(4, 2, 2);
|
||||||
|
|
||||||
/** The latest version number which is received from the Obsidian Ingots server */
|
/** The latest version number which is received from the Obsidian Ingots server */
|
||||||
public static String latestVersionNumber;
|
public static String latestVersionNumber;
|
||||||
|
@ -68,6 +68,9 @@ public class ObsidianIngots
|
||||||
/** The recent news which is received from the Obsidian Ingots server */
|
/** The recent news which is received from the Obsidian Ingots server */
|
||||||
public static String recentNews;
|
public static String recentNews;
|
||||||
|
|
||||||
|
/** The main MachineryManager instance that is used by all machines */
|
||||||
|
public static MachineryManager manager;
|
||||||
|
|
||||||
/** The IP used to connect to the Obsidian Ingots server */
|
/** The IP used to connect to the Obsidian Ingots server */
|
||||||
public static String hostIP = "71.56.58.57";
|
public static String hostIP = "71.56.58.57";
|
||||||
|
|
||||||
|
@ -982,6 +985,8 @@ public class ObsidianIngots
|
||||||
NetworkRegistry.instance().registerGuiHandler(this, new CommonGuiHandler());
|
NetworkRegistry.instance().registerGuiHandler(this, new CommonGuiHandler());
|
||||||
//Set the mod's instance
|
//Set the mod's instance
|
||||||
instance = this;
|
instance = this;
|
||||||
|
//Register the MachineryManager
|
||||||
|
manager = new MachineryManager();
|
||||||
System.out.println("[ObsidianIngots] Version " + versionNumber + " initializing...");
|
System.out.println("[ObsidianIngots] Version " + versionNumber + " initializing...");
|
||||||
new ThreadGetData();
|
new ThreadGetData();
|
||||||
proxy.registerRenderInformation();
|
proxy.registerRenderInformation();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package net.uberkat.obsidian.common;
|
package net.uberkat.obsidian.common;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Version v1.0.2. Simple version handling for Obsidian Ingots.
|
* Version v1.0.3. Simple version handling for Obsidian Ingots.
|
||||||
* @author AidanBrady
|
* @author AidanBrady
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -27,6 +27,18 @@ public class Version
|
||||||
build = buildNum;
|
build = buildNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a version number with 3 digits from a string, by splitting with the char '.'
|
||||||
|
* @param version - version number as a String
|
||||||
|
*/
|
||||||
|
public Version(String version)
|
||||||
|
{
|
||||||
|
String[] numbers = version.split(".");
|
||||||
|
major = Integer.getInteger(numbers[0]);
|
||||||
|
minor = Integer.getInteger(numbers[1]);
|
||||||
|
build = Integer.getInteger(numbers[2]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the version number to "0.0.0."
|
* Resets the version number to "0.0.0."
|
||||||
*/
|
*/
|
||||||
|
@ -43,14 +55,6 @@ public class Version
|
||||||
{
|
{
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
else if(major != 0 && minor != 0 && build == 0)
|
|
||||||
{
|
|
||||||
return major + "." + minor;
|
|
||||||
}
|
|
||||||
else if(major != 0 && minor == 0 && build == 0)
|
|
||||||
{
|
|
||||||
return major + "." + minor;
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
return major + "." + minor + "." + build;
|
return major + "." + minor + "." + build;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue