Merge branch 'rv1' of https://bitbucket.org/AlgorithmX2/appliedenergistics2 into rv1
This commit is contained in:
commit
8c87402134
11 changed files with 242 additions and 1 deletions
|
@ -19,6 +19,7 @@ import appeng.core.sync.network.NetworkHandler;
|
|||
import appeng.hooks.TickHandler;
|
||||
import appeng.integration.IntegrationRegistry;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.server.AECommand;
|
||||
import appeng.services.VersionChecker;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
@ -34,6 +35,7 @@ import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage;
|
|||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
|
||||
|
@ -200,4 +202,10 @@ public class AppEng
|
|||
WorldSettings.getInstance().init();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void serverStarting(FMLServerStartingEvent evt)
|
||||
{
|
||||
evt.registerServerCommand( new AECommand( evt.getServer() ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
9
core/AppEng.java.rej
Normal file
9
core/AppEng.java.rej
Normal file
|
@ -0,0 +1,9 @@
|
|||
diff a/core/AppEng.java b/core/AppEng.java (rejected hunks)
|
||||
@@ -34,7 +34,6 @@
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerAboutToStartEvent;
|
||||
-import cpw.mods.fml.common.event.FMLServerStartingEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
|
92
server/AECommand.java
Normal file
92
server/AECommand.java
Normal file
|
@ -0,0 +1,92 @@
|
|||
package appeng.server;
|
||||
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.command.WrongUsageException;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
public class AECommand extends CommandBase
|
||||
{
|
||||
|
||||
final MinecraftServer srv;
|
||||
|
||||
public AECommand(MinecraftServer server) {
|
||||
srv = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName()
|
||||
{
|
||||
return "ae2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandUsage(ICommandSender icommandsender)
|
||||
{
|
||||
return "commands.ae2.usage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredPermissionLevel()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processCommand(ICommandSender sender, String[] args)
|
||||
{
|
||||
if ( args.length == 0 )
|
||||
{
|
||||
throw new WrongUsageException( "commands.ae2.usage" );
|
||||
}
|
||||
else if ( "help".equals( args[0] ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( args.length > 1 )
|
||||
{
|
||||
Commands c = Commands.valueOf( args[1] );
|
||||
throw new WrongUsageException( c.command.getHelp( srv ) );
|
||||
}
|
||||
}
|
||||
catch (Throwable er)
|
||||
{
|
||||
if ( er instanceof WrongUsageException )
|
||||
throw (WrongUsageException) er;
|
||||
throw new WrongUsageException( "commands.ae2.usage" );
|
||||
}
|
||||
}
|
||||
else if ( "list".equals( args[0] ) )
|
||||
{
|
||||
throw new WrongUsageException( Joiner.on( ", " ).join( Commands.values() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
Commands c = Commands.valueOf( args[0] );
|
||||
if ( sender.canCommandSenderUseCommand( c.level, getCommandName() ) )
|
||||
c.command.call( srv, args, sender );
|
||||
else
|
||||
throw new WrongUsageException( "commands.ae2.permissions" );
|
||||
}
|
||||
catch (Throwable er)
|
||||
{
|
||||
if ( er instanceof WrongUsageException )
|
||||
throw (WrongUsageException) er;
|
||||
throw new WrongUsageException( "commands.ae2.usage" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* wtf?
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(Object arg0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
24
server/Commands.java
Normal file
24
server/Commands.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
package appeng.server;
|
||||
|
||||
import appeng.server.subcommands.ChunkLogger;
|
||||
import appeng.server.subcommands.Supporters;
|
||||
|
||||
public enum Commands
|
||||
{
|
||||
chunklogger(4, new ChunkLogger()), supporters(0, new Supporters());
|
||||
|
||||
public final int level;
|
||||
public final ISubCommand command;
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return name();
|
||||
}
|
||||
|
||||
private Commands(int level, ISubCommand w) {
|
||||
this.level = level;
|
||||
command = w;
|
||||
}
|
||||
|
||||
}
|
13
server/ISubCommand.java
Normal file
13
server/ISubCommand.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
package appeng.server;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
public interface ISubCommand
|
||||
{
|
||||
|
||||
String getHelp(MinecraftServer srv);
|
||||
|
||||
void call(MinecraftServer srv, String[] args, ICommandSender sender);
|
||||
|
||||
}
|
58
server/subcommands/ChunkLogger.java
Normal file
58
server/subcommands/ChunkLogger.java
Normal file
|
@ -0,0 +1,58 @@
|
|||
package appeng.server.subcommands;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentTranslation;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.event.world.ChunkEvent;
|
||||
import appeng.core.AELog;
|
||||
import appeng.server.ISubCommand;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class ChunkLogger implements ISubCommand
|
||||
{
|
||||
|
||||
boolean enabled = false;
|
||||
|
||||
@SubscribeEvent
|
||||
public void ChunkLoad(ChunkEvent.Load load)
|
||||
{
|
||||
if ( !load.world.isRemote )
|
||||
{
|
||||
AELog.info( "Chunk Loaded: " + load.getChunk().xPosition + ", " + load.getChunk().zPosition );
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void ChunkLoad(ChunkEvent.Unload unload)
|
||||
{
|
||||
if ( !unload.world.isRemote )
|
||||
{
|
||||
AELog.info( "Chunk Unloaded: " + unload.getChunk().xPosition + ", " + unload.getChunk().zPosition );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void call(MinecraftServer srv, String[] data, ICommandSender sender)
|
||||
{
|
||||
enabled = !enabled;
|
||||
|
||||
if ( enabled )
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.register( this );
|
||||
sender.addChatMessage( new ChatComponentTranslation( "commands.ae2.ChunkLoggerOn" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.unregister( this );
|
||||
sender.addChatMessage( new ChatComponentTranslation( "commands.ae2.ChunkLoggerOff" ) );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(MinecraftServer srv)
|
||||
{
|
||||
return "commands.ae2.ChunkLogger";
|
||||
}
|
||||
|
||||
}
|
26
server/subcommands/Supporters.java
Normal file
26
server/subcommands/Supporters.java
Normal file
|
@ -0,0 +1,26 @@
|
|||
package appeng.server.subcommands;
|
||||
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import appeng.server.ISubCommand;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
public class Supporters implements ISubCommand
|
||||
{
|
||||
|
||||
@Override
|
||||
public void call(MinecraftServer srv, String[] data, ICommandSender sender)
|
||||
{
|
||||
String[] who = { "Stig Halvorsen", "Josh Ricker", "Jenny \"Othlon\" Sutherland", "Hristo Bogdanov", "BevoLJ" };
|
||||
sender.addChatMessage( new ChatComponentText( "Special thanks to " + Joiner.on( ", " ).join( who ) ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp(MinecraftServer srv)
|
||||
{
|
||||
return "commands.ae2.Supporters";
|
||||
}
|
||||
|
||||
}
|
|
@ -48,6 +48,11 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile,
|
|||
public int renderFragment = 0;
|
||||
public String customName;
|
||||
|
||||
public boolean notLoaded()
|
||||
{
|
||||
return !worldObj.blockExists( xCoord, yCoord, zCoord );
|
||||
}
|
||||
|
||||
public TileEntity getTile()
|
||||
{
|
||||
return this;
|
||||
|
|
|
@ -37,7 +37,7 @@ public class TileCraftingStorageTile extends TileCraftingTile
|
|||
|
||||
public int getStorageBytes()
|
||||
{
|
||||
if ( worldObj == null )
|
||||
if ( worldObj == null || notLoaded() )
|
||||
return 0;
|
||||
|
||||
switch (worldObj.getBlockMetadata( xCoord, yCoord, zCoord ) & 3)
|
||||
|
|
|
@ -154,6 +154,9 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
|
|||
|
||||
public void updateMeta(boolean updateFormed)
|
||||
{
|
||||
if ( worldObj == null || notLoaded() )
|
||||
return;
|
||||
|
||||
boolean formed = isFormed();
|
||||
boolean power = false;
|
||||
|
||||
|
|
|
@ -31,6 +31,9 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
|
|||
|
||||
private void changePowerLevel()
|
||||
{
|
||||
if ( notLoaded() )
|
||||
return;
|
||||
|
||||
byte leel = (byte) (8.0 * (internalCurrentPower / internalMaxPower));
|
||||
|
||||
if ( leel > 7 )
|
||||
|
|
Loading…
Reference in a new issue