package blusunrize.immersiveengineering.common.blocks.multiblocks;
import blusunrize.immersiveengineering.api.MultiblockHandler.IMultiblock;
import blusunrize.immersiveengineering.api.crafting.IngredientStack;
import blusunrize.immersiveengineering.client.ClientUtils;
import blusunrize.immersiveengineering.common.IEContent;
import blusunrize.immersiveengineering.common.blocks.BlockTypes_MetalsAll;
import blusunrize.immersiveengineering.common.blocks.BlockTypes_MetalsIE;
import blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration0;
import blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration1;
import blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalMultiblock;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class MultiblockExcavatorDemo implements IMultiblock
{
public static MultiblockExcavatorDemo instance = new MultiblockExcavatorDemo();
static ItemStack[][][] structure = new ItemStack[7][8][3];
static{
for(int h=0;h<3;h++)
for(int l=0;l<6;l++)
for(int w=0;w<3;w++)
{
if(l>0&&w==1)
continue;
if(l==0)
{
if(w==0&&h==1)
structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta());
else if((w==1&&h==1)||(w==0&&h==2))
structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta());
else if(w==0&&h==0)
structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RADIATOR.getMeta());
else
structure[h+2][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.STEEL.getMeta());
}
else if(w==0)
{
if(l<3 && h==2)
structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.RADIATOR.getMeta());
else if(l<3)
structure[h+2][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.STEEL.getMeta());
else if(h==0)
structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta());
else
structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta());
}
else if(w==2)
{
if(l==1)
structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta());
else if(l==2)
structure[h+2][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.STEEL.getMeta());
else if(h==0)
structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta());
else if(h==1)
structure[h+2][l][w] = new ItemStack(IEContent.blockMetalDecoration0,1,BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta());
else
structure[h+2][l][w] = new ItemStack(IEContent.blockSheetmetal,1,BlockTypes_MetalsAll.STEEL.getMeta());
}
}
for(int h=0;h<7;h++)
for(int l=0;l<7;l++)
{
if((h==0||h==6) && l!=3)
continue;
if((l==0||l==6) && h!=3)
continue;
if(l==0||h==0||l==6||h==6 || ((l==1||l==5) && (h==1||h==5)) || (h==3&&l==3))
structure[h][l+1][1]= new ItemStack(IEContent.blockStorage,1,BlockTypes_MetalsIE.STEEL.getMeta());
else
structure[h][l+1][1]= new ItemStack(IEContent.blockMetalDecoration1,1,BlockTypes_MetalDecoration1.STEEL_SCAFFOLDING_0.getMeta());
}
}
@Override
public ItemStack[][][] getStructureManual()
{
return structure;
}
@Override
@SideOnly(Side.CLIENT)
public boolean overwriteBlockRender(ItemStack stack, int iterator)
{
return false;
}
@Override
@SideOnly(Side.CLIENT)
public boolean canRenderFormedStructure()
{
return true;
}
@SideOnly(Side.CLIENT)
static ItemStack renderStack;
@SideOnly(Side.CLIENT)
static ItemStack renderStack2;
@Override
@SideOnly(Side.CLIENT)
public void renderFormedStructure()
{
if(renderStack==null)
renderStack = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.EXCAVATOR.getMeta());
if(renderStack2==null)
renderStack2 = new ItemStack(IEContent.blockMetalMultiblock,1,BlockTypes_MetalMultiblock.BUCKET_WHEEL.getMeta());
GlStateManager.translate(2, 3.5, 2.875);
GlStateManager.rotate(-225, 0, 1, 0);
GlStateManager.rotate(-20, 1, 0, 0);
double s = 5.25;
GlStateManager.scale(s,s,s);
GlStateManager.disableCull();
ClientUtils.mc().getRenderItem().renderItem(renderStack, ItemCameraTransforms.TransformType.GUI);
GlStateManager.scale(1/s,1/s,1/s);
GlStateManager.rotate(20, 1, 0, 0);
GlStateManager.rotate(225, 0, 1, 0);
GlStateManager.translate(2.5,0,-1.375);
GlStateManager.rotate(-45, 0, 1, 0);
GlStateManager.rotate(-20, 1, 0, 0);
GlStateManager.scale(6.875, 6.875, 6.875);
ClientUtils.mc().getRenderItem().renderItem(renderStack2, ItemCameraTransforms.TransformType.GUI);
GlStateManager.enableCull();
}
@Override
public float getManualScale()
{
return 12;
}
@Override
public String getUniqueName()
{
return "IE:ExcavatorDemo";
}
@Override
public boolean isBlockTrigger(IBlockState state)
{
return false;
}
@Override
public boolean createStructure(World world, BlockPos pos, EnumFacing side, EntityPlayer player)
{
return false;
}
static final IngredientStack[] materials = new IngredientStack[]{
new IngredientStack("scaffoldingSteel", 26),
new IngredientStack("blockSheetmetalSteel", 15),
new IngredientStack("blockSteel", 9),
new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.RS_ENGINEERING.getMeta())),
new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 9, BlockTypes_MetalDecoration0.LIGHT_ENGINEERING.getMeta())),
new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 5, BlockTypes_MetalDecoration0.HEAVY_ENGINEERING.getMeta())),
new IngredientStack(new ItemStack(IEContent.blockMetalDecoration0, 3, BlockTypes_MetalDecoration0.RADIATOR.getMeta()))};
@Override
public IngredientStack[] getTotalMaterials()
{
return materials;
}
}