2014-03-07 07:15:54 +01:00
|
|
|
package appeng.container.implementations;
|
|
|
|
|
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2014-07-19 21:33:28 +02:00
|
|
|
import net.minecraft.inventory.Slot;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import appeng.api.AEApi;
|
2014-05-07 07:22:42 +02:00
|
|
|
import appeng.container.guisync.GuiSync;
|
2014-09-28 20:36:58 +02:00
|
|
|
import appeng.container.interfaces.IProgressProvider;
|
2014-03-11 07:52:48 +01:00
|
|
|
import appeng.container.slot.SlotOutput;
|
|
|
|
import appeng.container.slot.SlotRestrictedInput;
|
2014-07-19 21:33:28 +02:00
|
|
|
import appeng.recipes.handlers.Inscribe;
|
|
|
|
import appeng.recipes.handlers.Inscribe.InscriberRecipe;
|
2014-03-07 07:15:54 +01:00
|
|
|
import appeng.tile.misc.TileInscriber;
|
2014-03-11 07:52:48 +01:00
|
|
|
import appeng.util.Platform;
|
2014-03-07 07:15:54 +01:00
|
|
|
|
2014-09-28 20:36:58 +02:00
|
|
|
public class ContainerInscriber extends ContainerUpgradeable implements IProgressProvider
|
2014-03-07 07:15:54 +01:00
|
|
|
{
|
|
|
|
|
2014-09-25 22:30:19 +02:00
|
|
|
TileInscriber ti;
|
2014-03-07 07:15:54 +01:00
|
|
|
|
2014-07-19 21:33:28 +02:00
|
|
|
Slot top;
|
|
|
|
Slot middle;
|
|
|
|
Slot bottom;
|
|
|
|
|
2014-09-25 22:30:19 +02:00
|
|
|
@GuiSync(2)
|
2014-09-21 01:06:57 +02:00
|
|
|
public int maxProcessingTime = -1;
|
2014-05-07 07:22:42 +02:00
|
|
|
|
2014-09-25 22:30:19 +02:00
|
|
|
@GuiSync(3)
|
2014-03-11 07:52:48 +01:00
|
|
|
public int processingTime = -1;
|
|
|
|
|
2014-09-25 22:30:19 +02:00
|
|
|
public ContainerInscriber(InventoryPlayer ip, TileInscriber te)
|
|
|
|
{
|
|
|
|
super( ip, te );
|
|
|
|
ti = te;
|
|
|
|
|
|
|
|
addSlotToContainer( top = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, ti, 0, 45, 16, invPlayer ) );
|
|
|
|
addSlotToContainer( bottom = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, ti, 1, 45, 62, invPlayer ) );
|
|
|
|
addSlotToContainer( middle = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_INPUT, ti, 2, 63, 39, invPlayer ) );
|
|
|
|
|
|
|
|
addSlotToContainer( new SlotOutput( ti, 3, 113, 40, -1 ) );
|
|
|
|
|
2014-09-28 12:22:24 +02:00
|
|
|
bindPlayerInventory( ip, 0, getHeight() - /* height of player inventory */82 );
|
2014-09-25 22:30:19 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected int getHeight()
|
|
|
|
{
|
|
|
|
return 176;
|
|
|
|
}
|
2014-03-07 07:15:54 +01:00
|
|
|
|
2014-09-25 22:30:19 +02:00
|
|
|
@Override
|
|
|
|
public int availableUpgrades()
|
|
|
|
{
|
|
|
|
return 3;
|
|
|
|
}
|
2014-03-11 07:52:48 +01:00
|
|
|
|
2014-09-25 22:30:19 +02:00
|
|
|
@Override
|
|
|
|
protected boolean supportCapacity()
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2014-03-11 07:52:48 +01:00
|
|
|
|
2014-09-25 22:30:19 +02:00
|
|
|
@Override
|
|
|
|
/**
|
|
|
|
* Overridden super.setupConfig to prevent setting up the fake slots
|
|
|
|
*/
|
|
|
|
protected void setupConfig()
|
|
|
|
{
|
|
|
|
setupUpgrades();
|
2014-03-07 07:15:54 +01:00
|
|
|
}
|
|
|
|
|
2014-09-28 20:34:00 +02:00
|
|
|
@Override
|
2014-07-19 21:33:28 +02:00
|
|
|
public boolean isValidForSlot(Slot s, ItemStack is)
|
|
|
|
{
|
2014-09-25 22:30:19 +02:00
|
|
|
ItemStack PlateA = ti.getStackInSlot( 0 );
|
|
|
|
ItemStack PlateB = ti.getStackInSlot( 1 );
|
2014-07-19 21:33:28 +02:00
|
|
|
|
|
|
|
if ( s == middle )
|
|
|
|
{
|
|
|
|
for (ItemStack i : Inscribe.plates)
|
|
|
|
{
|
|
|
|
if ( Platform.isSameItemPrecise( i, is ) )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean matches = false;
|
|
|
|
boolean found = false;
|
|
|
|
|
|
|
|
for (InscriberRecipe i : Inscribe.recipes)
|
|
|
|
{
|
|
|
|
boolean matchA = (PlateA == null && i.plateA == null) || (Platform.isSameItemPrecise( PlateA, i.plateA )) && // and...
|
|
|
|
(PlateB == null && i.plateB == null) | (Platform.isSameItemPrecise( PlateB, i.plateB ));
|
|
|
|
|
|
|
|
boolean matchB = (PlateB == null && i.plateA == null) || (Platform.isSameItemPrecise( PlateB, i.plateA )) && // and...
|
|
|
|
(PlateA == null && i.plateB == null) | (Platform.isSameItemPrecise( PlateA, i.plateB ));
|
|
|
|
|
|
|
|
if ( matchA || matchB )
|
|
|
|
{
|
|
|
|
matches = true;
|
|
|
|
for (ItemStack option : i.imprintable)
|
|
|
|
{
|
|
|
|
if ( Platform.isSameItemPrecise( is, option ) )
|
|
|
|
found = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( matches && found == false )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (s == top && PlateB != null) || (s == bottom && PlateA != null) )
|
|
|
|
{
|
|
|
|
boolean isValid = false;
|
|
|
|
ItemStack otherSlot = null;
|
|
|
|
if ( s == top )
|
|
|
|
otherSlot = bottom.getStack();
|
|
|
|
else
|
|
|
|
otherSlot = top.getStack();
|
|
|
|
|
2014-07-19 22:16:25 +02:00
|
|
|
// name presses
|
2014-07-19 21:33:28 +02:00
|
|
|
if ( AEApi.instance().materials().materialNamePress.sameAsStack( otherSlot ) )
|
|
|
|
return AEApi.instance().materials().materialNamePress.sameAsStack( is );
|
|
|
|
|
|
|
|
// everything else
|
|
|
|
for (InscriberRecipe i : Inscribe.recipes)
|
|
|
|
{
|
|
|
|
if ( Platform.isSameItemPrecise( i.plateA, otherSlot ) )
|
|
|
|
{
|
|
|
|
isValid = Platform.isSameItemPrecise( is, i.plateB );
|
|
|
|
}
|
|
|
|
else if ( Platform.isSameItemPrecise( i.plateB, otherSlot ) )
|
|
|
|
{
|
|
|
|
isValid = Platform.isSameItemPrecise( is, i.plateA );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( isValid )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !isValid )
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-03-11 07:52:48 +01:00
|
|
|
@Override
|
|
|
|
public void detectAndSendChanges()
|
|
|
|
{
|
2014-09-25 22:30:19 +02:00
|
|
|
standardDetectAndSendChanges();
|
2014-03-11 07:52:48 +01:00
|
|
|
|
|
|
|
if ( Platform.isServer() )
|
|
|
|
{
|
2014-09-25 22:30:19 +02:00
|
|
|
this.maxProcessingTime = ti.maxProcessingTime;
|
|
|
|
this.processingTime = ti.processingTime;
|
2014-03-11 07:52:48 +01:00
|
|
|
}
|
|
|
|
}
|
2014-09-28 20:36:58 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getCurrentProgress()
|
|
|
|
{
|
|
|
|
return processingTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getMaxProgress()
|
|
|
|
{
|
|
|
|
return maxProcessingTime;
|
|
|
|
}
|
2014-03-07 07:15:54 +01:00
|
|
|
}
|