Inscriber Functional, No render.

This commit is contained in:
AlgorithmX2
2014-03-11 22:26:50 -05:00
parent c0e43fe087
commit 0ed0af3d34
6 changed files with 104 additions and 20 deletions
@@ -2,6 +2,8 @@ package appeng.client.gui.implementations;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import appeng.client.gui.AEBaseGui; import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiProgressBar;
import appeng.client.gui.widgets.GuiProgressBar.Direction;
import appeng.container.implementations.ContainerInscriber; import appeng.container.implementations.ContainerInscriber;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.tile.misc.TileInscriber; import appeng.tile.misc.TileInscriber;
@@ -9,21 +11,43 @@ import appeng.tile.misc.TileInscriber;
public class GuiInscriber extends AEBaseGui public class GuiInscriber extends AEBaseGui
{ {
ContainerInscriber cvc;
GuiProgressBar pb;
public GuiInscriber(InventoryPlayer inventoryPlayer, TileInscriber te) { public GuiInscriber(InventoryPlayer inventoryPlayer, TileInscriber te) {
super( new ContainerInscriber( inventoryPlayer, te ) ); super( new ContainerInscriber( inventoryPlayer, te ) );
cvc = (ContainerInscriber) inventorySlots;
this.ySize = 176; this.ySize = 176;
} }
@Override
public void initGui()
{
super.initGui();
pb = new GuiProgressBar( "guis/inscriber.png", 135, 39, 179, 39, 6, 18, Direction.VERTICAL );
this.buttonList.add( pb );
}
@Override @Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{ {
bindTexture( "guis/inscriber.png" ); bindTexture( "guis/inscriber.png" );
pb.xPosition = 135 + guiLeft;
pb.yPosition = 39 + guiTop;
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize ); this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
} }
@Override @Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{ {
int k = 25;
int l = -15;
pb.max = cvc.maxProessingTime;
pb.current = cvc.processingTime;
pb.FullMsg = ( pb.current * 100 / pb.max ) + "%";
fontRendererObj.drawString( GuiText.Inscriber.getLocal(), 8, 6, 4210752 ); fontRendererObj.drawString( GuiText.Inscriber.getLocal(), 8, 6, 4210752 );
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 ); fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
} }
@@ -39,8 +39,8 @@ public class ContainerInscriber extends AEBaseContainer
if ( Platform.isServer() ) if ( Platform.isServer() )
{ {
int localMax = this.maxProessingTime; int localMax = myte.maxProessingTime;
int localTime = this.processingTime; int localTime = myte.processingTime;
for (int i = 0; i < this.crafters.size(); ++i) for (int i = 0; i < this.crafters.size(); ++i)
{ {
+2
View File
@@ -130,6 +130,7 @@ import appeng.recipes.game.ShapelessRecipe;
import appeng.recipes.handlers.Grind; import appeng.recipes.handlers.Grind;
import appeng.recipes.handlers.Inscribe; import appeng.recipes.handlers.Inscribe;
import appeng.recipes.handlers.Macerator; import appeng.recipes.handlers.Macerator;
import appeng.recipes.handlers.Press;
import appeng.recipes.handlers.Pulverizer; import appeng.recipes.handlers.Pulverizer;
import appeng.recipes.handlers.Shaped; import appeng.recipes.handlers.Shaped;
import appeng.recipes.handlers.Shapeless; import appeng.recipes.handlers.Shapeless;
@@ -179,6 +180,7 @@ public class Registration
recipeRegistery.addNewCraftHandler( "smelt", Smelt.class ); recipeRegistery.addNewCraftHandler( "smelt", Smelt.class );
recipeRegistery.addNewCraftHandler( "inscribe", Inscribe.class ); recipeRegistery.addNewCraftHandler( "inscribe", Inscribe.class );
recipeRegistery.addNewCraftHandler( "press", Press.class );
recipeRegistery.addNewCraftHandler( "shaped", Shaped.class ); recipeRegistery.addNewCraftHandler( "shaped", Shaped.class );
recipeRegistery.addNewCraftHandler( "shapeless", Shapeless.class ); recipeRegistery.addNewCraftHandler( "shapeless", Shapeless.class );
+8 -2
View File
@@ -19,13 +19,16 @@ public class Inscribe implements ICraftHandler, IWebsiteSeralizer
public class InscriberRecipe public class InscriberRecipe
{ {
public InscriberRecipe(ItemStack[] imprintable, ItemStack plateA, ItemStack plateB, ItemStack out) { public InscriberRecipe(ItemStack[] imprintable, ItemStack plateA, ItemStack plateB, ItemStack out, boolean usePlates) {
this.imprintable = imprintable; this.imprintable = imprintable;
this.usePlates = usePlates;
this.plateA = plateA; this.plateA = plateA;
this.plateB = plateB; this.plateB = plateB;
output = out; output = out;
} }
final public boolean usePlates;
final public ItemStack plateA; final public ItemStack plateA;
final public ItemStack[] imprintable; final public ItemStack[] imprintable;
final public ItemStack plateB; final public ItemStack plateB;
@@ -33,6 +36,8 @@ public class Inscribe implements ICraftHandler, IWebsiteSeralizer
}; };
public boolean usePlates = false;
public static HashSet<ItemStack> plates = new HashSet(); public static HashSet<ItemStack> plates = new HashSet();
public static HashSet<ItemStack> inputs = new HashSet(); public static HashSet<ItemStack> inputs = new HashSet();
public static LinkedList<InscriberRecipe> recipes = new LinkedList(); public static LinkedList<InscriberRecipe> recipes = new LinkedList();
@@ -82,7 +87,8 @@ public class Inscribe implements ICraftHandler, IWebsiteSeralizer
for (ItemStack s : plateB.getItemStackSet()) for (ItemStack s : plateB.getItemStackSet())
plates.add( s ); plates.add( s );
InscriberRecipe ir = new InscriberRecipe( imprintable.getItemStackSet(), plateA.getItemStack(), plateB.getItemStack(), output.getItemStack() ); InscriberRecipe ir = new InscriberRecipe( imprintable.getItemStackSet(), plateA == null ? null : plateA.getItemStack(), plateB == null ? null
: plateB.getItemStack(), output.getItemStack(), usePlates );
recipes.add( ir ); recipes.add( ir );
} }
+10
View File
@@ -0,0 +1,10 @@
package appeng.recipes.handlers;
public class Press extends Inscribe
{
public Press() {
usePlates = true;
}
}
+58 -16
View File
@@ -9,7 +9,11 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.networking.IGridNode; import appeng.api.networking.IGridNode;
import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.energy.IEnergySource;
import appeng.api.networking.ticking.IGridTickable; import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation; import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest; import appeng.api.networking.ticking.TickingRequest;
@@ -22,7 +26,9 @@ import appeng.tile.events.TileEventType;
import appeng.tile.grid.AENetworkPowerTile; import appeng.tile.grid.AENetworkPowerTile;
import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation; import appeng.tile.inventory.InvOperation;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.inv.WrapperInventoryRange;
import appeng.util.item.AEItemStack; import appeng.util.item.AEItemStack;
public class TileInscriber extends AENetworkPowerTile implements IGridTickable public class TileInscriber extends AENetworkPowerTile implements IGridTickable
@@ -119,8 +125,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
public void setOrientation(ForgeDirection inForward, ForgeDirection inUp) public void setOrientation(ForgeDirection inForward, ForgeDirection inUp)
{ {
super.setOrientation( inForward, inUp ); super.setOrientation( inForward, inUp );
gridProxy.setValidSides( EnumSet.of( getUp(), getUp().getOpposite() ) ); ForgeDirection right = Platform.crossProduct( getForward(), getUp() );
setPowerSides( EnumSet.of( getUp(), getUp().getOpposite() ) ); gridProxy.setValidSides( EnumSet.of( getForward().getOpposite(), right, right.getOpposite() ) );
setPowerSides( EnumSet.of( getForward().getOpposite(), right, right.getOpposite() ) );
} }
@Override @Override
@@ -180,8 +187,12 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
{ {
try try
{ {
processingTime = 0; if ( mc != InvOperation.markDirty )
gridProxy.getTick().wakeDevice( gridProxy.getNode() ); {
if ( slot != 3 )
processingTime = 0;
gridProxy.getTick().wakeDevice( gridProxy.getNode() );
}
} }
catch (GridAccessException e) catch (GridAccessException e)
{ {
@@ -189,7 +200,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
} }
} }
private ItemStack getTask() private InscriberRecipe getTask()
{ {
for (InscriberRecipe i : Inscribe.recipes) for (InscriberRecipe i : Inscribe.recipes)
@@ -208,7 +219,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
for (ItemStack opion : i.imprintable) for (ItemStack opion : i.imprintable)
{ {
if ( Platform.isSameItemPrecise( opion, getStackInSlot( 2 ) ) ) if ( Platform.isSameItemPrecise( opion, getStackInSlot( 2 ) ) )
return i.output; return i;
} }
} }
@@ -234,24 +245,55 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
@Override @Override
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
{ {
if ( processingTime == 0 ) IEnergyGrid eg;
processingTime++; try
else {
processingTime += TicksSinceLastCall; eg = gridProxy.getEnergy();
IEnergySource src = this;
double powerReq = extractAEPower( 10, Actionable.SIMULATE, PowerMultiplier.CONFIG );
if ( powerReq < 9.99 )
{
src = eg;
powerReq = eg.extractAEPower( 10, Actionable.SIMULATE, PowerMultiplier.CONFIG );
}
if ( powerReq > 9.99 )
{
src.extractAEPower( 10, Actionable.MODULATE, PowerMultiplier.CONFIG );
if ( processingTime == 0 )
processingTime++;
else
processingTime += TicksSinceLastCall;
}
}
catch (GridAccessException e)
{
// :P
}
if ( processingTime > maxProessingTime ) if ( processingTime > maxProessingTime )
{ {
processingTime = 0; InscriberRecipe out = getTask();
ItemStack out = getTask();
if ( out != null ) if ( out != null )
{ {
setInventorySlotContents( 2, null ); ItemStack is = out.output.copy();
setInventorySlotContents( 3, out ); InventoryAdaptor ad = InventoryAdaptor.getAdaptor( new WrapperInventoryRange( inv, 3, 1, true ), ForgeDirection.UNKNOWN );
if ( ad.addItems( is ) == null )
{
processingTime = 0;
if ( out.usePlates )
{
setInventorySlotContents( 0, null );
setInventorySlotContents( 1, null );
}
setInventorySlotContents( 2, null );
}
} }
} }
return hasWork() ? TickRateModulation.URGENT : TickRateModulation.SLEEP; return hasWork() ? TickRateModulation.URGENT : TickRateModulation.SLEEP;
} }
} }