diff options
| author | Foghrye4 <foghrye4@gmail.com> | 2017-03-21 17:34:07 +0300 |
|---|---|---|
| committer | Foghrye4 <foghrye4@gmail.com> | 2017-03-21 17:34:07 +0300 |
| commit | 7305ba719930ea3fbf8aa987aeec48b33cdbd82e (patch) | |
| tree | 2307517925d965cd9228c8649013b07639987846 /ihl/explosion | |
| parent | 5cb4c6e24033cf337812390d99a6817d24d21eab (diff) | |
Oregen
Diffstat (limited to 'ihl/explosion')
| -rw-r--r-- | ihl/explosion/ChunkAndWorldLoadEventHandler.java | 4 | ||||
| -rw-r--r-- | ihl/explosion/ExplosionVectorBlockV2.java | 40 | ||||
| -rw-r--r-- | ihl/explosion/ExplosiveTileEntity.java | 4 | ||||
| -rw-r--r-- | ihl/explosion/PileBlock.java | 10 | ||||
| -rw-r--r-- | ihl/explosion/PileBlockRender.java | 513 | ||||
| -rw-r--r-- | ihl/explosion/PileTileEntityRender.java | 268 |
6 files changed, 415 insertions, 424 deletions
diff --git a/ihl/explosion/ChunkAndWorldLoadEventHandler.java b/ihl/explosion/ChunkAndWorldLoadEventHandler.java index b85e636..2f49484 100644 --- a/ihl/explosion/ChunkAndWorldLoadEventHandler.java +++ b/ihl/explosion/ChunkAndWorldLoadEventHandler.java @@ -37,10 +37,6 @@ public class ChunkAndWorldLoadEventHandler { IHLMod.explosionHandler.breakBlocksAndGetDescendants(event.world, bwArray[1], bwArray[2], bwArray[3], explosion, bwArray[0], bwArray[4], directionMask); } - if (!IHLMod.explosionHandler.isCalculating) { - IHLMod.explosionHandler.sendChunkUpdateToPlayersInExplosionAffectedZone(event.world, bwArray[1], - bwArray[2], bwArray[3]); - } } } } diff --git a/ihl/explosion/ExplosionVectorBlockV2.java b/ihl/explosion/ExplosionVectorBlockV2.java index 4489e55..daa16ce 100644 --- a/ihl/explosion/ExplosionVectorBlockV2.java +++ b/ihl/explosion/ExplosionVectorBlockV2.java @@ -13,6 +13,7 @@ import java.util.Map; import java.util.Set;
import java.util.Map.Entry;
+import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
@@ -26,6 +27,8 @@ import net.minecraft.world.Explosion; import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
+import net.minecraftforge.common.MinecraftForge;
+import net.minecraftforge.event.world.ExplosionEvent;
public class ExplosionVectorBlockV2 {
final Set<Integer> startVectors = new HashSet<Integer>();
@@ -39,7 +42,7 @@ public class ExplosionVectorBlockV2 { private final Map<Integer, ItemStack> cachedDrops = new HashMap<Integer, ItemStack>(128);
final Map<Integer, WorldSavedDataBlastWave> blastWaveByDimensionId = new HashMap<Integer, WorldSavedDataBlastWave>();
private final Map<ExtendedBlockStorage, Entity[]> cachedEntities = new HashMap<ExtendedBlockStorage, Entity[]>();
- public boolean isCalculating = false;
+ private final Random random = new Random();
public ExplosionVectorBlockV2() {
this.precalculateExplosion();
@@ -219,11 +222,13 @@ public class ExplosionVectorBlockV2 { }
} else {
block.onNeighborBlockChange(world, absX, absY, absZ, block);
- if ((++absY & 15) != 0) {
- int array_index = (absY & 15) << 8 | (absZ & 15) << 4 | (absX & 15);
- if (ebs.getBlockLSBArray()[array_index] == 0 && (ebs.getBlockMSBArray() == null
- || ebs.getBlockMSBArray().get(absX & 15, absY & 15, absZ & 15) == 0)) {
- this.placeDrops(world, absX, absY, absZ);
+ if (random.nextInt(8) == 0) {
+ if ((++absY & 15) != 0) {
+ int array_index = (absY & 15) << 8 | (absZ & 15) << 4 | (absX & 15);
+ if (ebs.getBlockLSBArray()[array_index] == 0 && (ebs.getBlockMSBArray() == null
+ || ebs.getBlockMSBArray().get(absX & 15, absY & 15, absZ & 15) == 0)) {
+ this.placeDrops(world, absX, absY, absZ);
+ }
}
}
}
@@ -275,6 +280,9 @@ public class ExplosionVectorBlockV2 { Iterator<Entry<Integer, ItemStack>> di = this.cachedDrops.entrySet().iterator();
if (di.hasNext()) {
Entry<Integer, ItemStack> cde = di.next();
+ while (di.hasNext()) {
+ cde = di.next();
+ }
ItemStack stack = cde.getValue();
if (stack != null && stack.getItem() != null && stack.stackSize > 0) {
if (stack.stackSize <= stack.getMaxStackSize()) {
@@ -328,19 +336,27 @@ public class ExplosionVectorBlockV2 { startPower, directionMask);
}
// Free and clean resources
- this.cachedDrops.clear();
this.cachedEntities.clear();
}
public void doExplosion(World world, int sourceX, int sourceY, int sourceZ, final Set<Integer> startVectors1,
int startPower) {
IHLMod.log.info("Starting explosion server");
- isCalculating = true;
Explosion explosion = new Explosion(world, null, sourceX, sourceY, sourceZ, 100f);
- for (int[] directionMask : directionMasks) {
- this.doExplosion(world, sourceX, sourceY, sourceZ, startVectors1, startPower, directionMask, explosion);
+ if (!MinecraftForge.EVENT_BUS.post(new ExplosionEvent.Start(world, explosion))) {
+ for (int[] directionMask : directionMasks) {
+ this.doExplosion(world, sourceX, sourceY, sourceZ, startVectors1, startPower, directionMask, explosion);
+ }
+ sendChunkUpdateToPlayersInExplosionAffectedZone(world, sourceX, sourceY, sourceZ);
+ for (Entry<Integer, ItemStack> entry : this.cachedDrops.entrySet()) {
+ IHLEntityFallingPile fallingPile = new IHLEntityFallingPile(world);
+ fallingPile.setPosition(sourceX + 0.5d, sourceY + 0.5d, sourceZ + 0.5d);
+ fallingPile.setEntityItemStack(entry.getValue());
+ fallingPile.setVelocity(random.nextDouble() - 0.5d, random.nextDouble() * 2,
+ random.nextDouble() - 0.5d);
+ world.spawnEntityInWorld(fallingPile);
+ }
+ this.cachedDrops.clear();
}
- sendChunkUpdateToPlayersInExplosionAffectedZone(world, sourceX, sourceY, sourceZ);
- isCalculating = false;
}
}
\ No newline at end of file diff --git a/ihl/explosion/ExplosiveTileEntity.java b/ihl/explosion/ExplosiveTileEntity.java index cfae646..b211d3b 100644 --- a/ihl/explosion/ExplosiveTileEntity.java +++ b/ihl/explosion/ExplosiveTileEntity.java @@ -63,11 +63,11 @@ public class ExplosiveTileEntity extends TileEntity { for (int oid : OreDictionary.getOreIDs(player.getCurrentEquippedItem())) { if (OreDictionary.getOreName(oid).matches("toolLighter")) { ignite(); - return true; + return false; } } } - return false; + return true; } public void ignite() { diff --git a/ihl/explosion/PileBlock.java b/ihl/explosion/PileBlock.java index a2c56c3..f9ea862 100644 --- a/ihl/explosion/PileBlock.java +++ b/ihl/explosion/PileBlock.java @@ -1,5 +1,7 @@ package ihl.explosion; +import java.util.ArrayList; + import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -10,6 +12,7 @@ import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; @@ -71,7 +74,7 @@ public class PileBlock extends Block implements ITileEntityProvider @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister par1IconRegister) { - this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":fluidAcetyleneFlowing"); + this.blockIcon = par1IconRegister.registerIcon(IHLModInfo.MODID + ":pileTextureSpace"); } @Override @@ -122,4 +125,9 @@ public class PileBlock extends Block implements ITileEntityProvider @Override public void dropBlockAsItemWithChance(World world, int x, int y, int z, int meta, float chance, int flag){} + + @Override + public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int meta, int fortune) { + return new ArrayList<ItemStack>(); + } } diff --git a/ihl/explosion/PileBlockRender.java b/ihl/explosion/PileBlockRender.java index 307cf3c..c5c8060 100644 --- a/ihl/explosion/PileBlockRender.java +++ b/ihl/explosion/PileBlockRender.java @@ -6,10 +6,8 @@ import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import cpw.mods.fml.client.registry.RenderingRegistry;
import ihl.utils.IHLMathUtils;
import net.minecraft.block.Block;
-import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.client.renderer.Tessellator;
-import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -17,326 +15,271 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
-public class PileBlockRender implements ISimpleBlockRenderingHandler
-{
- public static int renderId;
- public final PileTileEntityRender pileTileEntityRender;
+public class PileBlockRender implements ISimpleBlockRenderingHandler {
+ public static int renderId;
+ public final PileTileEntityRender pileTileEntityRender;
- public PileBlockRender()
- {
- renderId = RenderingRegistry.getNextAvailableRenderId();
+ public PileBlockRender() {
+ renderId = RenderingRegistry.getNextAvailableRenderId();
pileTileEntityRender = new PileTileEntityRender(this);
- }
+ }
@Override
- public int getRenderId()
- {
+ public int getRenderId() {
return renderId;
}
@Override
- public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderblocks)
- {
- Tessellator tessellator = Tessellator.instance;
- block.setBlockBoundsForItemRender();
- renderblocks.setRenderBoundsFromBlock(block);
- GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
- GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
- tessellator.startDrawingQuads();
- tessellator.setNormal(0.0F, -1.0F, 0.0F);
- renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, renderblocks.getBlockIconFromSideAndMetadata(block, 0, metadata));
- tessellator.draw();
- tessellator.startDrawingQuads();
- tessellator.setNormal(0.0F, 1.0F, 0.0F);
- renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, renderblocks.getBlockIconFromSideAndMetadata(block, 1, metadata));
- tessellator.draw();
- tessellator.startDrawingQuads();
- tessellator.setNormal(0.0F, 0.0F, -1.0F);
- renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderblocks.getBlockIconFromSideAndMetadata(block, 2, metadata));
- tessellator.draw();
- tessellator.startDrawingQuads();
- tessellator.setNormal(0.0F, 0.0F, 1.0F);
- renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderblocks.getBlockIconFromSideAndMetadata(block, 3, metadata));
- tessellator.draw();
- tessellator.startDrawingQuads();
- tessellator.setNormal(-1.0F, 0.0F, 0.0F);
- renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderblocks.getBlockIconFromSideAndMetadata(block, 4, metadata));
- tessellator.draw();
- tessellator.startDrawingQuads();
- tessellator.setNormal(1.0F, 0.0F, 0.0F);
- renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderblocks.getBlockIconFromSideAndMetadata(block, 5, metadata));
- tessellator.draw();
- GL11.glTranslatef(0.5F, 0.5F, 0.5F);
+ public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderblocks) {
+ Tessellator tessellator = Tessellator.instance;
+ block.setBlockBoundsForItemRender();
+ renderblocks.setRenderBoundsFromBlock(block);
+ GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
+ GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(0.0F, -1.0F, 0.0F);
+ renderblocks.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D,
+ renderblocks.getBlockIconFromSideAndMetadata(block, 0, metadata));
+ tessellator.draw();
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(0.0F, 1.0F, 0.0F);
+ renderblocks.renderFaceYPos(block, 0.0D, 0.0D, 0.0D,
+ renderblocks.getBlockIconFromSideAndMetadata(block, 1, metadata));
+ tessellator.draw();
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(0.0F, 0.0F, -1.0F);
+ renderblocks.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D,
+ renderblocks.getBlockIconFromSideAndMetadata(block, 2, metadata));
+ tessellator.draw();
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(0.0F, 0.0F, 1.0F);
+ renderblocks.renderFaceZPos(block, 0.0D, 0.0D, 0.0D,
+ renderblocks.getBlockIconFromSideAndMetadata(block, 3, metadata));
+ tessellator.draw();
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(-1.0F, 0.0F, 0.0F);
+ renderblocks.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D,
+ renderblocks.getBlockIconFromSideAndMetadata(block, 4, metadata));
+ tessellator.draw();
+ tessellator.startDrawingQuads();
+ tessellator.setNormal(1.0F, 0.0F, 0.0F);
+ renderblocks.renderFaceXPos(block, 0.0D, 0.0D, 0.0D,
+ renderblocks.getBlockIconFromSideAndMetadata(block, 5, metadata));
+ tessellator.draw();
+ GL11.glTranslatef(0.5F, 0.5F, 0.5F);
}
@Override
- public boolean renderWorldBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int meta, RenderBlocks blockRenderer)
- {
- TileEntity te = blockAccess.getTileEntity(x, y, z);
- if(te instanceof PileTileEntity)
- {
- PileTileEntity pte = (PileTileEntity) te;
- long itemHash = getItemStackHash(pte.content);
- if(this.pileTileEntityRender.textureIdMap.containsKey(itemHash))
- {
- Tessellator tessellator = Tessellator.instance;
- tessellator.draw();
- int texture=this.pileTileEntityRender.textureIdMap.get(itemHash);
- GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
- int[][][] brightness = new int[3][3][3];
- this.generateBrightnessMatrix(blockAccess, x, y, z, brightness);
- tessellator.startDrawing(GL11.GL_TRIANGLES);
- tessellator.setColorOpaque_F(1f, 1f, 1f);
- boolean[] blocksViewAround = this.getBlocksViewAround(blockAccess, x, y, z);
- if( blocksViewAround[0] &&
- blocksViewAround[1] &&
- blocksViewAround[2] &&
- blocksViewAround[3])
- {
- this.addFlatTop(tessellator, x, y, z, brightness);
- }
- else if(!blocksViewAround[0] &&
- blocksViewAround[1] &&
- blocksViewAround[2] &&
- blocksViewAround[3])
- {
- this.addSlope(tessellator, x, y, z, 1, 1, 0, 1, brightness);
- }
- else if(blocksViewAround[0] &&
- !blocksViewAround[1] &&
- blocksViewAround[2] &&
- blocksViewAround[3])
- {
- this.addSlope(tessellator, x, y, z, 0, 1, 1, 1, brightness);
- }
- else if(blocksViewAround[0] &&
- blocksViewAround[1] &&
- !blocksViewAround[2] &&
- blocksViewAround[3])
- {
- this.addSlope(tessellator, x, y, z, 1, 1, 1, 0, brightness);
- }
- else if(blocksViewAround[0] &&
- blocksViewAround[1] &&
- blocksViewAround[2] &&
- !blocksViewAround[3])
- {
- this.addSlope(tessellator, x, y, z, 1, 0, 1, 1, brightness);
- }
- // 2-sided piramid
- else if(blocksViewAround[0] &&
- blocksViewAround[1] &&
- !blocksViewAround[2] &&
- !blocksViewAround[3])
- {
- this.addSlope(tessellator, x, y, z, 1, 0, 1, 0, brightness);
- }
- else if(!blocksViewAround[0] &&
- blocksViewAround[1] &&
- blocksViewAround[2] &&
- !blocksViewAround[3])
- {
- this.addSlope(tessellator, x, y, z, 1, 0, 0, 1, brightness);
- }
- else if(!blocksViewAround[0] &&
- !blocksViewAround[1] &&
- blocksViewAround[2] &&
- blocksViewAround[3])
- {
- this.addSlope(tessellator, x, y, z, 0, 1, 0, 1, brightness);
- }
- else if(blocksViewAround[0] &&
- !blocksViewAround[1] &&
- !blocksViewAround[2] &&
- blocksViewAround[3])
- {
- this.addSlope(tessellator, x, y, z, 0, 1, 1, 0, brightness);
- }
- else
- {
- this.addPyramid(tessellator, x, y, z, brightness);
- }
- if(!blockAccess.getBlock(x, y-1, z).isOpaqueCube())
- {
- this.addBottom(tessellator, x, y, z, brightness);
- }
- tessellator.draw();
- Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
- tessellator.startDrawingQuads();
- }
- return true;
- }
- else
- {
- return false;
- }
+ public boolean renderWorldBlock(IBlockAccess blockAccess, int x, int y, int z, Block block, int meta,
+ RenderBlocks blockRenderer) {
+ TileEntity te = blockAccess.getTileEntity(x, y, z);
+ if (te instanceof PileTileEntity) {
+ PileTileEntity pte = (PileTileEntity) te;
+ long itemHash = getItemStackHash(pte.content);
+ if (this.pileTileEntityRender.subIconIdMap.containsKey(itemHash)) {
+ Tessellator tessellator = Tessellator.instance;
+ int subIconId = this.pileTileEntityRender.subIconIdMap.get(itemHash);
+ int[][][] brightness = new int[3][3][3];
+ this.generateBrightnessMatrix(blockAccess, x, y, z, brightness);
+ tessellator.setColorOpaque_F(1f, 1f, 1f);
+ boolean[] blocksViewAround = this.getBlocksViewAround(blockAccess, x, y, z);
+ if (blocksViewAround[0] && blocksViewAround[1] && blocksViewAround[2] && blocksViewAround[3]) {
+ this.addFlatTop(tessellator, x, y, z, brightness, subIconId);
+ } else if (!blocksViewAround[0] && blocksViewAround[1] && blocksViewAround[2] && blocksViewAround[3]) {
+ this.addSlope(tessellator, x, y, z, 0, brightness, subIconId);
+ } else if (blocksViewAround[0] && !blocksViewAround[1] && blocksViewAround[2] && blocksViewAround[3]) {
+ this.addSlope(tessellator, x, y, z, 1, brightness, subIconId);
+ } else if (blocksViewAround[0] && blocksViewAround[1] && !blocksViewAround[2] && blocksViewAround[3]) {
+ this.addSlope(tessellator, x, y, z, 2, brightness, subIconId);
+ } else if (blocksViewAround[0] && blocksViewAround[1] && blocksViewAround[2] && !blocksViewAround[3]) {
+ this.addSlope(tessellator, x, y, z, 3, brightness, subIconId);
+ }
+ // 2-sided piramid
+ else if (blocksViewAround[0] && blocksViewAround[1] && !blocksViewAround[2] && !blocksViewAround[3]) {
+ this.addTwoSidedPyramid(tessellator, x, y, z, 2, brightness, subIconId);
+ } else if (!blocksViewAround[0] && blocksViewAround[1] && blocksViewAround[2] && !blocksViewAround[3]) {
+ this.addTwoSidedPyramid(tessellator, x, y, z, 3, brightness, subIconId);
+ } else if (!blocksViewAround[0] && !blocksViewAround[1] && blocksViewAround[2] && blocksViewAround[3]) {
+ this.addTwoSidedPyramid(tessellator, x, y, z, 0, brightness, subIconId);
+ } else if (blocksViewAround[0] && !blocksViewAround[1] && !blocksViewAround[2] && blocksViewAround[3]) {
+ this.addTwoSidedPyramid(tessellator, x, y, z, 1, brightness, subIconId);
+ } else {
+ this.addPyramid(tessellator, x, y, z, brightness, subIconId);
+ }
+ if (!blockAccess.getBlock(x, y - 1, z).isOpaqueCube()) {
+ this.addBottom(tessellator, x, y, z, brightness, subIconId);
+ }
+ }
+ return true;
+ } else {
+ return false;
+ }
}
-
- private boolean[] getBlocksViewAround(IBlockAccess blockAccess, int x, int y, int z)
- {
- // +Z
- // ^
- //[ ][0][ ]
- //[3][x][1] ->+X
- //[ ][2][ ]
- return new boolean[] {
- blockAccess.getBlock(x, y, z+1).isOpaqueCube(),
- blockAccess.getBlock(x+1, y, z).isOpaqueCube(),
- blockAccess.getBlock(x, y, z-1).isOpaqueCube(),
- blockAccess.getBlock(x-1, y, z).isOpaqueCube(),
- };
+
+ private boolean[] getBlocksViewAround(IBlockAccess blockAccess, int x, int y, int z) {
+ // +Z
+ // ^
+ // [ ][0][ ]
+ // [3][x][1] ->+X
+ // [ ][2][ ]
+ return new boolean[] { blockAccess.getBlock(x, y, z + 1).isOpaqueCube(),
+ blockAccess.getBlock(x + 1, y, z).isOpaqueCube(), blockAccess.getBlock(x, y, z - 1).isOpaqueCube(),
+ blockAccess.getBlock(x - 1, y, z).isOpaqueCube(), };
}
- private void addBottom(Tessellator tessellator, int x, int y, int z, int[][][] brightness)
- {
- double[][] triangle1 = new double[3][3];
- double[][] triangle2 = new double[3][3];
- triangle1[0] = new double[] {0D,0D,1D};
- triangle1[1] = new double[] {0D,0D,0D};
- triangle1[2] = new double[] {1D,0D,0D};
- triangle2[0] = triangle1[0];
- triangle2[1] = triangle1[2];
- triangle2[2] = new double[] {1D,0D,1D};
- this.addTriangle(tessellator, triangle1, x, y, z, ForgeDirection.UP, brightness);
- this.addTriangle(tessellator, triangle2, x, y, z, ForgeDirection.UP, brightness);
+ private void addBottom(Tessellator tessellator, int x, int y, int z, int[][][] brightness, int subIconId) {
+ double[][] quad1 = new double[4][3];
+ quad1[0] = new double[] { 0D, 0D, 1D };
+ quad1[1] = new double[] { 0D, 0D, 0D };
+ quad1[2] = new double[] { 1D, 0D, 0D };
+ quad1[3] = new double[] { 1D, 0D, 1D };
+ this.addQuad(tessellator, quad1, x, y, z, ForgeDirection.UP, brightness, subIconId);
}
-
- private void addFlatTop(Tessellator tessellator, int x, int y, int z, int[][][] brightness)
- {
- double[][] triangle1 = new double[3][3];
- double[][] triangle2 = new double[3][3];
+
+ private void addFlatTop(Tessellator tessellator, int x, int y, int z, int[][][] brightness, int subIconId) {
+ double[][] quad1 = new double[4][3];
double height = 0.9D;
- triangle1[0] = new double[] {1D,height,0D};
- triangle1[1] = new double[] {0D,height,0D};
- triangle1[2] = new double[] {0D,height,1D};
- triangle2[0] = triangle1[2];
- triangle2[1] = new double[] {1D,height,1D};
- triangle2[2] = triangle1[0];
- this.addTriangle(tessellator, triangle1, x, y, z, ForgeDirection.UP, brightness);
- this.addTriangle(tessellator, triangle2, x, y, z, ForgeDirection.UP, brightness);
+ quad1[0] = new double[] { 1D, height, 0D };
+ quad1[1] = new double[] { 0D, height, 0D };
+ quad1[2] = new double[] { 0D, height, 1D };
+ quad1[3] = new double[] { 1D, height, 1D };
+ this.addQuad(tessellator, quad1, x, y, z, ForgeDirection.UP, brightness, subIconId);
}
-
- private void addSlope(Tessellator tessellator, int x, int y, int z, int px, int nx, int pz, int nz, int[][][] brightness)
- {
- double[][] triangle1 = new double[3][3];
- double[][] triangle2 = new double[3][3];
- if(px*pz+nx*nz==1)
- {
- triangle1[0] = new double[] {1D,px*nz,0D}; //+X -Z
- triangle1[1] = new double[] {0D,nx*nz,0D}; //-X -Z
- triangle1[2] = new double[] {1D,px*pz,1D}; //-X +Z
- triangle2[0] = triangle1[2];
- triangle2[1] = triangle1[1]; //+X +Z
- triangle2[2] = new double[] {0D,nx*pz,1D};
- }
- else
- {
- triangle1[0] = new double[] {1D,px*nz,0D}; //+X -Z
- triangle1[1] = new double[] {0D,nx*nz,0D}; //-X -Z
- triangle1[2] = new double[] {0D,nx*pz,1D}; //-X +Z
- triangle2[0] = triangle1[2];
- triangle2[1] = new double[] {1D,px*pz,1D}; //+X +Z
- triangle2[2] = triangle1[0];
+
+ private void addSlope(Tessellator tessellator, int x, int y, int z, int rotation,
+ int[][][] brightness, int subIconId) {
+ double[][] quad = new double[4][3];
+ quad[0] = new double[] { 1D,1D, 0D }; // +X -Z
+ quad[1] = new double[] { 0D, 1D, 0D }; // -X -Z
+ quad[2] = new double[] { 0D, 0D, 1D }; // -X +Z
+ quad[3] = new double[] { 1D, 0D, 1D };
+ while (rotation-- > 0) {
+ rotateQuadByYAxis(quad);
}
- this.addTriangle(tessellator, triangle1, x, y, z, ForgeDirection.UP, brightness);
- this.addTriangle(tessellator, triangle2, x, y, z, ForgeDirection.UP, brightness);
+ this.addQuad(tessellator, quad, x, y, z, ForgeDirection.UP, brightness, subIconId);
}
- private void addPyramid(Tessellator tessellator, int x, int y, int z, int[][][] brightness)
- {
- double[][] triangle1 = new double[3][3];
- double[][] triangle2 = new double[3][3];
- double[][] triangle3 = new double[3][3];
- double[][] triangle4 = new double[3][3];
+ private void addTwoSidedPyramid(Tessellator tessellator, int x, int y, int z, int rotation,
+ int[][][] brightness, int subIconId) {
+ double[][] quad = new double[4][3];
+ quad[0] = new double[] { 1D, 0D, 0D }; // +X -Z
+ quad[1] = new double[] { 0D, 1D, 0D }; // -X -Z
+ quad[2] = new double[] { 0D, 0D, 1D }; // -X +Z
+ quad[3] = new double[] { 1D, 0D, 1D };
+ while (rotation-- > 0) {
+ rotateQuadByYAxis(quad);
+ }
+ this.addQuad(tessellator, quad, x, y, z, ForgeDirection.UP, brightness, subIconId);
+ }
+
+ private void addPyramid(Tessellator tessellator, int x, int y, int z, int[][][] brightness, int subIconId) {
+ double[][] quad1 = new double[4][3];
+ double[][] quad2 = new double[4][3];
double pileHeight = 0.3D;
- triangle1[0] = new double[] {1D,0D,0D};
- triangle1[1] = new double[] {0D,0D,0D};
- triangle1[2] = new double[] {0.5D,pileHeight,0.5D};
- triangle2[0] = triangle1[1];
- triangle2[1] = new double[] {0D,0D,1D};
- triangle2[2] = triangle1[2];
- triangle3[0] = triangle2[1];
- triangle3[1] = new double[] {1D,0D,1D};
- triangle3[2] = triangle1[2];
- triangle4[0] = triangle3[1];
- triangle4[1] = triangle1[0];
- triangle4[2] = triangle1[2];
- this.addTriangle(tessellator, triangle1, x, y, z, ForgeDirection.UP, brightness);
- this.addTriangle(tessellator, triangle2, x, y, z, ForgeDirection.UP, brightness);
- this.addTriangle(tessellator, triangle3, x, y, z, ForgeDirection.UP, brightness);
- this.addTriangle(tessellator, triangle4, x, y, z, ForgeDirection.UP, brightness);
+ quad1[0] = new double[] { 1D, 0D, 1D };
+ quad1[1] = new double[] { 1D, 0D, 0D };
+ quad1[2] = new double[] { 0D, 0D, 0D };
+ quad1[3] = new double[] { 0.5D, pileHeight, 0.5D };
+ quad2 = copyAndRotateQuadByYAxis(quad1,2);
+ this.addQuad(tessellator, quad1, x, y, z, ForgeDirection.UP, brightness, subIconId);
+ this.addQuad(tessellator, quad2, x, y, z, ForgeDirection.UP, brightness, subIconId);
}
-
- private void addTriangle(Tessellator tessellator, double[][] triangle, int x, int y, int z, ForgeDirection uvmapping, int[][][] brightness)
- {
+
+ private void rotateQuadByYAxis(double[][] quad) {
+ for (double[] v : quad) {
+ double newV2 = 1 - v[0];
+ v[0] = v[2];
+ v[2] = newV2;
+ }
+ }
+
+ private double[][] copyAndRotateQuadByYAxis(double[][] quad, int rotation) {
+ double[][] quadOut = new double[4][3];
+ for (int i = 0; i < quad.length * 3; i++) {
+ quadOut[i / 3][i % 3] = quad[i / 3][i % 3];
+ }
+
+ while (rotation-- > 0) {
+ rotateQuadByYAxis(quadOut);
+ }
+ return quadOut;
+ }
+
+ private void addQuad(Tessellator tessellator, double[][] quad, int x, int y, int z, ForgeDirection uvmapping,
+ int[][][] brightness, int subIconId) {
int iu = 0;
int iv = 2;
- if(uvmapping.offsetY == 0)
- {
+ if (uvmapping.offsetY == 0) {
iv = 1;
- if(uvmapping.offsetZ == 0)
- {
+ if (uvmapping.offsetZ == 0) {
iu = 2;
}
}
- float[] normal = IHLMathUtils.get_triangle_normal(triangle);
- tessellator.setNormal(normal[0], normal[1], normal[2]);
- tessellator.setBrightness(this.getBrightness(triangle[0], brightness));
- tessellator.addVertexWithUV(x+triangle[0][0], y+triangle[0][1], z+triangle[0][2], triangle[0][iu], triangle[0][iv]);
- tessellator.setBrightness(this.getBrightness(triangle[1], brightness));
- tessellator.addVertexWithUV(x+triangle[1][0], y+triangle[1][1], z+triangle[1][2], triangle[1][iu], triangle[1][iv]);
- tessellator.setBrightness(this.getBrightness(triangle[2], brightness));
- tessellator.addVertexWithUV(x+triangle[2][0], y+triangle[2][1], z+triangle[2][2], triangle[2][iu], triangle[2][iv]);
+ float[] normal = IHLMathUtils.get_triangle_normal(quad);
+ float minu = pileTileEntityRender.getSubIconMinU(subIconId);
+ float minv = pileTileEntityRender.getSubIconMinV(subIconId);
+ float du = pileTileEntityRender.getSubIconDU(subIconId);
+ float dv = pileTileEntityRender.getSubIconDV(subIconId);
+
+ double u1 = minu + quad[0][iu] * du;
+ double u2 = minu + quad[1][iu] * du;
+ double u3 = minu + quad[2][iu] * du;
+ double u4 = minu + quad[3][iu] * du;
+ double v1 = minv + quad[0][iv] * dv;
+ double v2 = minv + quad[1][iv] * dv;
+ double v3 = minv + quad[2][iv] * dv;
+ double v4 = minv + quad[3][iv] * dv;
+
+ tessellator.setNormal(normal[0], normal[1], normal[2]);
+ tessellator.setBrightness(this.getBrightness(quad[0], brightness));
+ tessellator.addVertexWithUV(x + quad[0][0], y + quad[0][1], z + quad[0][2], u1, v1);
+ tessellator.setBrightness(this.getBrightness(quad[1], brightness));
+ tessellator.addVertexWithUV(x + quad[1][0], y + quad[1][1], z + quad[1][2], u2, v2);
+ tessellator.setBrightness(this.getBrightness(quad[2], brightness));
+ tessellator.addVertexWithUV(x + quad[2][0], y + quad[2][1], z + quad[2][2], u3, v3);
+ tessellator.setBrightness(this.getBrightness(quad[3], brightness));
+ tessellator.addVertexWithUV(x + quad[3][0], y + quad[3][1], z + quad[3][2], u4, v4);
}
-
- public long getItemStackHash(ItemStack stack)
- {
- if(stack==null)
- {
+
+ public long getItemStackHash(ItemStack stack) {
+ if (stack == null) {
return 0;
}
- return ((long)Item.getIdFromItem(stack.getItem())<<31^stack.getItemDamage());
+ return ((long) Item.getIdFromItem(stack.getItem()) << 31 ^ stack.getItemDamage());
}
-
- private void generateBrightnessMatrix(IBlockAccess blockAccess, int x, int y, int z, int[][][] brightness)
- {
- for(int ix = -1; ix <= 1; ix++)
- for(int iy = -1; iy <= 1; iy++)
- for(int iz = -1; iz <= 1; iz++)
- {
- Block block = blockAccess.getBlock(ix+x, iy+y, iz+z);
- if(block!=null && block!=Blocks.air)
- {
- brightness[ix+1][iy+1][iz+1] = block.getMixedBrightnessForBlock(blockAccess, ix+x, iy+y, iz+z);
- }
- else
- {
- brightness[ix+1][iy+1][iz+1] = block.getMixedBrightnessForBlock(blockAccess, x, y, z);
- }
- }
+
+ private void generateBrightnessMatrix(IBlockAccess blockAccess, int x, int y, int z, int[][][] brightness) {
+ for (int ix = -1; ix <= 1; ix++)
+ for (int iy = -1; iy <= 1; iy++)
+ for (int iz = -1; iz <= 1; iz++) {
+ Block block = blockAccess.getBlock(ix + x, iy + y, iz + z);
+ if (block != null && block != Blocks.air) {
+ brightness[ix + 1][iy + 1][iz + 1] = block.getMixedBrightnessForBlock(blockAccess, ix + x,
+ iy + y, iz + z);
+ } else {
+ brightness[ix + 1][iy + 1][iz + 1] = block.getMixedBrightnessForBlock(blockAccess, x, y, z);
+ }
+ }
}
-
- private int getBrightness(double v[], int[][][] brightness)
- {
- int x1 = v[0]<0.5d?0:1;
- int x2 = x1+1;
- int y1 = v[1]<0.5d?0:1;
- int y2 = y1+1;
- int z1 = v[2]<0.5d?0:1;
- int z2 = z1+1;
- float dx = v[0]<0.5d?(float)v[0]*2f:(float)v[0]*2f-1f;
- float dy = v[1]<0.5d?(float)v[1]*2f:(float)v[1]*2f-1f;
- float dz = v[2]<0.5d?(float)v[2]*2f:(float)v[2]*2f-1f;
+
+ private int getBrightness(double v[], int[][][] brightness) {
+ int x1 = v[0] < 0.5d ? 0 : 1;
+ int x2 = x1 + 1;
+ int y1 = v[1] < 0.5d ? 0 : 1;
+ int y2 = y1 + 1;
+ int z1 = v[2] < 0.5d ? 0 : 1;
+ int z2 = z1 + 1;
+ float dx = v[0] < 0.5d ? (float) v[0] * 2f : (float) v[0] * 2f - 1f;
+ float dy = v[1] < 0.5d ? (float) v[1] * 2f : (float) v[1] * 2f - 1f;
+ float dz = v[2] < 0.5d ? (float) v[2] * 2f : (float) v[2] * 2f - 1f;
int brightness1 = brightness[x1][y1][z1];
int brightness2 = brightness[x2][y2][z2];
- float d = IHLMathUtils.sqrt(dx*dx+dy*dy+dz*dz);
- return (int)(brightness1*(1f-d)*0.8f+brightness2*d*0.8f+brightness[1][1][1]*0.2f) & 16711935;
+ float d = IHLMathUtils.sqrt(dx * dx + dy * dy + dz * dz);
+ return (int) (brightness1 * (1f - d) * 0.8f + brightness2 * d * 0.8f + brightness[1][1][1] * 0.2f) & 16711935;
}
-
+
@Override
- public boolean shouldRender3DInInventory(int arg0)
- {
+ public boolean shouldRender3DInInventory(int arg0) {
return true;
}
}
-
\ No newline at end of file diff --git a/ihl/explosion/PileTileEntityRender.java b/ihl/explosion/PileTileEntityRender.java index ea8ab4f..2141e83 100644 --- a/ihl/explosion/PileTileEntityRender.java +++ b/ihl/explosion/PileTileEntityRender.java @@ -1,6 +1,5 @@ package ihl.explosion;
-import java.nio.IntBuffer;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
@@ -17,7 +16,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
-import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL30;
@@ -27,134 +25,164 @@ import ihl.IHLMod; import ihl.utils.IHLItemRenderer;
public class PileTileEntityRender extends TileEntitySpecialRenderer {
-
-private int fb=-1;
-private final int textureWidth=64;
-private final int textureHeight=64;
-private final PileBlockRender pileBlockRender;
-public final Map<Long,Integer> textureIdMap = new HashMap<Long,Integer>();
-private IntBuffer textureIDBuffer;
-private int nextAvailableId = -1;
-private boolean framebufferReady = false;
-private Minecraft mc;
-private final IHLItemRenderer ihlItemRenderer=new IHLItemRenderer(false);
-private final Random random = new Random();
-public PileTileEntityRender(PileBlockRender pileBlockRender1)
-{
- pileBlockRender=pileBlockRender1;
- mc = Minecraft.getMinecraft();
-}
+ private int fb = -1;
+ private final int textureWidth = 64;
+ private final int textureHeight = 64;
+ private final PileBlockRender pileBlockRender;
+ public final Map<Long, Integer> subIconIdMap = new HashMap<Long, Integer>();
+ private int nextAvailableId = -1;
+ private boolean framebufferReady = false;
+ private Minecraft mc;
+ private final IHLItemRenderer ihlItemRenderer = new IHLItemRenderer(false);
+ private final Random random = new Random();
-public void renderAModelAt(PileTileEntity tile, double x, double y, double z, float f)
-{
- ItemStack stack = tile.content;
- if(!framebufferReady)
- {
- this.generateFrameBuffer();
- Minecraft.getMinecraft().entityRenderer.setupCameraTransform(f, 0);
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ public PileTileEntityRender(PileBlockRender pileBlockRender1) {
+ pileBlockRender = pileBlockRender1;
+ mc = Minecraft.getMinecraft();
}
- else if(stack!=null)
- {
- long hash = this.pileBlockRender.getItemStackHash(stack);
- if(!textureIdMap.containsKey(hash))
- {
- textureIdMap.put(hash,textureIDBuffer.get(++nextAvailableId));
- this.preparetexture(nextAvailableId);
- this.drawTexture(tile);
- Minecraft.getMinecraft().entityRenderer.setupCameraTransform(f, 0);
- Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
- tile.updateBlockRender();
- }
+
+ public void renderAModelAt(PileTileEntity tile, double x, double y, double z, float f) {
+ ItemStack stack = tile.content;
+ if (!framebufferReady) {
+ this.generateFrameBuffer();
+ Minecraft.getMinecraft().entityRenderer.setupCameraTransform(f, 0);
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ } else if (stack != null) {
+ long hash = this.pileBlockRender.getItemStackHash(stack);
+ if (!subIconIdMap.containsKey(hash)) {
+
+ subIconIdMap.put(hash, ++nextAvailableId);
+ this.preparetexture();
+ this.drawTexture(tile, nextAvailableId);
+ Minecraft.getMinecraft().entityRenderer.setupCameraTransform(f, 0);
+ Minecraft.getMinecraft().getFramebuffer().bindFramebuffer(false);
+ tile.updateBlockRender();
+ }
+ }
+ }
+
+ private void generateFrameBuffer() {
+ fb = GL30.glGenFramebuffers();
+ this.preparetexture();
+ 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!");
+ }
+ this.framebufferReady = true;
+ }
+
+ private void preparetexture() {
+ GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fb);
+ int texture = Minecraft.getMinecraft().renderEngine.getTexture(TextureMap.locationBlocksTexture)
+ .getGlTextureId();
+ GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
+ GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, texture, 0);
+ }
+
+ private void drawTexture(PileTileEntity tile, int subIconId) {
+ IIcon picon = PileBlock.instance.getIcon(0, 0);
+ float minu = picon.getMinU();
+ float minv = picon.getMinV();
+ float maxu = picon.getMaxU();
+ float maxv = picon.getMaxV();
+ int iconwidth = picon.getIconWidth();
+ int iconheight = picon.getIconHeight();
+ float du = maxu - minu;
+ float dv = maxv - minv;
+ int iconNumU = picon.getIconWidth()/this.textureWidth;
+ int posu = (int) (minu * iconwidth / du) + subIconId % iconNumU * textureWidth;
+ int posv = (int) (minv * iconheight / dv) + subIconId / iconNumU * textureHeight;
+
+ GL11.glViewport(posu, posv, textureWidth, textureHeight);
+ GL11.glMatrixMode(GL11.GL_PROJECTION);
+ GL11.glLoadIdentity();
+ GL11.glOrtho(-1d, 1d, -1d, 1d, 0.05F, this.mc.gameSettings.renderDistanceChunks * 32F);
+ GL11.glMatrixMode(GL11.GL_MODELVIEW);
+ GL11.glLoadIdentity();
+ ItemStack stack = tile.content;
+ GL11.glTranslatef(0, 0, -1f);
+ GLU.gluLookAt(0, 0, 0, -32f/* x reference */, 0f/* y reference */, 0f/* z reference */, 0.0f, 1.0f, 0.0f);
+ GL11.glColor4f(1f, 1f, 1f, 1f);
+ GL11.glRotatef(90f, 0, 1f, 0);
+ GL11.glScalef(2f, 2f, 2f);
+ OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 0xf0, 0xf0);
+ if (stack.getItem() instanceof ItemBlock) {
+ Block block = ((ItemBlock) stack.getItem()).field_150939_a;
+ IIcon icon = block.getIcon(0, stack.getItemDamage());
+ double u1 = (double) icon.getInterpolatedU(0D);
+ double u2 = (double) icon.getInterpolatedU(16.0D);
+ double v1 = (double) icon.getInterpolatedV(0D);
+ double v2 = (double) icon.getInterpolatedV(16.0D);
+ Tessellator tessellator = Tessellator.instance;
+ bindTexture(TextureMap.locationBlocksTexture);
+ tessellator.startDrawingQuads();
+ tessellator.setColorOpaque_F(1f, 1f, 1f);
+ tessellator.addVertexWithUV(-0.5, -0.5, 0, u1, v1);
+ tessellator.addVertexWithUV(0.5, -0.5, 0, u1, v2);
+ tessellator.addVertexWithUV(0.5, 0.5, 0, u2, v2);
+ tessellator.addVertexWithUV(-0.5, 0.5, 0, u2, v1);
+ tessellator.draw();
+ }
+ for (int i = 0; i < 128; i++) {
+ GL11.glPushMatrix();
+ float tx = random.nextFloat() - 0.5f;
+ float ty = random.nextFloat() - 0.5f;
+ GL11.glTranslatef(tx, ty, 0);
+ this.ihlItemRenderer.doRender(RenderManager.instance, stack, 0f, 0f, 0f);
+ GL11.glTranslatef(-tx, -ty, 0);
+ GL11.glPopMatrix();
+ }
+ GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight());
}
-}
-private void generateFrameBuffer()
-{
- textureIDBuffer = BufferUtils.createIntBuffer(Short.MAX_VALUE);
- GL11.glGenTextures(textureIDBuffer);
- fb=GL30.glGenFramebuffers();
- this.preparetexture(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!");
- }
- this.framebufferReady=true;
-}
+ public float getSubIconMinU(int index)
+ {
+ IIcon picon = PileBlock.instance.getIcon(0, 0);
+ int iconNumU = picon.getIconWidth()/this.textureWidth;
+ float minu = picon.getMinU();
+ float maxu = picon.getMaxU();
+ float du = (maxu - minu)/iconNumU;
+ return minu + index%iconNumU*du;
+ }
-private void preparetexture(int textureID)
-{
- GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, fb);
- int texture = textureIDBuffer.get(textureID);
- GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
- GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_COLOR_ATTACHMENT0, GL11.GL_TEXTURE_2D, texture, 0);
- 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_NEAREST);
- GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
-}
-
-private void drawTexture(PileTileEntity tile)
-{
- GL11.glViewport(0, 0, textureWidth, textureHeight);
- GL11.glClearColor(0f, 0f, 0f, 1f);
- GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
- GL11.glMatrixMode(GL11.GL_PROJECTION);
- GL11.glLoadIdentity();
- GL11.glOrtho(-1d, 1d, -1d, 1d, 0.05F, this.mc.gameSettings.renderDistanceChunks * 32F);
- GL11.glMatrixMode(GL11.GL_MODELVIEW);
- GL11.glLoadIdentity();
- ItemStack stack = tile.content;
- GL11.glTranslatef(0, 0, -1f);
- GLU.gluLookAt(0, 0, 0, -32f/*x reference*/, 0f/*y reference*/, 0f/*z reference*/, 0.0f, 1.0f, 0.0f);
- GL11.glColor4f(1f, 1f, 1f, 1f);
- GL11.glRotatef(90f,0,1f,0);
- GL11.glScalef(2f, 2f, 2f);
- OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 0xf0, 0xf0);
-// Tessellator.instance.setBrightness(16711935);
- if(stack.getItem() instanceof ItemBlock)
+ public float getSubIconMinV(int index)
+ {
+ IIcon picon = PileBlock.instance.getIcon(0, 0);
+ int iconNumU = picon.getIconWidth()/this.textureWidth;
+ int iconNumV = picon.getIconHeight()/this.textureHeight;
+ float minv = picon.getMinV();
+ float maxv = picon.getMaxV();
+ float dv = (maxv - minv)/iconNumV;
+ return minv + index/iconNumU*dv;
+ }
+ public float getSubIconDU(int index)
{
- Block block = ((ItemBlock)stack.getItem()).field_150939_a;
- IIcon icon = block.getIcon(0, stack.getItemDamage());
- double u1 = (double)icon.getInterpolatedU(0D);
- double u2 = (double)icon.getInterpolatedU(16.0D);
- double v1 = (double)icon.getInterpolatedV(0D);
- double v2 = (double)icon.getInterpolatedV(16.0D);
- Tessellator tessellator = Tessellator.instance;
- bindTexture(TextureMap.locationBlocksTexture);
- tessellator.startDrawingQuads();
- tessellator.setColorOpaque_F(1f, 1f, 1f);
- tessellator.addVertexWithUV(-0.5,-0.5, 0,u1,v1);
- tessellator.addVertexWithUV( 0.5,-0.5, 0,u1,v2);
- tessellator.addVertexWithUV( 0.5, 0.5, 0,u2,v2);
- tessellator.addVertexWithUV(-0.5, 0.5, 0,u2,v1);
- tessellator.draw();
+ IIcon picon = PileBlock.instance.getIcon(0, 0);
+ int iconNumU = picon.getIconWidth()/this.textureWidth;
+ float minu = picon.getMinU();
+ float maxu = picon.getMaxU();
+ float du = (maxu - minu)/iconNumU;
+ return du;
}
- for (int i = 0; i < 128; i++)
+
+ public float getSubIconDV(int index)
{
- GL11.glPushMatrix();
- float tx = random.nextFloat()-0.5f;
- float ty = random.nextFloat()-0.5f;
- GL11.glTranslatef(tx, ty, 0);
- this.ihlItemRenderer.doRender(RenderManager.instance,stack, 0f, 0f, 0f);
- GL11.glTranslatef(-tx, -ty, 0);
- GL11.glPopMatrix();
+ IIcon picon = PileBlock.instance.getIcon(0, 0);
+ int iconNumV = picon.getIconHeight()/this.textureHeight;
+ float minv = picon.getMinV();
+ float maxv = picon.getMaxV();
+ float dv = (maxv - minv)/iconNumV;
+ return dv;
}
- GL11.glViewport(0, 0, Display.getWidth(), Display.getHeight());
-// IHLRenderUtils.instance.disableAmbientLighting();
-}
-@Override
-public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8)
-{
- this.renderAModelAt((PileTileEntity)par1TileEntity, par2, par4, par6, par8);
-}
+
+
+ @Override
+ public void renderTileEntityAt(TileEntity par1TileEntity, double par2, double par4, double par6, float par8) {
+ this.renderAModelAt((PileTileEntity) par1TileEntity, par2, par4, par6, par8);
+ }
}
\ No newline at end of file |
