Inscriber is fully functional, just needs textures.

This commit is contained in:
AlgorithmX2 2014-03-12 22:14:55 -05:00
parent 0ed0af3d34
commit a60d5a4cc7
8 changed files with 301 additions and 92 deletions

View file

@ -114,9 +114,8 @@ public class RenderBlockCharger extends BaseBlockRender
if ( sis != null )
{
applyTESRRotation( x, y, z, tile.getForward(), tile.getUp() );
GL11.glPushMatrix();
applyTESRRotation( x, y, z, tile.getForward(), tile.getUp() );
try
{

View file

@ -6,8 +6,8 @@ import net.minecraft.block.Block;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import net.minecraftforge.common.util.ForgeDirection;
@ -21,7 +21,9 @@ import appeng.block.misc.BlockInscriber;
import appeng.client.render.BaseBlockRender;
import appeng.client.texture.ExtraTextures;
import appeng.core.AELog;
import appeng.recipes.handlers.Inscribe.InscriberRecipe;
import appeng.tile.AEBaseTile;
import appeng.tile.misc.TileInscriber;
import appeng.util.Platform;
public class RenderBlockInscriber extends BaseBlockRender
@ -42,22 +44,14 @@ public class RenderBlockInscriber extends BaseBlockRender
blk.getRendererInstance().setTemporaryRenderIcons( ExtraTextures.BlockChargerInside.getIcon(), null, null, null, null, null );
setInvRenderBounds( renderer, 2, 0, 2, 14, 3, 14 );
// renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
setInvRenderBounds( renderer, 1, 0, 1, 15, 2, 15 );
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
setInvRenderBounds( renderer, 3, 3, 3, 13, 4, 13 );
// renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
setInvRenderBounds( renderer, 1, 14, 1, 15, 16, 15 );
renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
blk.getRendererInstance().setTemporaryRenderIcon( null );
blk.getRendererInstance().setTemporaryRenderIcons( null, ExtraTextures.BlockChargerInside.getIcon(), null, null, null, null );
setInvRenderBounds( renderer, 2, 13, 2, 14, 16, 14 );
// renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
setInvRenderBounds( renderer, 3, 12, 3, 13, 13, 13 );
// renderInvBlock( EnumSet.allOf( ForgeDirection.class ), blk, is, tess, 0xffffff, renderer );
renderer.renderAllFaces = false;
// blk.getRendererInstance().setTemporaryRenderIcon( null );
@ -77,27 +71,26 @@ public class RenderBlockInscriber extends BaseBlockRender
ForgeDirection fdx = Platform.crossProduct( fdz, fdy ).getOpposite();
renderer.renderAllFaces = true;
renderBlockBounds( renderer, 6, 1, 0, 10, 15, 2, fdx, fdy, fdz );
// sides...
renderBlockBounds( renderer, 3, 1, 0, 13, 15, 3, fdx, fdy, fdz );
boolean out = renderer.renderStandardBlock( blk, x, y, z );
blk.getRendererInstance().setTemporaryRenderIcons( ExtraTextures.BlockChargerInside.getIcon(), null, null, null, null, null );
renderBlockBounds( renderer, 0, 1, 0, 3, 15, 16, fdx, fdy, fdz );
out = renderer.renderStandardBlock( blk, x, y, z );
renderBlockBounds( renderer, 2, 0, 2, 14, 3, 14, fdx, fdy, fdz );
// out = renderer.renderStandardBlock( blk, x, y, z );
renderBlockBounds( renderer, 13, 1, 0, 16, 15, 16, fdx, fdy, fdz );
out = renderer.renderStandardBlock( blk, x, y, z );
renderBlockBounds( renderer, 3, 3, 3, 13, 4, 13, fdx, fdy, fdz );
// out = renderer.renderStandardBlock( blk, x, y, z );
// top bottom..
renderBlockBounds( renderer, 1, 0, 1, 15, 4, 15, fdx, fdy, fdz );
out = renderer.renderStandardBlock( blk, x, y, z );
renderBlockBounds( renderer, 1, 12, 1, 15, 16, 15, fdx, fdy, fdz );
out = renderer.renderStandardBlock( blk, x, y, z );
blk.getRendererInstance().setTemporaryRenderIcon( null );
blk.getRendererInstance().setTemporaryRenderIcons( null, ExtraTextures.BlockChargerInside.getIcon(), null, null, null, null );
renderBlockBounds( renderer, 2, 13, 2, 14, 16, 14, fdx, fdy, fdz );
// out = renderer.renderStandardBlock( blk, x, y, z );
renderBlockBounds( renderer, 3, 12, 3, 13, 13, 13, fdx, fdy, fdz );
// out = renderer.renderStandardBlock( blk, x, y, z );
renderer.renderAllFaces = false;
blk.getRendererInstance().setTemporaryRenderIcon( null );
@ -108,19 +101,110 @@ public class RenderBlockInscriber extends BaseBlockRender
@Override
public void renderTile(AEBaseBlock block, AEBaseTile tile, Tessellator tess, double x, double y, double z, float f, RenderBlocks renderer)
{
ItemStack sis = null;
if ( tile instanceof IInventory )
sis = ((IInventory) tile).getStackInSlot( 0 );
TileInscriber inv = (TileInscriber) tile;
GL11.glPushMatrix();
applyTESRRotation( x, y, z, tile.getForward(), tile.getUp() );
int light = tile.getWorldObj().getLightBrightnessForSkyBlocks( tile.xCoord, tile.yCoord, tile.zCoord, 0 );
int br = light;// << 20 | light << 4;
int var11 = br % 65536;
int var12 = br / 65536;
OpenGlHelper.setLightmapTextureCoords( OpenGlHelper.lightmapTexUnit, var11, var12 );
float TwoPx = 2.0f / 16.0f;
float middle = 0.5f;
float press = 0.2f;
float base = 0.4f;
long lprogress = 0;
if ( inv.smash )
{
long currentTime = System.currentTimeMillis();
lprogress = currentTime - inv.clientStart;
if ( lprogress > 800 )
inv.smash = false;
}
float rprogress = (float) (lprogress % 800) / 400.0f;
float progress = rprogress;
if ( progress > 1.0f )
progress = 1.0f - (progress - 1.0f);
press -= progress / 5.0f;
IIcon ic = ExtraTextures.MEDenseEnergyCell0.getIcon();
tess.startDrawingQuads();
middle += 0.02f;
tess.addVertexWithUV( TwoPx, middle + press, TwoPx, ic.getInterpolatedU( 2 ), ic.getInterpolatedV( 2 ) );
tess.addVertexWithUV( 1.0 - TwoPx, middle + press, TwoPx, ic.getInterpolatedU( 14 ), ic.getInterpolatedV( 2 ) );
tess.addVertexWithUV( 1.0 - TwoPx, middle + press, 1.0 - TwoPx, ic.getInterpolatedU( 14 ), ic.getInterpolatedV( 14 ) );
tess.addVertexWithUV( TwoPx, middle + press, 1.0 - TwoPx, ic.getInterpolatedU( 2 ), ic.getInterpolatedV( 14 ) );
tess.addVertexWithUV( TwoPx, middle + press, 1.0 - TwoPx, ic.getInterpolatedU( 2 ), ic.getInterpolatedV( 2 ) );
tess.addVertexWithUV( 1.0 - TwoPx, middle + press, 1.0 - TwoPx, ic.getInterpolatedU( 14 ), ic.getInterpolatedV( 2 ) );
tess.addVertexWithUV( 1.0 - TwoPx, middle + base, 1.0 - TwoPx, ic.getInterpolatedU( 14 ), ic.getInterpolatedV( 2 + 16 * (press - base) ) );
tess.addVertexWithUV( TwoPx, middle + base, 1.0 - TwoPx, ic.getInterpolatedU( 2 ), ic.getInterpolatedV( 2 + 16 * (press - base) ) );
middle -= 2.0f * 0.02f;
tess.addVertexWithUV( 1.0 - TwoPx, middle - press, TwoPx, ic.getInterpolatedU( 2 ), ic.getInterpolatedV( 2 ) );
tess.addVertexWithUV( TwoPx, middle - press, TwoPx, ic.getInterpolatedU( 14 ), ic.getInterpolatedV( 2 ) );
tess.addVertexWithUV( TwoPx, middle - press, 1.0 - TwoPx, ic.getInterpolatedU( 14 ), ic.getInterpolatedV( 14 ) );
tess.addVertexWithUV( 1.0 - TwoPx, middle - press, 1.0 - TwoPx, ic.getInterpolatedU( 2 ), ic.getInterpolatedV( 14 ) );
tess.addVertexWithUV( 1.0 - TwoPx, middle - press, 1.0 - TwoPx, ic.getInterpolatedU( 2 ), ic.getInterpolatedV( 2 ) );
tess.addVertexWithUV( TwoPx, middle - press, 1.0 - TwoPx, ic.getInterpolatedU( 14 ), ic.getInterpolatedV( 2 ) );
tess.addVertexWithUV( TwoPx, middle - base, 1.0 - TwoPx, ic.getInterpolatedU( 14 ), ic.getInterpolatedV( 2 + 16 * (press - base) ) );
tess.addVertexWithUV( 1.0 - TwoPx, middle + -base, 1.0 - TwoPx, ic.getInterpolatedU( 2 ), ic.getInterpolatedV( 2 + 16 * (press - base) ) );
tess.draw();
GL11.glPopMatrix();
int items = 0;
if ( inv.getStackInSlot( 0 ) != null )
items++;
if ( inv.getStackInSlot( 1 ) != null )
items++;
if ( inv.getStackInSlot( 2 ) != null )
items++;
if ( rprogress > 1.0f || items == 0 )
{
ItemStack is = inv.getStackInSlot( 3 );
if ( is == null )
{
InscriberRecipe ir = inv.getTask();
if ( ir != null )
is = ir.output.copy();
}
renderItem( is, 0.0f, block, tile, tess, x, y, z, f, renderer );
}
else
{
renderItem( inv.getStackInSlot( 0 ), press, block, tile, tess, x, y, z, f, renderer );
renderItem( inv.getStackInSlot( 1 ), -press, block, tile, tess, x, y, z, f, renderer );
renderItem( inv.getStackInSlot( 2 ), 0.0f, block, tile, tess, x, y, z, f, renderer );
}
}
public void renderItem(ItemStack sis, float o, AEBaseBlock block, AEBaseTile tile, Tessellator tess, double x, double y, double z, float f,
RenderBlocks renderer)
{
if ( sis != null )
{
applyTESRRotation( x, y, z, tile.getForward(), tile.getUp() );
sis = sis.copy();
GL11.glPushMatrix();
applyTESRRotation( x, y, z, tile.getForward(), tile.getUp() );
try
{
GL11.glTranslatef( 0.5f, 0.45f, 0.5f );
GL11.glTranslatef( 0.5f, 0.5f + o, 0.5f );
GL11.glScalef( 1.0f / 1.1f, 1.0f / 1.1f, 1.0f / 1.1f );
GL11.glScalef( 1.0f, 1.0f, 1.0f );
@ -132,6 +216,8 @@ public class RenderBlockInscriber extends BaseBlockRender
GL11.glRotatef( 30.0f, 0.0f, 1.0f, 0.0f );
}
GL11.glRotatef( 90.0f, 1, 0, 0 );
int light = tile.getWorldObj().getLightBrightnessForSkyBlocks( tile.xCoord, tile.yCoord, tile.zCoord, 0 );
int br = light;// << 20 | light << 4;
int var11 = br % 65536;

View file

@ -140,6 +140,9 @@ public class SlotRestrictedInput extends AppEngSlot
case INSCRIBER_PLATE:
if ( AEApi.instance().materials().materialNamePress.sameAs( i ) )
return true;
for (ItemStack is : Inscribe.plates)
if ( Platform.isSameItemPrecise( is, i ) )
return true;
@ -147,12 +150,11 @@ public class SlotRestrictedInput extends AppEngSlot
return false;
case INSCRIBER_INPUT:
for (ItemStack is : Inscribe.inputs)
if ( Platform.isSameItemPrecise( is, i ) )
return true;
return false;
return true;/*
* for (ItemStack is : Inscribe.inputs) if ( Platform.isSameItemPrecise( is, i ) ) return true;
*
* return false;
*/
case METAL_INGOTS:

View file

@ -3,6 +3,7 @@ package appeng.core;
import org.apache.logging.log4j.Level;
import appeng.core.features.AEFeature;
import appeng.tile.AEBaseTile;
import appeng.util.Platform;
import cpw.mods.fml.relauncher.FMLRelaunchLog;
@ -58,4 +59,12 @@ public class AELog
error( exception );
}
}
public static void blockUpdate(int xCoord, int yCoord, int zCoord, AEBaseTile aeBaseTile)
{
if ( AEConfig.instance.isFeatureEnabled( AEFeature.UpdateLogging ) )
{
info( aeBaseTile.getClass().getName() + " @ " + xCoord + ", " + yCoord + ", " + zCoord );
}
}
}

View file

@ -50,7 +50,7 @@ public enum AEFeature
Logging("Misc"), IntegrationLogging("Misc", false), CustomRecipes("Crafting", false), WebsiteRecipes("Misc", false),
inWorldSingularity("Crafting"), inWorldFluix("Crafting"), inWorldPurification("Crafting");
inWorldSingularity("Crafting"), inWorldFluix("Crafting"), inWorldPurification("Crafting"), UpdateLogging("Misc", false);
String Category;
boolean visible = true;

View file

@ -16,7 +16,7 @@ import appeng.util.Platform;
public class Inscribe implements ICraftHandler, IWebsiteSeralizer
{
public class InscriberRecipe
public static class InscriberRecipe
{
public InscriberRecipe(ItemStack[] imprintable, ItemStack plateA, ItemStack plateB, ItemStack out, boolean usePlates) {

View file

@ -284,7 +284,10 @@ public class AEBaseTile extends TileEntity implements IOrientable, ICommonTile
{
// TODO: Optimize Network Load
if ( worldObj != null )
{
AELog.blockUpdate( xCoord, yCoord, zCoord, this );
worldObj.markBlockForUpdate( xCoord, yCoord, zCoord );
}
}
}

View file

@ -9,6 +9,7 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.PowerMultiplier;
import appeng.api.networking.IGridNode;
@ -43,6 +44,12 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
public final int maxProessingTime = 100;
public int processingTime = 0;
// cycles from 0 - 16, at 8 it preforms the action, at 16 it reenables the normal rotuine.
public boolean smash;
public int finalStep;
public long clientStart;
@Override
public AECableType getCableConnectionType(ForgeDirection dir)
{
@ -73,6 +80,15 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
{
int slot = data.readByte();
boolean oldSmash = smash;
boolean newSmash = (slot & 64) == 64;
if ( oldSmash != newSmash && newSmash )
{
smash = true;
clientStart = System.currentTimeMillis();
}
for (int num = 0; num < inv.getSizeInventory(); num++)
{
if ( (slot & (1 << num)) > 0 )
@ -87,7 +103,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
@Override
public void writeToStream(ByteBuf data) throws IOException
{
int slot = 0;
int slot = smash ? 64 : 0;
for (int num = 0; num < inv.getSizeInventory(); num++)
{
@ -114,6 +130,12 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
};
@Override
public boolean requiresTESR()
{
return true;
}
public TileInscriber() {
gridProxy.setValidSides( EnumSet.noneOf( ForgeDirection.class ) );
internalMaxPower = 1500;
@ -126,8 +148,8 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
{
super.setOrientation( inForward, inUp );
ForgeDirection right = Platform.crossProduct( getForward(), getUp() );
gridProxy.setValidSides( EnumSet.of( getForward().getOpposite(), right, right.getOpposite() ) );
setPowerSides( EnumSet.of( getForward().getOpposite(), right, right.getOpposite() ) );
gridProxy.setValidSides( EnumSet.complementOf( EnumSet.of( getForward() ) ) );
setPowerSides( EnumSet.complementOf( EnumSet.of( getForward() ) ) );
}
@Override
@ -159,8 +181,14 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
{
if ( smash )
return false;
if ( i == 0 || i == 1 )
{
if ( AEApi.instance().materials().materialNamePress.sameAs( itemstack ) )
return true;
for (ItemStack s : Inscribe.plates)
if ( Platform.isSameItemPrecise( s, itemstack ) )
return true;
@ -168,9 +196,10 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
if ( i == 2 )
{
for (ItemStack s : Inscribe.inputs)
if ( Platform.isSameItemPrecise( s, itemstack ) )
return true;
return true;
// for (ItemStack s : Inscribe.inputs)
// if ( Platform.isSameItemPrecise( s, itemstack ) )
// return true;
}
return false;
@ -179,6 +208,9 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
@Override
public boolean canExtractItem(int i, ItemStack itemstack, int j)
{
if ( smash )
return false;
return i == 0 || i == 1 || i == 3;
}
@ -191,6 +223,10 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
{
if ( slot != 3 )
processingTime = 0;
if ( !smash )
markForUpdate();
gridProxy.getTick().wakeDevice( gridProxy.getNode() );
}
}
@ -200,13 +236,53 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
}
}
private InscriberRecipe getTask()
public InscriberRecipe getTask()
{
ItemStack PlateA = getStackInSlot( 0 );
ItemStack PlateB = getStackInSlot( 1 );
boolean isNameA = AEApi.instance().materials().materialNamePress.sameAs( PlateA );
boolean isNameB = AEApi.instance().materials().materialNamePress.sameAs( PlateB );
if ( (isNameA || isNameB) && (isNameA || PlateA == null) && (isNameB || PlateB == null) )
{
ItemStack renamedItem = getStackInSlot( 2 );
if ( renamedItem != null )
{
String name = "";
if ( PlateA != null )
{
NBTTagCompound tag = Platform.openNbtData( PlateA );
name += tag.getString( "InscribeName" );
}
if ( PlateB != null )
{
NBTTagCompound tag = Platform.openNbtData( PlateB );
if ( name.length() > 0 )
name += " ";
name += tag.getString( "InscribeName" );
}
ItemStack startingItem = renamedItem.copy();
renamedItem = renamedItem.copy();
NBTTagCompound tag = Platform.openNbtData( renamedItem );
NBTTagCompound display = tag.getCompoundTag( "display" );
tag.setTag( "display", display );
if ( name.length() > 0 )
display.setString( "Name", name );
else
display.removeTag( "Name" );
return new InscriberRecipe( new ItemStack[] { startingItem }, PlateA, PlateB, renamedItem, false );
}
}
for (InscriberRecipe i : Inscribe.recipes)
{
ItemStack PlateA = getStackInSlot( 0 );
ItemStack PlateB = getStackInSlot( 1 );
boolean matchA = (PlateA == null && i.plateA == null) || (Platform.isSameItemPrecise( PlateA, i.plateA )) && // and...
(PlateB == null && i.plateB == null) | (Platform.isSameItemPrecise( PlateB, i.plateB ));
@ -233,7 +309,7 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
return true;
processingTime = 0;
return false;
return false || smash;
}
@Override
@ -245,51 +321,85 @@ public class TileInscriber extends AENetworkPowerTile implements IGridTickable
@Override
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall)
{
IEnergyGrid eg;
try
if ( smash )
{
eg = gridProxy.getEnergy();
IEnergySource src = this;
double powerReq = extractAEPower( 10, Actionable.SIMULATE, PowerMultiplier.CONFIG );
if ( powerReq < 9.99 )
finalStep++;
if ( finalStep == 8 )
{
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 )
{
InscriberRecipe out = getTask();
if ( out != null )
{
ItemStack is = out.output.copy();
InventoryAdaptor ad = InventoryAdaptor.getAdaptor( new WrapperInventoryRange( inv, 3, 1, true ), ForgeDirection.UNKNOWN );
if ( ad.addItems( is ) == null )
InscriberRecipe out = getTask();
if ( out != null )
{
processingTime = 0;
if ( out.usePlates )
ItemStack is = out.output.copy();
InventoryAdaptor ad = InventoryAdaptor.getAdaptor( new WrapperInventoryRange( inv, 3, 1, true ), ForgeDirection.UNKNOWN );
if ( ad.addItems( is ) == null )
{
setInventorySlotContents( 0, null );
setInventorySlotContents( 1, null );
processingTime = 0;
if ( out.usePlates )
{
setInventorySlotContents( 0, null );
setInventorySlotContents( 1, null );
}
setInventorySlotContents( 2, null );
}
}
markDirty();
}
else if ( finalStep == 16 )
{
finalStep = 0;
smash = false;
markForUpdate();
}
}
else
{
IEnergyGrid eg;
try
{
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 )
{
processingTime = maxProessingTime;
InscriberRecipe out = getTask();
if ( out != null )
{
ItemStack is = out.output.copy();
InventoryAdaptor ad = InventoryAdaptor.getAdaptor( new WrapperInventoryRange( inv, 3, 1, true ), ForgeDirection.UNKNOWN );
if ( ad.simulateAdd( is ) == null )
{
smash = true;
finalStep = 0;
markForUpdate();
}
setInventorySlotContents( 2, null );
}
}
}