2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
|
|
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
|
|
*/
|
|
|
|
|
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-29 09:54:34 +02:00
|
|
|
final TileInscriber ti;
|
2014-03-07 07:15:54 +01:00
|
|
|
|
2014-09-29 09:54:34 +02:00
|
|
|
final Slot top;
|
|
|
|
final Slot middle;
|
|
|
|
final Slot bottom;
|
2014-07-19 21:33:28 +02:00
|
|
|
|
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 );
|
2014-12-29 15:13:47 +01:00
|
|
|
this.ti = te;
|
2014-09-25 22:30:19 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.addSlotToContainer( this.top = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, this.ti, 0, 45, 16, this.invPlayer ) );
|
|
|
|
this.addSlotToContainer( this.bottom = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, this.ti, 1, 45, 62, this.invPlayer ) );
|
|
|
|
this.addSlotToContainer( this.middle = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_INPUT, this.ti, 2, 63, 39, this.invPlayer ) );
|
2014-09-25 22:30:19 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.addSlotToContainer( new SlotOutput( this.ti, 3, 113, 40, -1 ) );
|
2014-09-25 22:30:19 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
this.bindPlayerInventory( ip, 0, this.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()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.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-12-29 15:13:47 +01:00
|
|
|
ItemStack PlateA = this.ti.getStackInSlot( 0 );
|
|
|
|
ItemStack PlateB = this.ti.getStackInSlot( 1 );
|
2014-07-19 21:33:28 +02:00
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( s == this.middle )
|
2014-07-19 21:33:28 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-09 21:33:31 +02:00
|
|
|
if ( matches && !found )
|
2014-07-19 21:33:28 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( (s == this.top && PlateB != null) || (s == this.bottom && PlateA != null) )
|
2014-07-19 21:33:28 +02:00
|
|
|
{
|
|
|
|
boolean isValid = false;
|
|
|
|
ItemStack otherSlot = null;
|
2014-12-29 15:13:47 +01:00
|
|
|
if ( s == this.top )
|
|
|
|
otherSlot = this.bottom.getStack();
|
2014-07-19 21:33:28 +02:00
|
|
|
else
|
2014-12-29 15:13:47 +01:00
|
|
|
otherSlot = this.top.getStack();
|
2014-07-19 21:33:28 +02:00
|
|
|
|
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-12-29 15:13:47 +01:00
|
|
|
this.standardDetectAndSendChanges();
|
2014-03-11 07:52:48 +01:00
|
|
|
|
|
|
|
if ( Platform.isServer() )
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
this.maxProcessingTime = this.ti.maxProcessingTime;
|
|
|
|
this.processingTime = this.ti.processingTime;
|
2014-03-11 07:52:48 +01:00
|
|
|
}
|
|
|
|
}
|
2014-09-28 20:36:58 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getCurrentProgress()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.processingTime;
|
2014-09-28 20:36:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getMaxProgress()
|
|
|
|
{
|
2014-12-29 15:13:47 +01:00
|
|
|
return this.maxProcessingTime;
|
2014-09-28 20:36:58 +02:00
|
|
|
}
|
2014-03-07 07:15:54 +01:00
|
|
|
}
|