Skip to content

Commit

Permalink
fix up sided inventory handling issues in worksites. Closes #179.
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowmage45 committed Dec 2, 2014
1 parent 903c515 commit 04949bd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.shadowmage.ancientwarfare.automation.gamedata.MailboxData;
import net.shadowmage.ancientwarfare.automation.gamedata.MailboxData.DeliverableItem;
import net.shadowmage.ancientwarfare.core.block.BlockRotationHandler.IRotatableTile;
import net.shadowmage.ancientwarfare.core.block.BlockRotationHandler.InventorySided;
import net.shadowmage.ancientwarfare.core.block.BlockRotationHandler.RelativeSide;
import net.shadowmage.ancientwarfare.core.block.BlockRotationHandler.RotationType;
import net.shadowmage.ancientwarfare.core.gamedata.AWGameData;
import net.shadowmage.ancientwarfare.core.interfaces.IOwnable;

public class TileMailbox extends TileEntity implements IOwnable, IInventory, ISidedInventory
public class TileMailbox extends TileEntity implements IOwnable, IInventory, ISidedInventory, IRotatableTile
{

private boolean autoExport;//should automatically try and export from output side
Expand Down Expand Up @@ -236,4 +238,16 @@ public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_)
return inventory.isItemValidForSlot(p_94041_1_, p_94041_2_);
}

@Override
public ForgeDirection getPrimaryFacing()
{
return ForgeDirection.getOrientation(getBlockMetadata());
}

@Override
public void setPrimaryFacing(ForgeDirection face)
{
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, face.ordinal(), 0);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,12 @@ public static class InventorySided implements IInventory, ISidedInventory, IInve

private HashMap<RelativeSide, int[]> slotsByInventorySide = new HashMap<RelativeSide, int[]>();
private HashMap<RelativeSide, boolean[]> extractInsertFlags = new HashMap<RelativeSide, boolean[]>();//inventoryside x boolean[2]; [0]=extract, [1]=insert
public final TileEntity te;
public final IRotatableTile te;
public final RotationType rType;
private ItemStack[] inventorySlots;
private ItemSlotFilter[] filtersByInventorySlot;

public InventorySided(TileEntity te, RotationType rType, int inventorySize)
public InventorySided(IRotatableTile te, RotationType rType, int inventorySize)
{
if(te==null || rType==null || inventorySize<=0){throw new IllegalArgumentException("te and rotation type may not be null, inventory size must be greater than 0");}
this.te = te;
Expand Down Expand Up @@ -374,7 +374,7 @@ public void setExtractInsertFlags(RelativeSide inventorySide, boolean[] flags)

public RelativeSide getInventorySide(int mcSide)
{
int meta = te.getBlockMetadata();
int meta = te.getPrimaryFacing().ordinal();
RelativeSide rSide = RelativeSide.getSideViewed(rType, meta, mcSide);
rSide = accessMap.get(rSide);
return rSide;
Expand Down Expand Up @@ -482,7 +482,7 @@ public int getInventoryStackLimit()
@Override
public void markDirty()
{
te.markDirty();
((TileEntity)te).markDirty();
}

@Override
Expand Down Expand Up @@ -551,7 +551,7 @@ public NBTTagCompound writeToNBT(NBTTagCompound tag)

public int getAccessDirectionFor(RelativeSide blockSide)
{
return RelativeSide.getMCSideToAccess(rType, te.getBlockMetadata(), blockSide);
return RelativeSide.getMCSideToAccess(rType, te.getPrimaryFacing().ordinal(), blockSide);
}

public EnumSet<RelativeSide> getValidSides()
Expand Down

0 comments on commit 04949bd

Please sign in to comment.