added a get vector method to the base prefab
This commit is contained in:
parent
ce4c40c0fb
commit
1e5383f9a3
4 changed files with 51 additions and 11 deletions
|
@ -14,7 +14,11 @@ import net.minecraftforge.common.ForgeDirection;
|
|||
import universalelectricity.core.vector.Vector3;
|
||||
import dark.api.IExtendedStorage;
|
||||
import dark.core.prefab.machine.TileEntityMulti;
|
||||
|
||||
/**
|
||||
* Helper that handles most of the interaction of the tile with the inventories around it
|
||||
* @author Rseifert
|
||||
*
|
||||
*/
|
||||
public class InvInteractionHelper
|
||||
{
|
||||
public World world;
|
||||
|
|
|
@ -4,22 +4,30 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.command.IEntitySelector;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
|
||||
public class ItemWorldHelper
|
||||
{
|
||||
|
||||
/** gets all EntityItems in a location using a start and end point */
|
||||
public static List<EntityItem> findAllItemIn(World world, Vector3 start, Vector3 end)
|
||||
public static List<EntityItem> findAllItemsIn(World world, Vector3 start, Vector3 end)
|
||||
{
|
||||
return world.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(start.x, start.y, start.z, end.x, end.y, end.z));
|
||||
}
|
||||
|
||||
public static List<EntityItem> getEntitiesInDirection(World world, Vector3 center, ForgeDirection dir)
|
||||
{
|
||||
List<EntityItem> list = world.selectEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getAABBPool().getAABB(center.x + dir.offsetX, center.y + dir.offsetY, center.z + dir.offsetZ, center.x + dir.offsetX + 1, center.y + dir.offsetY + 1, center.z + dir.offsetZ + 1), IEntitySelector.selectAnything);
|
||||
return list.size() > 0 ? list : null;
|
||||
}
|
||||
|
||||
/** Gets all EntityItems in an area and sorts them by a list of itemStacks
|
||||
*
|
||||
* @param world - world being worked in
|
||||
|
@ -29,7 +37,7 @@ public class ItemWorldHelper
|
|||
* @return a list of EntityItem that match the itemStacks desired */
|
||||
public static List<EntityItem> findSelectItems(World world, Vector3 start, Vector3 end, List<ItemStack> disiredItems)
|
||||
{
|
||||
List<EntityItem> entityItems = ItemWorldHelper.findAllItemIn(world, start, end);
|
||||
List<EntityItem> entityItems = ItemWorldHelper.findAllItemsIn(world, start, end);
|
||||
return filterEntityItemsList(entityItems, disiredItems);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ import net.minecraft.block.material.Material;
|
|||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -111,6 +113,17 @@ public abstract class BlockMachine extends BlockTile implements IExtraBlockInfo
|
|||
world.notifyBlockChange(x, y, z, world.getBlockId(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getComparatorInputOverride(World world, int x, int y, int z, int side)
|
||||
{
|
||||
TileEntity entity = world.getBlockTileEntity(x, y, z);
|
||||
if (entity instanceof IInventory)
|
||||
{
|
||||
return Container.calcRedstoneFromInventory((IInventory) entity);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createTileEntity(World world, int metadata)
|
||||
{
|
||||
|
|
|
@ -2,7 +2,6 @@ package dark.core.prefab.machine;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
|
@ -10,6 +9,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import universalelectricity.prefab.tile.TileEntityAdvanced;
|
||||
import dark.api.access.AccessGroup;
|
||||
import dark.api.access.AccessUser;
|
||||
|
@ -28,6 +28,7 @@ public class TileEntityInv extends TileEntityAdvanced implements IExternalInv, I
|
|||
protected IInvBox inventory;
|
||||
protected boolean lockInv;
|
||||
protected int invSlots = 1;
|
||||
private Vector3 thisPos;
|
||||
/** A list of user access data. */
|
||||
protected List<AccessGroup> groups = new ArrayList<AccessGroup>();
|
||||
|
||||
|
@ -36,6 +37,20 @@ public class TileEntityInv extends TileEntityAdvanced implements IExternalInv, I
|
|||
TerminalCommandRegistry.loadNewGroupSet(this);
|
||||
}
|
||||
|
||||
public void initiate()
|
||||
{
|
||||
thisPos = new Vector3(this);
|
||||
}
|
||||
|
||||
public Vector3 getThisPos()
|
||||
{
|
||||
if (this.thisPos == null || this.thisPos.intX() != xCoord || this.thisPos.intY() != yCoord || this.thisPos.intZ() != zCoord)
|
||||
{
|
||||
this.thisPos = new Vector3(this);
|
||||
}
|
||||
return this.thisPos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue