Created debug blocks
Not tested nor really done yet. The idea in creating these is to provide a sure way to test basic functions of machines. Since these debug block are very simple no real issue should arise of the block failing.
This commit is contained in:
parent
3f3c6f3679
commit
866c254aa7
12 changed files with 261 additions and 10 deletions
58
src/dark/common/debug/BlockDebug.java
Normal file
58
src/dark/common/debug/BlockDebug.java
Normal file
|
@ -0,0 +1,58 @@
|
|||
package dark.common.debug;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import dark.core.DarkMain;
|
||||
import dark.core.blocks.BlockMachine;
|
||||
|
||||
public class BlockDebug extends BlockMachine
|
||||
{
|
||||
enum debugBlocks
|
||||
{
|
||||
INF_POWER("infPower", TileEntityInfSupply.class),
|
||||
INF_FLUID("infFluid", TileEntityInfFluid.class),
|
||||
VOID("void", TileEntityVoid.class),
|
||||
INF_LOAD("infLoad", TileEntityInfLoad.class);
|
||||
|
||||
String name;
|
||||
Class<? extends TileEntity> clazz;
|
||||
|
||||
private debugBlocks(String name, Class<? extends TileEntity> clazz)
|
||||
{
|
||||
this.name = name;
|
||||
this.clazz = clazz;
|
||||
}
|
||||
}
|
||||
|
||||
public BlockDebug(int blockID, Configuration config)
|
||||
{
|
||||
super("DebugBlock", config, blockID, Material.clay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, int metadata)
|
||||
{
|
||||
if (metadata < debugBlocks.values().length)
|
||||
{
|
||||
try
|
||||
{
|
||||
return debugBlocks.values()[metadata].clazz.newInstance();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return super.createTileEntity(world, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World world)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
8
src/dark/common/debug/TileEntityInfFluid.java
Normal file
8
src/dark/common/debug/TileEntityInfFluid.java
Normal file
|
@ -0,0 +1,8 @@
|
|||
package dark.common.debug;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
public class TileEntityInfFluid extends TileEntity
|
||||
{
|
||||
|
||||
}
|
50
src/dark/common/debug/TileEntityInfLoad.java
Normal file
50
src/dark/common/debug/TileEntityInfLoad.java
Normal file
|
@ -0,0 +1,50 @@
|
|||
package dark.common.debug;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.block.IElectrical;
|
||||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
|
||||
public class TileEntityInfLoad extends TileEntity implements IElectrical
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
//TODO add wrench settings to close sides for testing
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float receiveElectricity(ForgeDirection from, ElectricityPack receive, boolean doReceive)
|
||||
{
|
||||
return this.canConnect(from) && receive != null ? receive.getWatts() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectricityPack provideElectricity(ForgeDirection from, ElectricityPack request, boolean doProvide)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRequest(ForgeDirection direction)
|
||||
{
|
||||
//TODO add config options to change this for testing
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProvide(ForgeDirection direction)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVoltage()
|
||||
{
|
||||
return 10000;
|
||||
}
|
||||
|
||||
}
|
60
src/dark/common/debug/TileEntityInfSupply.java
Normal file
60
src/dark/common/debug/TileEntityInfSupply.java
Normal file
|
@ -0,0 +1,60 @@
|
|||
package dark.common.debug;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.compatibility.TileEntityUniversalElectrical;
|
||||
import universalelectricity.core.block.IElectrical;
|
||||
import universalelectricity.core.electricity.ElectricityPack;
|
||||
|
||||
public class TileEntityInfSupply extends TileEntityUniversalElectrical implements IElectrical
|
||||
{
|
||||
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
super.updateEntity();
|
||||
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
this.produce();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection direction)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElectricityPack provideElectricity(ForgeDirection from, ElectricityPack request, boolean doProvide)
|
||||
{
|
||||
return this.canConnect(from) ? request : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getProvide(ForgeDirection direction)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVoltage()
|
||||
{
|
||||
return 120;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getMaxEnergyStored()
|
||||
{
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRequest(ForgeDirection direction)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
59
src/dark/common/debug/TileEntityVoid.java
Normal file
59
src/dark/common/debug/TileEntityVoid.java
Normal file
|
@ -0,0 +1,59 @@
|
|||
package dark.common.debug;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTank;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
/** Designed to debug fluid devices by draining everything that comes in at one time
|
||||
*
|
||||
* @author DarkGuardsman */
|
||||
public class TileEntityVoid extends TileEntity implements IFluidHandler
|
||||
{
|
||||
FluidTank tank = new FluidTank(1000000);
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
//TODO add wrench toggle options to change amount actually drained
|
||||
return resource != null && this.canDrain(from, resource.getFluid()) ? resource.amount : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
//TODO add wrench settings to close off sides for testing
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
{
|
||||
return new FluidTankInfo[] { this.tank.getInfo() };
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package dark.transmit.laser;
|
||||
package dark.common.transmit;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import universalelectricity.prefab.block.BlockAdvanced;
|
|
@ -1,4 +1,4 @@
|
|||
package dark.transmit.laser;
|
||||
package dark.common.transmit;
|
||||
|
||||
import net.minecraft.item.ItemBlock;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package dark.transmit.laser;
|
||||
package dark.common.transmit;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import dark.core.DarkMain;
|
|
@ -12,7 +12,7 @@ public class CoreRecipeLoader extends RecipeLoader
|
|||
{
|
||||
|
||||
/* BLOCKS */
|
||||
public static Block blockOre;
|
||||
public static Block blockOre, blockDebug;
|
||||
|
||||
/* ITEMS */
|
||||
public static Item itemMetals;
|
||||
|
|
|
@ -23,12 +23,14 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
|||
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import dark.common.debug.BlockDebug;
|
||||
import dark.core.blocks.BlockMulti;
|
||||
import dark.core.blocks.BlockOre;
|
||||
import dark.core.blocks.TileEntityMulti;
|
||||
import dark.core.helpers.FluidRestrictionHandler;
|
||||
import dark.core.items.EnumMeterials;
|
||||
import dark.core.items.ItemBattery;
|
||||
import dark.core.items.ItemBlockHolder;
|
||||
import dark.core.items.ItemOre;
|
||||
import dark.core.items.ItemOreDirv;
|
||||
import dark.core.items.ItemWrench;
|
||||
|
@ -98,7 +100,14 @@ public class DarkMain extends ModPrefab
|
|||
{
|
||||
super.init(event);
|
||||
|
||||
if (CoreRecipeLoader.blockOre != null)
|
||||
{
|
||||
GameRegistry.registerBlock(CoreRecipeLoader.blockOre, ItemOre.class, "DMOre");
|
||||
}
|
||||
if (CoreRecipeLoader.blockDebug != null)
|
||||
{
|
||||
GameRegistry.registerBlock(CoreRecipeLoader.blockDebug, ItemBlockHolder.class, "DMOre");
|
||||
}
|
||||
GameRegistry.registerBlock(blockMulti, "multiBlock");
|
||||
|
||||
GameRegistry.registerTileEntity(TileEntityMulti.class, "ALMulti");
|
||||
|
@ -154,11 +163,16 @@ public class DarkMain extends ModPrefab
|
|||
{
|
||||
CoreRecipeLoader.blockOre = new BlockOre(getNextID(), CONFIGURATION);
|
||||
}
|
||||
if (CONFIGURATION.get("general", "enableDebugBlocks", false).getBoolean(false))
|
||||
{
|
||||
CoreRecipeLoader.blockDebug = new BlockDebug(getNextID(), CONFIGURATION);
|
||||
}
|
||||
/* ITEMS */
|
||||
if (CONFIGURATION.get("general", "LoadOreItems", true).getBoolean(true))
|
||||
{
|
||||
CoreRecipeLoader.itemMetals = new ItemOreDirv(ITEM_ID_PREFIX++, CONFIGURATION);
|
||||
}
|
||||
|
||||
CONFIGURATION.save();
|
||||
/* CONFIG END */
|
||||
|
||||
|
|
|
@ -22,13 +22,13 @@ import dark.core.DarkMain;
|
|||
* each mod using this create there own basic block extending this to reduce need to input config
|
||||
* file each time
|
||||
*
|
||||
* @author Rseifert */
|
||||
* @author Darkguardsman */
|
||||
public abstract class BlockMachine extends BlockAdvanced implements ITileEntityProvider
|
||||
{
|
||||
/** @param name - The name the block will use for both the config and translation file
|
||||
* @param config - configuration reference used to pull blockID from
|
||||
* @param blockID - Default block id to be used for the config
|
||||
* @param material - Block material used for tool refrence? */
|
||||
* @param material - Block material used for tool reference? */
|
||||
public BlockMachine(String name, Configuration config, int blockID, Material material)
|
||||
{
|
||||
super(config.getBlock(name, blockID).getInt(), material);
|
||||
|
|
|
@ -74,6 +74,7 @@ public abstract class NetworkTileEntities
|
|||
return this.networkMember.contains(ent);
|
||||
}
|
||||
|
||||
/** removes a tile from all parts of the network */
|
||||
public boolean removeTile(TileEntity ent)
|
||||
{
|
||||
return this.networkMember.remove(ent);
|
||||
|
@ -133,13 +134,14 @@ public abstract class NetworkTileEntities
|
|||
return this.networkMember;
|
||||
}
|
||||
|
||||
/** Override this to write any data to the time. Called before a merge, split, or major edit of the
|
||||
* network */
|
||||
/** Override this to write any data to the tile. Called before a merge, split, or major edit of
|
||||
* the network */
|
||||
public void writeDataToTiles()
|
||||
{
|
||||
|
||||
}
|
||||
/** Override this to write any data to the time. Called after a merge, split, or major edit of the
|
||||
|
||||
/** Override this to read any data to the tile. Called after a merge, split, or major edit of the
|
||||
* network */
|
||||
public void readDataFromTiles()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue