PowerTo command setup done

Now to just figure out how to actual apply power to a block and this
command will be done.

Also i still can't get 7zip cmd installed on my computer too use. So i
had to create my own include script for now.
This commit is contained in:
Rseifert 2013-02-12 21:51:52 -05:00
parent 7e869bb5c0
commit 1b0a386f5c
5 changed files with 78 additions and 34 deletions

1
.gitignore vendored
View file

@ -23,5 +23,6 @@ CHANGELOG
!publish.bat
!publish_obf.bat
!include.bat
!include2.bat
!buildlocal.bat
!/README

4
Include2.bat Normal file
View file

@ -0,0 +1,4 @@
@echo off
cd resources
..\..\..\7za.exe a "..\jars\bin\minecraft.jar" "*"
pause

View file

@ -15,7 +15,7 @@ import universalelectricity.prefab.network.PacketManager;
*/
public abstract class TileEntityAssemblyNetwork extends TIC2Receiver
{
public boolean debugMode = false;
public boolean debugMode = true;
/**
* The range in which power can be transfered.
*/

View file

@ -13,74 +13,87 @@ import dark.minecraft.helpers.ItemWorldHelper;
public class CommandPowerTo extends Command
{
private int times;
private int curTimes;
private int duration;
private int ticksRan;
@Override
public void onTaskStart()
{
this.times = 0;
this.curTimes = 0;
this.duration = 0;
this.ticksRan = 0;
if (this.getArgs().length > 0)
{
this.times = this.getIntArg(0);
this.duration = this.getIntArg(0);
}
if (this.times <= 0)
this.times = 1;
if (this.duration <= 0)
{
this.duration = 20;
}
}
@Override
protected boolean doTask()
{
super.doTask();
if (this.ticksRan >= duration)
{
powerBlock(false);
return false;
}
Block block = Block.blocksList[this.world.getBlockId(tileEntity.getHandPosition().intX(), tileEntity.getHandPosition().intY(), tileEntity.getHandPosition().intZ())];
TileEntity targetTile = this.tileEntity.getHandPosition().getTileEntity(this.world);
if (tileEntity.getGrabbedEntities().size() > 0)
if (this.tileEntity.getGrabbedItems().size() > 0)
{
List<EntityItem> items = ItemWorldHelper.filterOutEntityItems(tileEntity.getGrabbedEntities());
if (items != null)
List<ItemStack> stacks = new ArrayList<ItemStack>();
stacks.add(new ItemStack(Block.torchRedstoneActive, 1, 0));
stacks.add(new ItemStack(Block.torchRedstoneIdle, 1, 0));
if (ItemWorldHelper.filterItems(this.tileEntity.getGrabbedItems(), stacks).size() > 0)
{
List<ItemStack> stacks = new ArrayList<ItemStack>();
stacks.add(new ItemStack(Block.torchRedstoneActive, 1, 0));
stacks.add(new ItemStack(Block.torchRedstoneIdle, 1, 0));
items = ItemWorldHelper.filterEntityItemsList(items, stacks);
if(items.size() > 0)
{
DebugToPlayer.SendToClosest(this.tileEntity, 10, "powering");
return true;
}
this.powerBlock(true);
}
}
this.curTimes++;
if (this.curTimes >= this.times)
return false;
this.ticksRan++;
return true;
}
public void powerBlock(boolean on)
{
if (!on)
{
// unpower block
//DebugToPlayer.SendToClosest(this.tileEntity, 20, "Power Off");
}
else
{
// power block
//DebugToPlayer.SendToClosest(this.tileEntity, 20, "Power on");
}
}
@Override
public String toString()
{
return "POWERTO " + Integer.toString(this.times);
return "POWERTO " + Integer.toString(this.duration);
}
@Override
public void readFromNBT(NBTTagCompound taskCompound)
{
super.readFromNBT(taskCompound);
this.times = taskCompound.getInteger("useTimes");
this.curTimes = taskCompound.getInteger("useCurTimes");
this.duration = taskCompound.getInteger("useTimes");
this.ticksRan = taskCompound.getInteger("useCurTimes");
}
@Override
public void writeToNBT(NBTTagCompound taskCompound)
{
super.writeToNBT(taskCompound);
taskCompound.setInteger("useTimes", this.times);
taskCompound.setInteger("useCurTimes", this.curTimes);
taskCompound.setInteger("useTimes", this.duration);
taskCompound.setInteger("useCurTimes", this.ticksRan);
}
}

View file

@ -49,13 +49,14 @@ public class ItemWorldHelper
{
if (entityItem.getEntityItem().itemID == itemStack.itemID && entityItem.getEntityItem().getItemDamage() == itemStack.getItemDamage() && !newItemList.contains(entityItem))
{
entityItems.add(entityItem);
newItemList.add(entityItem);
break;
}
}
}
return newItemList;
}
/**
* filters out EnittyItems from an Entity list
*/
@ -65,15 +66,40 @@ public class ItemWorldHelper
for (Entity entity : entities)
{
if(entity instanceof EntityItem)
{
if (entity instanceof EntityItem)
{
newEntityList.add((EntityItem) entity);
}
}
return newEntityList;
}
/**
* filter a list of itemStack to another list of itemStacks
*
* @param totalItems - full list of items being filtered
* @param desiredItems - list the of item that are being filtered too
* @return a list of item from the original that are wanted
*/
public static List<ItemStack> filterItems(List<ItemStack> totalItems, List<ItemStack> desiredItems)
{
List<ItemStack> newItemList = new ArrayList<ItemStack>();
for (ItemStack entityItem : totalItems)
{
for (ItemStack itemStack : desiredItems)
{
if (entityItem.itemID == itemStack.itemID && entityItem.getItemDamage() == itemStack.getItemDamage() && !newItemList.contains(entityItem))
{
newItemList.add(entityItem);
break;
}
}
}
return newItemList;
}
/**
* Drops an item stack at the exact center of the location without any velocity or random throw angle
*