Integrated crate pathfinding
This commit is contained in:
parent
c1eee86fd2
commit
287aef601d
3 changed files with 27 additions and 30 deletions
|
@ -11,6 +11,7 @@ import java.util.zip.ZipInputStream;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.prefab.implement.IToolConfigurator;
|
||||
import universalelectricity.prefab.multiblock.TileEntityMulti;
|
||||
import assemblyline.common.block.TileEntityCrate;
|
||||
import assemblyline.common.machine.TileEntityManipulator;
|
||||
|
@ -146,15 +147,4 @@ public class CommonProxy implements IGuiHandler
|
|||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isHoldingBCWrench(EntityPlayer player)
|
||||
{
|
||||
if (player.getCurrentEquippedItem() != null)
|
||||
{
|
||||
return (Items.getItem("wrench") != null && player.getCurrentEquippedItem().isItemEqual(Items.getItem("wrench")));
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package assemblyline.common.block;
|
||||
|
||||
import ic2.api.Items;
|
||||
import assemblyline.common.CommonProxy;
|
||||
import universalelectricity.core.implement.IItemElectric;
|
||||
import universalelectricity.prefab.BlockMachine;
|
||||
|
@ -33,7 +34,7 @@ public class BlockALMachine extends BlockMachine
|
|||
{
|
||||
this(string, id, material);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
|
||||
{
|
||||
|
@ -42,13 +43,26 @@ public class BlockALMachine extends BlockMachine
|
|||
*/
|
||||
if (player.inventory.getCurrentItem() != null)
|
||||
{
|
||||
if (CommonProxy.isHoldingBCWrench(player))
|
||||
if (isHoldingWrench(player))
|
||||
{
|
||||
return this.onUseWrench(world, x, y, z, player, side, hitX, hitY, hitZ);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return super.onBlockActivated(world, x, y, z, player, side, hitX, hitY, hitZ);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if the player is holding a foreign wrench.
|
||||
*/
|
||||
public static boolean isHoldingWrench(EntityPlayer player)
|
||||
{
|
||||
if (player.getCurrentEquippedItem() != null)
|
||||
{
|
||||
return (Items.getItem("wrench") != null && player.getCurrentEquippedItem().isItemEqual(Items.getItem("wrench")));
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ import universalelectricity.core.implement.IItemElectric;
|
|||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.implement.IToolConfigurator;
|
||||
import assemblyline.common.AssemblyLine;
|
||||
import assemblyline.common.PathfinderCrate;
|
||||
import assemblyline.common.TabAssemblyLine;
|
||||
|
||||
/**
|
||||
|
@ -138,24 +139,16 @@ public class BlockCrate extends BlockALMachine
|
|||
{
|
||||
success = this.insertCurrentItem(tileEntity, player);
|
||||
}
|
||||
|
||||
|
||||
if (!success && doSearch)
|
||||
{
|
||||
int radius = 10;
|
||||
for (int x = -radius; x < radius; x++)
|
||||
{
|
||||
for (int y = -radius; y < radius; y++)
|
||||
{
|
||||
for (int z = -radius; z < radius; z++)
|
||||
{
|
||||
Vector3 position = Vector3.add(new Vector3(tileEntity), new Vector3(x, y, z));
|
||||
TileEntity checkTile = position.getTileEntity(tileEntity.worldObj);
|
||||
PathfinderCrate pathfinder = new PathfinderCrate().init(tileEntity);
|
||||
|
||||
if (checkTile instanceof TileEntityCrate)
|
||||
{
|
||||
AssemblyLine.blockCrate.tryInsert(((TileEntityCrate) checkTile), player, allMode, false);
|
||||
}
|
||||
}
|
||||
for (TileEntity checkTile : pathfinder.iteratedNodes)
|
||||
{
|
||||
if (checkTile instanceof TileEntityCrate)
|
||||
{
|
||||
AssemblyLine.blockCrate.tryInsert(((TileEntityCrate) checkTile), player, allMode, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue