The files Atomic refactored

Delete! Exterminate!
This commit is contained in:
AtomicStryker 2012-12-08 18:28:48 +01:00
parent 5d41e8644d
commit 7215733690
8 changed files with 0 additions and 710 deletions

View file

@ -1,129 +0,0 @@
package assemblyline.machines.crafter;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import universalelectricity.core.UniversalElectricity;
import universalelectricity.prefab.BlockMachine;
import universalelectricity.prefab.UETab;
import assemblyline.AssemblyLine;
public class BlockCrafter extends BlockMachine
{
protected BlockCrafter(int id)
{
super("AutoCrafter", id, UniversalElectricity.machine);
this.setResistance(5.0f);
this.setHardness(5.0f);
this.setCreativeTab(UETab.INSTANCE);
}
public static enum CrafterType
{
CRAFTER("Crafter", 0, -1, TileEntityAutoCrafter.class);
public String name;
public int metadata;
public int guiID;
public Class<? extends TileEntity> tileEntity;
CrafterType(String name, int metadata, int guiID, Class<? extends TileEntity> tileEntity)
{
this.name = name;
this.metadata = metadata;
this.guiID = guiID;
this.tileEntity = tileEntity;
}
public static CrafterType get(int metadata)
{
for (CrafterType value : CrafterType.values())
{
if (metadata >= value.metadata && metadata < value.metadata + 4) { return value; }
}
return null;
}
/**
* Gets the direction based on the metadata
*
* @return A direction value from 0 to 4.
*/
public static int getDirection(int metadata)
{
return metadata - CrafterType.get(metadata).metadata;
}
/**
* @param currentDirection - An integer from 0 to 4.
* @return The metadata this block should change into.
*/
public int getNextDirectionMeta(int currentDirection)
{
currentDirection++;
if (currentDirection >= 4)
{
currentDirection = 0;
}
return currentDirection + this.metadata;
}
/**
* Creates a new TIleEntity.
*/
public TileEntity instantiateTileEntity()
{
try
{
return this.tileEntity.newInstance();
}
catch (Exception e)
{
e.printStackTrace();
return null;
}
}
}
@Override
public TileEntity createNewTileEntity(World var1)
{
return null;
}
@Override
public TileEntity createNewTileEntity(World var1, int metadata)
{
return CrafterType.get(metadata).instantiateTileEntity();
}
@Override
public boolean onMachineActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
{
if (!par1World.isRemote)
{
int metadata = par1World.getBlockMetadata(x, y, z);
int guiID = CrafterType.get(metadata).metadata;
if (guiID == -1)
return false;
par5EntityPlayer.openGui(AssemblyLine.instance, guiID, par1World, x, y, z);
return true;
}
return true;
}
@Override
public boolean onSneakUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
{
return false;
}
public int getRenderType()
{
return 0;
}
}

View file

@ -1,95 +0,0 @@
package assemblyline.machines.crafter;
import net.minecraft.src.Container;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.InventoryPlayer;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Slot;
/**
* I am planning to make the crafter not use a GUI.
*
* @author Calclavia
*
*/
@Deprecated
public class ContainerCrafter extends Container
{
private TileEntityAutoCrafter tileEntity;
public ContainerCrafter(InventoryPlayer par1InventoryPlayer, TileEntityAutoCrafter tileEntity)
{
this.tileEntity = tileEntity;
for (int r = 0; r < 3; r++)
{
for (int i = 0; i < 3; i++)
{
// this.addSlotToContainer(new
// Slot(tileEntity, i + r * 3, 33
// + i * 18, 34 + r * 18));
}
}
int var3;
for (var3 = 0; var3 < 3; ++var3)
{
for (int var4 = 0; var4 < 9; ++var4)
{
this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18));
}
}
for (var3 = 0; var3 < 9; ++var3)
{
this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142));
}
}
@Override
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
{
return true;
}
/**
* Called to transfer a stack from one inventory to the other eg. when shift clicking.
*/
@Override
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par1)
{
ItemStack itemStack3 = null;
Slot itemStack = (Slot) this.inventorySlots.get(par1);
if (itemStack != null && itemStack.getHasStack())
{
ItemStack itemStack2 = itemStack.getStack();
itemStack3 = itemStack2.copy();
if (par1 != 0)
{
if (itemStack2.itemID == Item.coal.shiftedIndex)
{
if (!this.mergeItemStack(itemStack2, 0, 1, false)) { return null; }
}
else if (par1 >= 30 && par1 < 37 && !this.mergeItemStack(itemStack2, 3, 30, false)) { return null; }
}
else if (!this.mergeItemStack(itemStack2, 3, 37, false)) { return null; }
if (itemStack2.stackSize == 0)
{
itemStack.putStack((ItemStack) null);
}
else
{
itemStack.onSlotChanged();
}
if (itemStack2.stackSize == itemStack3.stackSize) { return null; }
itemStack.onPickupFromSlot(par1EntityPlayer, itemStack2);
}
return itemStack3;
}
}

View file

@ -1,72 +0,0 @@
package assemblyline.machines.crafter;
import net.minecraft.src.Entity;
import net.minecraft.src.EntityItem;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.World;
import universalelectricity.core.vector.Vector3;
public class EntityCraftingArm extends Entity
{
/**
* Used to ID the type of arm
*/
static enum armType
{
ARM, SOLDER, DRILL, BREAKER
}
/**
* type of arm this robotic arm currently is
*/
public armType arm = armType.ARM;
/**
* stack this arm is holding if any
*/
public ItemStack stack = null;
/**
* TileEntity this arm is working with
*/
public TileEntityCraftingArm blockArm = null;
/**
* position that the arms claw should be at
*/
public Vector3 clawPos = new Vector3();
public boolean isWorking = false;
public EntityCraftingArm(World par1World)
{
super(par1World);
}
@Override
protected void entityInit()
{
}
@Override
protected void readEntityFromNBT(NBTTagCompound nbt)
{
this.arm = armType.values()[nbt.getInteger("type")];
}
@Override
protected void writeEntityToNBT(NBTTagCompound nbt)
{
nbt.setInteger("type", arm.ordinal());
}
public boolean grabItem(EntityItem item)
{
if (this.stack == null)
{
// TODO set current stack to item as
// soon as it reaches coords
}
return false;
}
}

View file

@ -1,14 +0,0 @@
package assemblyline.machines.crafter;
import net.minecraft.src.Item;
public class ItemCrafterArm extends Item
{
protected ItemCrafterArm(int par1)
{
super(par1);
this.setHasSubtypes(true);
}
}

View file

@ -1,38 +0,0 @@
package assemblyline.machines.crafter;
import net.minecraft.src.EntityItem;
import assemblyline.ai.Task;
/**
* Used by arms to collect items in a specific region.
*
* @author Calclavia
*/
public class TaskArmCollect extends Task
{
/**
* The item to be collected.
*/
private EntityItem entityItem;
public TaskArmCollect(TileEntityCraftingArm arm, EntityItem entityItem)
{
super(arm);
this.entityItem = entityItem;
}
@Override
protected boolean doTask()
{
super.doTask();
if (entityItem == null) { return false; }
/**
* Slowly stretch down the arm's model and grab the item
*/
return true;
}
}

View file

@ -1,53 +0,0 @@
package assemblyline.machines.crafter;
import net.minecraft.src.AxisAlignedBB;
import net.minecraft.src.Entity;
import assemblyline.ai.Task;
/**
* Used by arms to search for entities in a region
*
* @author Calclavia
*/
public class TaskArmSearch extends Task
{
/**
* The item to be collected.
*/
private Class<? extends Entity> entityToInclude;
private float searchSpeed;
private double radius;
private Entity foundEntity;
public TaskArmSearch(TileEntityCraftingArm arm, Class<? extends Entity> entityToInclude, double radius, float searchSpeed)
{
super(arm);
this.entityToInclude = entityToInclude;
this.radius = radius;
this.searchSpeed = searchSpeed;
}
@Override
public void onTaskStart()
{
this.foundEntity = (Entity) this.tileEntity.worldObj.getEntitiesWithinAABB(this.entityToInclude, AxisAlignedBB.getBoundingBox(this.tileEntity.xCoord - this.radius, this.tileEntity.yCoord - this.radius, this.tileEntity.zCoord - this.radius, this.tileEntity.xCoord + this.radius, this.tileEntity.yCoord + this.radius, this.tileEntity.zCoord + this.radius)).get(0);
}
@Override
protected boolean doTask()
{
super.doTask();
if (this.entityToInclude == null || this.foundEntity == null) { return false; }
/**
* Move the robotic arm around and emulate an item search. Then initiate a collect task.
*/
return true;
}
}

View file

@ -1,27 +0,0 @@
package assemblyline.machines.crafter;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.INetworkManager;
import net.minecraft.src.Packet250CustomPayload;
import universalelectricity.prefab.tile.TileEntityAdvanced;
import com.google.common.io.ByteArrayDataInput;
public class TileEntityAutoCrafter extends TileEntityAdvanced
{
public String getInvName()
{
return "Auto Crafter";
}
public int getSizeInventory()
{
return 10;
}
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
{
}
}

View file

@ -1,282 +0,0 @@
package assemblyline.machines.crafter;
import java.util.EnumSet;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IInventory;
import net.minecraft.src.INetworkManager;
import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NBTTagList;
import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.electricity.ElectricityConnections;
import universalelectricity.core.implement.IConductor;
import universalelectricity.core.implement.IJouleStorage;
import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.tile.TileEntityElectricityReceiver;
import assemblyline.ai.TaskManager;
import com.google.common.io.ByteArrayDataInput;
public class TileEntityCraftingArm extends TileEntityElectricityReceiver implements IInventory, IPacketReceiver, IJouleStorage
{
/**
* The items this container contains.
*/
protected ItemStack[] containingItems = new ItemStack[this.getSizeInventory()];
private TaskManager taskManager = new TaskManager();
/**
* Entity robotic arm to be used with this tileEntity
*/
public EntityCraftingArm EntityArm = null;
public final double WATT_REQUEST = 20;
public double wattsReceived = 0;
private int playerUsing = 0;
@Override
public void initiate()
{
ElectricityConnections.registerConnector(this, EnumSet.of(ForgeDirection.DOWN, ForgeDirection.SOUTH, ForgeDirection.NORTH, ForgeDirection.EAST, ForgeDirection.WEST));
}
public void updateEntity()
{
super.updateEntity();
if (!this.worldObj.isRemote)
{
for (int i = 0; i < 6; i++)
{
ForgeDirection inputDirection = ForgeDirection.getOrientation(i);
if (inputDirection != ForgeDirection.UP)
{
TileEntity inputTile = Vector3.getTileEntityFromSide(this.worldObj, Vector3.get(this), inputDirection);
if (inputTile != null)
{
if (inputTile instanceof IConductor)
{
if (this.getJoules() >= this.getMaxJoules())
{
((IConductor) inputTile).getNetwork().stopRequesting(this);
}
else
{
((IConductor) inputTile).getNetwork().startRequesting(this, this.WATT_REQUEST / this.getVoltage(), this.getVoltage());
this.setJoules(this.getJoules() + ((IConductor) inputTile).getNetwork().consumeElectricity(this).getWatts());
}
}
}
}
}
}
taskManager.onUpdate();
if (this.ticks % 5 == 0 && !this.isDisabled() && this.taskManager.hasTask() && EntityArm != null)
{
this.wattsReceived -= this.WATT_REQUEST;
this.doWork();
}
}
/**
* controls the robotic arm into doing a set task
*/
public void doWork()
{
}
@Override
public double getVoltage()
{
return 120;
}
/**
* Data
*/
@Override
public void handlePacketData(INetworkManager network, int packetType, Packet250CustomPayload packet, EntityPlayer player, ByteArrayDataInput dataStream)
{
}
/**
* inventory
*/
@Override
public int getSizeInventory()
{
return 1;
}
@Override
public String getInvName()
{
return "RoboticArm";
}
/**
* Inventory functions.
*/
@Override
public ItemStack getStackInSlot(int par1)
{
return this.containingItems[par1];
}
@Override
public ItemStack decrStackSize(int par1, int par2)
{
if (this.containingItems[par1] != null)
{
ItemStack var3;
if (this.containingItems[par1].stackSize <= par2)
{
var3 = this.containingItems[par1];
this.containingItems[par1] = null;
return var3;
}
else
{
var3 = this.containingItems[par1].splitStack(par2);
if (this.containingItems[par1].stackSize == 0)
{
this.containingItems[par1] = null;
}
return var3;
}
}
else
{
return null;
}
}
@Override
public ItemStack getStackInSlotOnClosing(int par1)
{
if (this.containingItems[par1] != null)
{
ItemStack var2 = this.containingItems[par1];
this.containingItems[par1] = null;
return var2;
}
else
{
return null;
}
}
@Override
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
{
this.containingItems[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{
par2ItemStack.stackSize = this.getInventoryStackLimit();
}
}
@Override
public int getInventoryStackLimit()
{
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer par1EntityPlayer)
{
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : par1EntityPlayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D;
}
@Override
public void openChest()
{
this.playerUsing++;
}
@Override
public void closeChest()
{
this.playerUsing--;
}
/**
* NBT Data
*/
@Override
public void readFromNBT(NBTTagCompound nbt)
{
super.readFromNBT(nbt);
NBTTagList var2 = nbt.getTagList("Items");
this.containingItems = new ItemStack[this.getSizeInventory()];
for (int var3 = 0; var3 < var2.tagCount(); ++var3)
{
NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(var3);
byte var5 = var4.getByte("Slot");
if (var5 >= 0 && var5 < this.containingItems.length)
{
this.containingItems[var5] = ItemStack.loadItemStackFromNBT(var4);
}
}
}
/**
* Writes a tile entity to NBT.
*/
@Override
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
NBTTagList var2 = new NBTTagList();
for (int var3 = 0; var3 < this.containingItems.length; ++var3)
{
if (this.containingItems[var3] != null)
{
NBTTagCompound var4 = new NBTTagCompound();
var4.setByte("Slot", (byte) var3);
this.containingItems[var3].writeToNBT(var4);
var2.appendTag(var4);
}
}
nbt.setTag("Items", var2);
}
@Override
public double getJoules(Object... data)
{
return this.wattsReceived;
}
@Override
public void setJoules(double joules, Object... data)
{
this.wattsReceived = joules;
}
@Override
public double getMaxJoules(Object... data)
{
return 1000;
}
}