diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 77036570..d6fa8bd0 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -659,8 +659,8 @@ public class Client implements IThreadListener { GL11.glLoadIdentity(); GL11.glMatrixMode(GL11.GL_MODELVIEW); this.textureMap = new TextureMap(); - this.textureManager.loadTexture(TextureMap.BLOCKS, this.textureMap); - this.textureManager.bindTexture(TextureMap.BLOCKS); + this.textureManager.loadTexture(TextureMap.locationBlocksTexture, this.textureMap); + this.textureManager.bindTexture(TextureMap.locationBlocksTexture); 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.update(); + this.textureMap.updateAnimations(); if (this.open != null) { this.open.updateScreen(); diff --git a/client/src/main/java/client/init/RenderRegistry.java b/client/src/main/java/client/init/RenderRegistry.java index 39f62d2a..e69fc53d 100644 --- a/client/src/main/java/client/init/RenderRegistry.java +++ b/client/src/main/java/client/init/RenderRegistry.java @@ -110,7 +110,6 @@ 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, Render> map, @@ -129,6 +128,8 @@ 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)); @@ -167,14 +168,14 @@ public abstract class RenderRegistry { } } - public static void registerAnimations(Map> 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); + public static void registerAnimations(Map> 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); } } diff --git a/client/src/main/java/client/renderer/ActiveRenderInfo.java b/client/src/main/java/client/renderer/ActiveRenderInfo.java new file mode 100755 index 00000000..a8e79b28 --- /dev/null +++ b/client/src/main/java/client/renderer/ActiveRenderInfo.java @@ -0,0 +1,150 @@ +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; + } +} diff --git a/client/src/main/java/client/renderer/DefaultVertexFormats.java b/client/src/main/java/client/renderer/DefaultVertexFormats.java index 60ade6a6..ab287a52 100755 --- a/client/src/main/java/client/renderer/DefaultVertexFormats.java +++ b/client/src/main/java/client/renderer/DefaultVertexFormats.java @@ -12,6 +12,7 @@ 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); @@ -54,6 +55,10 @@ 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); diff --git a/client/src/main/java/client/renderer/EntityRenderer.java b/client/src/main/java/client/renderer/EntityRenderer.java index 64996dc5..71968c7d 100755 --- a/client/src/main/java/client/renderer/EntityRenderer.java +++ b/client/src/main/java/client/renderer/EntityRenderer.java @@ -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.getData(); + this.lightmapColors = this.lightmapTexture.getTextureData(); 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.updateTexture(); + this.lightmapTexture.updateDynamicTexture(); this.lightmapUpdateNeeded = false; } } @@ -959,7 +959,7 @@ public class EntityRenderer { this.updateFogColor(partialTicks); GL11.glClear(16640); this.setupCameraTransform(partialTicks); - MatrixState.update(this.gm.player, this.gm.thirdPersonView == 2); + ActiveRenderInfo.updateRenderInfo(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.BLOCKS); + this.gm.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); 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.BLOCKS); + this.gm.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); 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 = MatrixState.getLookedBlock(this.gm.world, entity, partial); + Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(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 = MatrixState.getLookedBlock(this.gm.world, entity, partial); + Block block = ActiveRenderInfo.getBlockAtEntityViewpoint(this.gm.world, entity, partial); if(distance >= 1.0f) { ; diff --git a/client/src/main/java/client/renderer/ItemModelMesher.java b/client/src/main/java/client/renderer/ItemModelMesher.java index 1a4d16d8..a9f58e4d 100755 --- a/client/src/main/java/client/renderer/ItemModelMesher.java +++ b/client/src/main/java/client/renderer/ItemModelMesher.java @@ -10,34 +10,90 @@ import common.init.ItemRegistry; import common.item.Item; import common.item.ItemStack; -public class ItemModelMesher { - private final Map models = Maps.newHashMap(); - private final ModelManager manager; +public class ItemModelMesher +{ + private final Map simpleShapesCache = Maps.newHashMap(); + private final ModelManager modelManager; - public ItemModelMesher(ModelManager manager) { - this.manager = manager; - } + public ItemModelMesher(ModelManager modelManager) + { + this.modelManager = modelManager; + } - 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 model = this.models.get(ItemRegistry.getIdFromItem(item)); - if(model == null) - model = this.manager.getMissingModel(); - return model; - } + public IBakedModel getItemModel(ItemStack stack) + { + Item item = stack.getItem(); + IBakedModel ibakedmodel = this.simpleShapesCache.get(this.getIndex(item)); - public ModelManager getModelManager() { - return this.manager; - } + if (ibakedmodel == null) + { + ibakedmodel = this.modelManager.getMissingModel(); + } - 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())); - } - } + 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())); + } + } } diff --git a/client/src/main/java/client/renderer/ItemRenderer.java b/client/src/main/java/client/renderer/ItemRenderer.java index 5a86583e..0c310a61 100755 --- a/client/src/main/java/client/renderer/ItemRenderer.java +++ b/client/src/main/java/client/renderer/ItemRenderer.java @@ -515,7 +515,7 @@ public class ItemRenderer */ private void renderBlockInHand(float partialTicks, TextureAtlasSprite atlas) { - this.gm.getTextureManager().bindTexture(TextureMap.BLOCKS); + this.gm.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); // 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.BLOCKS); + this.gm.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); float f1 = textureatlassprite.getMinU(); float f2 = textureatlassprite.getMaxU(); float f3 = textureatlassprite.getMinV(); diff --git a/client/src/main/java/client/renderer/MatrixState.java b/client/src/main/java/client/renderer/MatrixState.java deleted file mode 100755 index 4d4b3112..00000000 --- a/client/src/main/java/client/renderer/MatrixState.java +++ /dev/null @@ -1,103 +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 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; - } -} diff --git a/client/src/main/java/client/renderer/Project.java b/client/src/main/java/client/renderer/Project.java index 83f07597..ce0b8a8b 100644 --- a/client/src/main/java/client/renderer/Project.java +++ b/client/src/main/java/client/renderer/Project.java @@ -38,7 +38,14 @@ import java.nio.IntBuffer; import org.lwjgl.opengl.GL11; -// 11-jan-2004 Erik Duijs +/** + * Project.java + *

+ *

+ * Created 11-jan-2004 + * + * @author Erik Duijs + */ public class Project { static final float PI = (float)Math.PI; @@ -60,6 +67,13 @@ 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; @@ -76,18 +90,35 @@ 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] = @@ -99,6 +130,12 @@ 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; @@ -170,6 +207,11 @@ 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++) { @@ -179,6 +221,14 @@ 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; @@ -204,6 +254,19 @@ 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, @@ -252,6 +315,17 @@ 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, @@ -290,6 +364,17 @@ 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, @@ -333,4 +418,31 @@ 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); +// } } diff --git a/client/src/main/java/client/renderer/RegionRenderCache.java b/client/src/main/java/client/renderer/RegionRenderCache.java index e8741451..d2cba9ea 100755 --- a/client/src/main/java/client/renderer/RegionRenderCache.java +++ b/client/src/main/java/client/renderer/RegionRenderCache.java @@ -186,17 +186,32 @@ public class RegionRenderCache implements IWorldAccess } } - public int getLightFor(LightType type, BlockPos pos) +// /** +// * 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) { 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(type, pos); + return this.chunks[i][j].getLight(p_175628_1_, pos); } else { - return type.defValue; + return p_175628_1_.defValue; } } + +// public int getStrongPower(BlockPos pos, EnumFacing direction) +// { +// IBlockState iblockstate = this.getBlockState(pos); +// return iblockstate.getBlock().getStrongPower(this, pos, iblockstate, direction); +// } } diff --git a/client/src/main/java/client/renderer/RenderBuffer.java b/client/src/main/java/client/renderer/RenderBuffer.java index 8b0e57ed..ceaa45a8 100755 --- a/client/src/main/java/client/renderer/RenderBuffer.java +++ b/client/src/main/java/client/renderer/RenderBuffer.java @@ -21,6 +21,8 @@ public class RenderBuffer private int vertexCount; private VertexFormatElement vertexFormatElement; private int vertexFormatIndex; + + /** None */ private boolean noColor; private int drawMode; private double xOffset; @@ -282,6 +284,9 @@ 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; @@ -348,6 +353,9 @@ public class RenderBuffer } } + /** + * Disabels color processing. + */ public void noColor() { this.noColor = true; diff --git a/client/src/main/java/client/renderer/RenderGlobal.java b/client/src/main/java/client/renderer/RenderGlobal.java index 112a56f7..e5e257c1 100755 --- a/client/src/main/java/client/renderer/RenderGlobal.java +++ b/client/src/main/java/client/renderer/RenderGlobal.java @@ -1553,7 +1553,7 @@ public class RenderGlobal if (!this.damagedBlocks.isEmpty()) { - this.renderEngine.bindTexture(TextureMap.BLOCKS); + this.renderEngine.bindTexture(TextureMap.locationBlocksTexture); this.preRenderDamagedBlocks(); worldRendererIn.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); worldRendererIn.setTranslation(-d0, -d1, -d2); diff --git a/client/src/main/java/client/renderer/VertexBuffer.java b/client/src/main/java/client/renderer/VertexBuffer.java index cf9f0954..ee8a33e7 100755 --- a/client/src/main/java/client/renderer/VertexBuffer.java +++ b/client/src/main/java/client/renderer/VertexBuffer.java @@ -5,39 +5,47 @@ import java.nio.ByteBuffer; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL15; -public class VertexBuffer { - private int id; - private final VertexFormat format; - private int count; +public class VertexBuffer +{ + private int glBufferId; + private final VertexFormat vertexFormat; + private int count; - public VertexBuffer(VertexFormat format) { - this.format = format; - this.id = GL15.glGenBuffers(); - } + public VertexBuffer(VertexFormat vertexFormatIn) + { + this.vertexFormat = vertexFormatIn; + this.glBufferId = GL15.glGenBuffers(); + } - public void bindBuffer() { - GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.id); - } + public void bindBuffer() + { + GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.glBufferId); + } - 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 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 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.id >= 0) { - GL15.glDeleteBuffers(this.id); - this.id = -1; - } - } + public void deleteGlBuffers() + { + if (this.glBufferId >= 0) + { + GL15.glDeleteBuffers(this.glBufferId); + this.glBufferId = -1; + } + } } diff --git a/client/src/main/java/client/renderer/VertexFormat.java b/client/src/main/java/client/renderer/VertexFormat.java index 35717324..0ab42813 100755 --- a/client/src/main/java/client/renderer/VertexFormat.java +++ b/client/src/main/java/client/renderer/VertexFormat.java @@ -10,6 +10,7 @@ public class VertexFormat private final List elements; private final List offsets; + /** The next available offset in this vertex format */ private int nextOffset; private int colorElementOffset; private List uvOffsetsById; diff --git a/client/src/main/java/client/renderer/blockmodel/BlockPartFace.java b/client/src/main/java/client/renderer/blockmodel/BlockPartFace.java index b5867c9c..03791d7b 100755 --- a/client/src/main/java/client/renderer/blockmodel/BlockPartFace.java +++ b/client/src/main/java/client/renderer/blockmodel/BlockPartFace.java @@ -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.MISSING : texture; + this.texture = texture == null ? TextureMap.LOCATION_MISSING_TEXTURE : texture; this.uv = uv; } } diff --git a/client/src/main/java/client/renderer/blockmodel/ModelBakery.java b/client/src/main/java/client/renderer/blockmodel/ModelBakery.java index 164dad40..50e9ba6a 100755 --- a/client/src/main/java/client/renderer/blockmodel/ModelBakery.java +++ b/client/src/main/java/client/renderer/blockmodel/ModelBakery.java @@ -7,6 +7,7 @@ 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; @@ -24,7 +25,9 @@ import common.world.State; public abstract class ModelBakery { - private static final Set BUILTINS = Sets.newHashSet( + private static final Set LOCATIONS_BUILTIN_TEXTURES = Sets.newHashSet( +// "blocks/water_flow", "blocks/water_still", +// "blocks/lava_flow", "blocks/lava_still", "blocks/destroy_stage_0", "blocks/destroy_stage_1", "blocks/destroy_stage_2", "blocks/destroy_stage_3", "blocks/destroy_stage_4", "blocks/destroy_stage_5", @@ -39,8 +42,8 @@ public abstract class ModelBakery static { for(int z = 0; z < FluidRegistry.getNumFluids(); z++) { String name = BlockRegistry.getNameFromBlock(FluidRegistry.getStaticBlock(z)).toString(); - BUILTINS.add("blocks/" + name + "_flow"); - BUILTINS.add("blocks/" + name + "_still"); + LOCATIONS_BUILTIN_TEXTURES.add("blocks/" + name + "_flow"); + LOCATIONS_BUILTIN_TEXTURES.add("blocks/" + name + "_still"); } } @@ -53,16 +56,90 @@ public abstract class ModelBakery FaceBakery faceBakery = new FaceBakery(); RegistrySimple bakedRegistry = new RegistrySimple(); List itemLocations = Lists.newArrayList(); +// Map> variantNames = Maps.>newIdentityHashMap(); +// variants.clear(); +// Map map = blockModelShapes.getMap(); models.put(MISSING, (ModelBlock)new ModelBlock(null).add().all()); variants.add(MISSING); for(Entry 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 list = variantNames.get(item); +// if(list == null) +// list = Collections.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); @@ -106,11 +183,14 @@ public abstract class ModelBakery } set.add(modelblock.getPrimary()); +// return set; +// set.addAll(getTextureLocations(modelblock)); } } - set.addAll(BUILTINS); - for (String resourcelocation : itemLocations) + set.addAll(LOCATIONS_BUILTIN_TEXTURES); +// final Set set = getVariantsTextureLocations(); + for (String resourcelocation : itemLocations) // .values()) { ModelBlock modelblock = (ModelBlock)models.get(resourcelocation); @@ -137,9 +217,21 @@ public abstract class ModelBakery } } } - set.remove(TextureMap.MISSING); - textureMap.loadSprites(set, sprites); - sprites.put(TextureMap.MISSING, textureMap.getMissingSprite()); +// 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()); for (String resourcelocation : itemLocations) // .values()) { @@ -179,25 +271,28 @@ public abstract class ModelBakery } } +// for (Entry entry : itemLocations.entrySet()) for (String entry : itemLocations) { - ModelBlock modelblock1 = (ModelBlock)models.get(entry); +// ResourceLocation resourcelocation = (ResourceLocation)entry.getValue(); +// ResourceLocation inventory = new ResourceLocation((String)entry.getKey(), "inventory"); + ModelBlock modelblock1 = (ModelBlock)models.get(entry) ; // resourcelocation); if (modelblock1 != null) { if (modelblock1.getParent() == MODEL_ENTITY) { - bakedRegistry.putObject(entry, new BuiltInModel(modelblock1.getTransform())); + bakedRegistry.putObject(entry /* inventory */, new BuiltInModel(modelblock1.getTransform())); } else { - bakedRegistry.putObject(entry, bakeModel(sprites, faceBakery, textureMap.getMissingSprite(), + bakedRegistry.putObject(entry /* inventory */, bakeModel(sprites, faceBakery, textureMap.getMissingSprite(), modelblock1, ModelRotation.X0_Y0, false)); } } else { - throw new RuntimeException("Fehlendes Modell für: " + entry); + throw new RuntimeException("Fehlendes Modell für: " + entry); // resourcelocation); } } diff --git a/client/src/main/java/client/renderer/blockmodel/ModelBlock.java b/client/src/main/java/client/renderer/blockmodel/ModelBlock.java index b963cd41..351704da 100755 --- a/client/src/main/java/client/renderer/blockmodel/ModelBlock.java +++ b/client/src/main/java/client/renderer/blockmodel/ModelBlock.java @@ -75,7 +75,7 @@ public class ModelBlock extends Model { } public ModelBlock face(String texture, Facing ... faces) { - texture = !texture.equals(TextureMap.MISSING) && texture.indexOf('/') == -1 ? "blocks/" + texture : texture; + texture = !texture.equals(TextureMap.LOCATION_MISSING_TEXTURE) && 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.MISSING : primary; + this.primary = primary == null ? TextureMap.LOCATION_MISSING_TEXTURE : 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.MISSING : this.layers[layer]; + return this.layers == null || this.layers[layer] == null ? TextureMap.LOCATION_MISSING_TEXTURE : this.layers[layer]; } public ModelBlock getParent() { diff --git a/client/src/main/java/client/renderer/blockmodel/ModelGenerator.java b/client/src/main/java/client/renderer/blockmodel/ModelGenerator.java index 4436c0af..b4870104 100755 --- a/client/src/main/java/client/renderer/blockmodel/ModelGenerator.java +++ b/client/src/main/java/client/renderer/blockmodel/ModelGenerator.java @@ -15,6 +15,8 @@ import common.util.Facing; import common.util.Vector3f; public abstract class ModelGenerator { +// public static final List LAYERS = Lists.newArrayList("layer0", "layer1", "layer2", "layer3", "layer4"); + public static List 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; @@ -235,6 +237,17 @@ public abstract class ModelGenerator { List spans = Lists.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; } diff --git a/client/src/main/java/client/renderer/blockmodel/ModelManager.java b/client/src/main/java/client/renderer/blockmodel/ModelManager.java index afd6b375..f5bddec7 100755 --- a/client/src/main/java/client/renderer/blockmodel/ModelManager.java +++ b/client/src/main/java/client/renderer/blockmodel/ModelManager.java @@ -90,6 +90,21 @@ 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); @@ -136,7 +151,8 @@ public class ModelManager StateMap mapper = this.mappers.get(block); if(mapper == null) mapper = new SingleStateMap(); - map.putAll(mapper.putStateModelLocations(block)); + map.putAll( // (Objects.firstNonNull(, )) + mapper.putStateModelLocations(block)); } } return map; diff --git a/client/src/main/java/client/renderer/entity/Render.java b/client/src/main/java/client/renderer/entity/Render.java index c364f8c6..4f29cae6 100755 --- a/client/src/main/java/client/renderer/entity/Render.java +++ b/client/src/main/java/client/renderer/entity/Render.java @@ -121,7 +121,7 @@ public abstract class Render while (f3 > 0.0F) { TextureAtlasSprite textureatlassprite2 = i % 2 == 0 ? textureatlassprite : textureatlassprite1; - this.bindTexture(TextureMap.BLOCKS); + this.bindTexture(TextureMap.locationBlocksTexture); float f6 = textureatlassprite2.getMinU(); float f7 = textureatlassprite2.getMinV(); float f8 = textureatlassprite2.getMaxU(); diff --git a/client/src/main/java/client/renderer/entity/RenderBlockEntity.java b/client/src/main/java/client/renderer/entity/RenderBlockEntity.java index 064c2099..8d40d113 100755 --- a/client/src/main/java/client/renderer/entity/RenderBlockEntity.java +++ b/client/src/main/java/client/renderer/entity/RenderBlockEntity.java @@ -75,6 +75,6 @@ public class RenderBlockEntity extends Render */ protected String getEntityTexture(Entity entity) { - return TextureMap.BLOCKS; + return TextureMap.locationBlocksTexture; } } diff --git a/client/src/main/java/client/renderer/entity/RenderDie.java b/client/src/main/java/client/renderer/entity/RenderDie.java index 0786f455..38be9de0 100755 --- a/client/src/main/java/client/renderer/entity/RenderDie.java +++ b/client/src/main/java/client/renderer/entity/RenderDie.java @@ -20,7 +20,7 @@ public class RenderDie extends Render protected String getEntityTexture(EntityDie entity) { - return TextureMap.BLOCKS; + return TextureMap.locationBlocksTexture; } public void doRender(EntityDie entity, double x, double y, double z, float partialTicks) diff --git a/client/src/main/java/client/renderer/entity/RenderEntityItem.java b/client/src/main/java/client/renderer/entity/RenderEntityItem.java index 9767fecd..4ba2eff4 100755 --- a/client/src/main/java/client/renderer/entity/RenderEntityItem.java +++ b/client/src/main/java/client/renderer/entity/RenderEntityItem.java @@ -159,7 +159,7 @@ public class RenderEntityItem extends Render */ protected String getEntityTexture(EntityItem entity) { - return TextureMap.BLOCKS; + return TextureMap.locationBlocksTexture; } // protected boolean canRenderName(EntityItem entity) diff --git a/client/src/main/java/client/renderer/entity/RenderFallingBlock.java b/client/src/main/java/client/renderer/entity/RenderFallingBlock.java index 4583e519..c004df8c 100755 --- a/client/src/main/java/client/renderer/entity/RenderFallingBlock.java +++ b/client/src/main/java/client/renderer/entity/RenderFallingBlock.java @@ -31,7 +31,7 @@ public class RenderFallingBlock extends Render { if (entity.getBlock() != null) { - this.bindTexture(TextureMap.BLOCKS); + this.bindTexture(TextureMap.locationBlocksTexture); State iblockstate = entity.getBlock(); Block block = iblockstate.getBlock(); BlockPos blockpos = new BlockPos(entity); @@ -69,6 +69,6 @@ public class RenderFallingBlock extends Render */ protected String getEntityTexture(EntityFalling entity) { - return TextureMap.BLOCKS; + return TextureMap.locationBlocksTexture; } } diff --git a/client/src/main/java/client/renderer/entity/RenderFireball.java b/client/src/main/java/client/renderer/entity/RenderFireball.java index 36068f60..0e68614c 100755 --- a/client/src/main/java/client/renderer/entity/RenderFireball.java +++ b/client/src/main/java/client/renderer/entity/RenderFireball.java @@ -61,6 +61,6 @@ public class RenderFireball extends Render */ protected String getEntityTexture(EntityProjectile entity) { - return TextureMap.BLOCKS; + return TextureMap.locationBlocksTexture; } } diff --git a/client/src/main/java/client/renderer/entity/RenderItem.java b/client/src/main/java/client/renderer/entity/RenderItem.java index 522de1df..803c1aa0 100755 --- a/client/src/main/java/client/renderer/entity/RenderItem.java +++ b/client/src/main/java/client/renderer/entity/RenderItem.java @@ -28,20 +28,34 @@ public class RenderItem { private static final String RES_ITEM_GLINT = "textures/glint.png"; - private final ItemModelMesher mesher; - private final TextureManager manager; + /** False when the renderer is rendering the item's effects into a GUI */ +// private boolean notRenderingEffectsInGUI = true; + /** 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.manager = textureManager; - this.mesher = new ItemModelMesher(modelManager); + this.textureManager = textureManager; + this.itemModelMesher = new ItemModelMesher(modelManager); +// RenderRegistry.registerItems(this.itemModelMesher); } + /** + * 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.mesher; + return this.itemModelMesher; } private void renderModel(IBakedModel model, ItemStack stack) @@ -56,6 +70,7 @@ 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); @@ -104,7 +119,7 @@ public class RenderItem GlState.depthFunc(GL11.GL_EQUAL); GlState.disableLighting(); GlState.blendFunc(GL11.GL_SRC_COLOR, GL11.GL_ONE); - this.manager.bindTexture(RES_ITEM_GLINT); + this.textureManager.bindTexture(RES_ITEM_GLINT); GL11.glMatrixMode(GL11.GL_TEXTURE); GL11.glPushMatrix(); GL11.glScalef(8.0F, 8.0F, 8.0F); @@ -125,7 +140,7 @@ public class RenderItem GlState.enableLighting(); GlState.depthFunc(GL11.GL_LEQUAL); GlState.depthMask(true); - this.manager.bindTexture(TextureMap.BLOCKS); + this.textureManager.bindTexture(TextureMap.locationBlocksTexture); } private void putQuadNormal(RenderBuffer renderer, BakedQuad quad) @@ -154,6 +169,12 @@ public class RenderItem if (flag && bakedquad.hasTintIndex()) { k = stack.getItem().getColorFromItemStack(stack, bakedquad.getTintIndex()); + +// if (EntityRenderer.anaglyphEnable) +// { +// k = TextureUtil.anaglyphColor(k); +// } + k = k | -16777216; } @@ -163,13 +184,13 @@ public class RenderItem public boolean shouldRenderItemIn3D(ItemStack stack) { - IBakedModel ibakedmodel = this.mesher.getItemModel(stack); + IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(stack); return ibakedmodel == null ? false : ibakedmodel.isGui3d(); } private void preTransform(ItemStack stack) { - IBakedModel ibakedmodel = this.mesher.getItemModel(stack); + IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(stack); Item item = stack.getItem(); if (item != null) @@ -189,7 +210,7 @@ public class RenderItem { if (stack != null) { - IBakedModel ibakedmodel = this.mesher.getItemModel(stack); + IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(stack); this.renderItemModelTransform(stack, ibakedmodel, cameraTransformType); } } @@ -198,7 +219,7 @@ public class RenderItem { if (stack != null && entityToRenderFor != null) { - IBakedModel ibakedmodel = this.mesher.getItemModel(stack); + IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(stack); if (entityToRenderFor.isPlayer()) { @@ -206,7 +227,7 @@ public class RenderItem Item item = stack.getItem(); String sprite = item == null ? null : item.getSprite(entityplayer, stack); if(sprite != null) - ibakedmodel = this.mesher.getModelManager().getModel("item/" + sprite); + ibakedmodel = this.itemModelMesher.getModelManager().getModel("item/" + sprite); } this.renderItemModelTransform(stack, ibakedmodel, cameraTransformType); @@ -215,7 +236,8 @@ public class RenderItem protected void renderItemModelTransform(ItemStack stack, IBakedModel model, Transforms.Camera cameraTransformType) { - this.manager.bindTexture(TextureMap.BLOCKS); + this.textureManager.bindTexture(TextureMap.locationBlocksTexture); +// this.textureManager.getTexture(TextureMap.locationBlocksTexture).unsetMipmap(); this.preTransform(stack); GlState.enableRescaleNormal(); GlState.alphaFunc(GL11.GL_GREATER, 0.1F); @@ -230,14 +252,16 @@ public class RenderItem GL11.glPopMatrix(); GlState.disableRescaleNormal(); GlState.disableBlend(); - this.manager.bindTexture(TextureMap.BLOCKS); + this.textureManager.bindTexture(TextureMap.locationBlocksTexture); +// this.textureManager.getTexture(TextureMap.locationBlocksTexture).restoreLastMipmap(); } private void renderItemIntoGUI(ItemStack stack, int x, int y) { - IBakedModel ibakedmodel = this.mesher.getItemModel(stack); + IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(stack); GL11.glPushMatrix(); - this.manager.bindTexture(TextureMap.BLOCKS); + this.textureManager.bindTexture(TextureMap.locationBlocksTexture); +// this.textureManager.getTexture(TextureMap.locationBlocksTexture).unsetMipmap(); GlState.enableRescaleNormal(); GlState.enableAlpha(); GlState.alphaFunc(GL11.GL_GREATER, 0.1F); @@ -251,7 +275,8 @@ public class RenderItem GlState.disableRescaleNormal(); GlState.disableLighting(); GL11.glPopMatrix(); - this.manager.bindTexture(TextureMap.BLOCKS); + this.textureManager.bindTexture(TextureMap.locationBlocksTexture); +// this.textureManager.getTexture(TextureMap.locationBlocksTexture).restoreLastMipmap(); } private void setupGuiTransform(int xPosition, int yPosition, boolean isGui3d) @@ -290,7 +315,7 @@ public class RenderItem public void onReload() { - this.mesher.rebuildCache(); + this.itemModelMesher.rebuildCache(); } public static void apply(Transforms trans, Transforms.Camera type) { diff --git a/client/src/main/java/client/renderer/entity/RenderItemEntity.java b/client/src/main/java/client/renderer/entity/RenderItemEntity.java index af9d47eb..2e660e43 100755 --- a/client/src/main/java/client/renderer/entity/RenderItemEntity.java +++ b/client/src/main/java/client/renderer/entity/RenderItemEntity.java @@ -30,7 +30,7 @@ public class RenderItemEntity extends Render 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.BLOCKS); + this.bindTexture(TextureMap.locationBlocksTexture); this.itemRenderer.renderItem(this.getStack(entity), Transforms.Camera.GROUND); GlState.disableRescaleNormal(); GL11.glPopMatrix(); @@ -44,6 +44,6 @@ public class RenderItemEntity extends Render protected String getEntityTexture(Entity entity) { - return TextureMap.BLOCKS; + return TextureMap.locationBlocksTexture; } } diff --git a/client/src/main/java/client/renderer/entity/RenderMinecart.java b/client/src/main/java/client/renderer/entity/RenderMinecart.java index cc8b7d8a..6844f89e 100755 --- a/client/src/main/java/client/renderer/entity/RenderMinecart.java +++ b/client/src/main/java/client/renderer/entity/RenderMinecart.java @@ -96,7 +96,7 @@ public class RenderMinecart extends Render if (iblockstate.getBlock().getRenderType() != -1) { GL11.glPushMatrix(); - this.bindTexture(TextureMap.BLOCKS); + this.bindTexture(TextureMap.locationBlocksTexture); float f4 = 0.75F; GL11.glScalef(f4, f4, f4); GL11.glTranslatef(-0.5F, (float)(j - 8) / 16.0F, 0.5F); diff --git a/client/src/main/java/client/renderer/entity/RenderTntPrimed.java b/client/src/main/java/client/renderer/entity/RenderTntPrimed.java index 88aa537e..5a8d0ded 100755 --- a/client/src/main/java/client/renderer/entity/RenderTntPrimed.java +++ b/client/src/main/java/client/renderer/entity/RenderTntPrimed.java @@ -66,6 +66,6 @@ public class RenderTntPrimed extends Render protected String getEntityTexture(EntityTnt entity) { - return TextureMap.BLOCKS; + return TextureMap.locationBlocksTexture; } } diff --git a/client/src/main/java/client/renderer/entity/RendererLivingEntity.java b/client/src/main/java/client/renderer/entity/RendererLivingEntity.java index 949810bf..26c5539b 100755 --- a/client/src/main/java/client/renderer/entity/RendererLivingEntity.java +++ b/client/src/main/java/client/renderer/entity/RendererLivingEntity.java @@ -560,13 +560,13 @@ public abstract class RendererLivingEntity extends Rende static { - int[] aint = textureBrightness.getData(); + int[] aint = textureBrightness.getTextureData(); for (int i = 0; i < 256; ++i) { aint[i] = -1; } - textureBrightness.updateTexture(); + textureBrightness.updateDynamicTexture(); } } diff --git a/client/src/main/java/client/renderer/layers/LayerMooshroomMushroom.java b/client/src/main/java/client/renderer/layers/LayerMooshroomMushroom.java index 8cd71080..424b2948 100755 --- a/client/src/main/java/client/renderer/layers/LayerMooshroomMushroom.java +++ b/client/src/main/java/client/renderer/layers/LayerMooshroomMushroom.java @@ -25,7 +25,7 @@ public class LayerMooshroomMushroom implements LayerRenderer if (!entitylivingbaseIn.isChild()) // && !entitylivingbaseIn.isInvisible()) { BlockRenderer blockrendererdispatcher = Client.CLIENT.getBlockRendererDispatcher(); - this.mooshroomRenderer.bindTexture(TextureMap.BLOCKS); + this.mooshroomRenderer.bindTexture(TextureMap.locationBlocksTexture); GlState.enableCull(); GlState.cullFace(GL11.GL_FRONT); GL11.glPushMatrix(); diff --git a/client/src/main/java/client/renderer/particle/EffectRenderer.java b/client/src/main/java/client/renderer/particle/EffectRenderer.java index 1ab1691e..49d88cbe 100755 --- a/client/src/main/java/client/renderer/particle/EffectRenderer.java +++ b/client/src/main/java/client/renderer/particle/EffectRenderer.java @@ -5,7 +5,7 @@ import java.util.Map; import org.lwjgl.opengl.GL11; -import client.renderer.MatrixState; +import client.renderer.ActiveRenderInfo; 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 = MatrixState.getRotationX(); - float f1 = MatrixState.getRotationZ(); - float f2 = MatrixState.getRotationYZ(); - float f3 = MatrixState.getRotationXY(); - float f4 = MatrixState.getRotationXZ(); + float f = ActiveRenderInfo.getRotationX(); + float f1 = ActiveRenderInfo.getRotationZ(); + float f2 = ActiveRenderInfo.getRotationYZ(); + float f3 = ActiveRenderInfo.getRotationXY(); + float f4 = ActiveRenderInfo.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.BLOCKS); + this.renderer.bindTexture(TextureMap.locationBlocksTexture); } GlState.color(1.0F, 1.0F, 1.0F, 1.0F); diff --git a/client/src/main/java/client/renderer/texture/DynamicTexture.java b/client/src/main/java/client/renderer/texture/DynamicTexture.java index dfa42678..1d82fcdb 100755 --- a/client/src/main/java/client/renderer/texture/DynamicTexture.java +++ b/client/src/main/java/client/renderer/texture/DynamicTexture.java @@ -5,41 +5,51 @@ import java.io.IOException; import client.renderer.GlState; -public class DynamicTexture extends Texture { - private final int[] data; - private final int width; - private final int height; +public class DynamicTexture extends Texture +{ + private final int[] dynamicTextureData; - public DynamicTexture(BufferedImage image) { - this(image.getWidth(), image.getHeight()); - image.getRGB(0, 0, image.getWidth(), image.getHeight(), this.data, 0, image.getWidth()); - this.updateTexture(); - } + /** width of this icon in pixels */ + private final int width; - public DynamicTexture(int width, int height) { - this.width = width; - this.height = height; - this.data = new int[width * height]; - TextureUtil.allocateTexture(this.getGlTextureId(), width, height); - } + /** height of this icon in pixels */ + private final int height; - public void loadTexture() throws IOException { - } + 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 updateTexture() { - GlState.bindTexture(this.getGlTextureId()); - TextureUtil.uploadTexture(this.data, this.width, this.height, 0, 0); - } + 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 int[] getData() { - return this.data; - } + public void loadTexture() throws IOException + { + } - public int getWidth() { - return this.width; - } + public void updateDynamicTexture() + { + GlState.bindTexture(this.getGlTextureId()); + TextureUtil.uploadTexture(this.dynamicTextureData, this.width, this.height, 0, 0); + } - public int getHeight() { - return this.height; - } + public int[] getTextureData() + { + return this.dynamicTextureData; + } + + public int getWidth() { + return this.width; + } + + public int getHeight() { + return this.height; + } } diff --git a/client/src/main/java/client/renderer/texture/EntityTexManager.java b/client/src/main/java/client/renderer/texture/EntityTexManager.java index bcde521d..81607038 100755 --- a/client/src/main/java/client/renderer/texture/EntityTexManager.java +++ b/client/src/main/java/client/renderer/texture/EntityTexManager.java @@ -73,10 +73,10 @@ public abstract class EntityTexManager manager.loadTexture(loc, dyntex); } else { - image.getRGB(0, 0, image.getWidth(), image.getHeight(), dyntex.getData(), 0, image.getWidth()); + image.getRGB(0, 0, image.getWidth(), image.getHeight(), dyntex.getTextureData(), 0, image.getWidth()); } - dyntex.updateTexture(); - LayerExtra extra = LayerExtra.getLayer(dyntex.getData(), dyntex.getWidth(), dyntex.getHeight(), entry.getValue()); + dyntex.updateDynamicTexture(); + LayerExtra extra = LayerExtra.getLayer(dyntex.getTextureData(), 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.getData(), 0, image.getWidth()); + image.getRGB(0, 0, image.getWidth(), image.getHeight(), dyntex.getTextureData(), 0, image.getWidth()); } - dyntex.updateTexture(); + dyntex.updateDynamicTexture(); // 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.getData(), model); - dyntex.updateTexture(); + EntityTexManager.compToImage(comp, dyntex.getTextureData(), model); + dyntex.updateDynamicTexture(); USER_TEXTURES.add(id); - LayerExtra extra = LayerExtra.getLayer(dyntex.getData(), dyntex.getWidth(), dyntex.getHeight(), model); + LayerExtra extra = LayerExtra.getLayer(dyntex.getTextureData(), dyntex.getWidth(), dyntex.getHeight(), model); if(extra != null) { extra = USER_LAYERS.put(id, extra); } diff --git a/client/src/main/java/client/renderer/texture/IIconCreator.java b/client/src/main/java/client/renderer/texture/IIconCreator.java new file mode 100755 index 00000000..ed1f0aaf --- /dev/null +++ b/client/src/main/java/client/renderer/texture/IIconCreator.java @@ -0,0 +1,6 @@ +package client.renderer.texture; + +public interface IIconCreator +{ + void registerSprites(TextureMap iconRegistry); +} diff --git a/client/src/main/java/client/renderer/texture/LayeredColorMaskTexture.java b/client/src/main/java/client/renderer/texture/LayeredColorMaskTexture.java index 8248aefe..dfb3312a 100755 --- a/client/src/main/java/client/renderer/texture/LayeredColorMaskTexture.java +++ b/client/src/main/java/client/renderer/texture/LayeredColorMaskTexture.java @@ -13,9 +13,10 @@ import common.log.Log; public class LayeredColorMaskTexture extends Texture { - private final String texture; - private final List layers; - private final List colors; + /** The location of the texture. */ + private final String textureLocation; + private final List field_174949_h; + private final List field_174950_i; private static int applyTint(int color, int tint) { int i = (color & 16711680) >> 16; @@ -30,11 +31,11 @@ public class LayeredColorMaskTexture extends Texture return color & -16777216 | k1 << 16 | l1 << 8 | i2; } - public LayeredColorMaskTexture(String texture, List layers, List colors) + public LayeredColorMaskTexture(String textureLocationIn, List p_i46101_2_, List p_i46101_3_) { - this.texture = texture; - this.layers = layers; - this.colors = colors; + this.textureLocation = textureLocationIn; + this.field_174949_h = p_i46101_2_; + this.field_174950_i = p_i46101_3_; } public void loadTexture() throws IOException @@ -44,7 +45,7 @@ public class LayeredColorMaskTexture extends Texture try { - BufferedImage bufferedimage1 = TextureUtil.readImage(FileUtils.getResource(this.texture)); + BufferedImage bufferedimage1 = TextureUtil.readImage(FileUtils.getResource(this.textureLocation)); int i = bufferedimage1.getType(); if (i == 0) @@ -56,10 +57,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.layers.size() && j < this.colors.size(); ++j) + for (int j = 0; j < 17 && j < this.field_174949_h.size() && j < this.field_174950_i.size(); ++j) { - String s = this.layers.get(j); - int color = this.colors.get(j).getColor(); + String s = (String)this.field_174949_h.get(j); + int color = this.field_174950_i.get(j).getColor(); if (s != null) { diff --git a/client/src/main/java/client/renderer/texture/LayeredTexture.java b/client/src/main/java/client/renderer/texture/LayeredTexture.java index 7485c005..26c5a968 100755 --- a/client/src/main/java/client/renderer/texture/LayeredTexture.java +++ b/client/src/main/java/client/renderer/texture/LayeredTexture.java @@ -12,11 +12,11 @@ import common.log.Log; public class LayeredTexture extends Texture { - public final List layers; + public final List layeredTextureNames; - public LayeredTexture(String[] layers) + public LayeredTexture(String[] textureNames) { - this.layers = Lists.newArrayList(layers); + this.layeredTextureNames = Lists.newArrayList(textureNames); } public void loadTexture() throws IOException @@ -26,7 +26,7 @@ public class LayeredTexture extends Texture try { - for (String s : this.layers) + for (String s : this.layeredTextureNames) { if (s != null) { diff --git a/client/src/main/java/client/renderer/texture/SimpleTexture.java b/client/src/main/java/client/renderer/texture/SimpleTexture.java index df5bc680..c4aa0ede 100755 --- a/client/src/main/java/client/renderer/texture/SimpleTexture.java +++ b/client/src/main/java/client/renderer/texture/SimpleTexture.java @@ -7,17 +7,20 @@ import java.io.InputStream; import client.util.FileUtils; public class SimpleTexture extends Texture { - private final String texture; + private final String location; - public SimpleTexture(String texture) { - this.texture = texture; + public SimpleTexture(String location) { + this.location = location; } public void loadTexture() throws IOException { this.deleteGlTexture(); InputStream in = null; try { - in = FileUtils.getResource(this.texture); + in = // this.location.startsWith("/") ? SimpleTexture.class.getResourceAsStream(this.location) : + FileUtils.getResource(this.location); +// if(in == null) +// throw new FileNotFoundException(this.location); BufferedImage img = TextureUtil.readImage(in); TextureUtil.uploadImage(this.getGlTextureId(), img); } diff --git a/client/src/main/java/client/renderer/texture/Stitcher.java b/client/src/main/java/client/renderer/texture/Stitcher.java index 223ad999..f9cff3b1 100755 --- a/client/src/main/java/client/renderer/texture/Stitcher.java +++ b/client/src/main/java/client/renderer/texture/Stitcher.java @@ -10,11 +10,27 @@ import common.collect.Sets; public class Stitcher { - private final Set holders = Sets.newHashSetWithExpectedSize(256); - private final List slots = new ArrayList(256); +// private static final int MAX_SIZE; + + private final Set setStitchHolders = Sets.newHashSetWithExpectedSize(256); + private final List stitchSlots = new ArrayList(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; @@ -26,6 +42,10 @@ public class Stitcher return i + 1; } +// static { +// MAX_SIZE = getMaximumTextureSize(); +// } + public int getCurrentWidth() { return this.currentWidth; @@ -39,28 +59,41 @@ public class Stitcher public void addSprite(TextureAtlasSprite p_110934_1_) { Stitcher.Holder stitcher$holder = new Stitcher.Holder(p_110934_1_); - this.holders.add(stitcher$holder); + +// if (this.maxTileDimension > 0) +// { +// stitcher$holder.setNewDimension(this.maxTileDimension); +// } + + this.setStitchHolders.add(stitcher$holder); } public void doStitch() { - Stitcher.Holder[] astitcher$holder = (Stitcher.Holder[])this.holders.toArray(new Stitcher.Holder[this.holders.size()]); + Stitcher.Holder[] astitcher$holder = (Stitcher.Holder[])this.setStitchHolders.toArray(new Stitcher.Holder[this.setStitchHolders.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 getStichSlots() { List list = Lists.newArrayList(); - for (Stitcher.Slot stitcher$slot : this.slots) + for (Stitcher.Slot stitcher$slot : this.stitchSlots) { stitcher$slot.getAllStitchSlots(list); } @@ -78,18 +111,21 @@ 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.slots.size(); ++i) + for (int i = 0; i < this.stitchSlots.size(); ++i) { - if (((Stitcher.Slot)this.slots.get(i)).addSlot(p_94310_1_)) + if (((Stitcher.Slot)this.stitchSlots.get(i)).addSlot(p_94310_1_)) { return; } p_94310_1_.rotate(); - if (((Stitcher.Slot)this.slots.get(i)).addSlot(p_94310_1_)) + if (((Stitcher.Slot)this.stitchSlots.get(i)).addSlot(p_94310_1_)) { return; } @@ -100,16 +136,28 @@ 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; @@ -120,8 +168,30 @@ public class Stitcher } else { - flag1 = j <= k; + flag1 = /* flag2 && */ 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) @@ -146,7 +216,9 @@ public class Stitcher } stitcher$slot.addSlot(p_94311_1_); - this.slots.add(stitcher$slot); + this.stitchSlots.add(stitcher$slot); +// return true; +// } } public static class Holder implements Comparable @@ -198,6 +270,11 @@ public class Stitcher } } + public String toString() + { + return "Holder{width=" + this.width + ", height=" + this.height + '}'; + } + public int compareTo(Stitcher.Holder p_compareTo_1_) { int i; @@ -342,5 +419,10 @@ 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 + '}'; + } } } diff --git a/client/src/main/java/client/renderer/texture/Texture.java b/client/src/main/java/client/renderer/texture/Texture.java index 68ed5207..4c0ab84a 100755 --- a/client/src/main/java/client/renderer/texture/Texture.java +++ b/client/src/main/java/client/renderer/texture/Texture.java @@ -6,21 +6,28 @@ import org.lwjgl.opengl.GL11; import client.renderer.GlState; -public abstract class Texture { - private int id = -1; +public abstract class Texture +{ + protected int glTextureId = -1; - public final int getGlTextureId() { - if(this.id == -1) - this.id = GL11.glGenTextures(); - return this.id; - } + public final int getGlTextureId() + { + if (this.glTextureId == -1) + { + this.glTextureId = GL11.glGenTextures(); + } - public final void deleteGlTexture() { - if(this.id != -1) { - GlState.deleteTexture(this.id); - this.id = -1; - } - } + return this.glTextureId; + } - public abstract void loadTexture() throws IOException; + public final void deleteGlTexture() + { + if (this.glTextureId != -1) + { + GlState.deleteTexture(this.glTextureId); + this.glTextureId = -1; + } + } + + public abstract void loadTexture() throws IOException; } diff --git a/client/src/main/java/client/renderer/texture/TextureAtlasSprite.java b/client/src/main/java/client/renderer/texture/TextureAtlasSprite.java index fb18431c..4226a064 100755 --- a/client/src/main/java/client/renderer/texture/TextureAtlasSprite.java +++ b/client/src/main/java/client/renderer/texture/TextureAtlasSprite.java @@ -56,52 +56,82 @@ 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; @@ -120,6 +150,7 @@ 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; } @@ -166,8 +197,24 @@ public class TextureAtlasSprite int j = image.getHeight(); this.width = i; this.height = j; - int[] aint = new int[i * 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]; image.getRGB(0, 0, i, j, aint, 0, i); +// } +// } if (frametime == 0) { @@ -185,15 +232,41 @@ 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); - } - this.frameCount = frames; - this.frametime = frametime; +// 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 list = Lists.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; +// } } } @@ -207,7 +280,9 @@ 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; @@ -247,4 +322,9 @@ 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 + '}'; + } } diff --git a/client/src/main/java/client/renderer/texture/TextureMap.java b/client/src/main/java/client/renderer/texture/TextureMap.java index 07043bf6..9c52b1e5 100755 --- a/client/src/main/java/client/renderer/texture/TextureMap.java +++ b/client/src/main/java/client/renderer/texture/TextureMap.java @@ -5,7 +5,6 @@ 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; @@ -17,12 +16,11 @@ 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 MISSING = "missingno"; - public static final String BLOCKS = "textures/atlas/blocks.png"; + public static final String LOCATION_MISSING_TEXTURE = "missingno"; + public static final String locationBlocksTexture = "textures/atlas/blocks.png"; private final List listAnimatedSprites; private final Map mapRegisteredSprites; @@ -38,9 +36,10 @@ public class TextureMap extends Texture this.mapUploadedSprites = Maps.newHashMap(); this.tickedTextures = Maps.>newHashMap(); this.animTextures = Maps.newHashMap(); - this.missingImage = new TextureAtlasSprite(MISSING); + this.missingImage = new TextureAtlasSprite(LOCATION_MISSING_TEXTURE); +// RenderRegistry.registerAnimations(this); Map map = Maps.newHashMap(); - Map> anim = Maps.newHashMap(); + Map> anim = Maps.newHashMap(); RenderRegistry.registerAnimations(anim); for(Block block : BlockRegistry.REGISTRY) { block.getAnimatedTextures(map); @@ -56,9 +55,9 @@ public class TextureMap extends Texture this.animTextures.put(entry.getKey(), (Integer)entry.getValue()); } else { - Class clazz = anim.get((TextureAnimation)entry.getValue()); + Class clazz = anim.get((String)entry.getValue()); if(clazz == null) - throw new RuntimeException("Animation '" + entry.getValue() + "' existiert nicht"); + throw new RuntimeException("Animation '" + (String)entry.getValue() + "' existiert nicht"); this.tickedTextures.put(entry.getKey(), clazz); } } @@ -77,25 +76,22 @@ public class TextureMap extends Texture { } - public void loadSprites(Set set, Map sprites) + public void loadSprites(IIconCreator creator) { this.mapRegisteredSprites.clear(); - for (String loc : set) - { - TextureAtlasSprite sprite = this.registerSprite(loc); - sprites.put(loc, sprite); - } + creator.registerSprites(this); this.initMissingImage(); this.deleteGlTexture(); this.loadTextureAtlas(); } - private void loadTextureAtlas() + public void loadTextureAtlas() { Stitcher stitcher = new Stitcher(); this.mapUploadedSprites.clear(); this.listAnimatedSprites.clear(); int j = Integer.MAX_VALUE; +// int k = 1 << this.mipmapLevels; for (Entry entry : this.mapRegisteredSprites.entrySet()) { @@ -110,7 +106,9 @@ public class TextureMap extends Texture textureatlassprite.loadSprite(animationmetadatasection); } else { - BufferedImage abufferedimage = TextureUtil.readImage(FileUtils.getResource(name)); + BufferedImage abufferedimage = // new BufferedImage[1 + this.mipmapLevels]; +// abufferedimage[0] = + TextureUtil.readImage(FileUtils.getResource(name)); Integer frametime = this.animTextures.get(textureatlassprite.getIconName()); textureatlassprite.loadSprite(abufferedimage, frametime == null ? 0 : frametime.intValue()); } @@ -134,9 +132,30 @@ 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 @@ -184,7 +203,7 @@ public class TextureMap extends Texture return textureatlassprite; } - public void update() + public void updateAnimations() { GlState.bindTexture(this.getGlTextureId()); @@ -194,7 +213,7 @@ public class TextureMap extends Texture } } - private TextureAtlasSprite registerSprite(String location) + public TextureAtlasSprite registerSprite(String location) { if (location == null) { @@ -214,6 +233,11 @@ public class TextureMap extends Texture } } +// public void tick() +// { +// this.updateAnimations(); +// } + public TextureAtlasSprite getMissingSprite() { return this.missingImage; diff --git a/client/src/main/java/client/renderer/texture/TextureUtil.java b/client/src/main/java/client/renderer/texture/TextureUtil.java index c50703e3..5fb705e8 100755 --- a/client/src/main/java/client/renderer/texture/TextureUtil.java +++ b/client/src/main/java/client/renderer/texture/TextureUtil.java @@ -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.getData(); + public static final int[] MISSING_DATA = MISSING.getTextureData(); public static void uploadTexture(int[] data, int w, int h, int x, int y) { @@ -75,6 +75,12 @@ 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); } @@ -124,6 +130,6 @@ public class TextureUtil System.arraycopy(l < k ? aint1 : aint, 0, MISSING_DATA, 16 * l + k, k); } - MISSING.updateTexture(); + MISSING.updateDynamicTexture(); } } diff --git a/client/src/main/java/client/renderer/tileentity/TileEntityPistonRenderer.java b/client/src/main/java/client/renderer/tileentity/TileEntityPistonRenderer.java index 237689da..f40c2475 100755 --- a/client/src/main/java/client/renderer/tileentity/TileEntityPistonRenderer.java +++ b/client/src/main/java/client/renderer/tileentity/TileEntityPistonRenderer.java @@ -33,7 +33,7 @@ public class TileEntityPistonRenderer extends TileEntitySpecialRenderer 0; + return FlammabilityRegistry.getEncouragement(worldIn.getState(pos).getBlock()) > 0; } public boolean canPlaceBlockAt(World worldIn, BlockPos pos) @@ -1144,8 +1144,8 @@ public class BlockFire extends Block } public void getAnimatedTextures(Map map) { - map.put("blocks/fire_layer_0", TextureAnimation.FIRE1); - map.put("blocks/fire_layer_1", TextureAnimation.FIRE2); + map.put("blocks/fire_layer_0", "fire1"); + map.put("blocks/fire_layer_1", "fire2"); } public boolean canExtinguish() { diff --git a/common/src/main/java/common/block/natural/BlockTintedFire.java b/common/src/main/java/common/block/natural/BlockTintedFire.java index 27a5edd8..70e64c67 100644 --- a/common/src/main/java/common/block/natural/BlockTintedFire.java +++ b/common/src/main/java/common/block/natural/BlockTintedFire.java @@ -4,7 +4,6 @@ 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; @@ -30,7 +29,7 @@ public class BlockTintedFire extends BlockFire { } public void getAnimatedTextures(Map map) { - map.put("blocks/flame_layer_0", TextureAnimation.FLAME1); - map.put("blocks/flame_layer_1", TextureAnimation.FLAME2); + map.put("blocks/flame_layer_0", "flame1"); + map.put("blocks/flame_layer_1", "flame2"); } } diff --git a/common/src/main/java/common/block/tech/BlockTNT.java b/common/src/main/java/common/block/tech/BlockTNT.java index 6dd8f680..eb771420 100755 --- a/common/src/main/java/common/block/tech/BlockTNT.java +++ b/common/src/main/java/common/block/tech/BlockTNT.java @@ -40,7 +40,6 @@ public class BlockTNT extends Block this.power = power; this.setDefaultState(this.getBaseState().withProperty(EXPLODE, Boolean.valueOf(false))); this.setTab(CheatTab.TECHNOLOGY); - this.setFlammable(15, 100); TNTS[power] = this; } diff --git a/common/src/main/java/common/init/BlockRegistry.java b/common/src/main/java/common/init/BlockRegistry.java index 867a036b..743f8eb5 100755 --- a/common/src/main/java/common/init/BlockRegistry.java +++ b/common/src/main/java/common/init/BlockRegistry.java @@ -130,7 +130,6 @@ 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; @@ -267,7 +266,7 @@ public abstract class BlockRegistry { .setStepSound(SoundType.STONE).setDisplay(color.getSubject(null) + " gefärbter Ton")); } registerBlock("coal_block", (new Block(Material.SOLID)).setHardness(5.0F).setResistance(10.0F) - .setStepSound(SoundType.STONE).setDisplay("Kohleblock").setTab(CheatTab.NATURE).setFlammable(5, 5)); + .setStepSound(SoundType.STONE).setDisplay("Kohleblock").setTab(CheatTab.NATURE)); registerBlock("sand", (new BlockFalling(Material.LOOSE)).setHardness(0.5F).setStepSound(SoundType.SAND).setDisplay("Sand").setShovelHarvestable().setTab(CheatTab.NATURE)); registerBlock("red_sand", (new BlockFalling(Material.LOOSE)).setHardness(0.5F).setStepSound(SoundType.SAND).setDisplay("Roter Sand").setShovelHarvestable().setTab(CheatTab.NATURE)); registerBlock("gravel", (new BlockGravel()).setHardness(0.6F).setStepSound(SoundType.GRAVEL).setDisplay("Kies").setShovelHarvestable()); @@ -286,9 +285,9 @@ public abstract class BlockRegistry { .setDisplay("Schwarzbruchstein").setTab(CheatTab.NATURE)); - registerFluid("water", "Wasser", true, LiquidType.WATER, false, 0, 5, 0.0f, TextureAnimation.WATER, TextureAnimation.WATERFLOW); + registerFluid("water", "Wasser", true, LiquidType.WATER, false, 0, 5, 0.0f, "water", "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, TextureAnimation.LAVA, TextureAnimation.LAVAFLOW); + registerFluid("magma", "Magma", false, LiquidType.HOT, true, 15, 40, 0.0f, "lava", "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); @@ -577,21 +576,21 @@ public abstract class BlockRegistry { - registerBlock("trapdoor", (new BlockTrapDoor(Material.WOOD)).setHardness(3.0F).setStepSound(SoundType.WOOD).setDisplay("Holzfalltür").setFlammable(5, 20)); + registerBlock("trapdoor", (new BlockTrapDoor(Material.WOOD)).setHardness(3.0F).setStepSound(SoundType.WOOD).setDisplay("Holzfalltür")); for(WoodType wood : WoodType.values()) { Block planks = (new Block(Material.WOOD)).setHardness(2.0F).setResistance(5.0F).setStepSound(SoundType.WOOD) - .setDisplay(wood.getDisplay() + "holzbretter").setTab(CheatTab.WOOD).setFlammable(5, 20); + .setDisplay(wood.getDisplay() + "holzbretter").setTab(CheatTab.WOOD); registerBlock(wood.getName() + "_planks", planks); registerBlock(wood.getName() + "_stairs", (new BlockStairs(planks.getState())) - .setDisplay(wood.getDisplay() + "holztreppe").setFlammable(5, 20)); + .setDisplay(wood.getDisplay() + "holztreppe")); registerBlock(wood.getName() + "_slab", (new BlockSlab(Material.WOOD, wood.getName() + "_planks")) - .setHardness(2.0F).setResistance(5.0F).setStepSound(SoundType.WOOD).setDisplay(wood.getDisplay() + "holzstufe").setFlammable(5, 20)); + .setHardness(2.0F).setResistance(5.0F).setStepSound(SoundType.WOOD).setDisplay(wood.getDisplay() + "holzstufe")); registerBlock(wood.getName() + "_fence", (new BlockFence(Material.WOOD, wood.getName() + "_planks")) - .setHardness(2.0F).setResistance(5.0F).setStepSound(SoundType.WOOD).setDisplay(wood.getDisplay() + "holzzaun").setFlammable(5, 20)); + .setHardness(2.0F).setResistance(5.0F).setStepSound(SoundType.WOOD).setDisplay(wood.getDisplay() + "holzzaun")); registerBlock(wood.getName() + "_fence_gate", (new BlockFenceGate(wood)).setHardness(2.0F).setResistance(5.0F) - .setStepSound(SoundType.WOOD).setDisplay(wood.getDisplay() + "holzzauntor").setFlammable(5, 20)); + .setStepSound(SoundType.WOOD).setDisplay(wood.getDisplay() + "holzzauntor")); registerBlock(wood.getName() + "_door", (new BlockDoor(Material.WOOD)).setHardness(3.0F).setStepSound(SoundType.WOOD) - .setDisplay(wood.getDisplay() + "holztür").setFlammable(5, 20)); + .setDisplay(wood.getDisplay() + "holztür")); } diff --git a/common/src/main/java/common/init/FlammabilityRegistry.java b/common/src/main/java/common/init/FlammabilityRegistry.java new file mode 100755 index 00000000..fd214fc6 --- /dev/null +++ b/common/src/main/java/common/init/FlammabilityRegistry.java @@ -0,0 +1,73 @@ +package common.init; + +import java.util.Map; + +import common.block.Block; +import common.block.artificial.BlockCarpet; +import common.block.artificial.BlockWool; +import common.block.foliage.BlockDoublePlant; +import common.block.foliage.BlockFlower; +import common.block.foliage.BlockLeaves; +import common.block.foliage.BlockTallGrass; +import common.block.foliage.LeavesType; +import common.block.tech.BlockTNT; +import common.collect.Maps; + +public abstract class FlammabilityRegistry { + private static final Map ENCOURAGEMENT = Maps.newIdentityHashMap(); + private static final Map FLAMMABILITY = Maps.newIdentityHashMap(); + + private static void setFlammable(Block block, int encouragement, int flammability) { + ENCOURAGEMENT.put(block, encouragement); + FLAMMABILITY.put(block, flammability); + } + + static void register() { + for(WoodType wood : WoodType.values()) { + setFlammable(BlockRegistry.getRegisteredBlock(wood.getName() + "_planks"), 5, 20); + setFlammable(BlockRegistry.getRegisteredBlock(wood.getName() + "_slab"), 5, 20); + setFlammable(BlockRegistry.getRegisteredBlock(wood.getName() + "_stairs"), 5, 20); + setFlammable(BlockRegistry.getRegisteredBlock(wood.getName() + "_fence"), 5, 20); + setFlammable(BlockRegistry.getRegisteredBlock(wood.getName() + "_fence_gate"), 5, 20); + setFlammable(BlockRegistry.getRegisteredBlock(wood.getName() + "_log"), 5, 5); + for(LeavesType type : LeavesType.values()) { + setFlammable(BlockLeaves.getLeavesBlock(wood, type), 30, 60); + } + setFlammable(BlockRegistry.getRegisteredBlock(wood.getName() + "_sapling"), 15, 100); + } + for(BlockTNT block : BlockTNT.TNTS) { + setFlammable(block, 15, 100); + } + for(BlockTallGrass block : BlockTallGrass.BUSHES) { + setFlammable(block, 60, 100); + } + for(BlockDoublePlant block : BlockDoublePlant.PLANTS) { + setFlammable(block, 60, 100); + } + for(BlockFlower block : BlockFlower.FLOWERS) { + setFlammable(block, 60, 100); + } + for(BlockWool block : BlockWool.WOOLS) { + setFlammable(block, 30, 60); + } + for(BlockCarpet block : BlockCarpet.CARPETS) { + setFlammable(block, 60, 20); + } + setFlammable(Blocks.bookshelf, 30, 20); + setFlammable(Blocks.deadbush, 60, 100); + setFlammable(Blocks.dry_leaves, 60, 100); + setFlammable(Blocks.vine, 15, 100); + setFlammable(Blocks.coal_block, 5, 5); + setFlammable(Blocks.hay_block, 60, 20); + } + + public static int getFlammability(Block block) { + Integer value = FLAMMABILITY.get(block); + return value == null ? 0 : value.intValue(); + } + + public static int getEncouragement(Block block) { + Integer value = ENCOURAGEMENT.get(block); + return value == null ? 0 : value.intValue(); + } +} diff --git a/common/src/main/java/common/init/Registry.java b/common/src/main/java/common/init/Registry.java index ebb63d80..fecbfde6 100755 --- a/common/src/main/java/common/init/Registry.java +++ b/common/src/main/java/common/init/Registry.java @@ -4,6 +4,7 @@ public abstract class Registry { public static void register() { NameRegistry.register(); BlockRegistry.register(); + FlammabilityRegistry.register(); SpeciesRegistry.register(); EntityRegistry.registerEggs(); ItemRegistry.register(); diff --git a/common/src/main/java/common/model/TextureAnimation.java b/common/src/main/java/common/model/TextureAnimation.java deleted file mode 100644 index e8591430..00000000 --- a/common/src/main/java/common/model/TextureAnimation.java +++ /dev/null @@ -1,5 +0,0 @@ -package common.model; - -public enum TextureAnimation { - FIRE1, FIRE2, FLAME1, FLAME2, LAVAFLOW, LAVA, WATERFLOW, WATER; -}