summaryrefslogtreecommitdiff
path: root/ihl/enviroment
diff options
context:
space:
mode:
authorFoghrye4 <foghrye4@gmail.com>2017-06-17 08:12:18 +0300
committerFoghrye4 <foghrye4@gmail.com>2017-06-17 08:12:18 +0300
commitdc3df3edd5843bde0c1335d6a8e460b2c832aa48 (patch)
treeaf13bfeee567f2351e35e1ef176d168fe37c8aac /ihl/enviroment
parent1da8dcd58647e34c9af94ceeecaeaf3b0d08c48c (diff)
full project files
Diffstat (limited to 'ihl/enviroment')
-rw-r--r--ihl/enviroment/LaserHitMirrorEventHandler.java48
-rw-r--r--ihl/enviroment/MirrorBlock.java200
-rw-r--r--ihl/enviroment/MirrorRender.java416
-rw-r--r--ihl/enviroment/MirrorTileEntity.java433
4 files changed, 0 insertions, 1097 deletions
diff --git a/ihl/enviroment/LaserHitMirrorEventHandler.java b/ihl/enviroment/LaserHitMirrorEventHandler.java
deleted file mode 100644
index 6cd61fc..0000000
--- a/ihl/enviroment/LaserHitMirrorEventHandler.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package ihl.enviroment;
-
-import cpw.mods.fml.common.eventhandler.SubscribeEvent;
-import ic2.api.event.LaserEvent;
-import ic2.core.item.tool.EntityMiningLaser;
-import net.minecraft.entity.Entity;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraftforge.common.util.ForgeDirection;
-
-public class LaserHitMirrorEventHandler
-{
- public LaserHitMirrorEventHandler(){}
-
- @SubscribeEvent
- public void onLaserHit(LaserEvent.LaserHitsBlockEvent event)
- {
- TileEntity te = event.world.getTileEntity(event.x, event.y, event.z);
- if(te instanceof MirrorTileEntity)
- {
- ForgeDirection mirrorDirection = ForgeDirection.getOrientation(((MirrorTileEntity)te).getFacing());
- Entity ls = event.lasershot;
- if((ls.motionX*mirrorDirection.offsetX+ls.motionY*mirrorDirection.offsetY+ls.motionZ*mirrorDirection.offsetZ)<0)
- {
- if(mirrorDirection.offsetX!=0)
- {
- ls.motionX=-ls.motionX;
- }
- if(mirrorDirection.offsetY!=0)
- {
- ls.motionY=-ls.motionY;
- }
- if(mirrorDirection.offsetZ!=0)
- {
- ls.motionZ=-ls.motionZ;
- }
- if(!event.world.isRemote)
- {
- EntityMiningLaser tLaser = new EntityMiningLaser(event.world, event.owner, event.range, event.power, event.blockBreaks, event.explosive, 0, 0, ls.posY);
- tLaser.setPosition(ls.posX, ls.posY, ls.posZ);
- tLaser.setLaserHeading(ls.motionX, ls.motionY, ls.motionZ, 1d);
- ls.setDead();
- event.world.spawnEntityInWorld(tLaser);
- }
- event.setCanceled(true);
- }
- }
- }
-}
diff --git a/ihl/enviroment/MirrorBlock.java b/ihl/enviroment/MirrorBlock.java
deleted file mode 100644
index e996876..0000000
--- a/ihl/enviroment/MirrorBlock.java
+++ /dev/null
@@ -1,200 +0,0 @@
-package ihl.enviroment;
-import cpw.mods.fml.common.registry.GameRegistry;
-import cpw.mods.fml.relauncher.Side;
-import cpw.mods.fml.relauncher.SideOnly;
-import ihl.IHLCreativeTab;
-import ihl.IHLModInfo;
-import ihl.utils.IHLUtils;
-import net.minecraft.block.Block;
-import net.minecraft.block.ITileEntityProvider;
-import net.minecraft.block.material.Material;
-import net.minecraft.client.renderer.texture.IIconRegister;
-import net.minecraft.entity.EntityLivingBase;
-import net.minecraft.item.ItemStack;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.AxisAlignedBB;
-import net.minecraft.util.MathHelper;
-import net.minecraft.world.IBlockAccess;
-import net.minecraft.world.World;
-
-public class MirrorBlock extends Block implements ITileEntityProvider {
-
- public MirrorBlock(String unlocalizedName1)
- {
- super(Material.glass);
- this.setBlockName(unlocalizedName1);
- GameRegistry.registerBlock(this, unlocalizedName1);
- this.setCreativeTab(IHLCreativeTab.tab);
- this.setHardness(0.3f);
- this.setResistance(0.3f);
- this.setBlockTextureName("clay");
- }
-
- public static void init()
- {
- new MirrorBlock("mirror");
- GameRegistry.registerTileEntity(MirrorTileEntity.class, "mirror");
- }
-
- @Override
- public TileEntity createNewTileEntity(World arg0, int arg1) {
- return new MirrorTileEntity();
- }
-
- @Override
- public boolean isOpaqueCube()
- {
- return false;
- }
-
- @Override
- public boolean renderAsNormalBlock()
- {
- return false;
- }
-
- @Override
- public void setBlockBoundsBasedOnState(IBlockAccess iBlockAccess, int x, int y, int z)
- {
- TileEntity te = iBlockAccess.getTileEntity(x, y, z);
- if(te!=null && te instanceof MirrorTileEntity)
- {
- MirrorTileEntity ate = (MirrorTileEntity) te;
- setBlockBoundsBasedOnFacing(ate.getFacing());
- }
- }
-
- @Override
- public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z)
- {
- TileEntity te = world.getTileEntity(x, y, z);
- if(te!=null && te instanceof MirrorTileEntity)
- {
- MirrorTileEntity ate = (MirrorTileEntity) te;
- int var2 = ate.getFacing() & 7;
- float var6 = 0.5F;
- float var7 = 0.09F;
- if (var2 == 0)
- {
- return AxisAlignedBB.getBoundingBox(x+0.5F - var6,y+1.0F - var7,z+ 0.5F - var6, x+0.5F + var6, y+1.0F, z+0.5F + var6);
- }
- else if (var2 == 1)
- {
- return AxisAlignedBB.getBoundingBox(x+0.5F - var6,y+ 0.0F,z+ 0.5F - var6, x+0.5F + var6, y+var7, z+0.5F + var6);
- }
- else if (var2 == 2)
- {
- return AxisAlignedBB.getBoundingBox(x+0.5F - var6,y+ 0.5F - var6,z+ 1.0F - var7, x+0.5F + var6, y+0.5F + var6, z+1.0F);
- }
- else if (var2 == 3)
- {
- return AxisAlignedBB.getBoundingBox(x+0.5F - var6,y+ 0.5F - var6,z+ 0.0F, x+0.5F + var6, y+0.5F + var6, z+var7);
- }
- else if (var2 == 4)
- {
- return AxisAlignedBB.getBoundingBox(x+1.0F - var7,y+ 0.5F - var6,z+0.5F - var6, x+1.0F, y+0.5F + var6, z+0.5F + var6);
- }
- else if (var2 == 5)
- {
- return AxisAlignedBB.getBoundingBox(x+0.0F,y+ 0.5F - var6, z+0.5F - var6, x+var7, y+0.5F + var6, z+0.5F + var6);
- }
- }
- return null;
- }
-
- private void setBlockBoundsBasedOnFacing(int facing)
- {
- int var2 = facing & 7;
- float var6 = 0.5F;
- float var7 = 0.09F;
- if (var2 == 0)
- {
- this.setBlockBounds(0.5F - var6, 1.0F - var7, 0.5F - var6, 0.5F + var6, 1.0F, 0.5F + var6);
- }
- else if (var2 == 1)
- {
- this.setBlockBounds(0.5F - var6, 0.0F, 0.5F - var6, 0.5F + var6, var7, 0.5F + var6);
- }
- else if (var2 == 2)
- {
- this.setBlockBounds(0.5F - var6, 0.5F - var6, 1.0F - var7, 0.5F + var6, 0.5F + var6, 1.0F);
- }
- else if (var2 == 3)
- {
- this.setBlockBounds(0.5F - var6, 0.5F - var6, 0.0F, 0.5F + var6, 0.5F + var6, var7);
- }
- else if (var2 == 4)
- {
- this.setBlockBounds(1.0F - var7, 0.5F - var6, 0.5F - var6, 1.0F, 0.5F + var6, 0.5F + var6);
- }
- else if (var2 == 5)
- {
- this.setBlockBounds(0.0F, 0.5F - var6, 0.5F - var6, var7, 0.5F + var6, 0.5F + var6);
- }
- }
-
- /**
- * Sets the block's bounds for rendering it as an item
- */
- @Override
- public void setBlockBoundsForItemRender()
- {
- float var1 = 0.5F;
- float var2 = 0.5F;
- float var3 = 0.05F;
- this.setBlockBounds(0.5F - var1, 0.5F - var2, 0.5F - var3, 0.5F + var1, 0.5F + var2, 0.5F + var3);
- }
-
- @Override
- public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemStack)
- {
- int var6 = MathHelper.floor_double(player.rotationPitch * 4.0F / 360.0F + 0.5D) & 3;
- int var7 = MathHelper.floor_double(player.rotationYaw * 4.0F / 360.0F + 0.5D) & 3;
- TileEntity t = world.getTileEntity(x, y, z);
- if(t!=null && t instanceof MirrorTileEntity)
- {
- MirrorTileEntity te = (MirrorTileEntity)t;
- if(var6==1)
- {
- te.setFacing((short) 1);
- }
- else if(var6==3)
- {
- te.setFacing((short) 0);
- }
- else
- {
- switch(var7)
- {
- case 0:
- te.setFacing((short) 2);
- break;
- case 1:
- te.setFacing((short) 5);
- break;
- case 2:
- te.setFacing((short) 3);
- break;
- case 3:
- te.setFacing((short) 4);
- break;
- default:
- break;
- }
- }
- }
- }
-
- @Override
- @SideOnly(Side.CLIENT)
- public void registerBlockIcons(IIconRegister par1IconRegister)
- {
- this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":mirror");
- }
-
- @Override
- public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag)
- {
- this.dropBlockAsItem(world, x, y, z, IHLUtils.getThisModItemStack("dustGlass"));
- }
-}
diff --git a/ihl/enviroment/MirrorRender.java b/ihl/enviroment/MirrorRender.java
deleted file mode 100644
index 60bc501..0000000
--- a/ihl/enviroment/MirrorRender.java
+++ /dev/null
@@ -1,416 +0,0 @@
-package ihl.enviroment;
-
-import java.nio.IntBuffer;
-import java.util.Iterator;
-
-import org.lwjgl.BufferUtils;
-import org.lwjgl.opengl.Display;
-import org.lwjgl.opengl.GL11;
-import org.lwjgl.opengl.GL30;
-import org.lwjgl.util.glu.GLU;
-import org.lwjgl.util.glu.Project;
-
-import ihl.IHLMod;
-import ihl.model.IHLBlockRenderer;
-import ihl.utils.IHLRenderUtils;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.renderer.GLAllocation;
-import net.minecraft.client.renderer.RenderHelper;
-import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.entity.Render;
-import net.minecraft.client.renderer.texture.TextureMap;
-import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
-import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
-import net.minecraft.entity.Entity;
-import net.minecraft.tileentity.TileEntity;
-
-public class MirrorRender extends TileEntitySpecialRenderer{
-private int texture=-1;
-private int fb=-1;
-private static final IntBuffer textureIDBuffer = BufferUtils.createIntBuffer(1);
-private static final float zNear = 1.5f;//1.5f
-private static final float zFar = 0.1f;//0.1f
-private final int textureWidth=512;
-private final int textureHeight=512;
-private final int[] xdepth;
-private final int[] ydepth;
-private final int[] textureU;
-private final int[] textureV;
-private final Minecraft mc;
-
-public MirrorRender()
-{
- xdepth=new int[] {0,0,1,1};
- ydepth=new int[] {0,1,1,0};
- textureU=new int[] {0,0,1,1};
- textureV=new int[]{0,1,1,0};
- mc=Minecraft.getMinecraft();
-}
-
-public void renderAModelAt(MirrorTileEntity tile, double x, double y, double z, float f) {
- float[] mAxis = tile.getMirrorAxis();
- if(texture==-1)
- {
- GL11.glGenTextures(textureIDBuffer);
- texture=textureIDBuffer.get(0);
- fb=GL30.glGenFramebuffers();
- GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fb);
- GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
- GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB8, textureWidth, textureHeight, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, (java.nio.ByteBuffer)null);
- GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
- GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
- GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER,GL11. GL_LINEAR);
- GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
- int depthBuffer = GL30.glGenRenderbuffers();
- GL30.glBindRenderbuffer(GL30.GL_RENDERBUFFER, depthBuffer);
- GL30.glRenderbufferStorage(GL30.GL_RENDERBUFFER, GL11.GL_DEPTH_COMPONENT, textureWidth, textureHeight);
- GL30.glFramebufferRenderbuffer(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL30.GL_RENDERBUFFER, depthBuffer);
- GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, texture, 0);
- if (GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER) != GL30.GL_FRAMEBUFFER_COMPLETE)
- {
- IHLMod.log.error("Something went wrong while creating frame buffer!");
- IHLMod.log.error(GL30.glCheckFramebufferStatus(GL30.GL_FRAMEBUFFER));
- }
- else
- {
- IHLMod.log.info("FrameBuffer loaded correctly!");
- }
- }
- //Show reflection when:
- //x>-1 when offsetX==-1
- //x<0 when offsetX==1
- if(tile.shouldReflect &&
- ((x>-0.8D && mAxis[3]==-1)||
- (x<-0.2 && mAxis[3]==1)||
- (y>-0.8D && mAxis[4]==-1)||
- (y<-0.2D && mAxis[4]==1)||
- (z>-0.8D && mAxis[5]==-1)||
- (z<-0.2D && mAxis[5]==1)))
- {
- GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fb);
- drawReflection(tile, x, y, z, f);
- mc.entityRenderer.setupCameraTransform(f, 0);
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
- GL11.glPushMatrix();
- GL11.glTranslatef((float) x, (float) y , (float) z);
- defineMeshAndTextureCoordinates(tile);
- IHLRenderUtils.instance.enableAmbientLighting();
- drawMirrorFrame(tile);
- IHLRenderUtils.instance.disableAmbientLighting();
- RenderHelper.enableStandardItemLighting();
- GL11.glPopMatrix();
- }
-}
-
- @Override
- public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8)
- {
- this.renderAModelAt((MirrorTileEntity)par1TileEntity, par2, par4, par6, par8);
- }
-
- private void drawReflection(MirrorTileEntity tile, double x, double y, double z, float f)
- {
- GL11.glViewport(0, 0, textureWidth, textureHeight);
- GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
- GL11.glColor4f(1f, 1f, 1f, 1f);
- setMirrorView(tile, x, y, z);
- IHLRenderUtils.instance.enableAmbientLighting();
- mc.renderGlobal.renderSky(f);
- mc.renderGlobal.renderClouds(f);
- IHLRenderUtils.instance.disableAmbientLighting();
- setMirrorView(tile, x, y, z);
- GL11.glColor4f(1f, 1f, 1f, 1f);
- bindTexture(TextureMap.locationBlocksTexture);
- GL11.glTranslatef((-tile.xCoord), (-tile.yCoord), (-tile.zCoord));
- if (tile.displayListCache != -1)
- {
- GL11.glCallList(tile.displayListCache);
- if(tile.needRenderUpdate)
- {
- IHLBlockRenderer.instance.refreshDisplayLists(tile.displayListCache, tile.bwc, tile.chunkCache);
- tile.needRenderUpdate=false;
- }
- }
- else if(tile.chunkCache!=null)
- {
- tile.displayListCache=GLAllocation.generateDisplayLists(1);
- IHLBlockRenderer.instance.refreshDisplayLists(tile.displayListCache, tile.bwc, tile.chunkCache);
- }
- Iterator<Entity> ientity = tile.reflectedEntity.iterator();
- while(ientity.hasNext())
- {
- Entity centity = ientity.next();
- Render render = (Render) IHLMod.proxy.getRenderForEntityClass(centity.getClass());
- if(render!=null)
- {
- render.doRender(centity, centity.prevPosX, centity.prevPosY, centity.prevPosZ, 1f, f);
- GL11.glEnable(GL11.GL_COLOR_MATERIAL);
- GL11.glColor4f(1f, 1f, 1f, 1f);
- }
- }
- Iterator<TileEntity> itentity = tile.reflectedTileEntity.iterator();
- while(itentity.hasNext())
- {
- TileEntity te = itentity.next();
- if(TileEntityRendererDispatcher.instance.hasSpecialRenderer(te))
- {
- TileEntitySpecialRenderer specialRenderer = TileEntityRendererDispatcher.instance.getSpecialRenderer(te);
- specialRenderer.renderTileEntityAt(te, te.xCoord, te.yCoord, te.zCoord, f);
- GL11.glEnable(GL11.GL_COLOR_MATERIAL);
- }
- }
- GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight());
- }
-
- private void defineMeshAndTextureCoordinates(MirrorTileEntity tile)
- {
- switch (tile.getFacing())
- {
- case 0://up
- xdepth[0]=1+tile.reflectExtensionRight;
- xdepth[1]=1+tile.reflectExtensionRight;
- xdepth[2]=0;
- xdepth[3]=0;
- ydepth[0]=0;
- ydepth[1]=1+tile.reflectExtensionTop;
- ydepth[2]=1+tile.reflectExtensionTop;
- ydepth[3]=0;
- textureU[0]=0;
- textureU[1]=0;
- textureU[2]=1;
- textureU[3]=1;
- textureV[0]=0;
- textureV[1]=1;
- textureV[2]=1;
- textureV[3]=0;
- break;
- case 1://down
- xdepth[0]=-tile.reflectExtensionRight;
- xdepth[1]=-tile.reflectExtensionRight;
- xdepth[2]=1;
- xdepth[3]=1;
- ydepth[0]=-tile.reflectExtensionTop;
- ydepth[1]=1;
- ydepth[2]=1;
- ydepth[3]=-tile.reflectExtensionTop;
- textureU[0]=0;
- textureU[1]=0;
- textureU[2]=1;
- textureU[3]=1;
- textureV[0]=0;
- textureV[1]=1;
- textureV[2]=1;
- textureV[3]=0;
- break;
- case 2:
- xdepth[0]=0;
- xdepth[1]=0;
- xdepth[2]=1+tile.reflectExtensionRight;
- xdepth[3]=1+tile.reflectExtensionRight;
- ydepth[0]=0;
- ydepth[1]=1+tile.reflectExtensionTop;
- ydepth[2]=1+tile.reflectExtensionTop;
- ydepth[3]=0;
- textureU[0]=0;
- textureU[1]=0;
- textureU[2]=1;
- textureU[3]=1;
- textureV[0]=0;
- textureV[1]=1;
- textureV[2]=1;
- textureV[3]=0;
- break;
- case 3:
- xdepth[0]=-tile.reflectExtensionRight;
- xdepth[1]=1;
- xdepth[2]=1;
- xdepth[3]=-tile.reflectExtensionRight;
- ydepth[0]=0;
- ydepth[1]=0;
- ydepth[2]=1+tile.reflectExtensionTop;
- ydepth[3]=1+tile.reflectExtensionTop;
- textureU[0]=1;
- textureU[1]=0;
- textureU[2]=0;
- textureU[3]=1;
- textureV[0]=0;
- textureV[1]=0;
- textureV[2]=1;
- textureV[3]=1;
- break;
- case 4:
- xdepth[0]=-tile.reflectExtensionRight;
- xdepth[1]=1;
- xdepth[2]=1;
- xdepth[3]=-tile.reflectExtensionRight;
- ydepth[0]=0;
- ydepth[1]=0;
- ydepth[2]=1+tile.reflectExtensionTop;
- ydepth[3]=1+tile.reflectExtensionTop;
- textureU[0]=1;
- textureU[1]=0;
- textureU[2]=0;
- textureU[3]=1;
- textureV[0]=0;
- textureV[1]=0;
- textureV[2]=1;
- textureV[3]=1;
- break;
- case 5:
- xdepth[0]=0;
- xdepth[1]=0;
- xdepth[2]=1+tile.reflectExtensionRight;
- xdepth[3]=1+tile.reflectExtensionRight;
- ydepth[0]=0;
- ydepth[1]=1+tile.reflectExtensionTop;
- ydepth[2]=1+tile.reflectExtensionTop;
- ydepth[3]=0;
- textureU[0]=0;
- textureU[1]=0;
- textureU[2]=1;
- textureU[3]=1;
- textureV[0]=0;
- textureV[1]=1;
- textureV[2]=1;
- textureV[3]=0;
- break;
- default:
- }
-
- }
-
- private void drawMirrorFrame(MirrorTileEntity tile)
- {
- GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
- GL11.glColor4f(1f, 1f, 1f, 1f);
- GL11.glDisable(GL11.GL_BLEND);
- Tessellator tessellator=Tessellator.instance;
- tessellator.startDrawingQuads();
- for(int i=0;i<xdepth.length;i++)
- {
- switch (tile.getFacing())
- {
- case 0:
- tessellator.addVertexWithUV(xdepth[i], 0.9d, ydepth[i],textureU[i],textureV[i]);
- break;
- case 1:
- tessellator.addVertexWithUV(xdepth[i], 0.1d, ydepth[i],textureU[i],textureV[i]);
- break;
- case 2:
- tessellator.addVertexWithUV(xdepth[i], ydepth[i], 0.9d,textureU[i],textureV[i]);
- break;
- case 3:
- tessellator.addVertexWithUV(xdepth[i], ydepth[i], 0.1d,textureU[i],textureV[i]);
- break;
- case 4:
- tessellator.addVertexWithUV(0.9d, ydepth[i], xdepth[i],textureU[i],textureV[i]);
- break;
- case 5:
- tessellator.addVertexWithUV(0.1d, ydepth[i], xdepth[i],textureU[i],textureV[i]);
- break;
- default:
- }
- }
- tessellator.draw();
- }
-
- private void setMirrorView(MirrorTileEntity tile, double x, double y, double z)
- {
- float mirrorHeightCoorrection, mirrorWidthCoorrection, xShift, yShift, shiftCorrection,yCorrection,xCorrection,zCorrection;
- GL11.glMatrixMode(GL11.GL_PROJECTION);
- GL11.glLoadIdentity();
- Project.gluPerspective(65f, (float)this.mc.displayWidth / (float)this.mc.displayHeight, 0.05F, this.mc.gameSettings.renderDistanceChunks * 32F);
- GL11.glMatrixMode(GL11.GL_MODELVIEW);
- GL11.glLoadIdentity();
- double aspectRatioMirror = Math.sqrt((tile.reflectExtensionTop+1)/(double)(tile.reflectExtensionRight+1));
- double aspectRatio = Display.getHeight()/(double)Display.getWidth()/aspectRatioMirror;
- shiftCorrection = tile.reflectExtensionTop*0.45f+tile.reflectExtensionRight*0.45f-0.5f;
- float kYS = 0.5f;//0.5f;
- float kZS = 0.0f;//0.5f;
- switch(tile.getFacing())
- {
- //swap y and z
- case 0://down facing mirror
- mirrorHeightCoorrection = (tile.reflectExtensionTop+1)*0.5f;
- yShift = (float)(z+mirrorHeightCoorrection)*kYS;
- yCorrection = mirrorHeightCoorrection-yShift*(tile.reflectExtensionTop*0.5f+1f);
- zCorrection = 2f+shiftCorrection-kZS;
- mirrorWidthCoorrection = (-tile.reflectExtensionRight+1)*0.5f;
- xShift = (float)(-x+mirrorWidthCoorrection)*0.5f-0.5f;
- GL11.glFrustum(-aspectRatio+xShift, aspectRatio+xShift, -aspectRatioMirror+yShift, aspectRatioMirror+yShift, zNear, zFar);
- xCorrection = mirrorWidthCoorrection+xShift*(tile.reflectExtensionRight*0.5f-0.375f/(tile.reflectExtensionRight+1)+1.125f);
- GLU.gluLookAt(xCorrection+tile.reflectExtensionRight, zCorrection, yCorrection, xCorrection+tile.reflectExtensionRight/*x reference*/, -32f+zCorrection/*y reference*/, yCorrection/*z reference*/, 0.0f, 0.0f, 1.0f);
- break;
- case 1://up facing mirror
- mirrorHeightCoorrection = (-tile.reflectExtensionTop+1)*0.5f;
- yShift = (float)(z+mirrorHeightCoorrection)*kYS;
- yCorrection = mirrorHeightCoorrection-yShift*(tile.reflectExtensionTop*0.5f+1f);
- zCorrection = -1f-shiftCorrection-kZS;
- mirrorWidthCoorrection = (-tile.reflectExtensionRight+1)*0.5f;
- xShift = (float)(x+mirrorWidthCoorrection)*0.5f;
- GL11.glFrustum(-aspectRatio+xShift, aspectRatio+xShift, -aspectRatioMirror+yShift, aspectRatioMirror+yShift, zNear, zFar);
- xCorrection = mirrorWidthCoorrection-xShift*(tile.reflectExtensionRight*0.5f+1f);
- GLU.gluLookAt(xCorrection, zCorrection, yCorrection, xCorrection/*x reference*/, 32f+zCorrection/*y reference*/, yCorrection/*z reference*/, 0.0f, 0.0f, 1.0f);
- break;
- case 2:
- mirrorHeightCoorrection = (tile.reflectExtensionTop+1)*0.5f;
- yShift = (float)(y+mirrorHeightCoorrection)*kYS;
- yCorrection = mirrorHeightCoorrection-yShift*(tile.reflectExtensionTop*0.5f+1f);
- zCorrection = 2f+shiftCorrection-kZS;
- mirrorWidthCoorrection = (tile.reflectExtensionRight+1)*0.5f;
- xShift = (float)(x+mirrorWidthCoorrection)*0.5f;
- GL11.glFrustum(-aspectRatio+xShift, aspectRatio+xShift, -aspectRatioMirror+yShift, aspectRatioMirror+yShift, zNear, zFar);
- xCorrection = mirrorWidthCoorrection-xShift*(tile.reflectExtensionRight*0.5f+1f);
- GLU.gluLookAt(xCorrection, yCorrection, zCorrection, xCorrection/*x reference*/, yCorrection/*y reference*/, -32f+zCorrection/*z reference*/, 0.0f, 1.0f, 0.0f);
- break;
- case 3:
- mirrorHeightCoorrection = (tile.reflectExtensionTop+1)*0.5f;
- yShift = (float)(y+mirrorHeightCoorrection)*kYS;
- yCorrection = mirrorHeightCoorrection-yShift*(tile.reflectExtensionRight*0.5f+1f);
- zCorrection = -1f-shiftCorrection-kZS;
- mirrorWidthCoorrection = 0.5f-tile.reflectExtensionRight*0.5f;
- xShift = (float)(-x-mirrorWidthCoorrection)*0.5f;
- GL11.glFrustum(-aspectRatio+xShift, aspectRatio+xShift, -aspectRatioMirror+yShift, aspectRatioMirror+yShift, zNear, zFar);
- xCorrection = mirrorWidthCoorrection+xShift*(tile.reflectExtensionTop*0.5f-0.375f/(tile.reflectExtensionTop+1)+1.125f);
- GLU.gluLookAt(xCorrection, yCorrection, zCorrection, xCorrection/*x reference*/, yCorrection/*y reference*/, 32f+zCorrection/*z reference*/, 0.0f, 1.0f, 0.0f);
- break;
- case 4:
- mirrorHeightCoorrection = (tile.reflectExtensionTop+1)*0.5f;
- yShift = (float)(y+mirrorHeightCoorrection)*kYS;
- yCorrection = mirrorHeightCoorrection-yShift*(tile.reflectExtensionTop*0.5f+1f);
- zCorrection = 2f+shiftCorrection-kZS;
- mirrorWidthCoorrection = 0.5f-tile.reflectExtensionRight*0.5f;
- xShift = (float)(-z-mirrorWidthCoorrection)*0.5f;
- GL11.glFrustum(-aspectRatio+xShift, aspectRatio+xShift, -aspectRatioMirror+yShift, aspectRatioMirror+yShift, zNear, zFar);
- xCorrection = mirrorWidthCoorrection+xShift*(tile.reflectExtensionRight*0.5f-0.375f/(tile.reflectExtensionRight+1)+1.125f);
- GLU.gluLookAt(zCorrection, yCorrection, xCorrection, zCorrection-32f/*x reference*/, yCorrection/*y reference*/, xCorrection/*z reference*/, 0.0f, 1.0f, 0.0f);
- break;
- case 5:
- mirrorHeightCoorrection = (tile.reflectExtensionTop+1)*0.5f;
- yShift = (float)(y+mirrorHeightCoorrection)*kYS;
- yCorrection = mirrorHeightCoorrection-yShift*(tile.reflectExtensionTop*0.5f+1f);
- zCorrection = -1f-shiftCorrection-kZS;
- mirrorWidthCoorrection = (tile.reflectExtensionRight+1)*0.5f;
- xShift = (float)(z+mirrorWidthCoorrection)*0.5f;
- GL11.glFrustum(-aspectRatio+xShift, aspectRatio+xShift, -aspectRatioMirror+yShift, aspectRatioMirror+yShift, zNear, zFar);
- xCorrection = mirrorWidthCoorrection-xShift*(tile.reflectExtensionRight*0.5f+1f);
- GLU.gluLookAt(zCorrection, yCorrection, xCorrection, zCorrection+32f/*x reference*/, yCorrection/*y reference*/, xCorrection/*z reference*/, 0.0f, 1.0f, 0.0f);
- break;
- default:
- mirrorHeightCoorrection = (tile.reflectExtensionTop+1)*0.5f;
- yShift = (float)(y+mirrorHeightCoorrection)*kYS;
- yCorrection = mirrorHeightCoorrection-yShift*(tile.reflectExtensionTop*0.5f+1f);
- zCorrection = 2f+shiftCorrection-kZS;
- mirrorWidthCoorrection = (tile.reflectExtensionRight+1)*0.5f;
- xShift = (float)(x+mirrorWidthCoorrection)*0.5f;
- GL11.glFrustum(-aspectRatio+xShift, aspectRatio+xShift, -aspectRatioMirror+yShift, aspectRatioMirror+yShift, zNear, zFar);
- xCorrection = mirrorWidthCoorrection-xShift*(tile.reflectExtensionRight*0.5f+1f);
- GLU.gluLookAt(xCorrection, yCorrection, zCorrection, xCorrection/*x reference*/, yCorrection/*y reference*/, -32f+zCorrection/*z reference*/, 0.0f, 1.0f, 0.0f);
- }
- }
-
- public static void deleteTextures()
- {
- GL11.glDeleteTextures(textureIDBuffer);
- }
-} \ No newline at end of file
diff --git a/ihl/enviroment/MirrorTileEntity.java b/ihl/enviroment/MirrorTileEntity.java
deleted file mode 100644
index 4060e59..0000000
--- a/ihl/enviroment/MirrorTileEntity.java
+++ /dev/null
@@ -1,433 +0,0 @@
-package ihl.enviroment;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import ic2.core.block.TileEntityBlock;
-import ihl.IHLMod;
-import ihl.handpump.BlockWithCoordinates;
-import ihl.utils.IHLUtils;
-import net.minecraft.block.Block;
-import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
-import net.minecraft.entity.Entity;
-import net.minecraft.entity.EntityLivingBase;
-import net.minecraft.entity.item.EntityBoat;
-import net.minecraft.entity.item.EntityItem;
-import net.minecraft.entity.item.EntityMinecart;
-import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.item.ItemStack;
-import net.minecraft.tileentity.TileEntity;
-import net.minecraft.util.AxisAlignedBB;
-import net.minecraft.world.ChunkCache;
-import net.minecraftforge.common.util.ForgeDirection;
-
-public class MirrorTileEntity extends TileEntityBlock
-{
- public final List<BlockWithCoordinates> bwc = new ArrayList<BlockWithCoordinates>();
- public final List<Entity> reflectedEntity = new ArrayList<Entity>();
- public final List<TileEntity> reflectedTileEntity = new ArrayList<TileEntity>();
- private int bwcListPos=0;
- private int reflectedTileEntityListPos=0;
- private int reflectionVolumePos=0;
- boolean firstTick=true;
- public int dnx,dpx,dny,dpy,dnz,dpz;
- boolean shouldReflect=true;
- int reflectExtensionRight=0;
- int reflectExtensionTop=0;
- int timer=0;
- int blockReflectionUpdateTimer=0;
- int reflectionVolumeSize=-1;
- AxisAlignedBB reflectionArea;
- int displayListCache=-1;
- public ChunkCache chunkCache;
- public boolean needRenderUpdate=false;
- private int minX;
- private int maxX;
- private int minY;
- private int maxY;
- private int minZ;
- private int maxZ;
- private int lastBWCSize;
-
- public MirrorTileEntity()
- {}
-
- @SuppressWarnings("unchecked")
- @Override
- public void updateEntityClient()
- {
- super.updateEntityClient();
- if(this.shouldReflect)
- {
- int i=0;
- for(i=0;i<Math.min(this.reflectionVolumeSize, IHLMod.config.mirrorReflectionUpdateSpeed);i++)
- {
- this.checkReflectionVolume();
- }
- for(i=0;i<Math.min(this.bwc.size(), IHLMod.config.mirrorReflectionUpdateSpeed);i++)
- {
- this.checkBWCList();
- }
- for(i=0;i<Math.min(this.reflectedTileEntity.size(), IHLMod.config.mirrorReflectionUpdateSpeed);i++)
- {
- this.checkTileEntityList();
- }
- }
- if(timer++>20)
- {
- boolean isFirst=true;
- TileEntity t = worldObj.getTileEntity(xCoord-mXT(),yCoord-mYT(), zCoord-mZT());
- if(t instanceof MirrorTileEntity)
- {
- if(((MirrorTileEntity)t).getFacing()==this.getFacing())
- {
- isFirst=false;
- }
- }
- t = worldObj.getTileEntity(xCoord-mXR(),yCoord-mYR(), zCoord-mZR());
- if(t instanceof MirrorTileEntity)
- {
- if(((MirrorTileEntity)t).getFacing()==this.getFacing())
- {
- isFirst=false;
- }
- }
- if(isFirst)
- {
- this.shouldReflect=true;
- this.reflectExtensionTop=0;
- this.reflectExtensionRight=0;
- for(int i=1;i<=IHLMod.config.mirrorReflectionRange+2;i++)
- {
- t = worldObj.getTileEntity(xCoord+mXT()*i,yCoord+mYT()*i, zCoord+mZT()*i);
- if(t instanceof MirrorTileEntity && ((MirrorTileEntity)t).getFacing()==this.getFacing())
- {
- MirrorTileEntity te = (MirrorTileEntity) t;
- te.shouldReflect=false;
- this.reflectExtensionTop=i;
- }
- else
- {
- break;
- }
- }
- a:for(int i0=1;i0<=IHLMod.config.mirrorReflectionRange+2;i0++)
- {
- for(int i=0;i<=this.reflectExtensionTop;i++)
- {
- t = worldObj.getTileEntity(xCoord+mXT()*i+mXR()*i0,yCoord+mYT()*i+mYR()*i0, zCoord+mZT()*i+mZR()*i0);
- if(t instanceof MirrorTileEntity && ((MirrorTileEntity)t).getFacing()==this.getFacing())
- {
- MirrorTileEntity te = (MirrorTileEntity) t;
- te.shouldReflect=false;
- }
- else
- {
- break a;
- }
- }
- this.reflectExtensionRight=i0;
- }
- }
- if(this.reflectionArea!=null)
- {
- this.reflectedEntity.clear();
- this.reflectedEntity.addAll(worldObj.getEntitiesWithinAABB(EntityLivingBase.class, this.reflectionArea));
- this.reflectedEntity.addAll(worldObj.getEntitiesWithinAABB(EntityBoat.class, this.reflectionArea));
- this.reflectedEntity.addAll(worldObj.getEntitiesWithinAABB(EntityItem.class, this.reflectionArea));
- this.reflectedEntity.addAll(worldObj.getEntitiesWithinAABB(EntityMinecart.class, this.reflectionArea));
- }
- timer=0;
- }
- if(firstTick && this.shouldReflect)
- {
- int ix,iy,iz;
- int range=IHLMod.config.mirrorReflectionRange;
- ForgeDirection direction = ForgeDirection.getOrientation(this.getFacing());
- bwc.clear();
- {
- dpx = direction.offsetX==-1?0:1;
- dnx = direction.offsetX==1?0:1;
- dpy = direction.offsetY==-1?0:1;
- dny = direction.offsetY==1?0:1;
- dpz = direction.offsetZ==-1?0:1;
- dnz = direction.offsetZ==1?0:1;
- reflectionVolumeSize=(range*dnx+range*dpx+dnx)*(range*dny+range*dpy+dny)*(range*dnz+range*dpz+dnz);
- reflectionArea = AxisAlignedBB.getBoundingBox(xCoord-range*dnx-1d, yCoord-range*dny-1d, zCoord-range*dnz-1d, xCoord+range*dpx+dnx+1d, yCoord+range*dpy+dny+1d, zCoord+range*dpz+dnz+1d);
- minX = xCoord-range*dnx;
- maxX = xCoord+range*dpx+dnx;
- minY = Math.max(yCoord-range*dny,0);
- maxY = Math.min(yCoord+range*dpy+dny,this.worldObj.getActualHeight());
- minZ = zCoord-range*dnz;
- maxZ = zCoord+range*dpz+dnz;
- chunkCache = new ChunkCache(worldObj, minX, minY, minZ, maxX, maxY, maxZ, 16);
- for(ix=minX;ix<maxX;ix++)
- {
- for(iy=minY;iy<maxY;iy++)
- {
- for(iz=minZ;iz<maxZ;iz++)
- {
- Block block = worldObj.getBlock(ix, iy, iz);
- if(block!=null && !block.isAir(worldObj, ix, iy, iz) && isBlockVisible(block,ix,iy,iz))
- {
- TileEntity te = worldObj.getTileEntity(ix, iy, iz);
- if(te!=null && !te.isInvalid() && !reflectedTileEntity.contains(te) && TileEntityRendererDispatcher.instance.hasSpecialRenderer(te) && !(te instanceof MirrorTileEntity))
- {
- reflectedTileEntity.add(te);
- }
- if(block.getRenderType()>=0)
- {
- bwc.add(new BlockWithCoordinates(block, ix, iy, iz, worldObj.getBlockMetadata(ix, iy, iz)));
- }
- }
-
- }
- }
- }
- }
- lastBWCSize=bwc.size();
- firstTick=false;
- }
- }
-
- private boolean isBlockVisible(Block block, int x, int y, int z)
- {
- if(block instanceof MirrorBlock)
- {
- ForgeDirection direction = ForgeDirection.getOrientation(this.getFacing());
- int x1=x*direction.offsetX;
- int y1=y*direction.offsetY;
- int z1=z*direction.offsetZ;
- int x2=xCoord*direction.offsetX;
- int y2=yCoord*direction.offsetY;
- int z2=zCoord*direction.offsetZ;
- return !(x1==x2 && y1==y2 && z1==z2);
- }
- if(block.shouldSideBeRendered(worldObj, x, y-1, z, 0))
- {
- return true;
- }
- if(block.shouldSideBeRendered(worldObj, x, y+1, z, 1))
- {
- return true;
- }
- if(block.shouldSideBeRendered(worldObj, x, y, z-1, 2))
- {
- return true;
- }
- if(block.shouldSideBeRendered(worldObj, x, y, z+1, 3))
- {
- return true;
- }
- if(block.shouldSideBeRendered(worldObj, x-1, y, z, 4))
- {
- return true;
- }
- if(block.shouldSideBeRendered(worldObj, x+1, y, z, 5))
- {
- return true;
- }
- return false;
- }
-
- @Override
- public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) {
- return false;
- }
-
- @Override
- public boolean wrenchCanRemove(EntityPlayer entityPlayer) {
- return true;
- }
-
- @Override
- public void setFacing(short side)
- {
- super.setFacing(side);
- this.bwc.clear();
- this.firstTick=true;
- }
-
- @Override
- public float getWrenchDropRate() {
- return 1F;
- }
-
- @Override
- public ItemStack getWrenchDrop(EntityPlayer entityPlayer) {
- return IHLUtils.getThisModItemStack("mirror");
- }
-
- public float[] getMirrorAxis()
- {
- ForgeDirection direction = ForgeDirection.getOrientation(this.getFacing());
- int mx = direction.offsetX!=0?-1:1;
- int my = direction.offsetY!=0?-1:1;
- int mz = direction.offsetZ!=0?-1:1;
- return new float[] {mx,my,mz,direction.offsetX,direction.offsetY,direction.offsetZ};
- }
-
- private void checkBWCList()
- {
- if(++this.bwcListPos>=bwc.size())
- {
- this.bwcListPos=0;
- }
- if(!bwc.isEmpty())
- {
- BlockWithCoordinates bwcEntry = bwc.get(bwcListPos);
- if(bwcEntry.block!=worldObj.getBlock(bwcEntry.x, bwcEntry.y, bwcEntry.z))
- {
- bwc.remove(bwcListPos);
- }
- }
- }
-
- private void checkTileEntityList()
- {
- if(++this.reflectedTileEntityListPos>=reflectedTileEntity.size())
- {
- this.reflectedTileEntityListPos=0;
- }
- if(!reflectedTileEntity.isEmpty())
- {
- TileEntity entry = reflectedTileEntity.get(reflectedTileEntityListPos);
- if(entry==null || entry.isInvalid() || entry!=worldObj.getTileEntity(entry.xCoord, entry.yCoord, entry.zCoord))
- {
- reflectedTileEntity.remove(reflectedTileEntityListPos);
- }
- }
- }
-
- private void checkReflectionVolume()
- {
- if(++this.reflectionVolumePos>=reflectionVolumeSize)
- {
- this.reflectionVolumePos=0;
- if(lastBWCSize!=bwc.size())
- {
- this.needRenderUpdate=true;
- lastBWCSize=bwc.size();
- }
- }
- if(reflectionVolumeSize>0)
- {
- //reflectionVolumePos = x+y*maxX+z*maxX*maxY;
- int z = reflectionVolumePos / (maxX-minX) / (maxY-minY);
- int y = (reflectionVolumePos % ((maxX-minX) * (maxY-minY)))/ (maxX-minX);
- int x = reflectionVolumePos - y * (maxX-minX) - z * (maxX-minX) * (maxY-minY);
- //for example position is 69 volume is 4*5*5=100, therefore z will be 69 / (4*5)=3
- //y will be (69 % (4*5))/4=9/4=2
- //x will be 69 - 2*4 - 3*4*5 = 69-8-60=1
- //for check 1+2*4+3*4*5=1+8+60
- int ix = minX+x;
- int iy = minY+y;
- int iz = minZ+z;
- Block block = worldObj.getBlock(ix, iy, iz);
- if(block!=null && !block.isAir(worldObj, ix, iy, iz) && isBlockVisible(block,ix,iy,iz))
- {
- TileEntity te = worldObj.getTileEntity(ix, iy, iz);
- if(te!=null && !te.isInvalid() && !reflectedTileEntity.contains(te) && TileEntityRendererDispatcher.instance.hasSpecialRenderer(te) && !(te instanceof MirrorTileEntity))
- {
- reflectedTileEntity.add(te);
- }
- if(block.getRenderType()>=0)
- {
- BlockWithCoordinates bwc1 = new BlockWithCoordinates(block, ix, iy, iz, worldObj.getBlockMetadata(ix, iy, iz));
- if(!bwc.contains(bwc1))
- {
- bwc.add(bwc1);
- }
- }
- }
- }
- }
-
- private int mXR()
- {
- switch(this.getFacing())
- {
- case 0:
- return 1;
- case 1:
- return -1;
- case 2:
- return 1;
- case 3:
- return -1;
- default:
- return 0;
- }
- }
-
- private int mYR()
- {
- return 0;
- }
-
- private int mZR()
- {
- switch(this.getFacing())
- {
- case 4:
- return -1;
- case 5:
- return 1;
- default:
- return 0;
- }
- }
-
- private int mXT()
- {
- return 0;
- }
-
- private int mYT()
- {
- switch(this.getFacing())
- {
- case 2:
- return 1;
- case 3:
- return 1;
- case 4:
- return 1;
- case 5:
- return 1;
- default:
- return 0;
- }
- }
-
- private int mZT()
- {
- switch(this.getFacing())
- {
- case 0:
- return 1;
- case 1:
- return -1;
- default:
- return 0;
- }
- }
-
- @Override
- public AxisAlignedBB getRenderBoundingBox()
- {
- double xMinD=(double)this.xCoord-this.reflectExtensionRight*Math.abs(this.mXR())-this.reflectExtensionTop*Math.abs(this.mXT());
- double xMaxD=(double)this.xCoord+this.reflectExtensionRight*Math.abs(this.mXR())+this.reflectExtensionTop*Math.abs(this.mXT())+1d;
- double yMinD=(double)this.yCoord-this.reflectExtensionRight*Math.abs(this.mYR())-this.reflectExtensionTop*Math.abs(this.mYT());
- double yMaxD=(double)this.yCoord+this.reflectExtensionRight*Math.abs(this.mYR())+this.reflectExtensionTop*Math.abs(this.mYT())+1d;
- double zMinD=(double)this.zCoord-this.reflectExtensionRight*Math.abs(this.mZR())-this.reflectExtensionTop*Math.abs(this.mZT());
- double zMaxD=(double)this.zCoord+this.reflectExtensionRight*Math.abs(this.mZR())+this.reflectExtensionTop*Math.abs(this.mZT())+1d;
- return AxisAlignedBB.getBoundingBox(xMinD, yMinD, zMinD, xMaxD, yMaxD, zMaxD);
- }
-
- @Override
- public boolean shouldRenderInPass(int pass)
- {
- return pass==0;
- }
-} \ No newline at end of file