rendering cleanup

This commit is contained in:
Sen 2025-06-22 12:27:25 +02:00
parent 1d937b466d
commit 3ae27fc27f
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
48 changed files with 365 additions and 978 deletions

View file

@ -659,8 +659,8 @@ public class Client implements IThreadListener {
GL11.glLoadIdentity();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
this.textureMap = new TextureMap();
this.textureManager.loadTexture(TextureMap.locationBlocksTexture, this.textureMap);
this.textureManager.bindTexture(TextureMap.locationBlocksTexture);
this.textureManager.loadTexture(TextureMap.BLOCKS, this.textureMap);
this.textureManager.bindTexture(TextureMap.BLOCKS);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
this.modelManager = new ModelManager(this.textureMap);
@ -777,7 +777,7 @@ public class Client implements IThreadListener {
{
this.controller.update();
}
this.textureMap.updateAnimations();
this.textureMap.update();
if (this.open != null)
{
this.open.updateScreen();

View file

@ -110,6 +110,7 @@ import common.init.Blocks;
import common.init.Items;
import common.init.SpeciesRegistry;
import common.init.SpeciesRegistry.ModelType;
import common.model.TextureAnimation;
public abstract class RenderRegistry {
public static void registerRenderers(Map<Class<? extends Entity>, Render<? extends Entity>> map,
@ -128,8 +129,6 @@ public abstract class RenderRegistry {
map.put(EntityDragon.class, new RenderDragon(mgr));
map.put(EntityCrystal.class, new RenderCrystal(mgr));
map.put(Entity.class, new RenderEntity(mgr));
// map.put(EntityPainting.class, new RenderPainting(mgr));
// map.put(EntityFrame.class, new RenderItemFrame(mgr, ritem));
map.put(EntityLeashKnot.class, new RenderLeashKnot(mgr));
map.put(EntityArrow.class, new RenderArrow(mgr));
map.put(EntitySnowball.class, new RenderItemEntity(mgr, Items.snowball, ritem));
@ -168,14 +167,14 @@ public abstract class RenderRegistry {
}
}
public static void registerAnimations(Map<String, Class<? extends TextureTicked>> anim) {
anim.put("fire1", TextureFlamesFX1.class);
anim.put("fire2", TextureFlamesFX2.class);
anim.put("flame1", TextureFlamesFXMono1.class);
anim.put("flame2", TextureFlamesFXMono2.class);
anim.put("lavaflow", TextureLavaFlowFX.class);
anim.put("lava", TextureLavaFX.class);
anim.put("waterflow", TextureWaterFlowFX.class);
anim.put("water", TextureWaterFX.class);
public static void registerAnimations(Map<TextureAnimation, Class<? extends TextureTicked>> anim) {
anim.put(TextureAnimation.FIRE1, TextureFlamesFX1.class);
anim.put(TextureAnimation.FIRE2, TextureFlamesFX2.class);
anim.put(TextureAnimation.FLAME1, TextureFlamesFXMono1.class);
anim.put(TextureAnimation.FLAME2, TextureFlamesFXMono2.class);
anim.put(TextureAnimation.LAVAFLOW, TextureLavaFlowFX.class);
anim.put(TextureAnimation.LAVA, TextureLavaFX.class);
anim.put(TextureAnimation.WATERFLOW, TextureWaterFlowFX.class);
anim.put(TextureAnimation.WATER, TextureWaterFX.class);
}
}

View file

@ -1,150 +0,0 @@
package client.renderer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import org.lwjgl.opengl.GL11;
import common.block.Block;
import common.block.liquid.BlockLiquid;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
import common.util.BlockPos;
import common.util.ExtMath;
import common.util.Vec3;
import common.world.State;
import common.world.World;
public class ActiveRenderInfo
{
/** The current GL viewport */
private static final IntBuffer VIEWPORT = ByteBuffer.allocateDirect(16 << 2).order(ByteOrder.nativeOrder()).asIntBuffer();
/** The current GL modelview matrix */
private static final FloatBuffer MODELVIEW = ByteBuffer.allocateDirect(16 << 2).order(ByteOrder.nativeOrder()).asFloatBuffer();
/** The current GL projection matrix */
private static final FloatBuffer PROJECTION = ByteBuffer.allocateDirect(16 << 2).order(ByteOrder.nativeOrder()).asFloatBuffer();
/** The computed view object coordinates */
private static final FloatBuffer OBJECTCOORDS = ByteBuffer.allocateDirect(3 << 2).order(ByteOrder.nativeOrder()).asFloatBuffer();
private static Vec3 position = new Vec3(0.0D, 0.0D, 0.0D);
private static final FloatBuffer SCREENCOORDS = ByteBuffer.allocateDirect(3 << 2).order(ByteOrder.nativeOrder()).asFloatBuffer();
/** The X component of the entity's yaw rotation */
private static float rotationX;
/** The combined X and Z components of the entity's pitch rotation */
private static float rotationXZ;
/** The Z component of the entity's yaw rotation */
private static float rotationZ;
/**
* The Y component (scaled along the Z axis) of the entity's pitch rotation
*/
private static float rotationYZ;
/**
* The Y component (scaled along the X axis) of the entity's pitch rotation
*/
private static float rotationXY;
/**
* Updates the current render info and camera location based on entity look angles and 1st/3rd person view mode
*/
public static void updateRenderInfo(EntityNPC entityplayerIn, boolean p_74583_1_)
{
GL11.glGetFloatv(2982, MODELVIEW);
GL11.glGetFloatv(2983, PROJECTION);
GL11.glGetIntegerv(GL11.GL_VIEWPORT, VIEWPORT);
float f = (float)((VIEWPORT.get(0) + VIEWPORT.get(2)) / 2);
float f1 = (float)((VIEWPORT.get(1) + VIEWPORT.get(3)) / 2);
Project.gluUnProject(f, f1, 0.0F, MODELVIEW, PROJECTION, VIEWPORT, OBJECTCOORDS);
position = new Vec3((double)OBJECTCOORDS.get(0), (double)OBJECTCOORDS.get(1), (double)OBJECTCOORDS.get(2));
int i = p_74583_1_ ? 1 : 0;
float f2 = entityplayerIn.rotPitch;
float f3 = entityplayerIn.rotYaw;
rotationX = ExtMath.cos(f3 * (float)Math.PI / 180.0F) * (float)(1 - i * 2);
rotationZ = ExtMath.sin(f3 * (float)Math.PI / 180.0F) * (float)(1 - i * 2);
rotationYZ = -rotationZ * ExtMath.sin(f2 * (float)Math.PI / 180.0F) * (float)(1 - i * 2);
rotationXY = rotationX * ExtMath.sin(f2 * (float)Math.PI / 180.0F) * (float)(1 - i * 2);
rotationXZ = ExtMath.cos(f2 * (float)Math.PI / 180.0F);
}
public static Vec3 getDisplayCoords(float x, float y, float z) {
Project.gluProject(x, y, z, MODELVIEW, PROJECTION, VIEWPORT, SCREENCOORDS);
return new Vec3((double)SCREENCOORDS.get(0), (double)SCREENCOORDS.get(1), (double)SCREENCOORDS.get(2));
}
public static Vec3 projectViewFromEntity(Entity p_178806_0_, double p_178806_1_)
{
double d0 = p_178806_0_.prevX + (p_178806_0_.posX - p_178806_0_.prevX) * p_178806_1_;
double d1 = p_178806_0_.prevY + (p_178806_0_.posY - p_178806_0_.prevY) * p_178806_1_;
double d2 = p_178806_0_.prevZ + (p_178806_0_.posZ - p_178806_0_.prevZ) * p_178806_1_;
double d3 = d0 + position.xCoord;
double d4 = d1 + position.yCoord;
double d5 = d2 + position.zCoord;
return new Vec3(d3, d4, d5);
}
public static Block getBlockAtEntityViewpoint(World worldIn, Entity p_180786_1_, float p_180786_2_)
{
Vec3 vec3 = projectViewFromEntity(p_180786_1_, (double)p_180786_2_);
BlockPos blockpos = new BlockPos(vec3);
State iblockstate = worldIn.getState(blockpos);
Block block = iblockstate.getBlock();
if (block.getMaterial().isLiquid())
{
float f = 0.0F;
if (iblockstate.getBlock() instanceof BlockLiquid)
{
f = BlockLiquid.getLiquidHeightPercent(((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue()) - 0.11111111F;
}
float f1 = (float)(blockpos.getY() + 1) - f;
if (vec3.yCoord >= (double)f1)
{
block = worldIn.getState(blockpos.up()).getBlock();
}
}
return block;
}
public static Vec3 getPosition()
{
return position;
}
public static float getRotationX()
{
return rotationX;
}
public static float getRotationXZ()
{
return rotationXZ;
}
public static float getRotationZ()
{
return rotationZ;
}
public static float getRotationYZ()
{
return rotationYZ;
}
public static float getRotationXY()
{
return rotationXY;
}
}

View file

@ -12,7 +12,6 @@ public class DefaultVertexFormats
public static final VertexFormat POSITION_NORMAL = new VertexFormat();
public static final VertexFormat POSITION_TEX_COLOR = new VertexFormat();
public static final VertexFormat POSITION_TEX_NORMAL = new VertexFormat();
// public static final VertexFormat POSITION_TEX_LMAP_COLOR = new VertexFormat();
public static final VertexFormat POSITION_TEX_COLOR_NORMAL = new VertexFormat();
public static final VertexFormatElement POSITION_3F = new VertexFormatElement(0, VertexFormatElement.EnumType.FLOAT, VertexFormatElement.EnumUsage.POSITION, 3);
public static final VertexFormatElement COLOR_4UB = new VertexFormatElement(0, VertexFormatElement.EnumType.UBYTE, VertexFormatElement.EnumUsage.COLOR, 4);
@ -55,10 +54,6 @@ public class DefaultVertexFormats
POSITION_TEX_NORMAL.addElement(TEX_2F);
POSITION_TEX_NORMAL.addElement(NORMAL_3B);
POSITION_TEX_NORMAL.addElement(PADDING_1B);
// POSITION_TEX_LMAP_COLOR.addElement(POSITION_3F);
// POSITION_TEX_LMAP_COLOR.addElement(TEX_2F);
// POSITION_TEX_LMAP_COLOR.addElement(TEX_2S);
// POSITION_TEX_LMAP_COLOR.addElement(COLOR_4UB);
POSITION_TEX_COLOR_NORMAL.addElement(POSITION_3F);
POSITION_TEX_COLOR_NORMAL.addElement(TEX_2F);
POSITION_TEX_COLOR_NORMAL.addElement(COLOR_4UB);

View file

@ -80,7 +80,7 @@ public class EntityRenderer {
this.itemRenderer = gmIn.getItemRenderer();
this.lightmapTexture = new DynamicTexture(16, 16);
gmIn.getTextureManager().loadTexture(locationLightMap, this.lightmapTexture);
this.lightmapColors = this.lightmapTexture.getTextureData();
this.lightmapColors = this.lightmapTexture.getData();
for (int i = 0; i < 32; ++i)
{
@ -879,7 +879,7 @@ public class EntityRenderer {
this.lightmapColors[n] = a << 24 | r << 16 | g << 8 | b;
}
this.lightmapTexture.updateDynamicTexture();
this.lightmapTexture.updateTexture();
this.lightmapUpdateNeeded = false;
}
}
@ -959,7 +959,7 @@ public class EntityRenderer {
this.updateFogColor(partialTicks);
GL11.glClear(16640);
this.setupCameraTransform(partialTicks);
ActiveRenderInfo.updateRenderInfo(this.gm.player, this.gm.thirdPersonView == 2);
MatrixState.update(this.gm.player, this.gm.thirdPersonView == 2);
Entity entity = this.gm.getRenderViewEntity();
double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partialTicks;
double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partialTicks;
@ -987,7 +987,7 @@ public class EntityRenderer {
this.renderCloudsCheck(renderglobal, partialTicks);
}
this.setupFog(0, partialTicks);
this.gm.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
this.gm.getTextureManager().bindTexture(TextureMap.BLOCKS);
ItemRenderer.disableStandardItemLighting();
renderglobal.setupTerrain(entity, (double)partialTicks, this.frameCount++, this.gm.player.noclip);
this.gm.renderGlobal.updateChunks(finishTimeNano);
@ -1065,7 +1065,7 @@ public class EntityRenderer {
this.setupFog(0, partialTicks);
GlState.enableBlend();
GlState.depthMask(false);
this.gm.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
this.gm.getTextureManager().bindTexture(TextureMap.BLOCKS);
GlState.shadeModel(GL11.GL_SMOOTH);
renderglobal.renderBlockLayer(BlockLayer.TRANSLUCENT, (double)partialTicks, entity);
GlState.shadeModel(GL11.GL_FLAT);
@ -1474,7 +1474,7 @@ public class EntityRenderer {
this.fogColorBlue *= mul;
}
Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(this.gm.world, entity, partial);
Block block = MatrixState.getLookedBlock(this.gm.world, entity, partial);
// if (this.cloudFog)
// {
@ -1600,7 +1600,7 @@ public class EntityRenderer {
GL11.glFogfv(GL11.GL_FOG_COLOR, (FloatBuffer)this.setFogColorBuffer(this.fogColorRed, this.fogColorGreen, this.fogColorBlue, 1.0F));
GL11.glNormal3f(0.0F, -1.0F, 0.0F);
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(this.gm.world, entity, partial);
Block block = MatrixState.getLookedBlock(this.gm.world, entity, partial);
if(distance >= 1.0f) {
;

View file

@ -10,90 +10,34 @@ import common.init.ItemRegistry;
import common.item.Item;
import common.item.ItemStack;
public class ItemModelMesher
{
private final Map<Integer, IBakedModel> simpleShapesCache = Maps.<Integer, IBakedModel>newHashMap();
private final ModelManager modelManager;
public class ItemModelMesher {
private final Map<Integer, IBakedModel> models = Maps.<Integer, IBakedModel>newHashMap();
private final ModelManager manager;
public ItemModelMesher(ModelManager modelManager)
{
this.modelManager = modelManager;
}
public ItemModelMesher(ModelManager manager) {
this.manager = manager;
}
public TextureAtlasSprite getParticleIcon(Item item)
{
return this.getItemModel(new ItemStack(item)).getBaseTexture();
}
public TextureAtlasSprite getParticleIcon(Item item) {
return this.getItemModel(new ItemStack(item)).getBaseTexture();
}
public IBakedModel getItemModel(ItemStack stack)
{
Item item = stack.getItem();
IBakedModel ibakedmodel = this.simpleShapesCache.get(this.getIndex(item));
public IBakedModel getItemModel(ItemStack stack) {
Item item = stack.getItem();
IBakedModel model = this.models.get(ItemRegistry.getIdFromItem(item));
if(model == null)
model = this.manager.getMissingModel();
return model;
}
if (ibakedmodel == null)
{
ibakedmodel = this.modelManager.getMissingModel();
}
public ModelManager getModelManager() {
return this.manager;
}
return ibakedmodel;
}
private int getIndex(Item item)
{
return ItemRegistry.getIdFromItem(item);
}
// public void register(Item item, int meta, ResourceLocation location)
// {
// this.simpleShapes.put(Integer.valueOf(this.getIndex(item, meta)), location);
// this.simpleShapesCache.put(Integer.valueOf(this.getIndex(item, meta)), this.modelManager.getModel(location));
// }
// public void register(Item item, ItemMeshDefinition definition)
// {
// this.shapers.put(item, definition);
// }
// public void registerItem(Item itm, int subType, String identifier)
// {
// this.register(itm, subType, new ResourceLocation(identifier, "inventory"));
//// String id = ItemRegistry.getNameFromItem(itm).toString();
//// if(id.equals(identifier)) {
////// throw new IllegalArgumentException("Duplikat: " + identifier);
//// Log.DATA.info("MATCHING: " + ItemRegistry.getNameFromItem(itm) + ":" + subType);
//// }
//// else {
//// Log.DATA.info("MISMATCH: " + ItemRegistry.getNameFromItem(itm) + ":" + subType + ": " + identifier);
//// }
// }
// public void registerBlock(Block blk, int subType, String identifier)
// {
// this.registerItem(ItemRegistry.getItemFromBlock(blk), subType, identifier);
// }
//
// public void registerBlock(Block blk, String identifier)
// {
// this.registerBlock(blk, 0, identifier);
// }
//
// public void registerItem(Item itm, String identifier)
// {
// this.registerItem(itm, 0, identifier);
// }
public ModelManager getModelManager()
{
return this.modelManager;
}
public void rebuildCache()
{
this.simpleShapesCache.clear();
for(Item item : ItemRegistry.REGISTRY) {
this.simpleShapesCache.put(this.getIndex(item),
this.modelManager.getModel("item/" +
ItemRegistry.getNameFromItem(item).toString()));
}
}
public void rebuildCache() {
this.models.clear();
for(Item item : ItemRegistry.REGISTRY) {
this.models.put(ItemRegistry.getIdFromItem(item), this.manager.getModel("item/" + ItemRegistry.getNameFromItem(item).toString()));
}
}
}

View file

@ -515,7 +515,7 @@ public class ItemRenderer
*/
private void renderBlockInHand(float partialTicks, TextureAtlasSprite atlas)
{
this.gm.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
this.gm.getTextureManager().bindTexture(TextureMap.BLOCKS);
// Tessellator tessellator = Tessellator.getInstance();
RenderBuffer worldrenderer = Tessellator.getBuffer();
float f = 0.1F;
@ -560,7 +560,7 @@ public class ItemRenderer
{
GL11.glPushMatrix();
TextureAtlasSprite textureatlassprite = this.gm.getTextureMapBlocks().getAtlasSprite("blocks/fire_layer_1");
this.gm.getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
this.gm.getTextureManager().bindTexture(TextureMap.BLOCKS);
float f1 = textureatlassprite.getMinU();
float f2 = textureatlassprite.getMaxU();
float f3 = textureatlassprite.getMinV();

View file

@ -0,0 +1,103 @@
package client.renderer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import org.lwjgl.opengl.GL11;
import common.block.Block;
import common.block.liquid.BlockLiquid;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
import common.util.BlockPos;
import common.util.ExtMath;
import common.util.Vec3;
import common.world.State;
import common.world.World;
public class MatrixState {
private static final IntBuffer VIEWPORT = ByteBuffer.allocateDirect(16 << 2).order(ByteOrder.nativeOrder()).asIntBuffer();
private static final FloatBuffer MODELVIEW = ByteBuffer.allocateDirect(16 << 2).order(ByteOrder.nativeOrder()).asFloatBuffer();
private static final FloatBuffer PROJECTION = ByteBuffer.allocateDirect(16 << 2).order(ByteOrder.nativeOrder()).asFloatBuffer();
private static final FloatBuffer OBJECTCOORDS = ByteBuffer.allocateDirect(3 << 2).order(ByteOrder.nativeOrder()).asFloatBuffer();
private static final FloatBuffer SCREENCOORDS = ByteBuffer.allocateDirect(3 << 2).order(ByteOrder.nativeOrder()).asFloatBuffer();
private static Vec3 position = new Vec3(0.0D, 0.0D, 0.0D);
private static float rotationX;
private static float rotationXZ;
private static float rotationZ;
private static float rotationYZ;
private static float rotationXY;
public static void update(EntityNPC player, boolean flip) {
GL11.glGetFloatv(GL11.GL_MODELVIEW_MATRIX, MODELVIEW);
GL11.glGetFloatv(GL11.GL_PROJECTION_MATRIX, PROJECTION);
GL11.glGetIntegerv(GL11.GL_VIEWPORT, VIEWPORT);
float x = (float)((VIEWPORT.get(0) + VIEWPORT.get(2)) / 2);
float y = (float)((VIEWPORT.get(1) + VIEWPORT.get(3)) / 2);
Project.gluUnProject(x, y, 0.0F, MODELVIEW, PROJECTION, VIEWPORT, OBJECTCOORDS);
position = new Vec3((double)OBJECTCOORDS.get(0), (double)OBJECTCOORDS.get(1), (double)OBJECTCOORDS.get(2));
int rot = flip ? 1 : 0;
float pitch = player.rotPitch;
float yaw = player.rotYaw;
rotationX = ExtMath.cos(yaw * (float)Math.PI / 180.0F) * (float)(1 - rot * 2);
rotationZ = ExtMath.sin(yaw * (float)Math.PI / 180.0F) * (float)(1 - rot * 2);
rotationYZ = -rotationZ * ExtMath.sin(pitch * (float)Math.PI / 180.0F) * (float)(1 - rot * 2);
rotationXY = rotationX * ExtMath.sin(pitch * (float)Math.PI / 180.0F) * (float)(1 - rot * 2);
rotationXZ = ExtMath.cos(pitch * (float)Math.PI / 180.0F);
}
public static Vec3 getDisplayCoords(float x, float y, float z) {
Project.gluProject(x, y, z, MODELVIEW, PROJECTION, VIEWPORT, SCREENCOORDS);
return new Vec3((double)SCREENCOORDS.get(0), (double)SCREENCOORDS.get(1), (double)SCREENCOORDS.get(2));
}
private static Vec3 project(Entity entity, double partial) {
double x = entity.prevX + (entity.posX - entity.prevX) * partial;
double y = entity.prevY + (entity.posY - entity.prevY) * partial;
double z = entity.prevZ + (entity.posZ - entity.prevZ) * partial;
return new Vec3(x + position.xCoord, y + position.yCoord, z + position.zCoord);
}
public static Block getLookedBlock(World world, Entity entity, float partial) {
Vec3 view = project(entity, (double)partial);
BlockPos pos = new BlockPos(view);
State state = world.getState(pos);
Block block = state.getBlock();
if(block.getMaterial().isLiquid()) {
float height = 0.0F;
if(state.getBlock() instanceof BlockLiquid)
height = BlockLiquid.getLiquidHeightPercent(((Integer)state.getValue(BlockLiquid.LEVEL)).intValue()) - 0.11111111F;
float y = (float)(pos.getY() + 1) - height;
if(view.yCoord >= (double)y)
block = world.getState(pos.up()).getBlock();
}
return block;
}
public static Vec3 getPosition() {
return position;
}
public static float getRotationX() {
return rotationX;
}
public static float getRotationXZ() {
return rotationXZ;
}
public static float getRotationZ() {
return rotationZ;
}
public static float getRotationYZ() {
return rotationYZ;
}
public static float getRotationXY() {
return rotationXY;
}
}

View file

@ -38,14 +38,7 @@ import java.nio.IntBuffer;
import org.lwjgl.opengl.GL11;
/**
* Project.java
* <p/>
* <p/>
* Created 11-jan-2004
*
* @author Erik Duijs
*/
// 11-jan-2004 Erik Duijs
public class Project {
static final float PI = (float)Math.PI;
@ -67,13 +60,6 @@ public class Project {
private static final float[] side = new float[3];
private static final float[] up = new float[3];
/**
* Normalize vector
*
* @param v
*
* @return float[]
*/
protected static float[] normalize(float[] v) {
float r;
@ -90,35 +76,18 @@ public class Project {
return v;
}
/**
* Calculate cross-product
*
* @param v1
* @param v2
* @param result
*/
protected static void cross(float[] v1, float[] v2, float[] result) {
result[0] = v1[1] * v2[2] - v1[2] * v2[1];
result[1] = v1[2] * v2[0] - v1[0] * v2[2];
result[2] = v1[0] * v2[1] - v1[1] * v2[0];
}
/**
* Make matrix an identity matrix
*/
private static void __gluMakeIdentityf(FloatBuffer m) {
int oldPos = m.position();
m.put(IDENTITY_MATRIX);
m.position(oldPos);
}
/**
* Method __gluMultMatrixVecf
*
* @param finalMatrix
* @param in
* @param out
*/
private static void __gluMultMatrixVecf(FloatBuffer m, float[] in, float[] out) {
for (int i = 0; i < 4; i++) {
out[i] =
@ -130,12 +99,6 @@ public class Project {
}
}
/**
* @param src
* @param inverse
*
* @return true if the matrix was succesfully inverted
*/
private static boolean __gluInvertMatrixf(FloatBuffer src, FloatBuffer inverse) {
int i, j, k, swap;
float t;
@ -207,11 +170,6 @@ public class Project {
return true;
}
/**
* @param a
* @param b
* @param r
*/
private static void __gluMultMatricesf(FloatBuffer a, FloatBuffer b, FloatBuffer r) {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
@ -221,14 +179,6 @@ public class Project {
}
}
/**
* Method gluPerspective.
*
* @param fovy
* @param aspect
* @param zNear
* @param zFar
*/
public static void gluPerspective(float fovy, float aspect, float zNear, float zFar) {
float sine, cotangent, deltaZ;
float radians = fovy / 2 * PI / 180;
@ -254,19 +204,6 @@ public class Project {
GL11.glMultMatrixf(matrix);
}
/**
* Method gluLookAt
*
* @param eyex
* @param eyey
* @param eyez
* @param centerx
* @param centery
* @param centerz
* @param upx
* @param upy
* @param upz
*/
public static void gluLookAt(
float eyex,
float eyey,
@ -315,17 +252,6 @@ public class Project {
GL11.glTranslatef(-eyex, -eyey, -eyez);
}
/**
* Method gluProject
*
* @param objx
* @param objy
* @param objz
* @param modelMatrix
* @param projMatrix
* @param viewport
* @param win_pos
*/
public static boolean gluProject(
float objx,
float objy,
@ -364,17 +290,6 @@ public class Project {
return true;
}
/**
* Method gluUnproject
*
* @param winx
* @param winy
* @param winz
* @param modelMatrix
* @param projMatrix
* @param viewport
* @param obj_pos
*/
public static boolean gluUnProject(
float winx,
float winy,
@ -418,31 +333,4 @@ public class Project {
return true;
}
// /**
// * Method gluPickMatrix
// *
// * @param x
// * @param y
// * @param deltaX
// * @param deltaY
// * @param viewport
// */
// public static void gluPickMatrix(
// float x,
// float y,
// float deltaX,
// float deltaY,
// IntBuffer viewport) {
// if (deltaX <= 0 || deltaY <= 0) {
// return;
// }
//
// /* Translate and scale the picked region to the entire window */
// SKC.glTranslatef(
// (viewport.get(viewport.position() + 2) - 2 * (x - viewport.get(viewport.position() + 0))) / deltaX,
// (viewport.get(viewport.position() + 3) - 2 * (y - viewport.get(viewport.position() + 1))) / deltaY,
// 0);
// SKC.glScalef(viewport.get(viewport.position() + 2) / deltaX, viewport.get(viewport.position() + 3) / deltaY, 1.0f);
// }
}

View file

@ -186,32 +186,17 @@ public class RegionRenderCache implements IWorldAccess
}
}
// /**
// * Checks to see if an air block exists at the provided location. Note that this only checks to see if the blocks
// * material is set to air, meaning it is possible for non-vanilla blocks to still pass this check.
// */
// public boolean isAirBlock(BlockPos pos)
// {
// return this.getBlockState(pos).getBlock() == Blocks.air;
// }
public int getLightFor(LightType p_175628_1_, BlockPos pos)
public int getLightFor(LightType type, BlockPos pos)
{
if (pos.getY() >= -World.MAX_SIZE_Y && pos.getY() < World.MAX_SIZE_Y)
{
int i = (pos.getX() >> 4) - this.xPos;
int j = (pos.getZ() >> 4) - this.zPos;
return this.chunks[i][j].getLight(p_175628_1_, pos);
return this.chunks[i][j].getLight(type, pos);
}
else
{
return p_175628_1_.defValue;
return type.defValue;
}
}
// public int getStrongPower(BlockPos pos, EnumFacing direction)
// {
// IBlockState iblockstate = this.getBlockState(pos);
// return iblockstate.getBlock().getStrongPower(this, pos, iblockstate, direction);
// }
}

View file

@ -21,8 +21,6 @@ public class RenderBuffer
private int vertexCount;
private VertexFormatElement vertexFormatElement;
private int vertexFormatIndex;
/** None */
private boolean noColor;
private int drawMode;
private double xOffset;
@ -284,9 +282,6 @@ public class RenderBuffer
}
}
/**
* Takes in the pass the call list is being requested for. Args: renderPass
*/
private int getColorIndex(int p_78909_1_)
{
return ((this.vertexCount - p_78909_1_) * this.vertexFormat.getNextOffset() + this.vertexFormat.getColorOffset()) / 4;
@ -353,9 +348,6 @@ public class RenderBuffer
}
}
/**
* Disabels color processing.
*/
public void noColor()
{
this.noColor = true;

View file

@ -1553,7 +1553,7 @@ public class RenderGlobal
if (!this.damagedBlocks.isEmpty())
{
this.renderEngine.bindTexture(TextureMap.locationBlocksTexture);
this.renderEngine.bindTexture(TextureMap.BLOCKS);
this.preRenderDamagedBlocks();
worldRendererIn.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
worldRendererIn.setTranslation(-d0, -d1, -d2);

View file

@ -5,47 +5,39 @@ import java.nio.ByteBuffer;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL15;
public class VertexBuffer
{
private int glBufferId;
private final VertexFormat vertexFormat;
private int count;
public class VertexBuffer {
private int id;
private final VertexFormat format;
private int count;
public VertexBuffer(VertexFormat vertexFormatIn)
{
this.vertexFormat = vertexFormatIn;
this.glBufferId = GL15.glGenBuffers();
}
public VertexBuffer(VertexFormat format) {
this.format = format;
this.id = GL15.glGenBuffers();
}
public void bindBuffer()
{
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.glBufferId);
}
public void bindBuffer() {
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.id);
}
public void bufferData(ByteBuffer buffer)
{
this.bindBuffer();
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
this.unbindBuffer();
this.count = buffer.limit() / this.vertexFormat.getNextOffset();
}
public void bufferData(ByteBuffer buffer) {
this.bindBuffer();
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, buffer, GL15.GL_STATIC_DRAW);
this.unbindBuffer();
this.count = buffer.limit() / this.format.getNextOffset();
}
public void drawArrays(int mode)
{
GL11.glDrawArrays(mode, 0, this.count);
}
public void drawArrays(int mode) {
GL11.glDrawArrays(mode, 0, this.count);
}
public void unbindBuffer()
{
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
public void unbindBuffer() {
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
}
public void deleteGlBuffers()
{
if (this.glBufferId >= 0)
{
GL15.glDeleteBuffers(this.glBufferId);
this.glBufferId = -1;
}
}
public void deleteGlBuffers() {
if(this.id >= 0) {
GL15.glDeleteBuffers(this.id);
this.id = -1;
}
}
}

View file

@ -10,7 +10,6 @@ public class VertexFormat
private final List<VertexFormatElement> elements;
private final List<Integer> offsets;
/** The next available offset in this vertex format */
private int nextOffset;
private int colorElementOffset;
private List<Integer> uvOffsetsById;

View file

@ -12,7 +12,7 @@ public class BlockPartFace {
public BlockPartFace(Facing cull, int tint, String texture, BlockFaceUV uv) {
this.cull = cull;
this.tint = tint;
this.texture = texture == null ? TextureMap.LOCATION_MISSING_TEXTURE : texture;
this.texture = texture == null ? TextureMap.MISSING : texture;
this.uv = uv;
}
}

View file

@ -7,7 +7,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import client.renderer.texture.IIconCreator;
import client.renderer.texture.TextureAtlasSprite;
import client.renderer.texture.TextureMap;
import common.collect.Lists;
@ -25,9 +24,7 @@ import common.world.State;
public abstract class ModelBakery
{
private static final Set<String> LOCATIONS_BUILTIN_TEXTURES = Sets.newHashSet(
// "blocks/water_flow", "blocks/water_still",
// "blocks/lava_flow", "blocks/lava_still",
private static final Set<String> BUILTINS = Sets.newHashSet(
"blocks/destroy_stage_0", "blocks/destroy_stage_1",
"blocks/destroy_stage_2", "blocks/destroy_stage_3",
"blocks/destroy_stage_4", "blocks/destroy_stage_5",
@ -42,8 +39,8 @@ public abstract class ModelBakery
static {
for(int z = 0; z < FluidRegistry.getNumFluids(); z++) {
String name = BlockRegistry.getNameFromBlock(FluidRegistry.getStaticBlock(z)).toString();
LOCATIONS_BUILTIN_TEXTURES.add("blocks/" + name + "_flow");
LOCATIONS_BUILTIN_TEXTURES.add("blocks/" + name + "_still");
BUILTINS.add("blocks/" + name + "_flow");
BUILTINS.add("blocks/" + name + "_still");
}
}
@ -56,90 +53,16 @@ public abstract class ModelBakery
FaceBakery faceBakery = new FaceBakery();
RegistrySimple<String, IBakedModel> bakedRegistry = new RegistrySimple();
List<String> itemLocations = Lists.<String>newArrayList();
// Map<Item, List<Integer>> variantNames = Maps.<Item, List<Integer>>newIdentityHashMap();
// variants.clear();
// Map<IBlockState, String> map = blockModelShapes.getMap();
models.put(MISSING, (ModelBlock)new ModelBlock(null).add().all());
variants.add(MISSING);
for(Entry<State, String> entry : map.entrySet()) {
ModelBlock model = (ModelBlock)entry.getKey().getBlock().getModel(ModelBlock.PROVIDER, BlockRegistry.getNameFromBlock(entry.getKey().getBlock())
.toString(), entry.getKey());
// ResourceLocation blk = new ResourceLocation(entry.getValue().getName());
models.put(entry.getValue(), model);
variants.add(entry.getValue());
}
// ResourceLocation loc = new ResourceLocation("item_frame");
// String res = "item_frame" + '#' + "normal";
// ModelBlock model = new ModelBlock("birch_planks")
// .add(3, 3, 15.5f, 13, 13, 16)
// .n("itemframe_background").uv(3, 3, 13, 13).noCull()
// .s("itemframe_background").uv(3, 3, 13, 13).noCull()
// .add(2, 2, 15, 14, 3, 16)
// .d().uv(2, 0, 14, 1).noCull()
// .u().uv(2, 15, 14, 16).noCull()
// .n().uv(2, 13, 14, 14).noCull()
// .s().uv(2, 13, 14, 14).noCull()
// .w().uv(15, 13, 16, 14).noCull()
// .e().uv(0, 13, 1, 14).noCull()
// .add(2, 13, 15, 14, 14, 16)
// .d().uv(2, 0, 14, 1).noCull()
// .u().uv(2, 15, 14, 16).noCull()
// .n().uv(2, 2, 14, 3).noCull()
// .s().uv(2, 2, 14, 3).noCull()
// .w().uv(15, 2, 16, 3).noCull()
// .e().uv(0, 2, 1, 3).noCull()
// .add(2, 3, 15, 3, 13, 16)
// .n().uv(13, 3, 14, 13).noCull()
// .s().uv(2, 3, 3, 13).noCull()
// .w().uv(15, 3, 16, 13).noCull()
// .e().uv(0, 3, 1, 13).noCull()
// .add(13, 3, 15, 14, 13, 16)
// .n().uv(2, 3, 3, 13).noCull()
// .s().uv(13, 3, 14, 13).noCull()
// .w().uv(15, 3, 16, 13).noCull()
// .e().uv(0, 3, 1, 13).noCull();
// models.put(res, model);
// variants.add(res);
// res = "item_frame" + '#' + "map";
// model = new ModelBlock("birch_planks")
// .add(1, 1, 15.001f, 15, 15, 16)
// .n("itemframe_background").uv(1, 1, 15, 15).noCull()
// .s("itemframe_background").uv(1, 1, 15, 15).noCull()
// .add(0, 0, 15.001f, 16, 1, 16)
// .d().uv(0, 0, 16, 1).noCull()
// .u().uv(0, 15, 16, 16).noCull()
// .n().uv(0, 15, 16, 16).noCull()
// .s().uv(0, 15, 16, 16).noCull()
// .w().uv(15, 15, 16, 16).noCull()
// .e().uv(0, 15, 1, 16).noCull()
// .add(0, 15, 15.001f, 16, 16, 16)
// .d().uv(0, 0, 16, 1).noCull()
// .u().uv(0, 15, 16, 16).noCull()
// .n().uv(0, 0, 16, 1).noCull()
// .s().uv(0, 0, 16, 1).noCull()
// .w().uv(15, 0, 16, 1).noCull()
// .e().uv(0, 0, 1, 1).noCull()
// .add(0, 1, 15.001f, 1, 15, 16)
// .n().uv(15, 1, 16, 15).noCull()
// .s().uv(0, 1, 1, 15).noCull()
// .w().uv(15, 1, 16, 15).noCull()
// .e().uv(0, 1, 1, 15).noCull()
// .add(15, 1, 15.001f, 16, 15, 16)
// .n().uv(0, 1, 1, 15).noCull()
// .s().uv(15, 1, 16, 15).noCull()
// .w().uv(15, 1, 16, 15).noCull()
// .e().uv(0, 1, 1, 15).noCull();
// models.put(res, model);
// variants.add(res);
// RenderRegistry.registerVariants(variantNames);
for (Item item : ItemRegistry.REGISTRY)
{
// List<Integer> list = variantNames.get(item);
// if(list == null)
// list = Collections.<Integer>singletonList(0);
// for(Integer s : list)
// {
String loc = "item/" + ItemRegistry.getNameFromItem(item);
models.put(loc, (ModelBlock)item.getModel(ModelBlock.PROVIDER, ItemRegistry.getNameFromItem(item)));
itemLocations.add(loc);
@ -183,14 +106,11 @@ public abstract class ModelBakery
}
set.add(modelblock.getPrimary());
// return set;
// set.addAll(getTextureLocations(modelblock));
}
}
set.addAll(LOCATIONS_BUILTIN_TEXTURES);
// final Set<ResourceLocation> set = getVariantsTextureLocations();
for (String resourcelocation : itemLocations) // .values())
set.addAll(BUILTINS);
for (String resourcelocation : itemLocations)
{
ModelBlock modelblock = (ModelBlock)models.get(resourcelocation);
@ -217,21 +137,9 @@ public abstract class ModelBakery
}
}
}
// set.addAll(getItemsTextureLocations());
set.remove(TextureMap.LOCATION_MISSING_TEXTURE);
IIconCreator iiconcreator = new IIconCreator()
{
public void registerSprites(TextureMap iconRegistry)
{
for (String resourcelocation : set)
{
TextureAtlasSprite textureatlassprite = iconRegistry.registerSprite(resourcelocation);
sprites.put(resourcelocation, textureatlassprite);
}
}
};
textureMap.loadSprites(iiconcreator);
sprites.put(TextureMap.LOCATION_MISSING_TEXTURE, textureMap.getMissingSprite());
set.remove(TextureMap.MISSING);
textureMap.loadSprites(set, sprites);
sprites.put(TextureMap.MISSING, textureMap.getMissingSprite());
for (String resourcelocation : itemLocations) // .values())
{
@ -271,28 +179,25 @@ public abstract class ModelBakery
}
}
// for (Entry<String, ResourceLocation> entry : itemLocations.entrySet())
for (String entry : itemLocations)
{
// ResourceLocation resourcelocation = (ResourceLocation)entry.getValue();
// ResourceLocation inventory = new ResourceLocation((String)entry.getKey(), "inventory");
ModelBlock modelblock1 = (ModelBlock)models.get(entry) ; // resourcelocation);
ModelBlock modelblock1 = (ModelBlock)models.get(entry);
if (modelblock1 != null)
{
if (modelblock1.getParent() == MODEL_ENTITY)
{
bakedRegistry.putObject(entry /* inventory */, new BuiltInModel(modelblock1.getTransform()));
bakedRegistry.putObject(entry, new BuiltInModel(modelblock1.getTransform()));
}
else
{
bakedRegistry.putObject(entry /* inventory */, bakeModel(sprites, faceBakery, textureMap.getMissingSprite(),
bakedRegistry.putObject(entry, bakeModel(sprites, faceBakery, textureMap.getMissingSprite(),
modelblock1, ModelRotation.X0_Y0, false));
}
}
else
{
throw new RuntimeException("Fehlendes Modell für: " + entry); // resourcelocation);
throw new RuntimeException("Fehlendes Modell für: " + entry);
}
}

View file

@ -75,7 +75,7 @@ public class ModelBlock extends Model {
}
public ModelBlock face(String texture, Facing ... faces) {
texture = !texture.equals(TextureMap.LOCATION_MISSING_TEXTURE) && texture.indexOf('/') == -1 ? "blocks/" + texture : texture;
texture = !texture.equals(TextureMap.MISSING) && texture.indexOf('/') == -1 ? "blocks/" + texture : texture;
this.last = new BlockPartFace[faces.length];
for(int z = 0; z < faces.length; z++) {
this.lastPart.mapFaces.put(faces[z], this.last[z] =
@ -146,7 +146,7 @@ public class ModelBlock extends Model {
}
this.elements = parent == null ? elements : parent.getElements();
this.gui3d = gui3d;
this.primary = primary == null ? TextureMap.LOCATION_MISSING_TEXTURE : primary;
this.primary = primary == null ? TextureMap.MISSING : primary;
this.parent = parent;
this.transform = transform;
this.uvLock = false;
@ -171,7 +171,7 @@ public class ModelBlock extends Model {
}
public String getTexture(int layer) {
return this.layers == null || this.layers[layer] == null ? TextureMap.LOCATION_MISSING_TEXTURE : this.layers[layer];
return this.layers == null || this.layers[layer] == null ? TextureMap.MISSING : this.layers[layer];
}
public ModelBlock getParent() {

View file

@ -15,8 +15,6 @@ import common.util.Facing;
import common.util.Vector3f;
public abstract class ModelGenerator {
// public static final List<String> LAYERS = Lists.newArrayList("layer0", "layer1", "layer2", "layer3", "layer4");
public static List<ModelBox> bakeModel(String textureLocation, int tx, int ty, int tw, int th, float x, float y, float z, int w, int h, int d)
{
int[] img;
@ -237,17 +235,6 @@ public abstract class ModelGenerator {
List<Span> spans = Lists.<Span>newArrayList();
for(int f = 0; f < sprite.getFrameCount(); ++f) {
compileSpans(spans, sprite.getFrameTextureData(f), 0, 0, w, h, w, h);
// int[] data = sprite.getFrameTextureData(f)[0];
// for(int y = 0; y < h; ++y) {
// for(int x = 0; x < w; ++x) {
// if(!isTransparent(data, x, y, w, h)) {
// checkAdd(SpanFacing.UP, spans, data, x, y, w, h);
// checkAdd(SpanFacing.DOWN, spans, data, x, y, w, h);
// checkAdd(SpanFacing.LEFT, spans, data, x, y, w, h);
// checkAdd(SpanFacing.RIGHT, spans, data, x, y, w, h);
// }
// }
// }
}
return spans;
}

View file

@ -90,21 +90,6 @@ public class ModelManager
return this.texMap.getAtlasSprite("blocks/obsidian");
}
if (block == Blocks.flowing_lava || block == Blocks.lava)
{
return this.texMap.getAtlasSprite("blocks/lava_still");
}
if (block == Blocks.flowing_water || block == Blocks.water)
{
return this.texMap.getAtlasSprite("blocks/water_still");
}
// if (block == Blocks.barrier)
// {
// return this.modelManager.getTextureMap().getAtlasSprite("items/barrier");
// }
if (block.getMaterial().isLiquid())
{
String texture = this.liquidMap.get(block);
@ -151,8 +136,7 @@ public class ModelManager
StateMap mapper = this.mappers.get(block);
if(mapper == null)
mapper = new SingleStateMap();
map.putAll( // (Objects.firstNonNull(, ))
mapper.putStateModelLocations(block));
map.putAll(mapper.putStateModelLocations(block));
}
}
return map;

View file

@ -121,7 +121,7 @@ public abstract class Render<T extends Entity>
while (f3 > 0.0F)
{
TextureAtlasSprite textureatlassprite2 = i % 2 == 0 ? textureatlassprite : textureatlassprite1;
this.bindTexture(TextureMap.locationBlocksTexture);
this.bindTexture(TextureMap.BLOCKS);
float f6 = textureatlassprite2.getMinU();
float f7 = textureatlassprite2.getMinV();
float f8 = textureatlassprite2.getMaxU();

View file

@ -75,6 +75,6 @@ public class RenderBlockEntity extends Render<Entity>
*/
protected String getEntityTexture(Entity entity)
{
return TextureMap.locationBlocksTexture;
return TextureMap.BLOCKS;
}
}

View file

@ -20,7 +20,7 @@ public class RenderDie extends Render<EntityDie>
protected String getEntityTexture(EntityDie entity)
{
return TextureMap.locationBlocksTexture;
return TextureMap.BLOCKS;
}
public void doRender(EntityDie entity, double x, double y, double z, float partialTicks)

View file

@ -159,7 +159,7 @@ public class RenderEntityItem extends Render<EntityItem>
*/
protected String getEntityTexture(EntityItem entity)
{
return TextureMap.locationBlocksTexture;
return TextureMap.BLOCKS;
}
// protected boolean canRenderName(EntityItem entity)

View file

@ -31,7 +31,7 @@ public class RenderFallingBlock extends Render<EntityFalling>
{
if (entity.getBlock() != null)
{
this.bindTexture(TextureMap.locationBlocksTexture);
this.bindTexture(TextureMap.BLOCKS);
State iblockstate = entity.getBlock();
Block block = iblockstate.getBlock();
BlockPos blockpos = new BlockPos(entity);
@ -69,6 +69,6 @@ public class RenderFallingBlock extends Render<EntityFalling>
*/
protected String getEntityTexture(EntityFalling entity)
{
return TextureMap.locationBlocksTexture;
return TextureMap.BLOCKS;
}
}

View file

@ -61,6 +61,6 @@ public class RenderFireball extends Render<EntityProjectile>
*/
protected String getEntityTexture(EntityProjectile entity)
{
return TextureMap.locationBlocksTexture;
return TextureMap.BLOCKS;
}
}

View file

@ -28,34 +28,20 @@ public class RenderItem
{
private static final String RES_ITEM_GLINT = "textures/glint.png";
/** False when the renderer is rendering the item's effects into a GUI */
// private boolean notRenderingEffectsInGUI = true;
private final ItemModelMesher mesher;
private final TextureManager manager;
/** Defines the zLevel of rendering of item on GUI. */
public float zLevel;
private final ItemModelMesher itemModelMesher;
private final TextureManager textureManager;
public RenderItem(TextureManager textureManager, ModelManager modelManager)
{
this.textureManager = textureManager;
this.itemModelMesher = new ItemModelMesher(modelManager);
// RenderRegistry.registerItems(this.itemModelMesher);
this.manager = textureManager;
this.mesher = new ItemModelMesher(modelManager);
}
/**
* False when the renderer is rendering the item's effects into a GUI
*
* @param isNot If the renderer is not rendering the effects in a GUI
*/
// public void isNotRenderingEffectsInGUI(boolean isNot)
// {
// this.notRenderingEffectsInGUI = isNot;
// }
public ItemModelMesher getItemModelMesher()
{
return this.itemModelMesher;
return this.mesher;
}
private void renderModel(IBakedModel model, ItemStack stack)
@ -70,7 +56,6 @@ public class RenderItem
private void renderModel(IBakedModel model, int color, ItemStack stack)
{
// Tessellator tessellator = Tessellator.getInstance();
RenderBuffer worldrenderer = Tessellator.getBuffer();
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
@ -119,7 +104,7 @@ public class RenderItem
GlState.depthFunc(GL11.GL_EQUAL);
GlState.disableLighting();
GlState.blendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE);
this.textureManager.bindTexture(RES_ITEM_GLINT);
this.manager.bindTexture(RES_ITEM_GLINT);
GL11.glMatrixMode(GL11.GL_TEXTURE);
GL11.glPushMatrix();
GL11.glScalef(8.0F, 8.0F, 8.0F);
@ -140,7 +125,7 @@ public class RenderItem
GlState.enableLighting();
GlState.depthFunc(GL11.GL_LEQUAL);
GlState.depthMask(true);
this.textureManager.bindTexture(TextureMap.locationBlocksTexture);
this.manager.bindTexture(TextureMap.BLOCKS);
}
private void putQuadNormal(RenderBuffer renderer, BakedQuad quad)
@ -169,12 +154,6 @@ public class RenderItem
if (flag && bakedquad.hasTintIndex())
{
k = stack.getItem().getColorFromItemStack(stack, bakedquad.getTintIndex());
// if (EntityRenderer.anaglyphEnable)
// {
// k = TextureUtil.anaglyphColor(k);
// }
k = k | -16777216;
}
@ -184,13 +163,13 @@ public class RenderItem
public boolean shouldRenderItemIn3D(ItemStack stack)
{
IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(stack);
IBakedModel ibakedmodel = this.mesher.getItemModel(stack);
return ibakedmodel == null ? false : ibakedmodel.isGui3d();
}
private void preTransform(ItemStack stack)
{
IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(stack);
IBakedModel ibakedmodel = this.mesher.getItemModel(stack);
Item item = stack.getItem();
if (item != null)
@ -210,7 +189,7 @@ public class RenderItem
{
if (stack != null)
{
IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(stack);
IBakedModel ibakedmodel = this.mesher.getItemModel(stack);
this.renderItemModelTransform(stack, ibakedmodel, cameraTransformType);
}
}
@ -219,7 +198,7 @@ public class RenderItem
{
if (stack != null && entityToRenderFor != null)
{
IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(stack);
IBakedModel ibakedmodel = this.mesher.getItemModel(stack);
if (entityToRenderFor.isPlayer())
{
@ -227,7 +206,7 @@ public class RenderItem
Item item = stack.getItem();
String sprite = item == null ? null : item.getSprite(entityplayer, stack);
if(sprite != null)
ibakedmodel = this.itemModelMesher.getModelManager().getModel("item/" + sprite);
ibakedmodel = this.mesher.getModelManager().getModel("item/" + sprite);
}
this.renderItemModelTransform(stack, ibakedmodel, cameraTransformType);
@ -236,8 +215,7 @@ public class RenderItem
protected void renderItemModelTransform(ItemStack stack, IBakedModel model, Transforms.Camera cameraTransformType)
{
this.textureManager.bindTexture(TextureMap.locationBlocksTexture);
// this.textureManager.getTexture(TextureMap.locationBlocksTexture).unsetMipmap();
this.manager.bindTexture(TextureMap.BLOCKS);
this.preTransform(stack);
GlState.enableRescaleNormal();
GlState.alphaFunc(GL11.GL_GREATER, 0.1F);
@ -252,16 +230,14 @@ public class RenderItem
GL11.glPopMatrix();
GlState.disableRescaleNormal();
GlState.disableBlend();
this.textureManager.bindTexture(TextureMap.locationBlocksTexture);
// this.textureManager.getTexture(TextureMap.locationBlocksTexture).restoreLastMipmap();
this.manager.bindTexture(TextureMap.BLOCKS);
}
private void renderItemIntoGUI(ItemStack stack, int x, int y)
{
IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(stack);
IBakedModel ibakedmodel = this.mesher.getItemModel(stack);
GL11.glPushMatrix();
this.textureManager.bindTexture(TextureMap.locationBlocksTexture);
// this.textureManager.getTexture(TextureMap.locationBlocksTexture).unsetMipmap();
this.manager.bindTexture(TextureMap.BLOCKS);
GlState.enableRescaleNormal();
GlState.enableAlpha();
GlState.alphaFunc(GL11.GL_GREATER, 0.1F);
@ -275,8 +251,7 @@ public class RenderItem
GlState.disableRescaleNormal();
GlState.disableLighting();
GL11.glPopMatrix();
this.textureManager.bindTexture(TextureMap.locationBlocksTexture);
// this.textureManager.getTexture(TextureMap.locationBlocksTexture).restoreLastMipmap();
this.manager.bindTexture(TextureMap.BLOCKS);
}
private void setupGuiTransform(int xPosition, int yPosition, boolean isGui3d)
@ -315,7 +290,7 @@ public class RenderItem
public void onReload()
{
this.itemModelMesher.rebuildCache();
this.mesher.rebuildCache();
}
public static void apply(Transforms trans, Transforms.Camera type) {

View file

@ -30,7 +30,7 @@ public class RenderItemEntity<T extends Entity> extends Render<T>
GL11.glScalef(0.5F, 0.5F, 0.5F);
GL11.glRotatef(-this.renderManager.playerViewY, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(this.renderManager.playerViewX, 1.0F, 0.0F, 0.0F);
this.bindTexture(TextureMap.locationBlocksTexture);
this.bindTexture(TextureMap.BLOCKS);
this.itemRenderer.renderItem(this.getStack(entity), Transforms.Camera.GROUND);
GlState.disableRescaleNormal();
GL11.glPopMatrix();
@ -44,6 +44,6 @@ public class RenderItemEntity<T extends Entity> extends Render<T>
protected String getEntityTexture(Entity entity)
{
return TextureMap.locationBlocksTexture;
return TextureMap.BLOCKS;
}
}

View file

@ -96,7 +96,7 @@ public class RenderMinecart<T extends EntityCart> extends Render<T>
if (iblockstate.getBlock().getRenderType() != -1)
{
GL11.glPushMatrix();
this.bindTexture(TextureMap.locationBlocksTexture);
this.bindTexture(TextureMap.BLOCKS);
float f4 = 0.75F;
GL11.glScalef(f4, f4, f4);
GL11.glTranslatef(-0.5F, (float)(j - 8) / 16.0F, 0.5F);

View file

@ -66,6 +66,6 @@ public class RenderTntPrimed extends Render<EntityTnt>
protected String getEntityTexture(EntityTnt entity)
{
return TextureMap.locationBlocksTexture;
return TextureMap.BLOCKS;
}
}

View file

@ -560,13 +560,13 @@ public abstract class RendererLivingEntity<T extends EntityLiving> extends Rende
static
{
int[] aint = textureBrightness.getTextureData();
int[] aint = textureBrightness.getData();
for (int i = 0; i < 256; ++i)
{
aint[i] = -1;
}
textureBrightness.updateDynamicTexture();
textureBrightness.updateTexture();
}
}

View file

@ -25,7 +25,7 @@ public class LayerMooshroomMushroom implements LayerRenderer<EntityMooshroom>
if (!entitylivingbaseIn.isChild()) // && !entitylivingbaseIn.isInvisible())
{
BlockRenderer blockrendererdispatcher = Client.CLIENT.getBlockRendererDispatcher();
this.mooshroomRenderer.bindTexture(TextureMap.locationBlocksTexture);
this.mooshroomRenderer.bindTexture(TextureMap.BLOCKS);
GlState.enableCull();
GlState.cullFace(GL11.GL_FRONT);
GL11.glPushMatrix();

View file

@ -5,7 +5,7 @@ import java.util.Map;
import org.lwjgl.opengl.GL11;
import client.renderer.ActiveRenderInfo;
import client.renderer.MatrixState;
import client.renderer.DefaultVertexFormats;
import client.renderer.GlState;
import client.renderer.RenderBuffer;
@ -212,11 +212,11 @@ public class EffectRenderer
*/
public void renderParticles(Entity entityIn, float partialTicks)
{
float f = ActiveRenderInfo.getRotationX();
float f1 = ActiveRenderInfo.getRotationZ();
float f2 = ActiveRenderInfo.getRotationYZ();
float f3 = ActiveRenderInfo.getRotationXY();
float f4 = ActiveRenderInfo.getRotationXZ();
float f = MatrixState.getRotationX();
float f1 = MatrixState.getRotationZ();
float f2 = MatrixState.getRotationYZ();
float f3 = MatrixState.getRotationXY();
float f4 = MatrixState.getRotationXZ();
EntityFX.interpPosX = entityIn.lastTickPosX + (entityIn.posX - entityIn.lastTickPosX) * (double)partialTicks;
EntityFX.interpPosY = entityIn.lastTickPosY + (entityIn.posY - entityIn.lastTickPosY) * (double)partialTicks;
EntityFX.interpPosZ = entityIn.lastTickPosZ + (entityIn.posZ - entityIn.lastTickPosZ) * (double)partialTicks;
@ -250,7 +250,7 @@ public class EffectRenderer
break;
case 1:
this.renderer.bindTexture(TextureMap.locationBlocksTexture);
this.renderer.bindTexture(TextureMap.BLOCKS);
}
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);

View file

@ -5,51 +5,41 @@ import java.io.IOException;
import client.renderer.GlState;
public class DynamicTexture extends Texture
{
private final int[] dynamicTextureData;
public class DynamicTexture extends Texture {
private final int[] data;
private final int width;
private final int height;
/** width of this icon in pixels */
private final int width;
public DynamicTexture(BufferedImage image) {
this(image.getWidth(), image.getHeight());
image.getRGB(0, 0, image.getWidth(), image.getHeight(), this.data, 0, image.getWidth());
this.updateTexture();
}
/** height of this icon in pixels */
private final int height;
public DynamicTexture(int width, int height) {
this.width = width;
this.height = height;
this.data = new int[width * height];
TextureUtil.allocateTexture(this.getGlTextureId(), width, height);
}
public DynamicTexture(BufferedImage bufferedImage)
{
this(bufferedImage.getWidth(), bufferedImage.getHeight());
bufferedImage.getRGB(0, 0, bufferedImage.getWidth(), bufferedImage.getHeight(), this.dynamicTextureData, 0, bufferedImage.getWidth());
this.updateDynamicTexture();
}
public void loadTexture() throws IOException {
}
public DynamicTexture(int textureWidth, int textureHeight)
{
this.width = textureWidth;
this.height = textureHeight;
this.dynamicTextureData = new int[textureWidth * textureHeight];
TextureUtil.allocateTexture(this.getGlTextureId(), textureWidth, textureHeight);
}
public void updateTexture() {
GlState.bindTexture(this.getGlTextureId());
TextureUtil.uploadTexture(this.data, this.width, this.height, 0, 0);
}
public void loadTexture() throws IOException
{
}
public int[] getData() {
return this.data;
}
public void updateDynamicTexture()
{
GlState.bindTexture(this.getGlTextureId());
TextureUtil.uploadTexture(this.dynamicTextureData, this.width, this.height, 0, 0);
}
public int getWidth() {
return this.width;
}
public int[] getTextureData()
{
return this.dynamicTextureData;
}
public int getWidth() {
return this.width;
}
public int getHeight() {
return this.height;
}
public int getHeight() {
return this.height;
}
}

View file

@ -73,10 +73,10 @@ public abstract class EntityTexManager
manager.loadTexture(loc, dyntex);
}
else {
image.getRGB(0, 0, image.getWidth(), image.getHeight(), dyntex.getTextureData(), 0, image.getWidth());
image.getRGB(0, 0, image.getWidth(), image.getHeight(), dyntex.getData(), 0, image.getWidth());
}
dyntex.updateDynamicTexture();
LayerExtra extra = LayerExtra.getLayer(dyntex.getTextureData(), dyntex.getWidth(), dyntex.getHeight(), entry.getValue());
dyntex.updateTexture();
LayerExtra extra = LayerExtra.getLayer(dyntex.getData(), dyntex.getWidth(), dyntex.getHeight(), entry.getValue());
if(EntityNPC.getSkinTexture(skin).equals(getDefault(entry.getValue()))) {
DEF_LAYERS.put(entry.getValue(), extra);
}
@ -116,9 +116,9 @@ public abstract class EntityTexManager
manager.loadTexture(loc, dyntex);
}
else {
image.getRGB(0, 0, image.getWidth(), image.getHeight(), dyntex.getTextureData(), 0, image.getWidth());
image.getRGB(0, 0, image.getWidth(), image.getHeight(), dyntex.getData(), 0, image.getWidth());
}
dyntex.updateDynamicTexture();
dyntex.updateTexture();
// setCape(cape, image);
}
// for(ModelType model : ModelType.values()) {
@ -203,10 +203,10 @@ public abstract class EntityTexManager
dyntex = new DynamicTexture(model.texWidth, model.texHeight);
manager.loadTexture(loc, dyntex);
}
EntityTexManager.compToImage(comp, dyntex.getTextureData(), model);
dyntex.updateDynamicTexture();
EntityTexManager.compToImage(comp, dyntex.getData(), model);
dyntex.updateTexture();
USER_TEXTURES.add(id);
LayerExtra extra = LayerExtra.getLayer(dyntex.getTextureData(), dyntex.getWidth(), dyntex.getHeight(), model);
LayerExtra extra = LayerExtra.getLayer(dyntex.getData(), dyntex.getWidth(), dyntex.getHeight(), model);
if(extra != null) {
extra = USER_LAYERS.put(id, extra);
}

View file

@ -1,6 +0,0 @@
package client.renderer.texture;
public interface IIconCreator
{
void registerSprites(TextureMap iconRegistry);
}

View file

@ -13,10 +13,9 @@ import common.log.Log;
public class LayeredColorMaskTexture extends Texture
{
/** The location of the texture. */
private final String textureLocation;
private final List<String> field_174949_h;
private final List<DyeColor> field_174950_i;
private final String texture;
private final List<String> layers;
private final List<DyeColor> colors;
private static int applyTint(int color, int tint) {
int i = (color & 16711680) >> 16;
@ -31,11 +30,11 @@ public class LayeredColorMaskTexture extends Texture
return color & -16777216 | k1 << 16 | l1 << 8 | i2;
}
public LayeredColorMaskTexture(String textureLocationIn, List<String> p_i46101_2_, List<DyeColor> p_i46101_3_)
public LayeredColorMaskTexture(String texture, List<String> layers, List<DyeColor> colors)
{
this.textureLocation = textureLocationIn;
this.field_174949_h = p_i46101_2_;
this.field_174950_i = p_i46101_3_;
this.texture = texture;
this.layers = layers;
this.colors = colors;
}
public void loadTexture() throws IOException
@ -45,7 +44,7 @@ public class LayeredColorMaskTexture extends Texture
try
{
BufferedImage bufferedimage1 = TextureUtil.readImage(FileUtils.getResource(this.textureLocation));
BufferedImage bufferedimage1 = TextureUtil.readImage(FileUtils.getResource(this.texture));
int i = bufferedimage1.getType();
if (i == 0)
@ -57,10 +56,10 @@ public class LayeredColorMaskTexture extends Texture
Graphics graphics = bufferedimage.getGraphics();
graphics.drawImage(bufferedimage1, 0, 0, (ImageObserver)null);
for (int j = 0; j < 17 && j < this.field_174949_h.size() && j < this.field_174950_i.size(); ++j)
for (int j = 0; j < 17 && j < this.layers.size() && j < this.colors.size(); ++j)
{
String s = (String)this.field_174949_h.get(j);
int color = this.field_174950_i.get(j).getColor();
String s = this.layers.get(j);
int color = this.colors.get(j).getColor();
if (s != null)
{

View file

@ -12,11 +12,11 @@ import common.log.Log;
public class LayeredTexture extends Texture
{
public final List<String> layeredTextureNames;
public final List<String> layers;
public LayeredTexture(String[] textureNames)
public LayeredTexture(String[] layers)
{
this.layeredTextureNames = Lists.newArrayList(textureNames);
this.layers = Lists.newArrayList(layers);
}
public void loadTexture() throws IOException
@ -26,7 +26,7 @@ public class LayeredTexture extends Texture
try
{
for (String s : this.layeredTextureNames)
for (String s : this.layers)
{
if (s != null)
{

View file

@ -7,20 +7,17 @@ import java.io.InputStream;
import client.util.FileUtils;
public class SimpleTexture extends Texture {
private final String location;
private final String texture;
public SimpleTexture(String location) {
this.location = location;
public SimpleTexture(String texture) {
this.texture = texture;
}
public void loadTexture() throws IOException {
this.deleteGlTexture();
InputStream in = null;
try {
in = // this.location.startsWith("/") ? SimpleTexture.class.getResourceAsStream(this.location) :
FileUtils.getResource(this.location);
// if(in == null)
// throw new FileNotFoundException(this.location);
in = FileUtils.getResource(this.texture);
BufferedImage img = TextureUtil.readImage(in);
TextureUtil.uploadImage(this.getGlTextureId(), img);
}

View file

@ -10,28 +10,12 @@ import common.collect.Sets;
public class Stitcher
{
// private static final int MAX_SIZE;
private final Set<Stitcher.Holder> setStitchHolders = Sets.<Stitcher.Holder>newHashSetWithExpectedSize(256);
private final List<Stitcher.Slot> stitchSlots = new ArrayList<Slot>(256);
private final Set<Stitcher.Holder> holders = Sets.<Stitcher.Holder>newHashSetWithExpectedSize(256);
private final List<Stitcher.Slot> slots = new ArrayList<Slot>(256);
private int currentWidth;
private int currentHeight;
// private static int getMaximumTextureSize() {
// for(int i = 16384; i > 0; i >>= 1) {
// SKC.glTexImage2D(SKC.GL_PROXY_TEXTURE_2D, 0, SKC.GL_RGBA, i, i, 0, SKC.GL_RGBA, SKC.GL_UNSIGNED_BYTE,
// (ByteBuffer)((ByteBuffer)null));
// int j = SKC.glGetTexLevelParameteri(SKC.GL_PROXY_TEXTURE_2D, 0, SKC.GL_TEXTURE_WIDTH);
//
// if(j != 0) {
// return i;
// }
// }
//
// return -1;
// }
private static int roundUpToPowerOfTwo(int value) {
int i = value - 1;
i = i | i >> 1;
@ -42,10 +26,6 @@ public class Stitcher
return i + 1;
}
// static {
// MAX_SIZE = getMaximumTextureSize();
// }
public int getCurrentWidth()
{
return this.currentWidth;
@ -59,41 +39,28 @@ public class Stitcher
public void addSprite(TextureAtlasSprite p_110934_1_)
{
Stitcher.Holder stitcher$holder = new Stitcher.Holder(p_110934_1_);
// if (this.maxTileDimension > 0)
// {
// stitcher$holder.setNewDimension(this.maxTileDimension);
// }
this.setStitchHolders.add(stitcher$holder);
this.holders.add(stitcher$holder);
}
public void doStitch()
{
Stitcher.Holder[] astitcher$holder = (Stitcher.Holder[])this.setStitchHolders.toArray(new Stitcher.Holder[this.setStitchHolders.size()]);
Stitcher.Holder[] astitcher$holder = (Stitcher.Holder[])this.holders.toArray(new Stitcher.Holder[this.holders.size()]);
Arrays.sort((Object[])astitcher$holder);
for (Stitcher.Holder stitcher$holder : astitcher$holder)
{
this.allocateSlot(stitcher$holder);
// {
// String s = String.format("Unable to fit: %s - size: %dx%d - Maybe try a lowerresolution resourcepack?", stitcher$holder.getAtlasSprite().getIconName(), Integer.valueOf(stitcher$holder.getAtlasSprite().getIconWidth()), Integer.valueOf(stitcher$holder.getAtlasSprite().getIconHeight()));
// throw new IndexOutOfBoundsException(s);
// }
}
// if (this.forcePowerOf2)
// {
this.currentWidth = roundUpToPowerOfTwo(this.currentWidth);
this.currentHeight = roundUpToPowerOfTwo(this.currentHeight);
// }
}
public List<TextureAtlasSprite> getStichSlots()
{
List<Stitcher.Slot> list = Lists.<Stitcher.Slot>newArrayList();
for (Stitcher.Slot stitcher$slot : this.stitchSlots)
for (Stitcher.Slot stitcher$slot : this.slots)
{
stitcher$slot.getAllStitchSlots(list);
}
@ -111,21 +78,18 @@ public class Stitcher
return list1;
}
/**
* Attempts to find space for specified tile
*/
private void allocateSlot(Stitcher.Holder p_94310_1_)
{
for (int i = 0; i < this.stitchSlots.size(); ++i)
for (int i = 0; i < this.slots.size(); ++i)
{
if (((Stitcher.Slot)this.stitchSlots.get(i)).addSlot(p_94310_1_))
if (((Stitcher.Slot)this.slots.get(i)).addSlot(p_94310_1_))
{
return;
}
p_94310_1_.rotate();
if (((Stitcher.Slot)this.stitchSlots.get(i)).addSlot(p_94310_1_))
if (((Stitcher.Slot)this.slots.get(i)).addSlot(p_94310_1_))
{
return;
}
@ -136,28 +100,16 @@ public class Stitcher
this.expandAndAllocateSlot(p_94310_1_);
}
/**
* Expand stitched texture in order to make space for specified tile
*/
private void expandAndAllocateSlot(Stitcher.Holder p_94311_1_)
{
int i = Math.min(p_94311_1_.getWidth(), p_94311_1_.getHeight());
boolean flag = this.currentWidth == 0 && this.currentHeight == 0;
boolean flag1;
// if (this.forcePowerOf2)
// {
int j = roundUpToPowerOfTwo(this.currentWidth);
int k = roundUpToPowerOfTwo(this.currentHeight);
int l = roundUpToPowerOfTwo(this.currentWidth + i);
int i1 = roundUpToPowerOfTwo(this.currentHeight + i);
// boolean flag2 = l <= MAX_SIZE;
// boolean flag3 = i1 <= MAX_SIZE;
//
// if (!flag2 && !flag3)
// {
// return false;
// }
boolean flag4 = j != l;
boolean flag5 = k != i1;
@ -168,30 +120,8 @@ public class Stitcher
}
else
{
flag1 = /* flag2 && */ j <= k;
flag1 = j <= k;
}
// }
// else
// {
// boolean flag6 = this.currentWidth + i <= this.maxWidth;
// boolean flag7 = this.currentHeight + i <= this.maxHeight;
//
// if (!flag6 && !flag7)
// {
// return false;
// }
//
// flag1 = flag6 && (flag || this.currentWidth <= this.currentHeight);
// }
// int j1 = Math.max(p_94311_1_.getWidth(), p_94311_1_.getHeight());
//
// if (Stitcher.roundUpToPowerOfTwo((flag1 ? this.currentHeight : this.currentWidth) + j1) > MAX_SIZE)
// {
// return false;
// }
// else
// {
Stitcher.Slot stitcher$slot;
if (flag1)
@ -216,9 +146,7 @@ public class Stitcher
}
stitcher$slot.addSlot(p_94311_1_);
this.stitchSlots.add(stitcher$slot);
// return true;
// }
this.slots.add(stitcher$slot);
}
public static class Holder implements Comparable<Stitcher.Holder>
@ -270,11 +198,6 @@ public class Stitcher
}
}
public String toString()
{
return "Holder{width=" + this.width + ", height=" + this.height + '}';
}
public int compareTo(Stitcher.Holder p_compareTo_1_)
{
int i;
@ -419,10 +342,5 @@ public class Stitcher
}
}
}
public String toString()
{
return "Slot{originX=" + this.originX + ", originY=" + this.originY + ", width=" + this.width + ", height=" + this.height + ", texture=" + this.holder + ", subSlots=" + this.subSlots + '}';
}
}
}

View file

@ -6,28 +6,21 @@ import org.lwjgl.opengl.GL11;
import client.renderer.GlState;
public abstract class Texture
{
protected int glTextureId = -1;
public abstract class Texture {
private int id = -1;
public final int getGlTextureId()
{
if (this.glTextureId == -1)
{
this.glTextureId = GL11.glGenTextures();
}
public final int getGlTextureId() {
if(this.id == -1)
this.id = GL11.glGenTextures();
return this.id;
}
return this.glTextureId;
}
public final void deleteGlTexture() {
if(this.id != -1) {
GlState.deleteTexture(this.id);
this.id = -1;
}
}
public final void deleteGlTexture()
{
if (this.glTextureId != -1)
{
GlState.deleteTexture(this.glTextureId);
this.glTextureId = -1;
}
}
public abstract void loadTexture() throws IOException;
public abstract void loadTexture() throws IOException;
}

View file

@ -56,82 +56,52 @@ public class TextureAtlasSprite
this.maxV = atlasSpirit.maxV;
}
/**
* Returns the X position of this icon on its texture sheet, in pixels.
*/
public int getOriginX()
{
return this.originX;
}
/**
* Returns the Y position of this icon on its texture sheet, in pixels.
*/
public int getOriginY()
{
return this.originY;
}
/**
* Returns the width of the icon, in pixels.
*/
public int getIconWidth()
{
return this.width;
}
/**
* Returns the height of the icon, in pixels.
*/
public int getIconHeight()
{
return this.height;
}
/**
* Returns the minimum U coordinate to use when rendering with this icon.
*/
public float getMinU()
{
return this.minU;
}
/**
* Returns the maximum U coordinate to use when rendering with this icon.
*/
public float getMaxU()
{
return this.maxU;
}
/**
* Gets a U coordinate on the icon. 0 returns uMin and 16 returns uMax. Other arguments return in-between values.
*/
public float getInterpolatedU(double u)
{
float f = this.maxU - this.minU;
return this.minU + f * (float)u / 16.0F;
}
/**
* Returns the minimum V coordinate to use when rendering with this icon.
*/
public float getMinV()
{
return this.minV;
}
/**
* Returns the maximum V coordinate to use when rendering with this icon.
*/
public float getMaxV()
{
return this.maxV;
}
/**
* Gets a V coordinate on the icon. 0 returns vMin and 16 returns vMax. Other arguments return in-between values.
*/
public float getInterpolatedV(double v)
{
float f = this.maxV - this.minV;
@ -150,7 +120,6 @@ public class TextureAtlasSprite
if(this.tickedTexture != null) {
int[] data = this.framesTextureData.get(0);
this.tickedTexture.renderStep(data);
// this.framesTextureData.set(0, data = TextureUtil.generateMipmapData(this.mipmapLevels, this.width, data, true));
TextureUtil.uploadTexture(data, this.width, this.height, this.originX, this.originY);
return;
}
@ -197,24 +166,8 @@ public class TextureAtlasSprite
int j = image.getHeight();
this.width = i;
this.height = j;
int[] aint = // new int[images.length][];
// for (int k = 0; k < images.length; ++k)
// {
// BufferedImage bufferedimage = images[k];
//
// if (image != null)
// {
// if (k > 0 && (bufferedimage.getWidth() != i >> k || bufferedimage.getHeight() != j >> k))
// {
// throw new RuntimeException(String.format("Unable to load miplevel: %d, image is size: %dx%d, expected %dx%d", k, bufferedimage.getWidth(), bufferedimage.getHeight(), i >> k, j >> k));
// }
// aint[k] =
new int[i * j];
int[] aint = new int[i * j];
image.getRGB(0, 0, i, j, aint, 0, i);
// }
// }
if (frametime == 0)
{
@ -232,41 +185,15 @@ public class TextureAtlasSprite
int l = i;
this.height = this.width;
for (int l1 = 0; l1 < frames; ++l1)
{
int[] aint2 = new int[k1 * l];
System.arraycopy(aint, l1 * aint2.length, aint2, 0, aint2.length);
this.framesTextureData.add(aint2);
}
// if (meta.getFrameCount() > 0)
// {
// Iterator iterator = meta.getFrameIndexSet().iterator();
//
// while (iterator.hasNext())
// {
// int i1 = ((Integer)iterator.next()).intValue();
//
// if (i1 >= j1)
// {
// throw new RuntimeException("invalid frameindex " + i1);
// }
//
// this.allocateFrameTextureData(i1);
// this.framesTextureData.set(i1, getFrameTextureData(aint, k1, l, i1));
// }
//
// this.animationMetadata = meta;
// }
// else
// {
// List<AnimationFrame> list = Lists.<AnimationFrame>newArrayList();
//
for (int l1 = 0; l1 < frames; ++l1)
{
int[] aint2 = new int[k1 * l];
System.arraycopy(aint, l1 * aint2.length, aint2, 0, aint2.length);
this.framesTextureData.add(aint2);
// list.add(new AnimationFrame(l1));
}
this.frameCount = frames;
this.frametime = frametime;
// }
this.frameCount = frames;
this.frametime = frametime;
}
}
@ -280,9 +207,7 @@ public class TextureAtlasSprite
throw new RuntimeException(e);
}
this.height = this.width = this.tickedTexture.getSize();
// for (int k = 0; k < aint.length; ++k) {
int[] aint = new int[this.height * this.width];
// }
this.framesTextureData.add(aint);
this.frameCount = 0;
this.frametime = 1;
@ -322,9 +247,4 @@ public class TextureAtlasSprite
this.frameCounter = 0;
this.tickCounter = 0;
}
public String toString()
{
return "TextureAtlasSprite{name=\'" + this.iconName + '\'' + ", frameCount=" + this.framesTextureData.size() + ", rotated=" + this.rotated + ", x=" + this.originX + ", y=" + this.originY + ", height=" + this.height + ", width=" + this.width + ", u0=" + this.minU + ", u1=" + this.maxU + ", v0=" + this.minV + ", v1=" + this.maxV + '}';
}
}

View file

@ -5,6 +5,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import client.init.RenderRegistry;
@ -16,11 +17,12 @@ import common.collect.Maps;
import common.init.BlockRegistry;
import common.init.FluidRegistry;
import common.log.Log;
import common.model.TextureAnimation;
public class TextureMap extends Texture
{
public static final String LOCATION_MISSING_TEXTURE = "missingno";
public static final String locationBlocksTexture = "textures/atlas/blocks.png";
public static final String MISSING = "missingno";
public static final String BLOCKS = "textures/atlas/blocks.png";
private final List<TextureAtlasSprite> listAnimatedSprites;
private final Map<String, TextureAtlasSprite> mapRegisteredSprites;
@ -36,10 +38,9 @@ public class TextureMap extends Texture
this.mapUploadedSprites = Maps.<String, TextureAtlasSprite>newHashMap();
this.tickedTextures = Maps.<String, Class<? extends TextureTicked>>newHashMap();
this.animTextures = Maps.<String, Integer>newHashMap();
this.missingImage = new TextureAtlasSprite(LOCATION_MISSING_TEXTURE);
// RenderRegistry.registerAnimations(this);
this.missingImage = new TextureAtlasSprite(MISSING);
Map<String, Object> map = Maps.newHashMap();
Map<String, Class<? extends TextureTicked>> anim = Maps.newHashMap();
Map<TextureAnimation, Class<? extends TextureTicked>> anim = Maps.newHashMap();
RenderRegistry.registerAnimations(anim);
for(Block block : BlockRegistry.REGISTRY) {
block.getAnimatedTextures(map);
@ -55,9 +56,9 @@ public class TextureMap extends Texture
this.animTextures.put(entry.getKey(), (Integer)entry.getValue());
}
else {
Class<? extends TextureTicked> clazz = anim.get((String)entry.getValue());
Class<? extends TextureTicked> clazz = anim.get((TextureAnimation)entry.getValue());
if(clazz == null)
throw new RuntimeException("Animation '" + (String)entry.getValue() + "' existiert nicht");
throw new RuntimeException("Animation '" + entry.getValue() + "' existiert nicht");
this.tickedTextures.put(entry.getKey(), clazz);
}
}
@ -76,22 +77,25 @@ public class TextureMap extends Texture
{
}
public void loadSprites(IIconCreator creator)
public void loadSprites(Set<String> set, Map<String, TextureAtlasSprite> sprites)
{
this.mapRegisteredSprites.clear();
creator.registerSprites(this);
for (String loc : set)
{
TextureAtlasSprite sprite = this.registerSprite(loc);
sprites.put(loc, sprite);
}
this.initMissingImage();
this.deleteGlTexture();
this.loadTextureAtlas();
}
public void loadTextureAtlas()
private void loadTextureAtlas()
{
Stitcher stitcher = new Stitcher();
this.mapUploadedSprites.clear();
this.listAnimatedSprites.clear();
int j = Integer.MAX_VALUE;
// int k = 1 << this.mipmapLevels;
for (Entry<String, TextureAtlasSprite> entry : this.mapRegisteredSprites.entrySet())
{
@ -106,9 +110,7 @@ public class TextureMap extends Texture
textureatlassprite.loadSprite(animationmetadatasection);
}
else {
BufferedImage abufferedimage = // new BufferedImage[1 + this.mipmapLevels];
// abufferedimage[0] =
TextureUtil.readImage(FileUtils.getResource(name));
BufferedImage abufferedimage = TextureUtil.readImage(FileUtils.getResource(name));
Integer frametime = this.animTextures.get(textureatlassprite.getIconName());
textureatlassprite.loadSprite(abufferedimage, frametime == null ? 0 : frametime.intValue());
}
@ -132,30 +134,9 @@ public class TextureMap extends Texture
j = Math.min(j, Math.min(textureatlassprite.getIconWidth(), textureatlassprite.getIconHeight()));
int l1 = Math.min(Integer.lowestOneBit(textureatlassprite.getIconWidth()), Integer.lowestOneBit(textureatlassprite.getIconHeight()));
// if (l1 < k)
// {
// Log.warn("Textur " + name + " mit Größe " + textureatlassprite.getIconWidth() + "x" + textureatlassprite.getIconHeight() + " begrenzt Mipmap-Level von " + MathHelper.calculateLogBaseTwo(k) + " auf " + MathHelper.calculateLogBaseTwo(l1));
// k = l1;
// }
stitcher.addSprite(textureatlassprite);
}
// int j1 = Math.min(j, k);
// int k1 = MathHelper.calculateLogBaseTwo(j1);
//
// if (k1 < this.mipmapLevels)
// {
// Log.warn(this.basePath + ": setze Mipmap-Level von " + this.mipmapLevels + " auf " + k1 + " herab, wegen der kleinsten Größe mit Potenz von zwei: " + j1);
// this.mipmapLevels = k1;
// }
// for (final TextureAtlasSprite textureatlassprite1 : this.mapRegisteredSprites.values())
// {
// textureatlassprite1.generateMipmaps(this.mipmapLevels);
// }
//
// this.missingImage.generateMipmaps(this.mipmapLevels);
stitcher.addSprite(this.missingImage);
try
@ -203,7 +184,7 @@ public class TextureMap extends Texture
return textureatlassprite;
}
public void updateAnimations()
public void update()
{
GlState.bindTexture(this.getGlTextureId());
@ -213,7 +194,7 @@ public class TextureMap extends Texture
}
}
public TextureAtlasSprite registerSprite(String location)
private TextureAtlasSprite registerSprite(String location)
{
if (location == null)
{
@ -233,11 +214,6 @@ public class TextureMap extends Texture
}
}
// public void tick()
// {
// this.updateAnimations();
// }
public TextureAtlasSprite getMissingSprite()
{
return this.missingImage;

View file

@ -21,7 +21,7 @@ public class TextureUtil
{
private static final IntBuffer BUFFER = ByteBuffer.allocateDirect(4194304 << 2).order(ByteOrder.nativeOrder()).asIntBuffer();
public static final DynamicTexture MISSING = new DynamicTexture(16, 16);
public static final int[] MISSING_DATA = MISSING.getTextureData();
public static final int[] MISSING_DATA = MISSING.getData();
public static void uploadTexture(int[] data, int w, int h, int x, int y)
{
@ -75,12 +75,6 @@ public class TextureUtil
{
// GlState.deleteTexture(id); //TODO: check needed
GlState.bindTexture(id);
// SKC.glTexParameteri(SKC.GL_TEXTURE_2D, SKC.GL_TEXTURE_MAX_LEVEL, 0);
// SKC.glTexParameterf(SKC.GL_TEXTURE_2D, SKC.GL_TEXTURE_MIN_LOD, 0.0F);
// SKC.glTexParameterf(SKC.GL_TEXTURE_2D, SKC.GL_TEXTURE_MAX_LOD, 0.0F);
// SKC.glTexParameterf(SKC.GL_TEXTURE_2D, SKC.GL_TEXTURE_LOD_BIAS, 0.0F);
GL11.nglTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
}
@ -130,6 +124,6 @@ public class TextureUtil
System.arraycopy(l < k ? aint1 : aint, 0, MISSING_DATA, 16 * l + k, k);
}
MISSING.updateDynamicTexture();
MISSING.updateTexture();
}
}

View file

@ -33,7 +33,7 @@ public class TileEntityPistonRenderer extends TileEntitySpecialRenderer<TileEnti
{
// Tessellator tessellator = Tessellator.getInstance();
RenderBuffer worldrenderer = Tessellator.getBuffer();
this.bindTexture(TextureMap.locationBlocksTexture);
this.bindTexture(TextureMap.BLOCKS);
ItemRenderer.disableStandardItemLighting();
GlState.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlState.enableBlend();

View file

@ -12,6 +12,7 @@ import common.model.Model;
import common.model.ModelProvider;
import common.model.ModelRotation;
import common.model.ParticleType;
import common.model.TextureAnimation;
import common.properties.Property;
import common.properties.PropertyBool;
import common.properties.PropertyInteger;
@ -1144,8 +1145,8 @@ public class BlockFire extends Block
}
public void getAnimatedTextures(Map<String, Object> map) {
map.put("blocks/fire_layer_0", "fire1");
map.put("blocks/fire_layer_1", "fire2");
map.put("blocks/fire_layer_0", TextureAnimation.FIRE1);
map.put("blocks/fire_layer_1", TextureAnimation.FIRE2);
}
public boolean canExtinguish() {

View file

@ -4,6 +4,7 @@ import java.util.Map;
import common.model.Model;
import common.model.ModelProvider;
import common.model.TextureAnimation;
import common.util.BlockPos;
import common.world.IWorldAccess;
import common.world.State;
@ -29,7 +30,7 @@ public class BlockTintedFire extends BlockFire {
}
public void getAnimatedTextures(Map<String, Object> map) {
map.put("blocks/flame_layer_0", "flame1");
map.put("blocks/flame_layer_1", "flame2");
map.put("blocks/flame_layer_0", TextureAnimation.FLAME1);
map.put("blocks/flame_layer_1", TextureAnimation.FLAME2);
}
}

View file

@ -130,6 +130,7 @@ import common.color.DyeColor;
import common.init.FluidRegistry.LiquidType;
import common.item.CheatTab;
import common.log.Log;
import common.model.TextureAnimation;
import common.util.ObjectIntIdentityMap;
import common.util.RegistryNamespacedDefaultedByKey;
import common.util.Util;
@ -285,9 +286,9 @@ public abstract class BlockRegistry {
.setDisplay("Schwarzbruchstein").setTab(CheatTab.NATURE));
registerFluid("water", "Wasser", true, LiquidType.WATER, false, 0, 5, 0.0f, "water", "waterflow");
registerFluid("water", "Wasser", true, LiquidType.WATER, false, 0, 5, 0.0f, TextureAnimation.WATER, TextureAnimation.WATERFLOW);
registerFluid("lava", "Lava", false, LiquidType.LAVA, true, 15, -30, 0.0f, 2, 3);
registerFluid("magma", "Magma", false, LiquidType.HOT, true, 15, 40, 0.0f, "lava", "lavaflow");
registerFluid("magma", "Magma", false, LiquidType.HOT, true, 15, 40, 0.0f, TextureAnimation.LAVA, TextureAnimation.LAVAFLOW);
registerFluid("mercury", "Quecksilber", false, LiquidType.COLD, true, 0, 40, 0.0f, 8, 4);
registerFluid("hydrogen", "Wasserstoff", false, LiquidType.COLD, true, 0, 50, 0.0f, 8, 4);
registerFluid("acid", "Säure", false, LiquidType.HOT, false, 0, 5, 0.0f, 1, 1);

View file

@ -0,0 +1,5 @@
package common.model;
public enum TextureAnimation {
FIRE1, FIRE2, FLAME1, FLAME2, LAVAFLOW, LAVA, WATERFLOW, WATER;
}