mirror of
https://github.com/GTNewHorizons/Chisel.git
synced 2026-11-20 04:19:50 +00:00
Some class renaming, move TextureSubmap to API and improve its methods
This commit is contained in:
1 parent
c2fa40d57e
commit
d50f2c9da5
36 files changed
+373
-294
No files matched your search
@@ -4,7 +4,7 @@ import com.cricketcraft.chisel.Chisel;
|
||||
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockCarpetRenderer extends BlockAdvancedMarbleRenderer {
|
||||
public class BlockCarpetRenderer extends RendererCTM {
|
||||
|
||||
public BlockCarpetRenderer() {
|
||||
super();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import com.cricketcraft.chisel.api.client.CTM;
|
||||
import com.cricketcraft.chisel.api.client.TextureSubmap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
@@ -246,7 +247,17 @@ public class RenderBlocksCTM extends RenderBlocks {
|
||||
}
|
||||
|
||||
void side(SubSide side, int iconIndex) {
|
||||
IIcon icon = iconIndex >= 16 ? submapSmall.icons[iconIndex - 16] : submap.icons[iconIndex];
|
||||
IIcon icon;
|
||||
TextureSubmap map;
|
||||
if (iconIndex >= 16) {
|
||||
iconIndex -= 16;
|
||||
map = submapSmall;
|
||||
} else {
|
||||
map = submap;
|
||||
}
|
||||
int x = iconIndex % map.getWidth();
|
||||
int y = iconIndex / map.getHeight();
|
||||
icon = map.getSubIcon(x, y);
|
||||
|
||||
double umax = icon.getMaxU();
|
||||
double umin = icon.getMinU();
|
||||
|
||||
@@ -11,22 +11,22 @@ public class RenderBlocksCTMCarpet extends RenderBlocksCTM {
|
||||
|
||||
@Override
|
||||
public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
rendererOld.renderFaceXNeg(block, 0, 0, 0, submapSmall.icon);
|
||||
rendererOld.renderFaceXNeg(block, 0, 0, 0, submapSmall.getBaseIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
rendererOld.renderFaceXPos(block, 0, 0, 0, submapSmall.icon);
|
||||
rendererOld.renderFaceXPos(block, 0, 0, 0, submapSmall.getBaseIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) {
|
||||
rendererOld.renderFaceZNeg(block, 0, 0, 0, submapSmall.icon);
|
||||
rendererOld.renderFaceZNeg(block, 0, 0, 0, submapSmall.getBaseIcon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) {
|
||||
rendererOld.renderFaceZPos(block, 0, 0, 0, submapSmall.icon);
|
||||
rendererOld.renderFaceZPos(block, 0, 0, 0, submapSmall.getBaseIcon());
|
||||
}
|
||||
|
||||
}
|
||||
+16
-4
@@ -1,17 +1,19 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import com.cricketcraft.chisel.api.client.CTM;
|
||||
import com.cricketcraft.chisel.api.client.TextureSubmap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
public class RenderBlocksCTMNoLight extends RenderBlocks {
|
||||
// TODO rewrite this to use the updated RenderBlocksCTM code
|
||||
public class RenderBlocksCTMFullbright extends RenderBlocks {
|
||||
|
||||
private static CTM ctm = CTM.getInstance();
|
||||
|
||||
RenderBlocksCTMNoLight() {
|
||||
RenderBlocksCTMFullbright() {
|
||||
super();
|
||||
resetVertices();
|
||||
}
|
||||
@@ -47,8 +49,18 @@ public class RenderBlocksCTMNoLight extends RenderBlocks {
|
||||
}
|
||||
|
||||
void side(int a, int b, int c, int d, int iconIndex, boolean flip) {
|
||||
IIcon icon = iconIndex >= 16 ? submapSmall.icons[iconIndex - 16] : submap.icons[iconIndex];
|
||||
|
||||
IIcon icon;
|
||||
TextureSubmap map;
|
||||
if (iconIndex >= 16) {
|
||||
iconIndex -= 16;
|
||||
map = submapSmall;
|
||||
} else {
|
||||
map = submap;
|
||||
}
|
||||
int x = iconIndex % map.getWidth();
|
||||
int y = iconIndex / map.getHeight();
|
||||
icon = map.getSubIcon(x, y);
|
||||
|
||||
double u0 = icon.getMaxU();
|
||||
double u1 = icon.getMinU();
|
||||
double v0 = icon.getMaxV();
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import com.cricketcraft.chisel.api.client.CTM;
|
||||
import com.cricketcraft.chisel.api.client.TextureSubmap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
@@ -35,11 +36,11 @@ public class RenderBlocksColumn extends RenderBlocks {
|
||||
sides[1] = iconTop;
|
||||
|
||||
if (yp && yn)
|
||||
sides[2] = submap.icons[2];
|
||||
sides[2] = submap.getSubIcon(0, 1);
|
||||
else if (yp)
|
||||
sides[2] = submap.icons[3];
|
||||
sides[2] = submap.getSubIcon(1, 1);
|
||||
else
|
||||
sides[2] = submap.icons[1];
|
||||
sides[2] = submap.getSubIcon(1, 0);
|
||||
|
||||
sides[3] = sides[4] = sides[5] = sides[2];
|
||||
} else {
|
||||
@@ -62,14 +63,14 @@ public class RenderBlocksColumn extends RenderBlocks {
|
||||
|
||||
// for some reason along the x axis the bottom texture on the ends is backwards. This flips it around.
|
||||
if (xp && xn) {
|
||||
sides[1] = submap.icons[2];
|
||||
sides[1] = submap.getSubIcon(0, 1);
|
||||
sides[0] = sides[1];
|
||||
} else if (xp) {
|
||||
sides[1] = submap.icons[3];
|
||||
sides[0] = submap.icons[1];
|
||||
sides[1] = submap.getSubIcon(1, 1);
|
||||
sides[0] = submap.getSubIcon(1, 0);
|
||||
} else {
|
||||
sides[1] = submap.icons[1];
|
||||
sides[0] = submap.icons[3];
|
||||
sides[1] = submap.getSubIcon(1, 0);
|
||||
sides[0] = submap.getSubIcon(1, 1);
|
||||
}
|
||||
sides[2] = sides[3] = sides[1];
|
||||
} else {
|
||||
@@ -93,16 +94,16 @@ public class RenderBlocksColumn extends RenderBlocks {
|
||||
sides[3] = iconTop;
|
||||
|
||||
if (zp && zn)
|
||||
sides[0] = submap.icons[2];
|
||||
sides[0] = submap.getSubIcon(0, 1);
|
||||
else if (zp)
|
||||
sides[0] = submap.icons[1];
|
||||
sides[0] = submap.getSubIcon(1, 0);
|
||||
else
|
||||
sides[0] = submap.icons[3];
|
||||
sides[0] = submap.getSubIcon(1, 1);
|
||||
|
||||
sides[1] = sides[4] = sides[5] = sides[0];
|
||||
} else {
|
||||
sides[0] = sides[1] = iconTop;
|
||||
sides[2] = sides[3] = sides[4] = sides[5] = submap.icons[0];
|
||||
sides[2] = sides[3] = sides[4] = sides[5] = submap.getSubIcon(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.cricketcraft.chisel.utils.Drawing;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class RenderStandardBlockNoSunlight implements ISimpleBlockRenderingHandler {
|
||||
|
||||
static int id;
|
||||
|
||||
public RenderStandardBlockNoSunlight() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int meta, int modelID, RenderBlocks renderer) {
|
||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
||||
Drawing.drawBlock(block, meta, renderer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
if (meta != 0)
|
||||
renderer.overrideBlockTexture = block.getIcon(0, meta);
|
||||
renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
|
||||
renderer.renderStandardBlockWithColorMultiplier(block, x, y, z, 1.0F, 1.0F, 1.0F);
|
||||
renderer.overrideBlockTexture = null;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int renderId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-3
@@ -8,7 +8,6 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper.TextureType;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.utils.Drawing;
|
||||
@@ -16,12 +15,12 @@ import com.cricketcraft.chisel.utils.Drawing;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockAdvancedMarbleRenderer implements ISimpleBlockRenderingHandler {
|
||||
public class RendererCTM implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public RenderBlocksCTM rendererCTM = new RenderBlocksCTM();
|
||||
RenderBlocksColumn rendererColumn = new RenderBlocksColumn();
|
||||
|
||||
public BlockAdvancedMarbleRenderer() {
|
||||
public RendererCTM() {
|
||||
if (Chisel.renderCTMId == 0) {
|
||||
Chisel.renderCTMId = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
+4
-5
@@ -8,19 +8,18 @@ import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.api.ICarvable;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.carving.CarvableHelper.TextureType;
|
||||
import com.cricketcraft.chisel.carving.CarvableVariation;
|
||||
import com.cricketcraft.chisel.utils.Drawing;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockCTMNoLightRenderer implements ISimpleBlockRenderingHandler {
|
||||
public class RendererCTMFullbright implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public RenderBlocksCTMNoLight rendererCTMNoLight = new RenderBlocksCTMNoLight();
|
||||
public RenderBlocksCTMFullbright rendererCTMNoLight = new RenderBlocksCTMFullbright();
|
||||
|
||||
public BlockCTMNoLightRenderer() {
|
||||
public RendererCTMFullbright() {
|
||||
if (Chisel.renderCTMNoLightId == 0) {
|
||||
Chisel.renderCTMNoLightId = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
+2
-2
@@ -15,11 +15,11 @@ import com.cricketcraft.chisel.utils.Drawing;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockMarblePaneRenderer implements ISimpleBlockRenderingHandler {
|
||||
public class RendererCTMPane implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public static int id;
|
||||
|
||||
public BlockMarblePaneRenderer() {
|
||||
public RendererCTMPane() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
+2
-2
@@ -12,9 +12,9 @@ import com.cricketcraft.chisel.utils.Drawing;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockEldritchRenderer implements ISimpleBlockRenderingHandler {
|
||||
public class RendererEldritch implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public BlockEldritchRenderer() {
|
||||
public RendererEldritch() {
|
||||
Chisel.renderEldritchId = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
+3
-4
@@ -1,25 +1,24 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import com.cricketcraft.chisel.config.Configurations;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.item.ItemDye;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.cricketcraft.chisel.Chisel;
|
||||
import com.cricketcraft.chisel.block.BlockCarvableGlow;
|
||||
import com.cricketcraft.chisel.config.Configurations;
|
||||
import com.cricketcraft.chisel.utils.Drawing;
|
||||
import com.cricketcraft.chisel.utils.GeneralClient;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockGlowRenderer implements ISimpleBlockRenderingHandler {
|
||||
public class RendererLayeredGlow implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public BlockGlowRenderer() {
|
||||
public RendererLayeredGlow() {
|
||||
Chisel.renderGlowId = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
+7
-7
@@ -1,6 +1,6 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import com.cricketcraft.chisel.block.BlockTexturedOre;
|
||||
import com.cricketcraft.chisel.block.BlockMultiLayerBase;
|
||||
import com.cricketcraft.chisel.utils.Drawing;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
@@ -10,21 +10,21 @@ import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public class BlockTexturedOreRenderer implements ISimpleBlockRenderingHandler {
|
||||
public class RendererMultiLayer implements ISimpleBlockRenderingHandler {
|
||||
|
||||
float bot = -0.001f, top = 1.0f - bot;
|
||||
public static int id;
|
||||
|
||||
public BlockTexturedOreRenderer() {
|
||||
public RendererMultiLayer() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block blck, int meta, int modelID, RenderBlocks renderer) {
|
||||
if (blck == null || !(blck instanceof BlockTexturedOre))
|
||||
if (blck == null || !(blck instanceof BlockMultiLayerBase))
|
||||
return;
|
||||
|
||||
BlockTexturedOre block = (BlockTexturedOre) blck;
|
||||
BlockMultiLayerBase block = (BlockMultiLayerBase) blck;
|
||||
|
||||
if (block.icon != null) {
|
||||
renderer.overrideBlockTexture = block.icon;
|
||||
@@ -44,9 +44,9 @@ public class BlockTexturedOreRenderer implements ISimpleBlockRenderingHandler {
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block blck, int modelId, RenderBlocks renderer) {
|
||||
if (blck == null || !(blck instanceof BlockTexturedOre))
|
||||
if (blck == null || !(blck instanceof BlockMultiLayerBase))
|
||||
return false;
|
||||
BlockTexturedOre block = (BlockTexturedOre) blck;
|
||||
BlockMultiLayerBase block = (BlockMultiLayerBase) blck;
|
||||
|
||||
if (block.currentPass == 0) {
|
||||
if (block.icon != null) {
|
||||
+2
-2
@@ -13,11 +13,11 @@ import com.cricketcraft.chisel.utils.Drawing;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockMarblePillarRenderer implements ISimpleBlockRenderingHandler {
|
||||
public class RendererPillar implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public static int id;
|
||||
|
||||
public BlockMarblePillarRenderer() {
|
||||
public RendererPillar() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
+2
-2
@@ -14,9 +14,9 @@ import com.cricketcraft.chisel.utils.Drawing;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockRoadLineRenderer implements ISimpleBlockRenderingHandler {
|
||||
public class RendererRoadLine implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public BlockRoadLineRenderer() {
|
||||
public RendererRoadLine() {
|
||||
Chisel.roadLineId = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
+2
-2
@@ -13,9 +13,9 @@ import com.cricketcraft.chisel.utils.Drawing;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockLayeredRenderer implements ISimpleBlockRenderingHandler {
|
||||
public class RendererSimpleLayered implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public BlockLayeredRenderer() {
|
||||
public RendererSimpleLayered() {
|
||||
Chisel.renderLayeredId = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
+2
-2
@@ -12,11 +12,11 @@ import com.cricketcraft.chisel.utils.Drawing;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockSnakeStoneRenderer implements ISimpleBlockRenderingHandler {
|
||||
public class RendererSnakeStone implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public static int id;
|
||||
|
||||
public BlockSnakeStoneRenderer() {
|
||||
public RendererSnakeStone() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
+2
-2
@@ -12,11 +12,11 @@ import com.cricketcraft.chisel.utils.Drawing;
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
|
||||
public class BlockMarbleStairsRenderer implements ISimpleBlockRenderingHandler {
|
||||
public class RendererStairs implements ISimpleBlockRenderingHandler {
|
||||
|
||||
public static int id;
|
||||
|
||||
public BlockMarbleStairsRenderer() {
|
||||
public RendererStairs() {
|
||||
id = RenderingRegistry.getNextAvailableRenderId();
|
||||
}
|
||||
|
||||
+6
-5
@@ -7,6 +7,7 @@ import net.minecraft.world.IBlockAccess;
|
||||
|
||||
import com.cricketcraft.chisel.api.client.CTM;
|
||||
import com.cricketcraft.chisel.api.client.ISubmapManager;
|
||||
import com.cricketcraft.chisel.api.client.TextureSubmap;
|
||||
import com.cricketcraft.chisel.init.ChiselBlocks;
|
||||
|
||||
import static com.cricketcraft.chisel.api.client.Dir.*;
|
||||
@@ -22,20 +23,20 @@ public class SubmapManagerFakeController implements ISubmapManager {
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return map.icons[0];
|
||||
return map.getSubIcon(0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
|
||||
ctm.buildConnectionMap(world, x, y, z, side, ChiselBlocks.futura, 2);
|
||||
if (ctm.connectedAnd(TOP, BOTTOM, LEFT, RIGHT)) {
|
||||
return map.icons[3];
|
||||
return map.getSubIcon(1, 1);
|
||||
} else if (ctm.connectedAnd(TOP, BOTTOM)) {
|
||||
return map.icons[2];
|
||||
return map.getSubIcon(0, 1);
|
||||
} else if (ctm.connectedAnd(LEFT, RIGHT)) {
|
||||
return map.icons[1];
|
||||
return map.getSubIcon(1, 0);
|
||||
} else {
|
||||
return map.icons[0];
|
||||
return map.getSubIcon(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.client.event.TextureStitchEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class TextureSubmap {
|
||||
|
||||
public int width, height;
|
||||
public IIcon icon;
|
||||
public IIcon icons[];
|
||||
|
||||
public TextureSubmap(IIcon i, int w, int h) {
|
||||
icon = i;
|
||||
width = w;
|
||||
height = h;
|
||||
icons = new IIcon[width * height];
|
||||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void TexturesStitched(TextureStitchEvent.Post event) {
|
||||
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
icons[y * width + x] = new TextureVirtual(icon, width, height, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
package com.cricketcraft.chisel.client.render;
|
||||
|
||||
import net.minecraft.util.IIcon;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class TextureVirtual implements IIcon {
|
||||
|
||||
private int width, height;
|
||||
private float umin, umax, vmin, vmax;
|
||||
private String name;
|
||||
private IIcon parentIcon;
|
||||
|
||||
TextureVirtual(IIcon parent, int w, int h, int x, int y) {
|
||||
parentIcon = parent;
|
||||
|
||||
umin = parentIcon.getInterpolatedU(16.0 * (x) / w);
|
||||
umax = parentIcon.getInterpolatedU(16.0 * (x + 1) / w);
|
||||
vmin = parentIcon.getInterpolatedV(16.0 * (y) / h);
|
||||
vmax = parentIcon.getInterpolatedV(16.0 * (y + 1) / h);
|
||||
|
||||
name = parentIcon.getIconName() + "|" + x + "." + y;
|
||||
|
||||
width = parentIcon.getIconWidth();
|
||||
height = parentIcon.getIconHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMinU() {
|
||||
return umin;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMaxU() {
|
||||
return umax;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getInterpolatedU(double d0) {
|
||||
return (float) (umin + (umax - umin) * d0 / 16.0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMinV() {
|
||||
return vmin;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getMaxV() {
|
||||
return vmax;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getInterpolatedV(double d0) {
|
||||
return (float) (vmin + (vmax - vmin) * d0 / 16.0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getIconName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getIconWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getIconHeight() {
|
||||
return height;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user