use of blusunrize.immersiveengineering.api.crafting.BlueprintCraftingRecipe in project ImmersiveEngineering by BluSunrize.
the class TileRenderAutoWorkbench method renderTileEntityAt.
@Override
public void renderTileEntityAt(TileEntityAutoWorkbench te, double x, double y, double z, float partialTicks, int destroyStage) {
if (!te.formed || te.isDummy() || !te.getWorld().isBlockLoaded(te.getPos(), false))
return;
//Grab model + correct eextended state
final BlockRendererDispatcher blockRenderer = Minecraft.getMinecraft().getBlockRendererDispatcher();
BlockPos blockPos = te.getPos();
IBlockState state = getWorld().getBlockState(blockPos);
if (state.getBlock() != IEContent.blockMetalMultiblock)
return;
state = state.getBlock().getActualState(state, getWorld(), blockPos);
state = state.withProperty(IEProperties.DYNAMICRENDER, true);
IBakedModel model = blockRenderer.getBlockModelShapes().getModelForState(state);
//Initialize Tesselator and VertexBuffer
Tessellator tessellator = Tessellator.getInstance();
VertexBuffer worldRenderer = tessellator.getBuffer();
//Outer GL Wrapping, initial translation
GlStateManager.pushMatrix();
GlStateManager.translate(x + .5, y + .5, z + .5);
if (te.mirrored)
GlStateManager.scale(te.facing.getFrontOffsetX() == 0 ? -1 : 1, 1, te.facing.getFrontOffsetZ() == 0 ? -1 : 1);
//Item Displacement
float[][] itemDisplays = new float[te.processQueue.size()][];
//Animations
float drill = 0;
float lift = 0;
float press = 0;
float liftPress = 0;
for (int i = 0; i < itemDisplays.length; i++) {
MultiblockProcess<IMultiblockRecipe> process = te.processQueue.get(i);
if (process == null || process.processTick <= 0 || process.processTick == process.maxTicks)
continue;
//+partialTicks
float processTimer = ((float) process.processTick) / process.maxTicks * 180;
if (processTimer <= 9)
continue;
float itemX = -1;
float itemY = -.34375f;
float itemZ = -.9375f;
float itemAngle = 90f;
if (//slide
processTimer <= 24) {
itemAngle = 67.5f;
if (processTimer <= 19) {
itemZ += .25 + (19 - processTimer) / 10f * .5f;
itemY += .25 + (19 - processTimer) / 10f * .21875f;
} else {
itemZ += (24 - processTimer) / 5f * .25f;
itemY += (24 - processTimer) / 5f * .25f;
}
} else if (processTimer <= 40) {
itemX += (processTimer - 24) / 16f;
} else if (processTimer <= 100) {
itemX += 1;
float drillStep = 0;
if (processTimer <= 60) {
lift = (processTimer - 40) / 20f * .3125f;
drillStep = 4 + (60 - processTimer) * 4;
} else if (processTimer <= 80) {
lift = .3125f;
drillStep = 4;
} else {
lift = (100 - processTimer) / 20f * .3125f;
drillStep = 4 + (processTimer - 80) * 4;
}
if (drillStep > 0)
drill = processTimer % drillStep / drillStep * 360;
itemY += Math.max(0, lift - .0625);
} else if (processTimer <= 116) {
itemX += 1;
itemZ += (processTimer - 100) / 16f;
} else if (processTimer <= 132) {
itemX += 1 + (processTimer - 116) / 16f;
itemZ += 1;
} else if (processTimer <= 172) {
itemX += 2;
itemZ += 1;
if (processTimer <= 142)
press = (processTimer - 132) / 10f;
else if (processTimer <= 162)
press = 1;
else
press = (172 - processTimer) / 10f;
liftPress = press * .0625f;
itemY += liftPress;
} else if (processTimer <= 180) {
itemX += 2 + (processTimer - 172) / 16f;
itemZ += 1;
}
itemDisplays[i] = new float[] { processTimer, itemX, itemY, itemZ, itemAngle };
}
ClientUtils.bindAtlas();
GlStateManager.pushMatrix();
ItemStack blueprintStack = te.inventory[0];
if (blueprintStack != null)
renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "blueprint");
GlStateManager.translate(0, lift, 0);
renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "lift");
GlStateManager.translate(0, -lift, 0);
EnumFacing f = te.getFacing();
float tx = f == EnumFacing.WEST ? -.9375f : f == EnumFacing.EAST ? .9375f : 0;
float tz = f == EnumFacing.NORTH ? -.9375f : f == EnumFacing.SOUTH ? .9375f : 0;
GlStateManager.translate(tx, 0, tz);
GlStateManager.rotate(drill, 0, 1, 0);
renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "drill");
GlStateManager.rotate(-drill, 0, 1, 0);
GlStateManager.translate(-tx, 0, -tz);
tx = f == EnumFacing.WEST ? -.59375f : f == EnumFacing.EAST ? .59375f : 0;
tz = f == EnumFacing.NORTH ? -.59375f : f == EnumFacing.SOUTH ? .59375f : 0;
GlStateManager.translate(tx, -.21875, tz);
GlStateManager.rotate(press * 90, -f.getFrontOffsetZ(), 0, f.getFrontOffsetX());
renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "press");
GlStateManager.rotate(-press * 90, -f.getFrontOffsetZ(), 0, f.getFrontOffsetX());
GlStateManager.translate(-tx, .21875, -tz);
GlStateManager.translate(0, liftPress, 0);
renderModelPart(blockRenderer, tessellator, worldRenderer, te.getWorld(), state, model, blockPos, "pressLift");
GlStateManager.translate(0, -liftPress, 0);
RenderHelper.enableStandardItemLighting();
GlStateManager.popMatrix();
switch(f) {
case NORTH:
break;
case SOUTH:
GlStateManager.rotate(180, 0, 1, 0);
break;
case WEST:
GlStateManager.rotate(90, 0, 1, 0);
break;
case EAST:
GlStateManager.rotate(-90, 0, 1, 0);
break;
}
//DRAW ITEMS HERE
for (int i = 0; i < itemDisplays.length; i++) if (itemDisplays[i] != null) {
MultiblockProcess<IMultiblockRecipe> process = te.processQueue.get(i);
if (process == null || !(process instanceof MultiblockProcessInWorld))
continue;
float scale = .3125f;
List<ItemStack> dList = ((MultiblockProcessInWorld) process).getDisplayItem();
if (!dList.isEmpty())
if (dList.size() < 2) {
GlStateManager.translate(itemDisplays[i][1], itemDisplays[i][2], itemDisplays[i][3]);
GlStateManager.rotate(itemDisplays[i][4], 1, 0, 0);
GlStateManager.scale(scale, scale, .5f);
ClientUtils.mc().getRenderItem().renderItem(dList.get(0), ItemCameraTransforms.TransformType.FIXED);
GlStateManager.scale(1 / scale, 1 / scale, 2);
GlStateManager.rotate(-itemDisplays[i][4], 1, 0, 0);
GlStateManager.translate(-itemDisplays[i][1], -itemDisplays[i][2], -itemDisplays[i][3]);
} else {
int size = dList.size();
int lines = (int) Math.ceil(size / 2f);
float spacer = (lines - 1) * .234375f;
for (int d = 0; d < size; d++) {
float oX = (size > 2 ? -.3125f : 0) + (lines - d / 2) * .0625f + d % 2 * .3125f;
float oZ = -spacer / 2f + d / 2 * .234375f;
float oY = 0;
float localItemX = itemDisplays[i][1] + oX;
float localItemY = itemDisplays[i][2] + oY;
float localItemZ = itemDisplays[i][3] + oZ;
float subProcess = itemDisplays[i][0] - d / 2 * 4;
float localAngle = itemDisplays[i][4];
if (//slide
subProcess <= 24) {
localAngle = 67.5f;
if (subProcess <= 19) {
localItemZ = -1 + .25f + (19 - subProcess) / 10f * .5f;
localItemY = -.34375f + .25f + (19 - subProcess) / 10f * .21875f;
} else {
localItemZ = -1 + (oZ - (24 - subProcess) / 5f * oZ);
localItemY = -.34375f + (24 - subProcess) / 5f * .25f;
}
}
GlStateManager.translate(localItemX, localItemY, localItemZ);
GlStateManager.rotate(localAngle, 1, 0, 0);
GlStateManager.scale(scale, scale, .5f);
ClientUtils.mc().getRenderItem().renderItem(dList.get(d), ItemCameraTransforms.TransformType.FIXED);
GlStateManager.scale(1 / scale, 1 / scale, 2);
GlStateManager.rotate(-localAngle, 1, 0, 0);
GlStateManager.translate(-localItemX, -localItemY, -localItemZ);
}
}
}
//Blueprint
double playerDistanceSq = ClientUtils.mc().thePlayer.getDistanceSq(blockPos);
if (blueprintStack != null && playerDistanceSq < 1000) {
BlueprintCraftingRecipe[] recipes = BlueprintCraftingRecipe.findRecipes(ItemNBTHelper.getString(blueprintStack, "blueprint"));
BlueprintCraftingRecipe recipe = (te.selectedRecipe < 0 || te.selectedRecipe >= recipes.length) ? null : recipes[te.selectedRecipe];
BlueprintLines blueprint = recipe == null ? null : getBlueprintDrawable(recipe, te.getWorld());
if (blueprint != null) {
//Width depends on distance
float lineWidth = playerDistanceSq < 6 ? 3 : playerDistanceSq < 25 ? 2 : playerDistanceSq < 40 ? 1 : .5f;
GlStateManager.translate(-.195, .125, .97);
GlStateManager.rotate(-45, 1, 0, 0);
GlStateManager.disableCull();
GlStateManager.disableTexture2D();
GlStateManager.enableBlend();
float scale = .0375f / (blueprint.textureScale / 16f);
GlStateManager.scale(scale, -scale, scale);
GlStateManager.color(1, 1, 1, 1);
blueprint.draw(lineWidth);
GlStateManager.scale(1 / scale, -1 / scale, 1 / scale);
GlStateManager.enableAlpha();
GlStateManager.enableTexture2D();
GlStateManager.enableCull();
}
}
GlStateManager.popMatrix();
}
use of blusunrize.immersiveengineering.api.crafting.BlueprintCraftingRecipe in project ImmersiveEngineering by BluSunrize.
the class GuiModWorkbench method drawScreen.
@Override
public void drawScreen(int mx, int my, float partial) {
super.drawScreen(mx, my, partial);
for (int i = 0; i < ((ContainerModWorkbench) inventorySlots).slotCount; i++) {
Slot s = inventorySlots.getSlot(i);
if (s instanceof IESlot.BlueprintOutput && !s.getHasStack()) {
BlueprintCraftingRecipe recipe = ((IESlot.BlueprintOutput) s).recipe;
if (recipe != null && recipe.output != null)
if (isPointInRegion(s.xDisplayPosition, s.yDisplayPosition, 16, 16, mx, my)) {
ArrayList<String> tooltip = new ArrayList<String>();
tooltip.add(recipe.output.getRarity().rarityColor + recipe.output.getDisplayName());
ArrayList<ItemStack> inputs = new ArrayList<ItemStack>();
for (IngredientStack stack : recipe.inputs) {
ItemStack toAdd = Utils.copyStackWithAmount(stack.getRandomizedExampleStack(this.mc.thePlayer.ticksExisted), stack.inputSize);
if (toAdd == null)
continue;
boolean isNew = true;
for (ItemStack ss : inputs) if (OreDictionary.itemMatches(ss, toAdd, true)) {
ss.stackSize += toAdd.stackSize;
isNew = false;
break;
}
if (isNew)
inputs.add(toAdd.copy());
}
for (ItemStack ss : inputs) tooltip.add(TextFormatting.GRAY.toString() + ss.stackSize + "x " + ss.getDisplayName());
ClientUtils.drawHoveringText(tooltip, mx, my, fontRendererObj);
RenderHelper.enableGUIStandardItemLighting();
}
}
}
}
use of blusunrize.immersiveengineering.api.crafting.BlueprintCraftingRecipe in project ImmersiveEngineering by BluSunrize.
the class GuiAutoWorkbench method initGui.
@Override
public void initGui() {
this.buttonList.clear();
super.initGui();
Slot s = inventorySlots.getSlot(0);
if (s != null && s.getHasStack() && s.getStack().getItem() instanceof ItemEngineersBlueprint) {
BlueprintCraftingRecipe[] recipes = BlueprintCraftingRecipe.findRecipes(ItemNBTHelper.getString(s.getStack(), "blueprint"));
if (recipes != null && recipes.length > 0) {
int l = recipes.length;
int xx = guiLeft + 121;
int yy = guiTop + (l > 6 ? 59 - (l - 3) / 3 * 18 : l > 3 ? 59 : 68);
for (int i = 0; i < l; i++) if (recipes[i] != null && recipes[i].output != null) {
this.buttonList.add(new GuiButtonItem(i, xx + (i % 3) * 18, yy + (i / 3) * 18, recipes[i].output.copy(), i == tile.selectedRecipe));
}
}
// ItemStack stack = s.getStack();
// IConfigurableTool tool = ((IConfigurableTool)stack.getItem());
// int buttonid = 0;
// ToolConfigBoolean[] boolArray = tool.getBooleanOptions(stack);
// if(boolArray!=null)
// for(ToolConfigBoolean b : boolArray)
// this.buttonList.add(new GuiButtonCheckbox(buttonid++, guiLeft+b.x,guiTop+b.y, tool.fomatConfigName(stack,b), b.value));
// ToolConfigFloat[] floatArray = tool.getFloatOptions(stack);
// if(floatArray!=null)
// for(ToolConfigFloat f : floatArray)
// this.buttonList.add(new GuiSliderIE(buttonid++, guiLeft+f.x,guiTop+f.y, 80, tool.fomatConfigName(stack,f), f.value));
}
}
use of blusunrize.immersiveengineering.api.crafting.BlueprintCraftingRecipe in project ImmersiveEngineering by BluSunrize.
the class TileEntityAutoWorkbench method update.
@Override
public void update() {
super.update();
if (isDummy() || isRSDisabled() || worldObj.isRemote || worldObj.getTotalWorldTime() % 16 != ((getPos().getX() ^ getPos().getZ()) & 15) || inventory[0] == null)
return;
BlueprintCraftingRecipe[] recipes = BlueprintCraftingRecipe.findRecipes(ItemNBTHelper.getString(inventory[0], "blueprint"));
if (recipes.length > 0 && (this.selectedRecipe >= 0 && this.selectedRecipe < recipes.length)) {
BlueprintCraftingRecipe recipe = recipes[this.selectedRecipe];
if (recipe != null && recipe.output != null) {
ItemStack[] query = new ItemStack[16];
System.arraycopy(this.inventory, 1, query, 0, 16);
int crafted = recipe.getMaxCrafted(query);
if (crafted > 0) {
if (this.addProcessToQueue(new MultiblockProcessInWorld(recipe, 0.78f), true)) {
this.addProcessToQueue(new MultiblockProcessInWorld(recipe, 0.78f, recipe.consumeInputs(query, 1)), false);
System.arraycopy(query, 0, this.inventory, 1, 16);
this.markDirty();
this.markContainingBlockForUpdate(null);
}
}
}
}
}
use of blusunrize.immersiveengineering.api.crafting.BlueprintCraftingRecipe in project ImmersiveEngineering by BluSunrize.
the class ClientEventHandler method onRenderItemFrame.
/*
@SubscribeEvent()
public void lastWorldRender(RenderWorldLastEvent event)
{
connectionsRendered = false;
ParticleRenderer.dispatch();
}
static boolean connectionsRendered = false;
public static void renderAllIEConnections(float partial)
{
if(connectionsRendered)
return;
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_CULL_FACE);
// GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glDisable(GL11.GL_ALPHA_TEST);
OpenGlHelper.glBlendFunc(770, 771, 1, 0);
GL11.glShadeModel(GL11.GL_SMOOTH);
RenderHelper.enableStandardItemLighting();
Tessellator.instance.startDrawing(GL11.GL_QUADS);
EntityLivingBase viewer = ClientUtils.mc().renderViewEntity;
double dx = viewer.lastTickPosX + (viewer.posX - viewer.lastTickPosX) * partial;//(double)event.partialTicks;
double dy = viewer.lastTickPosY + (viewer.posY - viewer.lastTickPosY) * partial;//(double)event.partialTicks;
double dz = viewer.lastTickPosZ + (viewer.posZ - viewer.lastTickPosZ) * partial;//(double)event.partialTicks;
for(Object o : ClientUtils.mc().renderGlobal.tileEntities)
if(o instanceof IImmersiveConnectable)
{
TileEntity tile = (TileEntity)o;
// int lb = tile.getWorldObj().getLightBrightnessForSkyBlocks(tile.xCoord, tile.yCoord, tile.zCoord, 0);
// int lb_j = lb % 65536;
// int lb_k = lb / 65536;
// OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, (float)lb_j / 1.0F, (float)lb_k / 1.0F);
Tessellator.instance.setTranslation(tile.xCoord-dx, tile.yCoord-dy, tile.zCoord-dz);
// GL11.glTranslated((tile.xCoord+.5-dx), (tile.yCoord+.5-dy), (tile.zCoord+.5-dz));
ClientUtils.renderAttachedConnections((TileEntity)tile);
// GL11.glTranslated(-(tile.xCoord+.5-dx), -(tile.yCoord+.5-dy), -(tile.zCoord+.5-dz));
}
Iterator<ImmersiveNetHandler.Connection> it = skyhookGrabableConnections.iterator();
World world = viewer.worldObj;
while(it.hasNext())
{
ImmersiveNetHandler.Connection con = it.next();
Tessellator.instance.setTranslation(con.start.posX-dx, con.start.posY-dy, con.start.posZ-dz);
double r = con.cableType.getRenderDiameter()/2;
ClientUtils.drawConnection(con, Utils.toIIC(con.start, world), Utils.toIIC(con.end, world), 0x00ff99,128,r*1.75, con.cableType.getIcon(con));
}
Tessellator.instance.setTranslation(0,0,0);
Tessellator.instance.draw();
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopMatrix();
connectionsRendered = true;
}
*/
@SubscribeEvent
public void onRenderItemFrame(RenderItemInFrameEvent event) {
if (event.getItem() != null && event.getItem().getItem() instanceof ItemEngineersBlueprint) {
double playerDistanceSq = ClientUtils.mc().thePlayer.getDistanceSq(event.getEntityItemFrame().getPosition());
if (playerDistanceSq < 1000) {
BlueprintCraftingRecipe[] recipes = BlueprintCraftingRecipe.findRecipes(ItemNBTHelper.getString(event.getItem(), "blueprint"));
if (recipes != null && recipes.length > 0) {
int i = event.getEntityItemFrame().getRotation();
BlueprintCraftingRecipe recipe = recipes[i % recipes.length];
BlueprintLines blueprint = recipe == null ? null : TileRenderAutoWorkbench.getBlueprintDrawable(recipe, event.getEntityItemFrame().getEntityWorld());
if (blueprint != null) {
GlStateManager.rotate(-i * 45.0F, 0.0F, 0.0F, 1.0F);
ClientUtils.bindTexture("immersiveengineering:textures/models/blueprintFrame.png");
GlStateManager.translate(-.5, .5, -.001);
ClientUtils.drawTexturedRect(.125f, -.875f, .75f, .75f, 1d, 0d, 1d, 0d);
//Width depends on distance
float lineWidth = playerDistanceSq < 3 ? 3 : playerDistanceSq < 25 ? 2 : playerDistanceSq < 40 ? 1 : .5f;
GlStateManager.translate(.75, -.25, -.002);
GlStateManager.disableCull();
GlStateManager.disableTexture2D();
GlStateManager.enableBlend();
float scale = .0375f / (blueprint.getTextureScale() / 16f);
GlStateManager.scale(-scale, -scale, scale);
GlStateManager.color(1, 1, 1, 1);
blueprint.draw(lineWidth);
GlStateManager.scale(1 / scale, -1 / scale, 1 / scale);
GlStateManager.enableAlpha();
GlStateManager.enableTexture2D();
GlStateManager.enableCull();
event.setCanceled(true);
}
}
}
}
}
Aggregations