Worked on use cmd and added a logger

This commit is contained in:
Rseifert 2013-02-07 23:43:59 -05:00
parent cb854bebda
commit 8c60099e0e
3 changed files with 77 additions and 15 deletions

View file

@ -1,6 +1,7 @@
package assemblyline.common;
import java.io.File;
import java.util.logging.Logger;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
@ -29,6 +30,7 @@ import assemblyline.common.machine.encoder.ItemDisk;
import assemblyline.common.machine.imprinter.BlockImprinter;
import assemblyline.common.machine.imprinter.ItemImprinter;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
@ -91,9 +93,13 @@ public class AssemblyLine
public static Item itemImprint;
public static Item itemDisk;
public static Logger FMLog = Logger.getLogger(AssemblyLine.NAME);
@PreInit
public void preInit(FMLPreInitializationEvent event)
{
FMLog.setParent(FMLLog.getLogger());
FMLog.info("Initializing...");
UniversalElectricity.register(this, 1, 2, 5, false);
instance = this;
@ -137,6 +143,7 @@ public class AssemblyLine
@Init
public void load(FMLInitializationEvent evt)
{
FMLog.info("Loading...");
proxy.init();
System.out.println(NAME + " Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " languages.");
@ -173,13 +180,8 @@ public class AssemblyLine
// Manipulator
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(blockManipulator, 2), new Object[] { Block.dispenser, "basicCircuit" }));
}
@ServerStarted
public void serverStarted(FMLServerStartedEvent evt)
{
// LOLOLOL i wish
// MinecraftServer.getServer().getConfigurationManager().getBannedPlayers().remove("briman0094");
FMLog.info("Ready to Use");
}
public static void printSidedData(String data)

View file

@ -0,0 +1,52 @@
package assemblyline.common;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class DebugToPlayer
{
/**
* Send a debug message to the player using world xyz
*
* @param r - range
* @param msg - display message under 200 chars
*/
public static void SendToClosest(World world, int x, int y, int z, int r, String msg)
{
EntityPlayer player = world.getClosestPlayer(x, y, z, r);
if (player != null)
{
msg = trimForDisplay(msg);
player.sendChatToPlayer("Debug: " + msg);
}
}
/**
* Sends a debug message to the player using the tileEntity as the center
*
* @param r - range
* @param msg - display message under 200 chars
*/
public static void SendToClosest(TileEntity ent, int r, String msg)
{
if (ent != null)
{
DebugToPlayer.SendToClosest(ent.worldObj, ent.xCoord, ent.yCoord, ent.zCoord, r, msg);
}
}
/**
* cleans up the display text and adds the [Debug] prefix too the text
*
* @param msg - display string under 200 chars
* @return
*/
public static String trimForDisplay(String msg)
{
// TODO trim the length to under 255 to prevent crashing
msg = msg.trim();
msg = "[Debug] " + msg;
return msg;
}
}

View file

@ -9,6 +9,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ISidedInventory;
import assemblyline.api.IArmbotUseable;
import assemblyline.common.DebugToPlayer;
public class CommandUse extends Command
{
@ -45,19 +46,26 @@ public class CommandUse extends Command
else if (targetTile instanceof ISidedInventory)
{
// TODO add IInventory side behavior for placing and taking items.
if(tileEntity.getGrabbedEntities().size() > 0)
if (tileEntity.getGrabbedEntities().size() > 0)
{
//add items to inv
}else
// add items to inv
}
else
{
//remove items from inv
// remove items from inv
}
}
else if (block == Block.lever)
{
block.onBlockActivated(this.world, tileEntity.getHandPosition().intX(), tileEntity.getHandPosition().intY(), tileEntity.getHandPosition().intZ(), null, 0, 0, 0, 0);
}
}
else
{
try{
boolean f = block.onBlockActivated(this.world, tileEntity.getHandPosition().intX(), tileEntity.getHandPosition().intY(), tileEntity.getHandPosition().intZ(), null, 0, 0, 0, 0);
}catch(Exception e)
{
e.printStackTrace();
}
}