Added Imprinter
This commit is contained in:
parent
605d4212c5
commit
00403e800b
11 changed files with 485 additions and 909 deletions
|
@ -5,6 +5,8 @@ import resonantinduction.archaic.crate.BlockCrate;
|
||||||
import resonantinduction.archaic.crate.TileCrate;
|
import resonantinduction.archaic.crate.TileCrate;
|
||||||
import resonantinduction.archaic.engineering.BlockEngineeringTable;
|
import resonantinduction.archaic.engineering.BlockEngineeringTable;
|
||||||
import resonantinduction.archaic.engineering.TileEngineeringTable;
|
import resonantinduction.archaic.engineering.TileEngineeringTable;
|
||||||
|
import resonantinduction.archaic.imprint.BlockImprinter;
|
||||||
|
import resonantinduction.archaic.imprint.TileImprinter;
|
||||||
import resonantinduction.core.Reference;
|
import resonantinduction.core.Reference;
|
||||||
import resonantinduction.core.ResonantInduction;
|
import resonantinduction.core.ResonantInduction;
|
||||||
import resonantinduction.core.Settings;
|
import resonantinduction.core.Settings;
|
||||||
|
@ -47,6 +49,7 @@ public class Archaic
|
||||||
|
|
||||||
public static Block blockEngineeringTable;
|
public static Block blockEngineeringTable;
|
||||||
public static Block blockCrate;
|
public static Block blockCrate;
|
||||||
|
public static Block blockImprinter;
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void preInit(FMLPreInitializationEvent evt)
|
public void preInit(FMLPreInitializationEvent evt)
|
||||||
|
@ -54,6 +57,7 @@ public class Archaic
|
||||||
NetworkRegistry.instance().registerGuiHandler(this, proxy);
|
NetworkRegistry.instance().registerGuiHandler(this, proxy);
|
||||||
blockEngineeringTable = contentRegistry.createTile(BlockEngineeringTable.class, TileEngineeringTable.class);
|
blockEngineeringTable = contentRegistry.createTile(BlockEngineeringTable.class, TileEngineeringTable.class);
|
||||||
blockCrate = contentRegistry.createTile(BlockCrate.class, TileCrate.class);
|
blockCrate = contentRegistry.createTile(BlockCrate.class, TileCrate.class);
|
||||||
|
blockImprinter = contentRegistry.createTile(BlockImprinter.class, TileImprinter.class);
|
||||||
proxy.preInit();
|
proxy.preInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package resonantinduction.archaic.crate;
|
package resonantinduction.archaic.crate;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.minecraft.client.renderer.texture.IconRegister;
|
import net.minecraft.client.renderer.texture.IconRegister;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.EntityPlayerMP;
|
import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
@ -414,4 +417,12 @@ public class BlockCrate extends BlockRI
|
||||||
{
|
{
|
||||||
return new TileCrate();
|
return new TileCrate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||||
|
{
|
||||||
|
par3List.add(new ItemStack(par1, 1, 0));
|
||||||
|
par3List.add(new ItemStack(par1, 1, 1));
|
||||||
|
par3List.add(new ItemStack(par1, 1, 2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,198 +1,21 @@
|
||||||
package resonantinduction.archaic.crate;
|
package resonantinduction.archaic.crate;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
|
||||||
import net.minecraft.client.renderer.RenderBlocks;
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
import net.minecraft.client.renderer.entity.RenderItem;
|
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.world.World;
|
import resonantinduction.core.render.RenderItemOverlayTile;
|
||||||
import net.minecraftforge.client.ForgeHooksClient;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import universalelectricity.api.vector.Vector3;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public class RenderCrate extends TileEntitySpecialRenderer
|
public class RenderCrate extends RenderItemOverlayTile
|
||||||
{
|
{
|
||||||
private final RenderBlocks renderBlocks = new RenderBlocks();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
||||||
{
|
{
|
||||||
Vector3 vec = new Vector3(x, y, z);
|
|
||||||
double distance = vec.distance(new Vector3(0, 0, 0));
|
|
||||||
if (tileEntity instanceof TileCrate)
|
if (tileEntity instanceof TileCrate)
|
||||||
{
|
{
|
||||||
|
TileCrate tile = (TileCrate) tileEntity;
|
||||||
TileCrate tileCrate = (TileCrate) tileEntity;
|
renderItemOnSides(tileEntity, tile.getSampleStack(), x, y, z, "Empty");
|
||||||
|
|
||||||
RenderItem renderItem = ((RenderItem) RenderManager.instance.getEntityClassRenderObject(EntityItem.class));
|
|
||||||
|
|
||||||
String itemName = "Empty";
|
|
||||||
String amount = "";
|
|
||||||
ItemStack itemStack = tileCrate.getSampleStack();
|
|
||||||
|
|
||||||
if (itemStack != null)
|
|
||||||
{
|
|
||||||
itemName = itemStack.getDisplayName();
|
|
||||||
amount = Integer.toString(itemStack.stackSize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int side = 2; side < 6; side++)
|
|
||||||
{
|
|
||||||
ForgeDirection direction = ForgeDirection.getOrientation(side);
|
|
||||||
if (tileCrate.worldObj.isBlockSolidOnSide(tileCrate.xCoord + direction.offsetX, tileCrate.yCoord, tileCrate.zCoord + direction.offsetZ, direction.getOpposite()))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
this.setupLight(tileCrate, direction.offsetX, direction.offsetZ);
|
|
||||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
|
|
||||||
|
|
||||||
if (itemStack != null)
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
|
|
||||||
switch (side)
|
|
||||||
{
|
|
||||||
case 2:
|
|
||||||
GL11.glTranslated(x + 0.65, y + 0.9, z - 0.01);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
GL11.glTranslated(x + 0.35, y + 0.9, z + 1.01);
|
|
||||||
GL11.glRotatef(180, 0, 1, 0);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
GL11.glTranslated(x - 0.01, y + 0.9, z + 0.35);
|
|
||||||
GL11.glRotatef(90, 0, 1, 0);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
GL11.glTranslated(x + 1.01, y + 0.9, z + 0.65);
|
|
||||||
GL11.glRotatef(-90, 0, 1, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
float scale = 0.03125F;
|
|
||||||
GL11.glScalef(0.6f * scale, 0.6f * scale, 0);
|
|
||||||
GL11.glRotatef(180, 0, 0, 1);
|
|
||||||
|
|
||||||
TextureManager renderEngine = Minecraft.getMinecraft().renderEngine;
|
|
||||||
|
|
||||||
GL11.glDisable(2896);
|
|
||||||
if (!ForgeHooksClient.renderInventoryItem(this.renderBlocks, renderEngine, itemStack, true, 0.0F, 0.0F, 0.0F))
|
|
||||||
{
|
|
||||||
renderItem.renderItemIntoGUI(this.getFontRenderer(), renderEngine, itemStack, 0, 0);
|
|
||||||
}
|
|
||||||
GL11.glEnable(2896);
|
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.renderText(itemName, side, 0.02f, x, y - 0.35f, z);
|
|
||||||
this.renderText(amount, side, 0.02f, x, y - 0.15f, z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupLight(TileEntity tileEntity, int xDifference, int zDifference)
|
|
||||||
{
|
|
||||||
World world = tileEntity.worldObj;
|
|
||||||
|
|
||||||
if (world.isBlockOpaqueCube(tileEntity.xCoord + xDifference, tileEntity.yCoord, tileEntity.zCoord + zDifference))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int br = world.getLightBrightnessForSkyBlocks(tileEntity.xCoord + xDifference, tileEntity.yCoord, tileEntity.zCoord + zDifference, 0);
|
|
||||||
int var11 = br % 65536;
|
|
||||||
int var12 = br / 65536;
|
|
||||||
float scale = 0.6F;
|
|
||||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var11 * scale, var12 * scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderText(String text, int side, float maxScale, double x, double y, double z)
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
|
|
||||||
GL11.glPolygonOffset(-10, -10);
|
|
||||||
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
|
|
||||||
|
|
||||||
float displayWidth = 1 - (2 / 16);
|
|
||||||
float displayHeight = 1 - (2 / 16);
|
|
||||||
GL11.glTranslated(x, y, z);
|
|
||||||
|
|
||||||
switch (side)
|
|
||||||
{
|
|
||||||
case 3:
|
|
||||||
GL11.glTranslatef(0, 1, 0);
|
|
||||||
GL11.glRotatef(0, 0, 1, 0);
|
|
||||||
GL11.glRotatef(90, 1, 0, 0);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
GL11.glTranslatef(1, 1, 1);
|
|
||||||
GL11.glRotatef(180, 0, 1, 0);
|
|
||||||
GL11.glRotatef(90, 1, 0, 0);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
GL11.glTranslatef(0, 1, 1);
|
|
||||||
GL11.glRotatef(90, 0, 1, 0);
|
|
||||||
GL11.glRotatef(90, 1, 0, 0);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
GL11.glTranslatef(1, 1, 0);
|
|
||||||
GL11.glRotatef(-90, 0, 1, 0);
|
|
||||||
GL11.glRotatef(90, 1, 0, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find Center
|
|
||||||
GL11.glTranslatef(displayWidth / 2, 1F, displayHeight / 2);
|
|
||||||
GL11.glRotatef(-90, 1, 0, 0);
|
|
||||||
|
|
||||||
FontRenderer fontRenderer = this.getFontRenderer();
|
|
||||||
|
|
||||||
int requiredWidth = Math.max(fontRenderer.getStringWidth(text), 1);
|
|
||||||
int lineHeight = fontRenderer.FONT_HEIGHT + 2;
|
|
||||||
int requiredHeight = lineHeight * 1;
|
|
||||||
float scaler = 0.8f;
|
|
||||||
float scaleX = (displayWidth / requiredWidth);
|
|
||||||
float scaleY = (displayHeight / requiredHeight);
|
|
||||||
float scale = scaleX * scaler;
|
|
||||||
|
|
||||||
if (maxScale > 0)
|
|
||||||
{
|
|
||||||
scale = Math.min(scale, maxScale);
|
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glScalef(scale, -scale, scale);
|
|
||||||
GL11.glDepthMask(false);
|
|
||||||
|
|
||||||
int offsetX;
|
|
||||||
int offsetY;
|
|
||||||
int realHeight = (int) Math.floor(displayHeight / scale);
|
|
||||||
int realWidth = (int) Math.floor(displayWidth / scale);
|
|
||||||
|
|
||||||
offsetX = (realWidth - requiredWidth) / 2;
|
|
||||||
offsetY = (realHeight - requiredHeight) / 2;
|
|
||||||
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
fontRenderer.drawString("\u00a7f" + text, offsetX - (realWidth / 2), 1 + offsetY - (realHeight / 2), 1);
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glDepthMask(true);
|
|
||||||
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
|
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Icon;
|
import net.minecraft.util.Icon;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import resonantinduction.archaic.imprint.TileImprinter;
|
|
||||||
import resonantinduction.core.prefab.block.BlockRI;
|
import resonantinduction.core.prefab.block.BlockRI;
|
||||||
import universalelectricity.api.vector.Vector2;
|
import universalelectricity.api.vector.Vector2;
|
||||||
import universalelectricity.api.vector.Vector3;
|
import universalelectricity.api.vector.Vector3;
|
||||||
|
@ -103,7 +102,7 @@ public class BlockEngineeringTable extends BlockRI
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int hitSide, float hitX, float hitY, float hitZ)
|
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int hitSide, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
TileEntity te = world.getBlockTileEntity(x, y, z);
|
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
|
@ -222,14 +221,15 @@ public class BlockEngineeringTable extends BlockRI
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
public boolean onUseWrench(World worldorld, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
TileEntity tileEntity = par1World.getBlockTileEntity(x, y, z);
|
TileEntity tileEntity = worldorld.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
if (tileEntity instanceof TileImprinter)
|
if (tileEntity instanceof TileEngineeringTable)
|
||||||
{
|
{
|
||||||
((TileImprinter) tileEntity).searchInventories = !((TileImprinter) tileEntity).searchInventories;
|
TileEngineeringTable tile = (TileEngineeringTable) tileEntity;
|
||||||
par1World.markBlockForUpdate(x, y, z);
|
tile.searchInventories = !tile.searchInventories;
|
||||||
|
worldorld.markBlockForUpdate(x, y, z);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,269 +1,25 @@
|
||||||
package resonantinduction.archaic.engineering;
|
package resonantinduction.archaic.engineering;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
|
||||||
import net.minecraft.client.renderer.OpenGlHelper;
|
|
||||||
import net.minecraft.client.renderer.RenderBlocks;
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
import net.minecraft.client.renderer.entity.RenderItem;
|
|
||||||
import net.minecraft.client.renderer.entity.RenderManager;
|
|
||||||
import net.minecraft.client.renderer.texture.TextureManager;
|
|
||||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
import resonantinduction.core.render.RenderItemOverlayTile;
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.client.ForgeHooksClient;
|
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import universalelectricity.api.vector.Vector3;
|
import universalelectricity.api.vector.Vector3;
|
||||||
import calclavia.lib.render.RenderUtility;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public class RenderEngineeringTable extends TileEntitySpecialRenderer
|
public class RenderEngineeringTable extends RenderItemOverlayTile
|
||||||
{
|
{
|
||||||
private final RenderBlocks renderBlocks = new RenderBlocks();
|
private final RenderBlocks renderBlocks = new RenderBlocks();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
||||||
{
|
{
|
||||||
Vector3 vec = new Vector3(x, y, z);
|
|
||||||
double distance = vec.distance(new Vector3(0, 0, 0));
|
|
||||||
|
|
||||||
if (tileEntity instanceof TileEngineeringTable)
|
if (tileEntity instanceof TileEngineeringTable)
|
||||||
{
|
{
|
||||||
TileEngineeringTable tile = (TileEngineeringTable) tileEntity;
|
TileEngineeringTable tile = (TileEngineeringTable) tileEntity;
|
||||||
|
renderTopCrafting(tileEntity, tile.craftingMatrix, x, y, z);
|
||||||
RenderItem renderItem = ((RenderItem) RenderManager.instance.getEntityClassRenderObject(EntityItem.class));
|
renderItemOnSides(tileEntity, tile.getStackInSlot(9), x, y, z);
|
||||||
|
|
||||||
/**
|
|
||||||
* Render the Crafting Matrix
|
|
||||||
*/
|
|
||||||
|
|
||||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
|
||||||
MovingObjectPosition objectPosition = player.rayTrace(8, 1);
|
|
||||||
boolean isLooking = false;
|
|
||||||
|
|
||||||
if (objectPosition != null)
|
|
||||||
{
|
|
||||||
isLooking |= objectPosition.blockX == tile.xCoord && objectPosition.blockY == tile.yCoord && objectPosition.blockZ == tile.zCoord;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < tile.craftingMatrix.length; i++)
|
|
||||||
{
|
|
||||||
if (tile.craftingMatrix[i] != null)
|
|
||||||
{
|
|
||||||
Vector3 translation = new Vector3(x + (double) (i / 3) / 3d + (0.5 / 3d), y + 1.1, z + (double) (i % 3) / 3d + (0.5 / 3d));
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glTranslated(translation.x, translation.y, translation.z);
|
|
||||||
GL11.glScalef(0.7f, 0.7f, 0.7f);
|
|
||||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
|
|
||||||
this.renderItem(tileEntity.worldObj, ForgeDirection.UP, tile.craftingMatrix[i], new Vector3(), 0, 0);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
|
|
||||||
if (isLooking)
|
|
||||||
RenderUtility.renderFloatingText("" + tile.craftingMatrix[i].stackSize, (float) translation.x, (float) translation.y - 2f, (float) translation.z);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Render the Output
|
|
||||||
*/
|
|
||||||
String itemName = "No Output";
|
|
||||||
String amount = "";
|
|
||||||
ItemStack itemStack = tile.getStackInSlot(9);
|
|
||||||
|
|
||||||
if (itemStack != null)
|
|
||||||
{
|
|
||||||
itemName = itemStack.getDisplayName();
|
|
||||||
amount = Integer.toString(itemStack.stackSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int side = 2; side < 6; side++)
|
|
||||||
{
|
|
||||||
ForgeDirection direction = ForgeDirection.getOrientation(side);
|
|
||||||
|
|
||||||
if (tile.worldObj.isBlockSolidOnSide(tile.xCoord + direction.offsetX, tile.yCoord, tile.zCoord + direction.offsetZ, direction.getOpposite()))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setupLight(tile, direction.offsetX, direction.offsetZ);
|
|
||||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
|
|
||||||
|
|
||||||
if (itemStack != null)
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
|
|
||||||
switch (side)
|
|
||||||
{
|
|
||||||
case 2:
|
|
||||||
GL11.glTranslated(x + 0.65, y + 0.9, z - 0.01);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
GL11.glTranslated(x + 0.35, y + 0.9, z + 1.01);
|
|
||||||
GL11.glRotatef(180, 0, 1, 0);
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
GL11.glTranslated(x - 0.01, y + 0.9, z + 0.35);
|
|
||||||
GL11.glRotatef(90, 0, 1, 0);
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
GL11.glTranslated(x + 1.01, y + 0.9, z + 0.65);
|
|
||||||
GL11.glRotatef(-90, 0, 1, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
float scale = 0.03125F;
|
|
||||||
GL11.glScalef(0.6f * scale, 0.6f * scale, 0);
|
|
||||||
GL11.glRotatef(180, 0, 0, 1);
|
|
||||||
|
|
||||||
TextureManager renderEngine = Minecraft.getMinecraft().renderEngine;
|
|
||||||
|
|
||||||
GL11.glDisable(2896);
|
|
||||||
if (!ForgeHooksClient.renderInventoryItem(this.renderBlocks, renderEngine, itemStack, true, 0.0F, 0.0F, 0.0F))
|
|
||||||
{
|
|
||||||
renderItem.renderItemIntoGUI(this.getFontRenderer(), renderEngine, itemStack, 0, 0);
|
|
||||||
}
|
|
||||||
GL11.glEnable(2896);
|
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.renderText(itemName, side, 0.02f, x, y - 0.35f, z);
|
|
||||||
this.renderText(amount, side, 0.02f, x, y - 0.15f, z);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupLight(TileEntity tileEntity, int xDifference, int zDifference)
|
|
||||||
{
|
|
||||||
World world = tileEntity.worldObj;
|
|
||||||
|
|
||||||
if (world.isBlockOpaqueCube(tileEntity.xCoord + xDifference, tileEntity.yCoord, tileEntity.zCoord + zDifference))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int br = world.getLightBrightnessForSkyBlocks(tileEntity.xCoord + xDifference, tileEntity.yCoord, tileEntity.zCoord + zDifference, 0);
|
|
||||||
int var11 = br % 65536;
|
|
||||||
int var12 = br / 65536;
|
|
||||||
float scale = 0.6F;
|
|
||||||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var11 * scale, var12 * scale);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderText(String text, int side, float maxScale, double x, double y, double z)
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
|
|
||||||
GL11.glPolygonOffset(-10, -10);
|
|
||||||
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
|
|
||||||
|
|
||||||
float displayWidth = 1 - (2 / 16);
|
|
||||||
float displayHeight = 1 - (2 / 16);
|
|
||||||
GL11.glTranslated(x, y, z);
|
|
||||||
|
|
||||||
switch (side)
|
|
||||||
{
|
|
||||||
case 3:
|
|
||||||
GL11.glTranslatef(0, 1, 0);
|
|
||||||
GL11.glRotatef(0, 0, 1, 0);
|
|
||||||
GL11.glRotatef(90, 1, 0, 0);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
GL11.glTranslatef(1, 1, 1);
|
|
||||||
GL11.glRotatef(180, 0, 1, 0);
|
|
||||||
GL11.glRotatef(90, 1, 0, 0);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
GL11.glTranslatef(0, 1, 1);
|
|
||||||
GL11.glRotatef(90, 0, 1, 0);
|
|
||||||
GL11.glRotatef(90, 1, 0, 0);
|
|
||||||
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
GL11.glTranslatef(1, 1, 0);
|
|
||||||
GL11.glRotatef(-90, 0, 1, 0);
|
|
||||||
GL11.glRotatef(90, 1, 0, 0);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find Center
|
|
||||||
GL11.glTranslatef(displayWidth / 2, 1F, displayHeight / 2);
|
|
||||||
GL11.glRotatef(-90, 1, 0, 0);
|
|
||||||
|
|
||||||
FontRenderer fontRenderer = this.getFontRenderer();
|
|
||||||
|
|
||||||
int requiredWidth = Math.max(fontRenderer.getStringWidth(text), 1);
|
|
||||||
int lineHeight = fontRenderer.FONT_HEIGHT + 2;
|
|
||||||
int requiredHeight = lineHeight * 1;
|
|
||||||
float scaler = 0.8f;
|
|
||||||
float scaleX = (displayWidth / requiredWidth);
|
|
||||||
float scaleY = (displayHeight / requiredHeight);
|
|
||||||
float scale = scaleX * scaler;
|
|
||||||
|
|
||||||
if (maxScale > 0)
|
|
||||||
{
|
|
||||||
scale = Math.min(scale, maxScale);
|
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glScalef(scale, -scale, scale);
|
|
||||||
GL11.glDepthMask(false);
|
|
||||||
|
|
||||||
int offsetX;
|
|
||||||
int offsetY;
|
|
||||||
int realHeight = (int) Math.floor(displayHeight / scale);
|
|
||||||
int realWidth = (int) Math.floor(displayWidth / scale);
|
|
||||||
|
|
||||||
offsetX = (realWidth - requiredWidth) / 2;
|
|
||||||
offsetY = (realHeight - requiredHeight) / 2;
|
|
||||||
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
fontRenderer.drawString("\u00a7f" + text, offsetX - (realWidth / 2), 1 + offsetY - (realHeight / 2), 1);
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glDepthMask(true);
|
|
||||||
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
|
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void renderItem(World world, ForgeDirection dir, ItemStack itemStack, Vector3 position, float rotationYaw, int angle)
|
|
||||||
{
|
|
||||||
if (itemStack != null)
|
|
||||||
{
|
|
||||||
EntityItem entityitem = new EntityItem(world, 0.0D, 0.0D, 0.0D, itemStack.copy());
|
|
||||||
entityitem.getEntityItem().stackSize = 1;
|
|
||||||
entityitem.hoverStart = 0.0F;
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glTranslatef(-0.453125F * (float) dir.offsetX, -0.18F, -0.453125F * (float) dir.offsetZ);
|
|
||||||
GL11.glRotatef(180.0F + rotationYaw, 0.0F, 1.0F, 0.0F);
|
|
||||||
GL11.glRotatef((float) (-90 * angle), 0.0F, 0.0F, 1.0F);
|
|
||||||
|
|
||||||
switch (angle)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
GL11.glTranslatef(-0.16F, -0.16F, 0.0F);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
GL11.glTranslatef(0.0F, -0.32F, 0.0F);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
GL11.glTranslatef(0.16F, -0.16F, 0.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
RenderItem.renderInFrame = true;
|
|
||||||
RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
|
||||||
RenderItem.renderInFrame = false;
|
|
||||||
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,19 @@
|
||||||
package resonantinduction.archaic.imprint;
|
package resonantinduction.archaic.imprint;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
import net.minecraft.client.renderer.texture.IconRegister;
|
import net.minecraft.client.renderer.texture.IconRegister;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Icon;
|
import net.minecraft.util.Icon;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import resonantinduction.archaic.Archaic;
|
|
||||||
import resonantinduction.core.Reference;
|
import resonantinduction.core.Reference;
|
||||||
import resonantinduction.core.prefab.block.BlockRI;
|
import resonantinduction.core.prefab.block.BlockRI;
|
||||||
|
import universalelectricity.api.vector.Vector2;
|
||||||
|
import universalelectricity.api.vector.Vector3;
|
||||||
|
import calclavia.lib.utility.InventoryUtility;
|
||||||
|
import codechicken.multipart.ControlKeyModifer;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
@ -26,7 +25,7 @@ public class BlockImprinter extends BlockRI
|
||||||
|
|
||||||
public BlockImprinter()
|
public BlockImprinter()
|
||||||
{
|
{
|
||||||
super("engineeringTable", Material.wood);
|
super("imprinter", Material.wood);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
|
@ -64,85 +63,107 @@ public class BlockImprinter extends BlockRI
|
||||||
return this.imprinter_side;
|
return this.imprinter_side;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called upon block activation (right click on the block.) */
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9)
|
public boolean onMachineActivated(World world, int x, int y, int z, EntityPlayer player, int hitSide, float hitX, float hitY, float hitZ)
|
||||||
|
{
|
||||||
|
TileEntity te = world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if (te instanceof TileImprinter)
|
||||||
|
{
|
||||||
|
TileImprinter tile = (TileImprinter) te;
|
||||||
|
|
||||||
|
if (hitSide == 1)
|
||||||
{
|
{
|
||||||
if (!world.isRemote)
|
if (!world.isRemote)
|
||||||
{
|
{
|
||||||
entityPlayer.openGui(Archaic.INSTANCE, 0, world, x, y, z);
|
ItemStack current = player.inventory.getCurrentItem();
|
||||||
|
|
||||||
|
Vector2 hitVector = new Vector2(hitX, hitZ);
|
||||||
|
double regionLength = 1d / 3d;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crafting Matrix
|
||||||
|
*/
|
||||||
|
matrix:
|
||||||
|
for (int j = 0; j < 3; j++)
|
||||||
|
{
|
||||||
|
for (int k = 0; k < 3; k++)
|
||||||
|
{
|
||||||
|
Vector2 check = new Vector2(j, k).scale(regionLength);
|
||||||
|
|
||||||
|
if (check.distance(hitVector) < regionLength)
|
||||||
|
{
|
||||||
|
int slotID = j * 3 + k;
|
||||||
|
boolean didInsert = false;
|
||||||
|
ItemStack checkStack = tile.inventory[slotID];
|
||||||
|
|
||||||
|
if (current != null)
|
||||||
|
{
|
||||||
|
if (checkStack == null || checkStack.isItemEqual(current))
|
||||||
|
{
|
||||||
|
if (ControlKeyModifer.isControlDown(player))
|
||||||
|
{
|
||||||
|
if (checkStack == null)
|
||||||
|
{
|
||||||
|
tile.inventory[slotID] = current;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tile.inventory[slotID].stackSize += current.stackSize;
|
||||||
|
current.stackSize = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
current = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (checkStack == null)
|
||||||
|
{
|
||||||
|
tile.inventory[slotID] = current.splitStack(1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tile.inventory[slotID].stackSize++;
|
||||||
|
current.stackSize--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (current == null || current.stackSize <= 0)
|
||||||
|
{
|
||||||
|
player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
didInsert = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!didInsert && checkStack != null)
|
||||||
|
{
|
||||||
|
InventoryUtility.dropItemStack(world, new Vector3(player), checkStack, 0);
|
||||||
|
tile.inventory[slotID] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
break matrix;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tile.onInventoryChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if (hitSide != 0)
|
||||||
@Override
|
|
||||||
public void dropEntireInventory(World par1World, int x, int y, int z, int par5, int par6)
|
|
||||||
{
|
{
|
||||||
TileEntity tileEntity = par1World.getBlockTileEntity(x, y, z);
|
if (!world.isRemote)
|
||||||
|
|
||||||
if (tileEntity != null)
|
|
||||||
{
|
{
|
||||||
if (tileEntity instanceof TileImprinter)
|
ItemStack output = tile.getStackInSlot(9);
|
||||||
{
|
InventoryUtility.dropItemStack(world, new Vector3(player), output, 0);
|
||||||
TileImprinter inventory = (TileImprinter) tileEntity;
|
tile.setInventorySlotContents(9, null);
|
||||||
|
tile.onInventoryChanged();
|
||||||
for (int i = 0; i < inventory.getSizeInventory(); ++i)
|
|
||||||
{
|
|
||||||
ItemStack itemStack = inventory.getStackInSlot(i);
|
|
||||||
|
|
||||||
if (itemStack != null)
|
|
||||||
{
|
|
||||||
Random random = new Random();
|
|
||||||
float var8 = random.nextFloat() * 0.8F + 0.1F;
|
|
||||||
float var9 = random.nextFloat() * 0.8F + 0.1F;
|
|
||||||
float var10 = random.nextFloat() * 0.8F + 0.1F;
|
|
||||||
|
|
||||||
while (itemStack.stackSize > 0)
|
|
||||||
{
|
|
||||||
int var11 = random.nextInt(21) + 10;
|
|
||||||
|
|
||||||
if (var11 > itemStack.stackSize)
|
|
||||||
{
|
|
||||||
var11 = itemStack.stackSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
itemStack.stackSize -= var11;
|
|
||||||
|
|
||||||
if (i != inventory.craftingOutputSlot)
|
|
||||||
{
|
|
||||||
EntityItem entityItem = new EntityItem(par1World, (x + var8), (y + var9), (z + var10), new ItemStack(itemStack.itemID, var11, itemStack.getItemDamage()));
|
|
||||||
|
|
||||||
if (itemStack.hasTagCompound())
|
|
||||||
{
|
|
||||||
entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
|
|
||||||
}
|
|
||||||
|
|
||||||
float var13 = 0.05F;
|
|
||||||
entityItem.motionX = ((float) random.nextGaussian() * var13);
|
|
||||||
entityItem.motionY = ((float) random.nextGaussian() * var13 + 0.2F);
|
|
||||||
entityItem.motionZ = ((float) random.nextGaussian() * var13);
|
|
||||||
par1World.spawnEntityInWorld(entityItem);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onUseWrench(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
|
|
||||||
{
|
|
||||||
TileEntity tileEntity = par1World.getBlockTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if (tileEntity instanceof TileImprinter)
|
|
||||||
{
|
|
||||||
((TileImprinter) tileEntity).searchInventories = !((TileImprinter) tileEntity).searchInventories;
|
|
||||||
par1World.markBlockForUpdate(x, y, z);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,145 +0,0 @@
|
||||||
package resonantinduction.archaic.imprint;
|
|
||||||
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
|
||||||
import net.minecraft.inventory.Container;
|
|
||||||
import net.minecraft.inventory.Slot;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import calclavia.lib.prefab.slot.ISlotWatcher;
|
|
||||||
import calclavia.lib.prefab.slot.SlotCraftingResult;
|
|
||||||
import calclavia.lib.prefab.slot.SlotSpecific;
|
|
||||||
import calclavia.lib.prefab.slot.SlotWatched;
|
|
||||||
|
|
||||||
public class ContainerImprinter extends Container implements ISlotWatcher
|
|
||||||
{
|
|
||||||
public InventoryPlayer inventoryPlayer;
|
|
||||||
public TileImprinter tileEntity;
|
|
||||||
|
|
||||||
public ContainerImprinter(InventoryPlayer inventoryPlayer, TileImprinter tileEntity)
|
|
||||||
{
|
|
||||||
this.tileEntity = tileEntity;
|
|
||||||
this.tileEntity.container = this;
|
|
||||||
this.inventoryPlayer = inventoryPlayer;
|
|
||||||
|
|
||||||
/** Crafting Matrix */
|
|
||||||
for (int x = 0; x < 3; x++)
|
|
||||||
{
|
|
||||||
for (int y = 0; y < 3; y++)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new SlotWatched(this.tileEntity, y + x * 3, 9 + y * 18, 16 + x * 18, this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Imprint Input for Imprinting
|
|
||||||
this.addSlotToContainer(new SlotSpecific(this.tileEntity, TileImprinter.IMPRINTER_MATRIX_START, 68, 34, ItemBlockFilter.class));
|
|
||||||
// Item to be imprinted
|
|
||||||
this.addSlotToContainer(new SlotWatched(this.tileEntity, TileImprinter.IMPRINTER_MATRIX_START + 1, 92, 34, this));
|
|
||||||
// Result of Crafting/Imprinting
|
|
||||||
this.addSlotToContainer(new SlotCraftingResult(this.tileEntity, this, this.tileEntity, TileImprinter.IMPRINTER_MATRIX_START + 2, 148, 34));
|
|
||||||
|
|
||||||
// Imprinter Inventory
|
|
||||||
for (int ii = 0; ii < 2; ii++)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 9; i++)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new SlotWatched(this.tileEntity, (i + ii * 9) + TileImprinter.INVENTORY_START, 8 + i * 18, 80 + ii * 18, this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Player Inventory
|
|
||||||
int var3;
|
|
||||||
|
|
||||||
for (var3 = 0; var3 < 3; ++var3)
|
|
||||||
{
|
|
||||||
for (int var4 = 0; var4 < 9; ++var4)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new SlotWatched(inventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 120 + var3 * 18, this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var3 = 0; var3 < 9; ++var3)
|
|
||||||
{
|
|
||||||
this.addSlotToContainer(new SlotWatched(inventoryPlayer, var3, 8 + var3 * 18, 178, this));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.tileEntity.openChest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onContainerClosed(EntityPlayer par1EntityPlayer)
|
|
||||||
{
|
|
||||||
super.onContainerClosed(par1EntityPlayer);
|
|
||||||
this.tileEntity.closeChest();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canInteractWith(EntityPlayer player)
|
|
||||||
{
|
|
||||||
return this.tileEntity.isUseableByPlayer(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Called to transfer a stack from one inventory to the other eg. when shift clicking. */
|
|
||||||
@Override
|
|
||||||
public ItemStack transferStackInSlot(EntityPlayer player, int slot)
|
|
||||||
{
|
|
||||||
ItemStack copyStack = null;
|
|
||||||
Slot slotObj = (Slot) this.inventorySlots.get(slot);
|
|
||||||
|
|
||||||
if (slotObj != null && slotObj.getHasStack())
|
|
||||||
{
|
|
||||||
ItemStack slotStack = slotObj.getStack();
|
|
||||||
copyStack = slotStack.copy();
|
|
||||||
|
|
||||||
if (slot == TileImprinter.INVENTORY_START - 1)
|
|
||||||
{
|
|
||||||
// Prevents filter from being duplicated
|
|
||||||
this.tileEntity.setInventorySlotContents(TileImprinter.INVENTORY_START - 1, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (slot > this.tileEntity.getSizeInventory() - 1)
|
|
||||||
{
|
|
||||||
if (this.getSlot(TileImprinter.IMPRINTER_MATRIX_START).isItemValid(slotStack))
|
|
||||||
{
|
|
||||||
if (!this.mergeItemStack(slotStack, TileImprinter.IMPRINTER_MATRIX_START, TileImprinter.IMPRINTER_MATRIX_START + 1, true))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!this.mergeItemStack(slotStack, TileImprinter.INVENTORY_START, this.tileEntity.getSizeInventory(), false))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!this.mergeItemStack(slotStack, this.tileEntity.getSizeInventory(), this.tileEntity.getSizeInventory() + 36, false))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (slotStack.stackSize == 0)
|
|
||||||
{
|
|
||||||
slotObj.putStack(null);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
slotObj.onSlotChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (slotStack.stackSize == copyStack.stackSize)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
slotObj.onPickupFromSlot(player, slotStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.slotContentsChanged(slot);
|
|
||||||
return copyStack;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void slotContentsChanged(int slot)
|
|
||||||
{
|
|
||||||
this.tileEntity.onInventoryChanged();
|
|
||||||
this.detectAndSendChanges();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package resonantinduction.archaic.imprint;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderItem;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.client.ForgeHooksClient;
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import resonantinduction.core.render.RenderItemOverlayTile;
|
||||||
|
import universalelectricity.api.vector.Vector3;
|
||||||
|
import calclavia.lib.render.RenderUtility;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public class RenderImprinter extends RenderItemOverlayTile
|
||||||
|
{
|
||||||
|
private final RenderBlocks renderBlocks = new RenderBlocks();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8)
|
||||||
|
{
|
||||||
|
if (tileEntity instanceof TileImprinter)
|
||||||
|
{
|
||||||
|
TileImprinter tile = (TileImprinter) tileEntity;
|
||||||
|
renderTopCrafting(tileEntity, tile.inventory, x, y, z);
|
||||||
|
renderItemOnSides(tileEntity, tile.getStackInSlot(9), x, y, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,47 +10,24 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.crafting.CraftingManager;
|
import net.minecraft.item.crafting.CraftingManager;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.nbt.NBTTagList;
|
import net.minecraft.nbt.NBTTagList;
|
||||||
|
import net.minecraft.network.packet.Packet;
|
||||||
import resonantinduction.api.IArmbot;
|
import resonantinduction.api.IArmbot;
|
||||||
import resonantinduction.api.IArmbotUseable;
|
import resonantinduction.api.IArmbotUseable;
|
||||||
import resonantinduction.api.events.AutoCraftEvent;
|
import resonantinduction.api.events.AutoCraftEvent;
|
||||||
|
import resonantinduction.core.ResonantInduction;
|
||||||
import resonantinduction.electrical.encoder.coding.args.ArgumentData;
|
import resonantinduction.electrical.encoder.coding.args.ArgumentData;
|
||||||
import universalelectricity.api.vector.Vector3;
|
import universalelectricity.api.vector.Vector3;
|
||||||
|
import calclavia.lib.network.IPacketReceiver;
|
||||||
|
import calclavia.lib.network.PacketHandler;
|
||||||
import calclavia.lib.prefab.slot.ISlotPickResult;
|
import calclavia.lib.prefab.slot.ISlotPickResult;
|
||||||
import calclavia.lib.prefab.tile.TileAdvanced;
|
import calclavia.lib.prefab.tile.TileAdvanced;
|
||||||
import calclavia.lib.utility.AutoCraftingManager;
|
|
||||||
import calclavia.lib.utility.AutoCraftingManager.IAutoCrafter;
|
|
||||||
import calclavia.lib.utility.LanguageUtility;
|
|
||||||
|
|
||||||
import com.builtbroken.common.Pair;
|
import com.builtbroken.common.Pair;
|
||||||
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
|
||||||
public class TileImprinter extends TileAdvanced implements ISidedInventory, IArmbotUseable, ISlotPickResult, IAutoCrafter
|
public class TileImprinter extends TileAdvanced implements ISidedInventory, IPacketReceiver
|
||||||
{
|
{
|
||||||
public static final int IMPRINTER_MATRIX_START = 9;
|
public ItemStack[] inventory = new ItemStack[10];
|
||||||
public static final int INVENTORY_START = IMPRINTER_MATRIX_START + 3;
|
|
||||||
|
|
||||||
private AutoCraftingManager craftManager;
|
|
||||||
/** 9 slots for crafting, 1 slot for an imprint, 1 slot for an item */
|
|
||||||
public ItemStack[] craftingMatrix = new ItemStack[9];
|
|
||||||
public static final int[] craftingSlots = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
|
|
||||||
|
|
||||||
public ItemStack[] imprinterMatrix = new ItemStack[3];
|
|
||||||
public static final int[] imprinterSlots = { IMPRINTER_MATRIX_START, IMPRINTER_MATRIX_START + 1, IMPRINTER_MATRIX_START + 2 };
|
|
||||||
int imprintInputSlot = 0;
|
|
||||||
int imprintOutputSlot = 1;
|
|
||||||
int craftingOutputSlot = 2;
|
|
||||||
|
|
||||||
/** The Imprinter inventory containing slots. */
|
|
||||||
public ItemStack[] containingItems = new ItemStack[18];
|
|
||||||
public static int[] inventorySlots;
|
|
||||||
|
|
||||||
/** The containing currently used by the imprinter. */
|
|
||||||
public ContainerImprinter container;
|
|
||||||
|
|
||||||
/** Is the current crafting result a result of an imprint? */
|
|
||||||
private boolean isImprinting = false;
|
|
||||||
|
|
||||||
/** The ability for the imprinter to serach nearby inventories. */
|
|
||||||
public boolean searchInventories = true;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canUpdate()
|
public boolean canUpdate()
|
||||||
|
@ -58,20 +35,31 @@ public class TileImprinter extends TileAdvanced implements ISidedInventory, IArm
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets the AutoCraftingManager that does all the crafting results */
|
|
||||||
public AutoCraftingManager getCraftingManager()
|
|
||||||
{
|
|
||||||
if (craftManager == null)
|
|
||||||
{
|
|
||||||
craftManager = new AutoCraftingManager(this);
|
|
||||||
}
|
|
||||||
return craftManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSizeInventory()
|
public int getSizeInventory()
|
||||||
{
|
{
|
||||||
return this.craftingMatrix.length + this.imprinterMatrix.length + this.containingItems.length;
|
return this.inventory.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Packet getDescriptionPacket()
|
||||||
|
{
|
||||||
|
NBTTagCompound nbt = new NBTTagCompound();
|
||||||
|
this.writeToNBT(nbt);
|
||||||
|
return ResonantInduction.PACKET_TILE.getPacket(this, nbt);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.readFromNBT(PacketHandler.readNBTTagCompound(data));
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -83,18 +71,7 @@ public class TileImprinter extends TileAdvanced implements ISidedInventory, IArm
|
||||||
{
|
{
|
||||||
if (slot < this.getSizeInventory())
|
if (slot < this.getSizeInventory())
|
||||||
{
|
{
|
||||||
if (slot < IMPRINTER_MATRIX_START)
|
inventory[slot] = itemStack;
|
||||||
{
|
|
||||||
this.craftingMatrix[slot] = itemStack;
|
|
||||||
}
|
|
||||||
else if (slot < INVENTORY_START)
|
|
||||||
{
|
|
||||||
this.imprinterMatrix[slot - IMPRINTER_MATRIX_START] = itemStack;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.containingItems[slot - INVENTORY_START] = itemStack;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,18 +109,7 @@ public class TileImprinter extends TileAdvanced implements ISidedInventory, IArm
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getStackInSlot(int slot)
|
public ItemStack getStackInSlot(int slot)
|
||||||
{
|
{
|
||||||
if (slot < IMPRINTER_MATRIX_START)
|
return this.inventory[slot];
|
||||||
{
|
|
||||||
return this.craftingMatrix[slot];
|
|
||||||
}
|
|
||||||
else if (slot < INVENTORY_START)
|
|
||||||
{
|
|
||||||
return this.imprinterMatrix[slot - IMPRINTER_MATRIX_START];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return this.containingItems[slot - INVENTORY_START];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -165,12 +131,6 @@ public class TileImprinter extends TileAdvanced implements ISidedInventory, IArm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getInvName()
|
|
||||||
{
|
|
||||||
return LanguageUtility.getLocal("tile.imprinter.name");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void openChest()
|
public void openChest()
|
||||||
{
|
{
|
||||||
|
@ -183,47 +143,6 @@ public class TileImprinter extends TileAdvanced implements ISidedInventory, IArm
|
||||||
this.onInventoryChanged();
|
this.onInventoryChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct an InventoryCrafting Matrix on the fly.
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public InventoryCrafting getCraftingMatrix()
|
|
||||||
{
|
|
||||||
if (this.container != null)
|
|
||||||
{
|
|
||||||
InventoryCrafting inventoryCrafting = new InventoryCrafting(this.container, 3, 3);
|
|
||||||
|
|
||||||
for (int i = 0; i < this.craftingMatrix.length; i++)
|
|
||||||
{
|
|
||||||
inventoryCrafting.setInventorySlotContents(i, this.craftingMatrix[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return inventoryCrafting;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void replaceCraftingMatrix(InventoryCrafting inventoryCrafting)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < this.craftingMatrix.length; i++)
|
|
||||||
{
|
|
||||||
this.craftingMatrix[i] = inventoryCrafting.getStackInSlot(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isMatrixEmpty()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 9; i++)
|
|
||||||
{
|
|
||||||
if (this.craftingMatrix[i] != null)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Updates all the output slots. Call this to update the Imprinter. */
|
/** Updates all the output slots. Call this to update the Imprinter. */
|
||||||
@Override
|
@Override
|
||||||
public void onInventoryChanged()
|
public void onInventoryChanged()
|
||||||
|
@ -231,20 +150,18 @@ public class TileImprinter extends TileAdvanced implements ISidedInventory, IArm
|
||||||
if (!this.worldObj.isRemote)
|
if (!this.worldObj.isRemote)
|
||||||
{
|
{
|
||||||
/** Makes the stamping recipe for filters */
|
/** Makes the stamping recipe for filters */
|
||||||
this.isImprinting = false;
|
ItemStack fitlerStack = this.inventory[9];
|
||||||
|
|
||||||
if (this.isMatrixEmpty() && this.imprinterMatrix[imprintInputSlot] != null && this.imprinterMatrix[1] != null)
|
if (fitlerStack != null && fitlerStack.getItem() instanceof ItemBlockFilter)
|
||||||
{
|
{
|
||||||
if (this.imprinterMatrix[imprintInputSlot].getItem() instanceof ItemBlockFilter)
|
ItemStack outputStack = fitlerStack.copy();
|
||||||
{
|
|
||||||
ItemStack outputStack = this.imprinterMatrix[imprintInputSlot].copy();
|
|
||||||
outputStack.stackSize = 1;
|
outputStack.stackSize = 1;
|
||||||
ArrayList<ItemStack> filters = ItemBlockFilter.getFilters(outputStack);
|
ArrayList<ItemStack> filters = ItemBlockFilter.getFilters(outputStack);
|
||||||
boolean filteringItemExists = false;
|
boolean filteringItemExists = false;
|
||||||
|
|
||||||
for (ItemStack filteredStack : filters)
|
for (ItemStack filteredStack : filters)
|
||||||
{
|
{
|
||||||
if (filteredStack.isItemEqual(this.imprinterMatrix[imprintOutputSlot]))
|
if (filteredStack.isItemEqual(fitlerStack))
|
||||||
{
|
{
|
||||||
filters.remove(filteredStack);
|
filters.remove(filteredStack);
|
||||||
filteringItemExists = true;
|
filteringItemExists = true;
|
||||||
|
@ -254,122 +171,18 @@ public class TileImprinter extends TileAdvanced implements ISidedInventory, IArm
|
||||||
|
|
||||||
if (!filteringItemExists)
|
if (!filteringItemExists)
|
||||||
{
|
{
|
||||||
filters.add(this.imprinterMatrix[imprintOutputSlot]);
|
filters.add(fitlerStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemBlockFilter.setFilters(outputStack, filters);
|
ItemBlockFilter.setFilters(outputStack, filters);
|
||||||
this.imprinterMatrix[craftingOutputSlot] = outputStack;
|
this.inventory[9] = outputStack;
|
||||||
this.isImprinting = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.isImprinting)
|
|
||||||
{
|
|
||||||
this.imprinterMatrix[craftingOutputSlot] = null;
|
|
||||||
|
|
||||||
/** Try to craft from crafting grid. If not possible, then craft from imprint. */
|
|
||||||
boolean didCraft = false;
|
|
||||||
|
|
||||||
/** Simulate an Inventory Crafting Instance */
|
|
||||||
InventoryCrafting inventoryCrafting = this.getCraftingMatrix();
|
|
||||||
|
|
||||||
if (inventoryCrafting != null)
|
|
||||||
{
|
|
||||||
ItemStack matrixOutput = CraftingManager.getInstance().findMatchingRecipe(inventoryCrafting, this.worldObj);
|
|
||||||
|
|
||||||
if (matrixOutput != null && this.getCraftingManager().getIdealRecipe(matrixOutput) != null)
|
|
||||||
{
|
|
||||||
this.imprinterMatrix[craftingOutputSlot] = matrixOutput;
|
|
||||||
didCraft = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.imprinterMatrix[imprintInputSlot] != null && !didCraft)
|
|
||||||
{
|
|
||||||
if (this.imprinterMatrix[imprintInputSlot].getItem() instanceof ItemBlockFilter)
|
|
||||||
{
|
|
||||||
|
|
||||||
ArrayList<ItemStack> filters = ItemBlockFilter.getFilters(this.imprinterMatrix[0]);
|
|
||||||
|
|
||||||
for (ItemStack outputStack : filters)
|
|
||||||
{
|
|
||||||
if (outputStack != null)
|
|
||||||
{
|
|
||||||
// System.out.println("Imprint: Geting recipe for " +
|
|
||||||
// outputStack.toString());
|
|
||||||
Pair<ItemStack, ItemStack[]> idealRecipe = this.getCraftingManager().getIdealRecipe(outputStack);
|
|
||||||
|
|
||||||
if (idealRecipe != null)
|
|
||||||
{
|
|
||||||
// System.out.println("Imprint: found ideal recipe for " +
|
|
||||||
// idealRecipe.getKey().toString());
|
|
||||||
ItemStack recipeOutput = idealRecipe.left();
|
|
||||||
if (recipeOutput != null & recipeOutput.stackSize > 0)
|
|
||||||
{
|
|
||||||
this.imprinterMatrix[craftingOutputSlot] = recipeOutput;
|
|
||||||
didCraft = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!didCraft)
|
|
||||||
{
|
|
||||||
this.imprinterMatrix[craftingOutputSlot] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPickUpFromSlot(EntityPlayer entityPlayer, int s, ItemStack itemStack)
|
|
||||||
{
|
|
||||||
if (itemStack != null)
|
|
||||||
{
|
|
||||||
if (this.isImprinting)
|
|
||||||
{
|
|
||||||
this.imprinterMatrix[0] = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Pair<ItemStack, ItemStack[]> idealRecipeItem = this.getCraftingManager().getIdealRecipe(itemStack);
|
|
||||||
|
|
||||||
if (idealRecipeItem != null)
|
|
||||||
{
|
|
||||||
this.getCraftingManager().consumeItems(idealRecipeItem.right().clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Tries to let the Armbot craft an item. */
|
|
||||||
@Override
|
|
||||||
public boolean onUse(IArmbot armbot, List<ArgumentData> data)
|
|
||||||
{
|
|
||||||
this.onInventoryChanged();
|
|
||||||
|
|
||||||
if (this.imprinterMatrix[craftingOutputSlot] != null)
|
|
||||||
{
|
|
||||||
AutoCraftEvent.PreCraft event = new AutoCraftEvent.PreCraft(this.worldObj, new Vector3(this), this, this.imprinterMatrix[craftingOutputSlot]);
|
|
||||||
if (!event.isCanceled())
|
|
||||||
{
|
|
||||||
armbot.grabObject(this.imprinterMatrix[craftingOutputSlot].copy());
|
|
||||||
this.onPickUpFromSlot(null, 2, this.imprinterMatrix[craftingOutputSlot]);
|
|
||||||
this.imprinterMatrix[craftingOutputSlot] = null;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ///////////////////////////////////////
|
// ///////////////////////////////////////
|
||||||
// // Save And Data processing //////
|
// // Save And Data processing //////
|
||||||
// ///////////////////////////////////////
|
// ///////////////////////////////////////
|
||||||
|
|
||||||
/** NBT Data */
|
/** NBT Data */
|
||||||
@Override
|
@Override
|
||||||
public void readFromNBT(NBTTagCompound nbt)
|
public void readFromNBT(NBTTagCompound nbt)
|
||||||
|
@ -377,9 +190,7 @@ public class TileImprinter extends TileAdvanced implements ISidedInventory, IArm
|
||||||
super.readFromNBT(nbt);
|
super.readFromNBT(nbt);
|
||||||
|
|
||||||
NBTTagList var2 = nbt.getTagList("Items");
|
NBTTagList var2 = nbt.getTagList("Items");
|
||||||
this.craftingMatrix = new ItemStack[9];
|
this.inventory = new ItemStack[10];
|
||||||
this.imprinterMatrix = new ItemStack[3];
|
|
||||||
this.containingItems = new ItemStack[18];
|
|
||||||
|
|
||||||
for (int i = 0; i < var2.tagCount(); ++i)
|
for (int i = 0; i < var2.tagCount(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -391,8 +202,6 @@ public class TileImprinter extends TileAdvanced implements ISidedInventory, IArm
|
||||||
this.setInventorySlotContents(var5, ItemStack.loadItemStackFromNBT(var4));
|
this.setInventorySlotContents(var5, ItemStack.loadItemStackFromNBT(var4));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.searchInventories = nbt.getBoolean("searchInventories");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Writes a tile entity to NBT. */
|
/** Writes a tile entity to NBT. */
|
||||||
|
@ -415,20 +224,23 @@ public class TileImprinter extends TileAdvanced implements ISidedInventory, IArm
|
||||||
}
|
}
|
||||||
|
|
||||||
nbt.setTag("Items", var2);
|
nbt.setTag("Items", var2);
|
||||||
|
|
||||||
nbt.setBoolean("searchInventories", this.searchInventories);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ///////////////////////////////////////
|
// ///////////////////////////////////////
|
||||||
// // Inventory Access side Methods //////
|
// // Inventory Access side Methods //////
|
||||||
// ///////////////////////////////////////
|
// ///////////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInvNameLocalized()
|
public boolean isInvNameLocalized()
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getInvName()
|
||||||
|
{
|
||||||
|
return getBlockType().getLocalizedName();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
public boolean isItemValidForSlot(int i, ItemStack itemstack)
|
||||||
{
|
{
|
||||||
|
@ -445,13 +257,12 @@ public class TileImprinter extends TileAdvanced implements ISidedInventory, IArm
|
||||||
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
public boolean isUseableByPlayer(EntityPlayer entityplayer)
|
||||||
{
|
{
|
||||||
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : entityplayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D;
|
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : entityplayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getAccessibleSlotsFromSide(int side)
|
public int[] getAccessibleSlotsFromSide(int side)
|
||||||
{
|
{
|
||||||
return this.getCraftingInv();
|
return side == 1 ? new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 } : new int[10];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -465,18 +276,4 @@ public class TileImprinter extends TileAdvanced implements ISidedInventory, IArm
|
||||||
{
|
{
|
||||||
return this.isItemValidForSlot(slot, itemstack);
|
return this.isItemValidForSlot(slot, itemstack);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int[] getCraftingInv()
|
|
||||||
{
|
|
||||||
if (TileImprinter.inventorySlots == null)
|
|
||||||
{
|
|
||||||
TileImprinter.inventorySlots = new int[18];
|
|
||||||
for (int i = 0; i < inventorySlots.length; i++)
|
|
||||||
{
|
|
||||||
inventorySlots[i] = TileImprinter.INVENTORY_START + i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return TileImprinter.inventorySlots;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,265 @@
|
||||||
|
package resonantinduction.core.render;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
|
import net.minecraft.client.renderer.OpenGlHelper;
|
||||||
|
import net.minecraft.client.renderer.RenderBlocks;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderItem;
|
||||||
|
import net.minecraft.client.renderer.entity.RenderManager;
|
||||||
|
import net.minecraft.client.renderer.texture.TextureManager;
|
||||||
|
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.client.ForgeHooksClient;
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
|
import universalelectricity.api.vector.Vector3;
|
||||||
|
import calclavia.lib.render.RenderUtility;
|
||||||
|
import cpw.mods.fml.relauncher.Side;
|
||||||
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public abstract class RenderItemOverlayTile extends TileEntitySpecialRenderer
|
||||||
|
{
|
||||||
|
private final RenderBlocks renderBlocks = new RenderBlocks();
|
||||||
|
|
||||||
|
public void renderTopCrafting(TileEntity tileEntity, ItemStack[] inventory, double x, double y, double z)
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Render the Crafting Matrix
|
||||||
|
*/
|
||||||
|
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||||
|
MovingObjectPosition objectPosition = player.rayTrace(8, 1);
|
||||||
|
boolean isLooking = false;
|
||||||
|
|
||||||
|
if (objectPosition != null)
|
||||||
|
{
|
||||||
|
isLooking |= objectPosition.blockX == tileEntity.xCoord && objectPosition.blockY == tileEntity.yCoord && objectPosition.blockZ == tileEntity.zCoord;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 9; i++)
|
||||||
|
{
|
||||||
|
if (inventory[i] != null)
|
||||||
|
{
|
||||||
|
Vector3 translation = new Vector3(x + (double) (i / 3) / 3d + (0.5 / 3d), y + 1.1, z + (double) (i % 3) / 3d + (0.5 / 3d));
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glTranslated(translation.x, translation.y, translation.z);
|
||||||
|
GL11.glScalef(0.7f, 0.7f, 0.7f);
|
||||||
|
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
|
||||||
|
this.renderItem(tileEntity.worldObj, ForgeDirection.UP, inventory[i], new Vector3(), 0, 0);
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
|
if (isLooking)
|
||||||
|
RenderUtility.renderFloatingText("" + inventory[i].stackSize, (float) translation.x, (float) translation.y - 2f, (float) translation.z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderItemOnSides(TileEntity tile, ItemStack itemStack, double x, double y, double z)
|
||||||
|
{
|
||||||
|
renderItemOnSides(tile, itemStack, x, y, z, "No Output");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void renderItemOnSides(TileEntity tile, ItemStack itemStack, double x, double y, double z, String itemName)
|
||||||
|
{
|
||||||
|
RenderItem renderItem = ((RenderItem) RenderManager.instance.getEntityClassRenderObject(EntityItem.class));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the Output
|
||||||
|
*/
|
||||||
|
String amount = "";
|
||||||
|
|
||||||
|
if (itemStack != null)
|
||||||
|
{
|
||||||
|
itemName = itemStack.getDisplayName();
|
||||||
|
amount = Integer.toString(itemStack.stackSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int side = 2; side < 6; side++)
|
||||||
|
{
|
||||||
|
ForgeDirection direction = ForgeDirection.getOrientation(side);
|
||||||
|
|
||||||
|
if (tile.worldObj.isBlockSolidOnSide(tile.xCoord + direction.offsetX, tile.yCoord, tile.zCoord + direction.offsetZ, direction.getOpposite()))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setupLight(tile, direction.offsetX, direction.offsetZ);
|
||||||
|
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
|
||||||
|
|
||||||
|
if (itemStack != null)
|
||||||
|
{
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
|
switch (side)
|
||||||
|
{
|
||||||
|
case 2:
|
||||||
|
GL11.glTranslated(x + 0.65, y + 0.9, z - 0.01);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
GL11.glTranslated(x + 0.35, y + 0.9, z + 1.01);
|
||||||
|
GL11.glRotatef(180, 0, 1, 0);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
GL11.glTranslated(x - 0.01, y + 0.9, z + 0.35);
|
||||||
|
GL11.glRotatef(90, 0, 1, 0);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
GL11.glTranslated(x + 1.01, y + 0.9, z + 0.65);
|
||||||
|
GL11.glRotatef(-90, 0, 1, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
float scale = 0.03125F;
|
||||||
|
GL11.glScalef(0.6f * scale, 0.6f * scale, 0);
|
||||||
|
GL11.glRotatef(180, 0, 0, 1);
|
||||||
|
|
||||||
|
TextureManager renderEngine = Minecraft.getMinecraft().renderEngine;
|
||||||
|
|
||||||
|
GL11.glDisable(2896);
|
||||||
|
if (!ForgeHooksClient.renderInventoryItem(this.renderBlocks, renderEngine, itemStack, true, 0.0F, 0.0F, 0.0F))
|
||||||
|
{
|
||||||
|
renderItem.renderItemIntoGUI(this.getFontRenderer(), renderEngine, itemStack, 0, 0);
|
||||||
|
}
|
||||||
|
GL11.glEnable(2896);
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.renderText(itemName, side, 0.02f, x, y - 0.35f, z);
|
||||||
|
this.renderText(amount, side, 0.02f, x, y - 0.15f, z);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupLight(TileEntity tileEntity, int xDifference, int zDifference)
|
||||||
|
{
|
||||||
|
World world = tileEntity.worldObj;
|
||||||
|
|
||||||
|
if (world.isBlockOpaqueCube(tileEntity.xCoord + xDifference, tileEntity.yCoord, tileEntity.zCoord + zDifference))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int br = world.getLightBrightnessForSkyBlocks(tileEntity.xCoord + xDifference, tileEntity.yCoord, tileEntity.zCoord + zDifference, 0);
|
||||||
|
int var11 = br % 65536;
|
||||||
|
int var12 = br / 65536;
|
||||||
|
float scale = 0.6F;
|
||||||
|
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, var11 * scale, var12 * scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderText(String text, int side, float maxScale, double x, double y, double z)
|
||||||
|
{
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
|
||||||
|
GL11.glPolygonOffset(-10, -10);
|
||||||
|
GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL);
|
||||||
|
|
||||||
|
float displayWidth = 1 - (2 / 16);
|
||||||
|
float displayHeight = 1 - (2 / 16);
|
||||||
|
GL11.glTranslated(x, y, z);
|
||||||
|
|
||||||
|
switch (side)
|
||||||
|
{
|
||||||
|
case 3:
|
||||||
|
GL11.glTranslatef(0, 1, 0);
|
||||||
|
GL11.glRotatef(0, 0, 1, 0);
|
||||||
|
GL11.glRotatef(90, 1, 0, 0);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
GL11.glTranslatef(1, 1, 1);
|
||||||
|
GL11.glRotatef(180, 0, 1, 0);
|
||||||
|
GL11.glRotatef(90, 1, 0, 0);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
GL11.glTranslatef(0, 1, 1);
|
||||||
|
GL11.glRotatef(90, 0, 1, 0);
|
||||||
|
GL11.glRotatef(90, 1, 0, 0);
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
GL11.glTranslatef(1, 1, 0);
|
||||||
|
GL11.glRotatef(-90, 0, 1, 0);
|
||||||
|
GL11.glRotatef(90, 1, 0, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find Center
|
||||||
|
GL11.glTranslatef(displayWidth / 2, 1F, displayHeight / 2);
|
||||||
|
GL11.glRotatef(-90, 1, 0, 0);
|
||||||
|
|
||||||
|
FontRenderer fontRenderer = this.getFontRenderer();
|
||||||
|
|
||||||
|
int requiredWidth = Math.max(fontRenderer.getStringWidth(text), 1);
|
||||||
|
int lineHeight = fontRenderer.FONT_HEIGHT + 2;
|
||||||
|
int requiredHeight = lineHeight * 1;
|
||||||
|
float scaler = 0.8f;
|
||||||
|
float scaleX = (displayWidth / requiredWidth);
|
||||||
|
float scaleY = (displayHeight / requiredHeight);
|
||||||
|
float scale = scaleX * scaler;
|
||||||
|
|
||||||
|
if (maxScale > 0)
|
||||||
|
{
|
||||||
|
scale = Math.min(scale, maxScale);
|
||||||
|
}
|
||||||
|
|
||||||
|
GL11.glScalef(scale, -scale, scale);
|
||||||
|
GL11.glDepthMask(false);
|
||||||
|
|
||||||
|
int offsetX;
|
||||||
|
int offsetY;
|
||||||
|
int realHeight = (int) Math.floor(displayHeight / scale);
|
||||||
|
int realWidth = (int) Math.floor(displayWidth / scale);
|
||||||
|
|
||||||
|
offsetX = (realWidth - requiredWidth) / 2;
|
||||||
|
offsetY = (realHeight - requiredHeight) / 2;
|
||||||
|
|
||||||
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
|
fontRenderer.drawString("\u00a7f" + text, offsetX - (realWidth / 2), 1 + offsetY - (realHeight / 2), 1);
|
||||||
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
GL11.glDepthMask(true);
|
||||||
|
GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL);
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void renderItem(World world, ForgeDirection dir, ItemStack itemStack, Vector3 position, float rotationYaw, int angle)
|
||||||
|
{
|
||||||
|
if (itemStack != null)
|
||||||
|
{
|
||||||
|
EntityItem entityitem = new EntityItem(world, 0.0D, 0.0D, 0.0D, itemStack.copy());
|
||||||
|
entityitem.getEntityItem().stackSize = 1;
|
||||||
|
entityitem.hoverStart = 0.0F;
|
||||||
|
GL11.glPushMatrix();
|
||||||
|
GL11.glTranslatef(-0.453125F * (float) dir.offsetX, -0.18F, -0.453125F * (float) dir.offsetZ);
|
||||||
|
GL11.glRotatef(180.0F + rotationYaw, 0.0F, 1.0F, 0.0F);
|
||||||
|
GL11.glRotatef((float) (-90 * angle), 0.0F, 0.0F, 1.0F);
|
||||||
|
|
||||||
|
switch (angle)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
GL11.glTranslatef(-0.16F, -0.16F, 0.0F);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
GL11.glTranslatef(0.0F, -0.32F, 0.0F);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
GL11.glTranslatef(0.16F, -0.16F, 0.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
RenderItem.renderInFrame = true;
|
||||||
|
RenderManager.instance.renderEntityWithPosYaw(entityitem, 0.0D, 0.0D, 0.0D, 0.0F, 0.0F);
|
||||||
|
RenderItem.renderInFrame = false;
|
||||||
|
|
||||||
|
GL11.glPopMatrix();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,9 +10,14 @@ meta.resonantinduction.credits=Visit website for credits.
|
||||||
fluid.mixture=Mixture
|
fluid.mixture=Mixture
|
||||||
|
|
||||||
### Archaic Module
|
### Archaic Module
|
||||||
|
## Machines
|
||||||
|
tile.resonantinduction\:imprinter.name=Imprinter
|
||||||
|
tile.resonantinduction\:engineeringTable.name=Engineering Table
|
||||||
|
|
||||||
## Transport
|
## Transport
|
||||||
tile.resonantinduction\:crate.name=Crate
|
tile.resonantinduction\:crate.name=Crate
|
||||||
tile.resonantinduction\:engineeringTable.name=Engineering Table
|
tile.resonantinduction\:fluidPipe.0.name=Wood Trough
|
||||||
|
tile.resonantinduction\:fluidPipe.1.name=Stone Trough
|
||||||
|
|
||||||
### Mechanical Module
|
### Mechanical Module
|
||||||
## Transport
|
## Transport
|
||||||
|
@ -22,8 +27,6 @@ tile.resonantinduction\:conveyorBelt.name=Conveyor Belt
|
||||||
tile.resonantinduction\:tank.name=Tank
|
tile.resonantinduction\:tank.name=Tank
|
||||||
|
|
||||||
# Fluid pipes
|
# Fluid pipes
|
||||||
tile.resonantinduction\:fluidPipe.0.name=Wood Trough
|
|
||||||
tile.resonantinduction\:fluidPipe.1.name=Black Wood Trough
|
|
||||||
tile.resonantinduction\:fluidPipe.2.name=Red Wood Trough
|
tile.resonantinduction\:fluidPipe.2.name=Red Wood Trough
|
||||||
tile.resonantinduction\:fluidPipe.3.name=Green Wood Trough
|
tile.resonantinduction\:fluidPipe.3.name=Green Wood Trough
|
||||||
tile.resonantinduction\:fluidPipe.4.name=Brown Wood Trough
|
tile.resonantinduction\:fluidPipe.4.name=Brown Wood Trough
|
||||||
|
@ -132,7 +135,6 @@ tile.crate.2.name=Elite Crate
|
||||||
|
|
||||||
tile.DMHopper.0.name = [WIP]Hopper 2.0
|
tile.DMHopper.0.name = [WIP]Hopper 2.0
|
||||||
|
|
||||||
tile.imprinter.name=Imprinter
|
|
||||||
tile.encoder.name=[WIP]Encoder
|
tile.encoder.name=[WIP]Encoder
|
||||||
tile.detector.name=Detector
|
tile.detector.name=Detector
|
||||||
tile.craneController.name=Crane Controller
|
tile.craneController.name=Crane Controller
|
||||||
|
|
Loading…
Reference in a new issue