integrate renderer class

This commit is contained in:
Sen 2025-08-06 13:53:25 +02:00
parent dc85ecc293
commit e0a031c5d0
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
18 changed files with 4185 additions and 4657 deletions

View file

@ -56,13 +56,11 @@ import client.init.DimensionMapping;
import client.network.ClientLoginHandler;
import client.network.ClientPlayer;
import client.network.DummyConnection;
import client.renderer.BlockRenderer;
import client.renderer.Drawing;
import client.renderer.EffectRenderer;
import client.renderer.EntityRenderer;
import client.renderer.Renderer;
import client.renderer.GlState;
import client.renderer.ItemRenderer;
import client.renderer.RenderGlobal;
import client.renderer.blockmodel.ModelManager;
import client.renderer.chunk.RenderChunk;
import client.renderer.entity.RenderItem;
@ -241,7 +239,7 @@ public class Client implements IThreadListener {
public static class DistanceFunction implements IntFunction {
public void apply(IntVar cv, int value) {
Client.CLIENT.distance(value);
Client.CLIENT.applyDistance();
}
}
@ -347,22 +345,22 @@ public class Client implements IThreadListener {
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
Client.this.renderGlobal.markBlocksForUpdate(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
Client.this.renderer.markUpdate(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
}
public void clientNotifyLight(BlockPos pos) {
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
Client.this.renderGlobal.markBlocksForUpdate(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
Client.this.renderer.markUpdate(x - 1, y - 1, z - 1, x + 1, y + 1, z + 1);
}
public void clientRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {
Client.this.renderGlobal.markBlocksForUpdate(x1 - 1, y1 - 1, z1 - 1, x2 + 1, y2 + 1, z2 + 1);
Client.this.renderer.markUpdate(x1 - 1, y1 - 1, z1 - 1, x2 + 1, y2 + 1, z2 + 1);
}
public void setLastLightning(int last, int color) {
Client.this.entityRenderer.setLastLightning(last, color);
Client.this.renderer.setLastLightning(last, color);
}
}
@ -497,10 +495,8 @@ public class Client implements IThreadListener {
private ItemRenderer itemRenderer;
private TextureMap textureMap;
private ModelManager modelManager;
private BlockRenderer blockRenderer;
public RenderGlobal renderGlobal;
public EffectRenderer effectRenderer;
public EntityRenderer entityRenderer;
public Renderer renderer;
public Gui open;
private SoundManager soundManager;
@ -759,10 +755,9 @@ public class Client implements IThreadListener {
this.textureManager.onReload();
this.modelManager.onReload();
this.renderItem.onReload();
this.blockRenderer.onReload();
this.renderGlobal.onReload();
this.renderer.cacheSprites();
EntityTexManager.loadNpcTextures();
this.renderGlobal.loadRenderers();
this.renderer.loadRenderers();
this.logFeed("Texturen wurden neu geladen");
}
@ -794,11 +789,8 @@ public class Client implements IThreadListener {
this.renderManager = new RenderManager(this.textureManager, this.renderItem);
this.itemRenderer = new ItemRenderer(this);
this.renderItem.onReload();
this.entityRenderer = new EntityRenderer(this);
this.blockRenderer = new BlockRenderer(this.modelManager, this);
this.blockRenderer.onReload();
this.renderGlobal = new RenderGlobal(this);
this.renderGlobal.onReload();
this.renderer = new Renderer(this, this.modelManager);
this.renderer.cacheSprites();
EntityTexManager.loadNpcTextures();
this.effectRenderer = new EffectRenderer(this.textureManager);
@ -868,7 +860,7 @@ public class Client implements IThreadListener {
this.thirdPersonView = 0;
}
this.renderGlobal.setDisplayListEntitiesDirty();
this.renderer.setDisplayListEntitiesDirty();
}
boolean hadZoom = this.zooming;
@ -909,7 +901,7 @@ public class Client implements IThreadListener {
{
--this.rightClickTimer;
}
this.entityRenderer.getMouseOver(1.0F);
this.renderer.getMouseOver(1.0F);
if (this.world != null)
{
this.controller.update();
@ -990,8 +982,7 @@ public class Client implements IThreadListener {
this.ensureAreaLoaded(this.player);
}
}
this.entityRenderer.updateRenderer();
this.renderGlobal.updateClouds();
this.renderer.update();
this.world.updateEntities();
}
this.soundManager.update();
@ -1035,7 +1026,7 @@ public class Client implements IThreadListener {
GL11.glClear(16640);
GlState.enableTexture2D();
if(this.world != null)
this.entityRenderer.renderWorld((float)this.tickFraction, System.nanoTime() - this.tickStart);
this.renderer.renderWorld((float)this.tickFraction, System.nanoTime() - this.tickStart);
GL11.glPopMatrix();
GlState.disableTexture2D();
@ -1379,7 +1370,7 @@ public class Client implements IThreadListener {
if(this.cameraUsed) {
this.cameraUsed = false;
if(this.world != null)
this.entityRenderer.setLastLightning(1, 0xffffff);
this.renderer.setLastLightning(1, 0xffffff);
}
if(this.isDirty())
this.save();
@ -1581,7 +1572,7 @@ public class Client implements IThreadListener {
}
else if (itemstack.getSize() != i)
{
this.entityRenderer.itemRenderer.resetProgress();
this.itemRenderer.resetProgress();
}
}
}
@ -1593,7 +1584,7 @@ public class Client implements IThreadListener {
if (itemstack1 != null && this.controller.sendUseItem(this.player, this.world, itemstack1))
{
this.entityRenderer.itemRenderer.resetProgress();
this.itemRenderer.resetProgress();
}
}
}
@ -1655,19 +1646,16 @@ public class Client implements IThreadListener {
this.entityIds = this.world.entityIds;
this.initWorld();
if (this.renderGlobal != null)
{
this.renderGlobal.setWorldAndLoadRenderers(world);
}
this.renderer.setWorldAndLoadRenderers(this.world);
if (this.effectRenderer != null)
{
this.effectRenderer.setWorld(world);
this.effectRenderer.setWorld(this.world);
}
if (this.player == null)
{
this.player = this.controller.createPlayerEntity(world, type);
this.player = this.controller.createPlayerEntity(this.world, type);
this.player.rotYaw = -180.0F;
}
@ -1778,11 +1766,6 @@ public class Client implements IThreadListener {
return Thread.currentThread() == this.thread;
}
public BlockRenderer getBlockRendererDispatcher()
{
return this.blockRenderer;
}
public RenderManager getRenderManager()
{
return this.renderManager;
@ -1884,8 +1867,8 @@ public class Client implements IThreadListener {
// (this.isServer() ? "ES: " + this.server.getFolderName() :
// "MS: " + (
// this.connected != null ? this.connected : "[???]"))),
this.renderGlobal.getDebugInfoRenders() + "\n" +
this.renderGlobal.getDebugInfoEntities() + "\n" +
this.renderer.getDebugInfoRenders() + "\n" +
this.renderer.getDebugInfoEntities() + "\n" +
"Partikel: " + this.effectRenderer.getParticleCount() + ". O: " + this.entities.size() + "\n" +
"Chunk-Cache: M " + this.chunkMapping.getNumHashElements() + ", L " + this.chunkListing.size() + "\n" +
String.format("XYZ: %.3f / %.3f / %.3f", this.viewEntity.posX,
@ -1904,7 +1887,7 @@ public class Client implements IThreadListener {
this.dimensionName) + "\n" +
"Licht: " + chunk.getLightSub(pos, 0) + " (" + chunk.getLight(LightType.SKY, pos) + " Himmel, "
+ chunk.getLight(LightType.BLOCK, pos) + " Blöcke, " + String.format(
"%.1f", this.entityRenderer.getSunBrightness(1.0f) * 15.0f) + " Welt), A: "
"%.1f", this.renderer.getSunBrightness(1.0f) * 15.0f) + " Welt), A: "
+ String.format("%.1f °", this.world.getCelestialAngle(1.0f)) + "\n" +
String.format("Zeit: %s" + (this.world.dimension.hasRotation() ? ", R %d / %d T" : "") + (this.world.dimension.hasOrbit() ? ", U %d / %d T" : ""),
this.world.formatEpochSimple(),
@ -2323,7 +2306,7 @@ public class Client implements IThreadListener {
Log.SYSTEM.info("Beende ...");
unload(false);
this.getSoundManager().unload();
this.renderGlobal.stopChunkBuilders();
this.renderer.stopChunkBuilders();
if(this.audio.end())
Log.SOUND.info("Audiogerät geschlossen");
Log.flushLog();
@ -2526,9 +2509,9 @@ public class Client implements IThreadListener {
return this.audio;
}
public void distance(int distance) {
if(this.renderGlobal != null)
this.renderGlobal.setDisplayListEntitiesDirty();
public void applyDistance() {
if(this.renderer != null)
this.renderer.setDisplayListEntitiesDirty();
}
private void registerDebug(Keysym key, String help, DebugRunner runner) {
@ -2609,7 +2592,7 @@ public class Client implements IThreadListener {
this.registerDebug(Keysym.X, "Röntgenblick umschalten", new DebugRunner() {
public void execute(Keysym key) {
Client.this.xrayActive ^= true;
Client.this.renderGlobal.loadRenderers();
Client.this.renderer.loadRenderers();
Client.this.logFeed("Röntgenblick: %s", Client.this.xrayActive ? "an" : "aus");
}
});
@ -2628,7 +2611,7 @@ public class Client implements IThreadListener {
this.registerDebug(Keysym.Y, "Alle Chunks neu kompilieren", new DebugRunner() {
public void execute(Keysym key) {
Client.this.logFeed("Kompiliere alle Chunks neu");
Client.this.renderGlobal.loadRenderers();
Client.this.renderer.loadRenderers();
Client.this.logFeed("Alle Chunks wurden neu kompiliert");
}
});
@ -3127,10 +3110,10 @@ public class Client implements IThreadListener {
GlState.depthMask(false);
GL11.glPushMatrix();
GL11.glTranslatef((float)(this.fbX / 2), (float)(this.fbY / 2), 0.0F);
this.entityRenderer.rotateCamera(this.viewEntity, partialTicks);
RenderGlobal.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 24D, 1D, 1D), 255, 0, 0, 255);
RenderGlobal.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 1D, 1D, 24D), 0, 0, 255, 255);
RenderGlobal.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 1D, -20D, 1D), 0, 255, 0, 255);
this.renderer.rotateCamera(this.viewEntity, partialTicks);
Renderer.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 24D, 1D, 1D), 255, 0, 0, 255);
Renderer.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 1D, 1D, 24D), 0, 0, 255, 255);
Renderer.drawOutlinedBoundingBox(new BoundingBox(0.0D, 0.0D, 0.0D, 1D, -20D, 1D), 0, 255, 0, 255);
GL11.glPopMatrix();
GlState.depthMask(true);
GlState.enableTexture2D();
@ -3410,7 +3393,7 @@ public class Client implements IThreadListener {
this.nextEmptyChunkListing.clear();
this.emptyChunk = null;
this.outsideChunk = null;
this.entityRenderer.resetLightning();
this.renderer.resetLightning();
this.entities = null;
this.unloaded = null;
this.tiles = null;
@ -3428,7 +3411,7 @@ public class Client implements IThreadListener {
}
public void markBlockRangeForRenderUpdate(int x1, int y1, int z1, int x2, int y2, int z2) {
this.renderGlobal.markBlocksForUpdate(x1 - 1, y1 - 1, z1 - 1, x2 + 1, y2 + 1, z2 + 1);
this.renderer.markUpdate(x1 - 1, y1 - 1, z1 - 1, x2 + 1, y2 + 1, z2 + 1);
}
private void markReload(int cx, int cz, int range) {

View file

@ -25,7 +25,7 @@ public class GuiMenu extends Gui {
if(this.gm.world != null)
super.drawMainBackground();
else
this.gm.renderGlobal.renderStarField(this.gm.fbX, this.gm.fbY, 0x000000, 0xffffff, (float)this.ticks + this.gm.getTickFraction(), this.rand);
this.gm.renderer.renderStarField(this.gm.fbX, this.gm.fbY, 0x000000, 0xffffff, (float)this.ticks + this.gm.getTickFraction(), this.rand);
}
private final Random rand = new Random();

View file

@ -1352,7 +1352,7 @@ public class ClientPlayer implements IClientPlayer
public void handleBlockBreakAnim(SPacketBlockBreakAnim packetIn)
{
NetHandler.checkThread(packetIn, this, this.gm, this.world);
this.gm.renderGlobal.sendBlockBreakProgress(packetIn.getBreakerId(), packetIn.getPosition(), packetIn.getProgress());
this.gm.renderer.setBreakProgress(packetIn.getBreakerId(), packetIn.getPosition(), packetIn.getProgress());
}
public void handleMapChunkBulk(SPacketMapChunkBulk packetIn)

View file

@ -1,600 +1,5 @@
package client.renderer;
import java.util.BitSet;
import java.util.List;
import java.util.Map;
import org.lwjgl.opengl.GL11;
import client.Client;
import client.renderer.blockmodel.BakedModel;
import client.renderer.blockmodel.BakedQuad;
import client.renderer.blockmodel.IBakedModel;
import client.renderer.blockmodel.ModelManager;
import client.renderer.texture.Sprite;
import client.renderer.texture.TextureMap;
import common.block.Block;
import common.block.Material;
import common.block.liquid.BlockDynamicLiquid;
import common.block.liquid.BlockLiquid;
import common.block.liquid.BlockStaticLiquid;
import common.collect.Maps;
import common.init.BlockRegistry;
import common.init.Blocks;
import common.util.BlockPos;
import common.util.ExtMath;
import common.util.Facing;
import common.util.Pair;
import common.util.Vec3i;
import common.world.IBlockAccess;
import common.world.IWorldAccess;
import common.world.State;
public class BlockRenderer
{
private ModelManager manager;
private final Client gm;
private final Map<BlockLiquid, Sprite[]> fluids = Maps.newHashMap();
public BlockRenderer(ModelManager manager, Client gm)
{
this.manager = manager;
this.gm = gm;
this.initAtlasSprites();
}
public ModelManager getModelManager()
{
return this.manager;
}
public void renderBlockDamage(State state, BlockPos pos, Sprite texture, IWorldAccess blockAccess)
{
Block block = state.getBlock();
if (block != Blocks.air && !block.getMaterial().isLiquid())
{
state = block.getState(state, blockAccess, pos);
IBakedModel ibakedmodel = this.manager.getModelForState(state);
IBakedModel ibakedmodel1 = (new BakedModel.Builder(ibakedmodel, texture)).makeBakedModel();
// Tessellator.getInstance();
this.renderModel(blockAccess, ibakedmodel1, state, pos, Tessellator.getBuffer());
}
}
public boolean renderBlock(State state, BlockPos pos, IWorldAccess world, RenderBuffer rb) {
Block block = state.getBlock();
if(this.gm.xrayActive && !block.isXrayVisible())
return false;
if(block == Blocks.air)
return false;
else if(block.getMaterial().isLiquid())
return this.renderFluid(world, state, pos, rb);
IBakedModel model = this.getModelFromBlockState(state, world, pos);
return this.renderBase(world, model, state, pos, rb, !this.gm.xrayActive);
}
public IBakedModel getModelFromBlockState(State state, IWorldAccess worldIn, BlockPos pos)
{
Block block = state.getBlock();
if (!this.gm.debugWorld)
{
try
{
state = block.getState(state, worldIn, pos);
}
catch (Exception var6)
{
;
}
}
return this.manager.getModelForState(state);
// if (pos != null && this.gameSettings.allowBlockAlternatives && ibakedmodel instanceof WeightedBakedModel)
// {
// ibakedmodel = ((WeightedBakedModel)ibakedmodel).getAlternativeModel(MathHelper.getPositionRandom(pos));
// }
//
// return ibakedmodel;
}
public void renderBlockEntity(State state, float brightness)
{
if (state.getBlock() != Blocks.air && !state.getBlock().getMaterial().isLiquid())
{
IBakedModel model = this.manager.getModelForState(state);
this.renderModelBrightness(model, state, brightness, true);
}
}
// public boolean isRenderTypeChest(Block p_175021_1_, int p_175021_2_)
// {
// if (p_175021_1_ == null)
// {
// return false;
// }
// else
// {
// int i = p_175021_1_.getRenderType();
// return i == 3 ? false : i == 2;
// }
// }
public void onReload()
{
this.initAtlasSprites();
}
private boolean renderBase(IWorldAccess blockAccessIn, IBakedModel modelIn, State blockStateIn, BlockPos blockPosIn, RenderBuffer worldRendererIn, boolean checkSides)
{
Block block = blockStateIn.getBlock();
block.setBlockBounds(blockAccessIn, blockPosIn);
return this.renderModel(blockAccessIn, modelIn, blockStateIn, blockPosIn, worldRendererIn, checkSides);
}
private boolean renderModel(IWorldAccess blockAccessIn, IBakedModel modelIn, State blockStateIn, BlockPos blockPosIn, RenderBuffer worldRendererIn)
{
Block block = blockStateIn.getBlock();
block.setBlockBounds(blockAccessIn, blockPosIn);
return this.renderModel(blockAccessIn, modelIn, blockStateIn, blockPosIn, worldRendererIn, true);
}
public boolean renderModel(IWorldAccess blockAccessIn, IBakedModel modelIn, State blockStateIn, BlockPos blockPosIn, RenderBuffer worldRendererIn, boolean checkSides)
{
// return this.renderModelStandard(blockAccessIn, modelIn, , blockPosIn, worldRendererIn, checkSides);
// }
//
// public boolean renderModelStandard(IWorldAccess blockAccessIn, IBakedModel modelIn, Block blockIn, BlockPos blockPosIn, RenderBuffer worldRendererIn, boolean checkSides)
// {
Block blockIn = blockStateIn.getBlock();
boolean flag = false;
BitSet bitset = new BitSet(3);
for (Facing enumfacing : Facing.values())
{
List<BakedQuad> list = modelIn.getFace(enumfacing);
if (!list.isEmpty())
{
BlockPos blockpos = blockPosIn.offset(enumfacing);
if (!checkSides || blockIn.canRender(blockAccessIn, blockpos, enumfacing))
{
int i = blockIn.getLightmapValue(blockAccessIn, blockpos);
this.renderModelStandardQuads(blockAccessIn, blockIn, blockPosIn, enumfacing, i, false, worldRendererIn, list, bitset);
flag = true;
}
}
}
List<BakedQuad> list1 = modelIn.getQuads();
if (list1.size() > 0)
{
this.renderModelStandardQuads(blockAccessIn, blockIn, blockPosIn, (Facing)null, -1, true, worldRendererIn, list1, bitset);
flag = true;
}
return flag;
}
private void fillQuadBounds(Block blockIn, int[] vertexData, Facing facingIn, float[] quadBounds, BitSet boundsFlags)
{
float f = 32.0F;
float f1 = 32.0F;
float f2 = 32.0F;
float f3 = -32.0F;
float f4 = -32.0F;
float f5 = -32.0F;
for (int i = 0; i < 4; ++i)
{
float f6 = Float.intBitsToFloat(vertexData[i * 7]);
float f7 = Float.intBitsToFloat(vertexData[i * 7 + 1]);
float f8 = Float.intBitsToFloat(vertexData[i * 7 + 2]);
f = Math.min(f, f6);
f1 = Math.min(f1, f7);
f2 = Math.min(f2, f8);
f3 = Math.max(f3, f6);
f4 = Math.max(f4, f7);
f5 = Math.max(f5, f8);
}
if (quadBounds != null)
{
quadBounds[Facing.WEST.getIndex()] = f;
quadBounds[Facing.EAST.getIndex()] = f3;
quadBounds[Facing.DOWN.getIndex()] = f1;
quadBounds[Facing.UP.getIndex()] = f4;
quadBounds[Facing.NORTH.getIndex()] = f2;
quadBounds[Facing.SOUTH.getIndex()] = f5;
quadBounds[Facing.WEST.getIndex() + Facing.values().length] = 1.0F - f;
quadBounds[Facing.EAST.getIndex() + Facing.values().length] = 1.0F - f3;
quadBounds[Facing.DOWN.getIndex() + Facing.values().length] = 1.0F - f1;
quadBounds[Facing.UP.getIndex() + Facing.values().length] = 1.0F - f4;
quadBounds[Facing.NORTH.getIndex() + Facing.values().length] = 1.0F - f2;
quadBounds[Facing.SOUTH.getIndex() + Facing.values().length] = 1.0F - f5;
}
float f9 = 1.0E-4F;
float f10 = 0.9999F;
switch (facingIn)
{
case DOWN:
boundsFlags.set(1, f >= 1.0E-4F || f2 >= 1.0E-4F || f3 <= 0.9999F || f5 <= 0.9999F);
boundsFlags.set(0, (f1 < 1.0E-4F || blockIn.isFullCube()) && f1 == f4);
break;
case UP:
boundsFlags.set(1, f >= 1.0E-4F || f2 >= 1.0E-4F || f3 <= 0.9999F || f5 <= 0.9999F);
boundsFlags.set(0, (f4 > 0.9999F || blockIn.isFullCube()) && f1 == f4);
break;
case NORTH:
boundsFlags.set(1, f >= 1.0E-4F || f1 >= 1.0E-4F || f3 <= 0.9999F || f4 <= 0.9999F);
boundsFlags.set(0, (f2 < 1.0E-4F || blockIn.isFullCube()) && f2 == f5);
break;
case SOUTH:
boundsFlags.set(1, f >= 1.0E-4F || f1 >= 1.0E-4F || f3 <= 0.9999F || f4 <= 0.9999F);
boundsFlags.set(0, (f5 > 0.9999F || blockIn.isFullCube()) && f2 == f5);
break;
case WEST:
boundsFlags.set(1, f1 >= 1.0E-4F || f2 >= 1.0E-4F || f4 <= 0.9999F || f5 <= 0.9999F);
boundsFlags.set(0, (f < 1.0E-4F || blockIn.isFullCube()) && f == f3);
break;
case EAST:
boundsFlags.set(1, f1 >= 1.0E-4F || f2 >= 1.0E-4F || f4 <= 0.9999F || f5 <= 0.9999F);
boundsFlags.set(0, (f3 > 0.9999F || blockIn.isFullCube()) && f == f3);
}
}
private void renderModelStandardQuads(IWorldAccess blockAccessIn, Block blockIn, BlockPos blockPosIn, Facing faceIn, int brightnessIn, boolean ownBrightness, RenderBuffer worldRendererIn, List<BakedQuad> listQuadsIn, BitSet boundsFlags)
{
double d0 = (double)blockPosIn.getX();
double d1 = (double)blockPosIn.getY();
double d2 = (double)blockPosIn.getZ();
// EnumOffsetType block$enumoffsettype = blockIn.getOffsetType();
//
// if (block$enumoffsettype != EnumOffsetType.NONE)
// {
// int i = blockPosIn.getX();
// int j = blockPosIn.getZ();
// long k = (long)(i * 3129871) ^ (long)j * 116129781L;
// k = k * k * 42317861L + k * 11L;
// d0 += ((double)((float)(k >> 16 & 15L) / 15.0F) - 0.5D) * 0.5D;
// d2 += ((double)((float)(k >> 24 & 15L) / 15.0F) - 0.5D) * 0.5D;
//
// if (block$enumoffsettype == EnumOffsetType.XYZ)
// {
// d1 += ((double)((float)(k >> 20 & 15L) / 15.0F) - 1.0D) * 0.2D;
// }
// }
for (BakedQuad bakedquad : listQuadsIn)
{
if (ownBrightness)
{
this.fillQuadBounds(blockIn, bakedquad.getVertexData(), bakedquad.getFace(), (float[])null, boundsFlags);
brightnessIn = boundsFlags.get(0) ? blockIn.getLightmapValue(blockAccessIn, blockPosIn.offset(bakedquad.getFace())) : blockIn.getLightmapValue(blockAccessIn, blockPosIn);
}
worldRendererIn.addVertexData(bakedquad.getVertexData());
worldRendererIn.putBrightness4(brightnessIn, brightnessIn, brightnessIn, brightnessIn);
worldRendererIn.putPosition(d0, d1, d2);
}
}
private void renderModelBrightnessColor(IBakedModel bakedModel, float brightness)
{
for (Facing enumfacing : Facing.values())
{
this.renderModelBrightnessColorQuads(brightness, bakedModel.getFace(enumfacing));
}
this.renderModelBrightnessColorQuads(brightness, bakedModel.getQuads());
}
private void renderModelBrightness(IBakedModel model, State p_178266_2_, float brightness, boolean p_178266_4_)
{
Block block = p_178266_2_.getBlock();
GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);
if (!p_178266_4_)
{
GlState.color(brightness, brightness, brightness, 1.0F);
}
this.renderModelBrightnessColor(model, brightness);
}
private void renderModelBrightnessColorQuads(float brightness, List<BakedQuad> listQuads)
{
RenderBuffer worldrenderer = Tessellator.getBuffer();
for (BakedQuad bakedquad : listQuads)
{
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
worldrenderer.addVertexData(bakedquad.getVertexData());
worldrenderer.putColorRGB_F4(brightness, brightness, brightness);
Vec3i vec3i = bakedquad.getFace().getDirectionVec();
worldrenderer.putNormal((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ());
Tessellator.draw();
}
}
private void initAtlasSprites()
{
TextureMap texturemap = Client.CLIENT.getTextureMapBlocks();
for(Pair<BlockStaticLiquid, BlockDynamicLiquid> liquid : BlockLiquid.LIQUIDS) {
String name = BlockRegistry.getName(liquid.first());
Sprite[] sprites = new Sprite[] {texturemap.getAtlasSprite("blocks/" + name + "_still"), texturemap.getAtlasSprite("blocks/" + name + "_flow")};
this.fluids.put(liquid.second(), sprites);
this.fluids.put(liquid.first(), sprites);
}
}
private boolean renderFluid(IWorldAccess blockAccess, State blockStateIn, BlockPos blockPosIn, RenderBuffer worldRendererIn)
{
BlockLiquid blockliquid = (BlockLiquid)blockStateIn.getBlock();
blockliquid.setBlockBounds(blockAccess, blockPosIn);
Sprite[] atextureatlassprite = this.fluids.get(blockliquid);
boolean flag = blockliquid.canRender(blockAccess, blockPosIn.up(), Facing.UP);
boolean flag1 = blockliquid.canRender(blockAccess, blockPosIn.down(), Facing.DOWN);
boolean[] aboolean = new boolean[] {blockliquid.canRender(blockAccess, blockPosIn.north(), Facing.NORTH), blockliquid.canRender(blockAccess, blockPosIn.south(), Facing.SOUTH), blockliquid.canRender(blockAccess, blockPosIn.west(), Facing.WEST), blockliquid.canRender(blockAccess, blockPosIn.east(), Facing.EAST)};
if (!flag && !flag1 && !aboolean[0] && !aboolean[1] && !aboolean[2] && !aboolean[3])
{
return false;
}
else
{
boolean flag2 = false;
float f3 = 0.5F;
float f4 = 1.0F;
float f5 = 0.8F;
float f6 = 0.6F;
float f7 = this.getFluidHeight(blockAccess, blockPosIn);
float f8 = this.getFluidHeight(blockAccess, blockPosIn.south());
float f9 = this.getFluidHeight(blockAccess, blockPosIn.east().south());
float f10 = this.getFluidHeight(blockAccess, blockPosIn.east());
double d0 = (double)blockPosIn.getX();
double d1 = (double)blockPosIn.getY();
double d2 = (double)blockPosIn.getZ();
float f11 = 0.001F;
if (flag)
{
flag2 = true;
Sprite textureatlassprite = atextureatlassprite[0];
float f12 = (float)BlockLiquid.getFlowDirection(blockAccess, blockPosIn, blockliquid);
if (f12 > -999.0F)
{
textureatlassprite = atextureatlassprite[1];
}
f7 -= f11;
f8 -= f11;
f9 -= f11;
f10 -= f11;
float f13;
float f14;
float f15;
float f16;
float f17;
float f18;
float f19;
float f20;
if (f12 < -999.0F)
{
f13 = textureatlassprite.getInterpolatedU(0.0D);
f17 = textureatlassprite.getInterpolatedV(0.0D);
f14 = f13;
f18 = textureatlassprite.getInterpolatedV(16.0D);
f15 = textureatlassprite.getInterpolatedU(16.0D);
f19 = f18;
f16 = f15;
f20 = f17;
}
else
{
float f21 = ExtMath.sin(f12) * 0.25F;
float f22 = ExtMath.cos(f12) * 0.25F;
float f23 = 8.0F;
f13 = textureatlassprite.getInterpolatedU((double)(8.0F + (-f22 - f21) * 16.0F));
f17 = textureatlassprite.getInterpolatedV((double)(8.0F + (-f22 + f21) * 16.0F));
f14 = textureatlassprite.getInterpolatedU((double)(8.0F + (-f22 + f21) * 16.0F));
f18 = textureatlassprite.getInterpolatedV((double)(8.0F + (f22 + f21) * 16.0F));
f15 = textureatlassprite.getInterpolatedU((double)(8.0F + (f22 + f21) * 16.0F));
f19 = textureatlassprite.getInterpolatedV((double)(8.0F + (f22 - f21) * 16.0F));
f16 = textureatlassprite.getInterpolatedU((double)(8.0F + (f22 - f21) * 16.0F));
f20 = textureatlassprite.getInterpolatedV((double)(8.0F + (-f22 - f21) * 16.0F));
}
int k2 = blockliquid.getLightmapValue(blockAccess, blockPosIn);
int l2 = k2 >> 16 & 65535;
int i3 = k2 & 65535;
float f24 = f4;
float f25 = f4;
float f26 = f4;
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(f24, f25, f26, 1.0F).tex((double)f13, (double)f17).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).color(f24, f25, f26, 1.0F).tex((double)f14, (double)f18).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).color(f24, f25, f26, 1.0F).tex((double)f15, (double)f19).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).color(f24, f25, f26, 1.0F).tex((double)f16, (double)f20).lightmap(l2, i3).endVertex();
if (blockliquid.shouldRenderSides(blockAccess, blockPosIn.up()))
{
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f7, d2 + 0.0D).color(f24, f25, f26, 1.0F).tex((double)f13, (double)f17).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f10, d2 + 0.0D).color(f24, f25, f26, 1.0F).tex((double)f16, (double)f20).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1 + (double)f9, d2 + 1.0D).color(f24, f25, f26, 1.0F).tex((double)f15, (double)f19).lightmap(l2, i3).endVertex();
worldRendererIn.pos(d0 + 0.0D, d1 + (double)f8, d2 + 1.0D).color(f24, f25, f26, 1.0F).tex((double)f14, (double)f18).lightmap(l2, i3).endVertex();
}
}
if (flag1)
{
float f35 = atextureatlassprite[0].getMinU();
float f36 = atextureatlassprite[0].getMaxU();
float f37 = atextureatlassprite[0].getMinV();
float f38 = atextureatlassprite[0].getMaxV();
int l1 = blockliquid.getLightmapValue(blockAccess, blockPosIn.down());
int i2 = l1 >> 16 & 65535;
int j2 = l1 & 65535;
worldRendererIn.pos(d0, d1, d2 + 1.0D).color(f3, f3, f3, 1.0F).tex((double)f35, (double)f38).lightmap(i2, j2).endVertex();
worldRendererIn.pos(d0, d1, d2).color(f3, f3, f3, 1.0F).tex((double)f35, (double)f37).lightmap(i2, j2).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1, d2).color(f3, f3, f3, 1.0F).tex((double)f36, (double)f37).lightmap(i2, j2).endVertex();
worldRendererIn.pos(d0 + 1.0D, d1, d2 + 1.0D).color(f3, f3, f3, 1.0F).tex((double)f36, (double)f38).lightmap(i2, j2).endVertex();
flag2 = true;
}
for (int i1 = 0; i1 < 4; ++i1)
{
int j1 = 0;
int k1 = 0;
if (i1 == 0)
{
--k1;
}
if (i1 == 1)
{
++k1;
}
if (i1 == 2)
{
--j1;
}
if (i1 == 3)
{
++j1;
}
BlockPos blockpos = blockPosIn.add(j1, 0, k1);
Sprite textureatlassprite1 = atextureatlassprite[1];
if (aboolean[i1])
{
float f39;
float f40;
double d3;
double d4;
double d5;
double d6;
if (i1 == 0)
{
f39 = f7;
f40 = f10;
d3 = d0;
d5 = d0 + 1.0D;
d4 = d2 + (double)f11;
d6 = d2 + (double)f11;
}
else if (i1 == 1)
{
f39 = f9;
f40 = f8;
d3 = d0 + 1.0D;
d5 = d0;
d4 = d2 + 1.0D - (double)f11;
d6 = d2 + 1.0D - (double)f11;
}
else if (i1 == 2)
{
f39 = f8;
f40 = f7;
d3 = d0 + (double)f11;
d5 = d0 + (double)f11;
d4 = d2 + 1.0D;
d6 = d2;
}
else
{
f39 = f10;
f40 = f9;
d3 = d0 + 1.0D - (double)f11;
d5 = d0 + 1.0D - (double)f11;
d4 = d2;
d6 = d2 + 1.0D;
}
flag2 = true;
float f41 = textureatlassprite1.getInterpolatedU(0.0D);
float f27 = textureatlassprite1.getInterpolatedU(8.0D);
float f28 = textureatlassprite1.getInterpolatedV((double)((1.0F - f39) * 16.0F * 0.5F));
float f29 = textureatlassprite1.getInterpolatedV((double)((1.0F - f40) * 16.0F * 0.5F));
float f30 = textureatlassprite1.getInterpolatedV(8.0D);
int j = blockliquid.getLightmapValue(blockAccess, blockpos);
int k = j >> 16 & 65535;
int l = j & 65535;
float f31 = i1 < 2 ? f5 : f6;
float f32 = f4 * f31;
float f33 = f4 * f31;
float f34 = f4 * f31;
worldRendererIn.pos(d3, d1 + (double)f39, d4).color(f32, f33, f34, 1.0F).tex((double)f41, (double)f28).lightmap(k, l).endVertex();
worldRendererIn.pos(d5, d1 + (double)f40, d6).color(f32, f33, f34, 1.0F).tex((double)f27, (double)f29).lightmap(k, l).endVertex();
worldRendererIn.pos(d5, d1 + 0.0D, d6).color(f32, f33, f34, 1.0F).tex((double)f27, (double)f30).lightmap(k, l).endVertex();
worldRendererIn.pos(d3, d1 + 0.0D, d4).color(f32, f33, f34, 1.0F).tex((double)f41, (double)f30).lightmap(k, l).endVertex();
worldRendererIn.pos(d3, d1 + 0.0D, d4).color(f32, f33, f34, 1.0F).tex((double)f41, (double)f30).lightmap(k, l).endVertex();
worldRendererIn.pos(d5, d1 + 0.0D, d6).color(f32, f33, f34, 1.0F).tex((double)f27, (double)f30).lightmap(k, l).endVertex();
worldRendererIn.pos(d5, d1 + (double)f40, d6).color(f32, f33, f34, 1.0F).tex((double)f27, (double)f29).lightmap(k, l).endVertex();
worldRendererIn.pos(d3, d1 + (double)f39, d4).color(f32, f33, f34, 1.0F).tex((double)f41, (double)f28).lightmap(k, l).endVertex();
}
}
return flag2;
}
}
private float getFluidHeight(IBlockAccess blockAccess, BlockPos blockPosIn)
{
int i = 0;
float f = 0.0F;
for (int j = 0; j < 4; ++j)
{
BlockPos blockpos = blockPosIn.add(-(j & 1), 0, -(j >> 1 & 1));
if (blockAccess.getState(blockpos.up()).getBlock().getMaterial().isLiquid())
{
return 1.0F;
}
State iblockstate = blockAccess.getState(blockpos);
Material material = iblockstate.getBlock().getMaterial();
if (!material.isLiquid())
{
if (!material.isSolid())
{
++f;
++i;
}
}
else
{
int k = ((Integer)iblockstate.getValue(BlockLiquid.LEVEL)).intValue();
if (k >= 8 || k == 0)
{
f += BlockLiquid.getLiquidHeightPercent(k) * 10.0F;
i += 10;
}
f += BlockLiquid.getLiquidHeightPercent(k);
++i;
}
}
return 1.0F - f / (float)i;
}
}

View file

@ -709,7 +709,7 @@ public class EffectRenderer {
}
protected Icon(double x, double y, double z, State state, boolean hit) {
this(x, y, z, hit ? 0.6f : 1.0f, Client.CLIENT.getBlockRendererDispatcher().getModelManager().getTexture(state));
this(x, y, z, hit ? 0.6f : 1.0f, Client.CLIENT.renderer.getModelManager().getTexture(state));
this.gravity = 1.0F;
this.red = this.green = this.blue = 0.6F;
if(hit) {

File diff suppressed because it is too large Load diff

View file

@ -414,7 +414,7 @@ public class ItemRenderer
if (iblockstate.getBlock() != Blocks.air)
{
this.renderBlockInside(partialTicks, this.gm.getBlockRendererDispatcher().getModelManager().getTexture(iblockstate));
this.renderBlockInside(partialTicks, this.gm.renderer.getModelManager().getTexture(iblockstate));
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -7,7 +7,7 @@ import common.util.ExtMath;
public class ViewFrustum
{
protected final RenderGlobal renderGlobal;
protected final Renderer renderGlobal;
protected final Client gm;
protected int countChunksY;
protected int countChunksX;
@ -18,7 +18,7 @@ public class ViewFrustum
return i < 0 ? -((-i - 1) / 16) - 1 : i / 16;
}
public ViewFrustum(Client worldIn, int renderDistanceChunks, RenderGlobal p_i46246_3_)
public ViewFrustum(Client worldIn, int renderDistanceChunks, Renderer p_i46246_3_)
{
this.renderGlobal = p_i46246_3_;
this.gm = worldIn;

View file

@ -11,11 +11,10 @@ import java.util.concurrent.locks.ReentrantLock;
import org.lwjgl.opengl.GL11;
import client.Client;
import client.renderer.BlockRenderer;
import client.renderer.DefaultVertexFormats;
import client.renderer.Renderer;
import client.renderer.RegionRenderCache;
import client.renderer.RenderBuffer;
import client.renderer.RenderGlobal;
import client.renderer.VertexBuffer;
import client.renderer.tileentity.SpecialRenderer;
import client.renderer.tileentity.ElementRenderer;
@ -33,7 +32,7 @@ import common.world.State;
public class RenderChunk
{
private Client gm;
private final RenderGlobal renderGlobal;
private final Renderer renderGlobal;
public static int renderChunksUpdated;
private BlockPos position;
public CompiledChunk compiledChunk = CompiledChunk.DUMMY;
@ -49,7 +48,7 @@ public class RenderChunk
private boolean needsUpdate = true;
private EnumMap<Facing, BlockPos> mapEnumFacing = Maps.newEnumMap(Facing.class);
public RenderChunk(Client worldIn, RenderGlobal renderGlobalIn, BlockPos blockPosIn, int indexIn)
public RenderChunk(Client worldIn, Renderer renderGlobalIn, BlockPos blockPosIn, int indexIn)
{
this.gm = worldIn;
this.renderGlobal = renderGlobalIn;
@ -141,7 +140,7 @@ public class RenderChunk
{
++renderChunksUpdated;
boolean[] aboolean = new boolean[BlockLayer.values().length];
BlockRenderer blockrendererdispatcher = this.gm.getBlockRendererDispatcher();
Renderer renderer = this.gm.renderer;
for (BlockPos.MutableBlockPos blockpos$mutableblockpos : BlockPos.getAllInBoxMutable(blockpos, blockpos1))
{
@ -181,7 +180,7 @@ public class RenderChunk
this.preRenderBlocks(worldrenderer, blockpos);
}
aboolean[idx] |= blockrendererdispatcher.renderBlock(iblockstate, blockpos$mutableblockpos, iblockaccess, worldrenderer);
aboolean[idx] |= renderer.renderBlock(iblockstate, blockpos$mutableblockpos, iblockaccess, worldrenderer);
}
}

View file

@ -3,7 +3,6 @@ package client.renderer.entity;
import org.lwjgl.opengl.GL11;
import client.Client;
import client.renderer.BlockRenderer;
import client.renderer.texture.TextureMap;
import common.entity.Entity;
import common.world.State;
@ -28,7 +27,6 @@ public class RenderBlockEntity extends Render<Entity>
// if(entity.isInvisible()) {
// return;
// }
BlockRenderer blockrendererdispatcher = Client.CLIENT.getBlockRendererDispatcher();
GL11.glPushMatrix();
GL11.glTranslatef((float)x, (float)y + 0.5F, (float)z);
@ -45,7 +43,7 @@ public class RenderBlockEntity extends Render<Entity>
// float f2 = (1.0F - ((float)entity.fuse - partialTicks + 1.0F) / 100.0F) * 0.8F;
this.bindEntityTexture(entity);
GL11.glTranslatef(-0.5F, -0.5F, 0.5F);
blockrendererdispatcher.renderBlockEntity(state, entity.getBrightness(partialTicks));
Client.CLIENT.renderer.renderBlockEntity(this.state, entity.getBrightness(partialTicks));
GL11.glTranslatef(0.0F, 0.0F, 1.0F);
// if (entity.fuse / 5 % 2 == 0)

View file

@ -3,10 +3,10 @@ package client.renderer.entity;
import org.lwjgl.opengl.GL11;
import client.Client;
import client.renderer.BlockRenderer;
import client.renderer.DefaultVertexFormats;
import client.renderer.GlState;
import client.renderer.RenderBuffer;
import client.renderer.Renderer;
import client.renderer.Tessellator;
import client.renderer.blockmodel.IBakedModel;
import client.renderer.texture.TextureMap;
@ -33,27 +33,27 @@ public class RenderFallingBlock extends Render<EntityFalling>
if (entity.getBlock() != null)
{
this.bindTexture(TextureMap.BLOCKS);
State iblockstate = entity.getBlock();
Block block = iblockstate.getBlock();
BlockPos blockpos = new BlockPos(entity);
State state = entity.getBlock();
Block block = state.getBlock();
BlockPos pos = new BlockPos(entity);
World world = entity.getWorldObj();
if (iblockstate != world.getState(blockpos) && block != Blocks.air && !block.getMaterial().isLiquid())
if (state != world.getState(pos) && block != Blocks.air && !block.getMaterial().isLiquid())
{
GL11.glPushMatrix();
GL11.glTranslatef((float)x, (float)y, (float)z);
GlState.disableLighting();
// Tessellator tessellator = Tessellator.getInstance();
RenderBuffer worldrenderer = Tessellator.getBuffer();
worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
int i = blockpos.getX();
int j = blockpos.getY();
int k = blockpos.getZ();
worldrenderer.setTranslation((double)((float)(-i) - 0.5F), (double)(-j), (double)((float)(-k) - 0.5F));
BlockRenderer blockrendererdispatcher = Client.CLIENT.getBlockRendererDispatcher();
IBakedModel ibakedmodel = blockrendererdispatcher.getModelFromBlockState(iblockstate, world, (BlockPos)null);
blockrendererdispatcher.renderModel(world, ibakedmodel, iblockstate, blockpos, worldrenderer, false);
worldrenderer.setTranslation(0.0D, 0.0D, 0.0D);
RenderBuffer rb = Tessellator.getBuffer();
rb.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK);
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
rb.setTranslation((double)((float)(-i) - 0.5F), (double)(-j), (double)((float)(-k) - 0.5F));
Renderer renderer = Client.CLIENT.renderer;
IBakedModel model = renderer.getBlockModel(state, world, null);
renderer.renderModel(world, model, state, pos, rb, false);
rb.setTranslation(0.0D, 0.0D, 0.0D);
Tessellator.draw();
GlState.enableLighting();
GL11.glPopMatrix();

View file

@ -9,9 +9,9 @@ import client.Client;
import client.init.RenderRegistry;
import client.renderer.DefaultVertexFormats;
import client.renderer.Drawing;
import client.renderer.Renderer;
import client.renderer.GlState;
import client.renderer.RenderBuffer;
import client.renderer.RenderGlobal;
import client.renderer.Tessellator;
import client.renderer.texture.Sprite;
import client.renderer.texture.TextureManager;
@ -24,36 +24,15 @@ import common.util.BoundingBox;
import common.util.Vec3;
import common.world.World;
public class RenderManager
{
// private class Overlay {
// private final int x;
// private final int y;
// private final String str;
//
// private Overlay(int x, int y, String str) {
// this.x = x;
// this.y = y;
// this.str = str;
// }
// }
public class RenderManager {
private Map<Class<? extends Entity>, Render<? extends Entity>> entityRenderMap = Maps.<Class<? extends Entity>, Render<? extends Entity>>newHashMap();
private Map<ModelType, RenderNpc> models = Maps.newEnumMap(ModelType.class);
// private final List<Overlay> overlays = Lists.newArrayList();
/** Renders fonts */
// private FontRenderer textRenderer;
private double renderPosX;
private double renderPosY;
private double renderPosZ;
public TextureManager renderEngine;
/** Reference to the World object. */
public World worldObj;
/** Rendermanager's variable for the player */
public Entity livingPlayer;
public Entity pointedEntity;
public float playerViewY;
@ -63,55 +42,26 @@ public class RenderManager
public double viewerPosY;
public double viewerPosZ;
private boolean renderOutlines = false;
// private boolean renderShadow = true;
/** whether bounding box should be rendered or not */
private boolean debugBoundingBox = false;
public RenderManager(TextureManager renderEngineIn, RenderItem itemRendererIn)
{
public RenderManager(TextureManager renderEngineIn, RenderItem itemRendererIn) {
this.renderEngine = renderEngineIn;
RenderRegistry.registerRenderers(this.entityRenderMap, this.models, this, itemRendererIn);
for(RenderNpc render : this.models.values()) {
render.initSegments();
}
// this.playerRenderer = new RenderPlayer(this);
}
// public void addOverlay(double x, double y, double z, String str) {
// Vec3 vec = ActiveRenderInfo.getDisplayCoords((float)x, (float)y, (float)z);
// this.overlays.add(new Overlay((int)vec.xCoord, this.gm.fb_y - 1 - (int)vec.yCoord, str));
// }
//
// public void drawOverlays(boolean render) {
// if(render)
// for(Overlay overlay : this.overlays) {
// this.drawOverlay(overlay.str, overlay.x, overlay.y);
// }
// this.overlays.clear();
// }
// private void drawOverlay(String text, int x, int y) {
// int w, h;
// Vec2i size = Drawing.txt_size(0, 0, 0, 0, 65536, 65536, Font.DEFAULT, text);
// x -= size.xpos / 2;
// y -= size.ypos;
// Drawing.txt_draw(x, y, x, y, x + 440, y + 260, 0xffffffff, 0x3f000000, Font.DEFAULT, text);
// }
public void setRenderPosition(double renderPosXIn, double renderPosYIn, double renderPosZIn)
{
public void setRenderPosition(double renderPosXIn, double renderPosYIn, double renderPosZIn) {
this.renderPosX = renderPosXIn;
this.renderPosY = renderPosYIn;
this.renderPosZ = renderPosZIn;
}
private <T extends Entity> Render<T> getEntityClassRenderObject(Class <? extends Entity > entityClass)
{
private <T extends Entity> Render<T> getEntityClassRenderObject(Class<? extends Entity> entityClass) {
Render<? extends Entity> render = (Render)this.entityRenderMap.get(entityClass);
if (render == null && entityClass != Entity.class)
{
if(render == null && entityClass != Entity.class) {
render = this.<Entity>getEntityClassRenderObject((Class<? extends Entity>)entityClass.getSuperclass());
this.entityRenderMap.put(entityClass, render);
}
@ -119,63 +69,23 @@ public class RenderManager
return (Render<T>)render;
}
// private <T extends EntityLiving> Render<T> getLivingRenderObject(Class <? extends EntityLiving > entityClass)
// {
// if(EntityNPCClient.class.isAssignableFrom(entityClass)) {
// return (Render<T>)this.playerRenderer;
// }
// Render <? extends EntityLiving > render = (Render)this.entityRenderMap.get(entityClass);
// if (render == null && entityClass != EntityLiving.class)
// {
// render = this.<EntityLiving>getLivingRenderObject((Class <? extends EntityLiving >)entityClass.getSuperclass());
// }
// return (Render<T>)render;
// }
private <T extends Entity> Render<T> getEntityRenderObject(Entity entityIn)
{
// if (entityIn.isPlayer())
// {
// return (Render<T>)this.models.get(((EntityNPC)entityIn).getModel());
// }
// else
// {
private <T extends Entity> Render<T> getEntityRenderObject(Entity entityIn) {
return this.<T>getEntityClassRenderObject(entityIn.getClass());
// }
}
public RenderNpc getRenderObject(ModelType model) {
return this.models.get(model);
}
public void cacheActiveRenderInfo(World worldIn, Entity livingPlayerIn, Entity pointedEntityIn, Client optionsIn, float partialTicks)
{
public void cacheActiveRenderInfo(World worldIn, Entity livingPlayerIn, Entity pointedEntityIn, Client optionsIn, float partialTicks) {
this.worldObj = worldIn;
this.gm = optionsIn;
this.livingPlayer = livingPlayerIn;
this.pointedEntity = pointedEntityIn;
// this.textRenderer = textRendererIn;
// if (livingPlayerIn instanceof EntityLivingBase && ((EntityLivingBase)livingPlayerIn).isPlayerSleeping())
// {
// IBlockState iblockstate = worldIn.getBlockState(new BlockPos(livingPlayerIn));
// Block block = iblockstate.getBlock();
//
// if (block instanceof BlockBed)
// {
// int i = ((EnumFacing)iblockstate.getValue(BlockBed.FACING)).getHorizontalIndex();
// this.playerViewY = (float)(i * 90 + 180);
// this.playerViewX = 0.0F;
// }
// }
// else
// {
this.playerViewY = livingPlayerIn.prevYaw + (livingPlayerIn.rotYaw - livingPlayerIn.prevYaw) * partialTicks;
this.playerViewX = livingPlayerIn.prevPitch + (livingPlayerIn.rotPitch - livingPlayerIn.prevPitch) * partialTicks;
// }
if (optionsIn.thirdPersonView == 2)
{
if(optionsIn.thirdPersonView == 2) {
this.playerViewY += 180.0F;
}
@ -184,41 +94,33 @@ public class RenderManager
this.viewerPosZ = livingPlayerIn.lastTickPosZ + (livingPlayerIn.posZ - livingPlayerIn.lastTickPosZ) * (double)partialTicks;
}
public void setPlayerViewY(float playerViewYIn)
{
public void setPlayerViewY(float playerViewYIn) {
this.playerViewY = playerViewYIn;
}
// public boolean isRenderShadow()
// {
// return this.renderShadow;
// }
//
// public void setRenderShadow(boolean renderShadowIn)
// {
// this.renderShadow = renderShadowIn;
// }
public void setDebugBoundingBox(boolean debugBoundingBoxIn)
{
public void setDebugBoundingBox(boolean debugBoundingBoxIn) {
this.debugBoundingBox = debugBoundingBoxIn;
}
public boolean isDebugBoundingBox()
{
public boolean isDebugBoundingBox() {
return this.debugBoundingBox;
}
public boolean shouldRender(Entity entityIn, double camX, double camY, double camZ)
{
public void set(World worldIn) {
this.worldObj = worldIn;
}
public void setRenderOutlines(boolean renderOutlinesIn) {
this.renderOutlines = renderOutlinesIn;
}
public boolean shouldRender(Entity entityIn, double camX, double camY, double camZ) {
Render<Entity> render = this.<Entity>getEntityRenderObject(entityIn);
return render != null && render.shouldRender(entityIn, camX, camY, camZ);
}
public boolean renderEntity(Entity entity, float partialTicks)
{
if (entity.ticksExisted == 0)
{
public boolean renderEntity(Entity entity, float partialTicks) {
if(entity.ticksExisted == 0) {
entity.lastTickPosX = entity.posX;
entity.lastTickPosY = entity.posY;
entity.lastTickPosZ = entity.posZ;
@ -227,11 +129,9 @@ public class RenderManager
double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partialTicks;
double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partialTicks;
double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)partialTicks;
// float f = entity.prevYaw + (entity.rotYaw - entity.prevYaw) * partialTicks;
int i = entity.getBrightnessForRender(partialTicks);
if (entity.isBurning())
{
if(entity.isBurning()) {
i = 15728880;
}
@ -242,21 +142,17 @@ public class RenderManager
return this.renderEntity(entity, d0 - this.renderPosX, d1 - this.renderPosY, d2 - this.renderPosZ, partialTicks);
}
public boolean renderEntity(Entity entity, double x, double y, double z, float partialTicks)
{
public boolean renderEntity(Entity entity, double x, double y, double z, float partialTicks) {
Render<Entity> render = this.<Entity>getEntityRenderObject(entity);
if (render != null && this.renderEngine != null)
{
if (render instanceof RendererLivingEntity)
{
if(render != null && this.renderEngine != null) {
if(render instanceof RendererLivingEntity) {
((RendererLivingEntity)render).setRenderOutlines(this.renderOutlines);
}
render.doRender(entity, x, y, z, partialTicks);
if (!this.renderOutlines && this.gm != null && entity.canRenderOnFire())
{
if(!this.renderOutlines && this.gm != null && entity.canRenderOnFire()) {
this.renderEntityFire(entity, x, y, z);
}
@ -265,8 +161,7 @@ public class RenderManager
this.renderDebugBoundingBox(entity, x, y, z, partialTicks);
}
}
else if (this.renderEngine != null)
{
else if(this.renderEngine != null) {
return false;
}
@ -298,8 +193,7 @@ public class RenderManager
GL11.glPopMatrix();
}
private void renderEntityFire(Entity entity, double x, double y, double z)
{
private void renderEntityFire(Entity entity, double x, double y, double z) {
GlState.disableLighting();
TextureMap map = this.gm.getTextureMapBlocks();
Sprite layer0 = map.getAtlasSprite("blocks/fire_layer_0");
@ -320,8 +214,7 @@ public class RenderManager
int i = 0;
rb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
while (f3 > 0.0F)
{
while(f3 > 0.0F) {
Sprite layer = i % 2 == 0 ? layer0 : layer1;
this.renderEngine.bindTexture(TextureMap.BLOCKS);
float f6 = layer.getMinU();
@ -329,8 +222,7 @@ public class RenderManager
float f8 = layer.getMaxU();
float f9 = layer.getMaxV();
if (i / 2 % 2 == 0)
{
if(i / 2 % 2 == 0) {
float f10 = f8;
f8 = f6;
f6 = f10;
@ -352,8 +244,7 @@ public class RenderManager
GlState.enableLighting();
}
private void renderDebugBoundingBox(Entity entityIn, double x, double y, double z, float partialTicks)
{
private void renderDebugBoundingBox(Entity entityIn, double x, double y, double z, float partialTicks) {
GlState.depthMask(false);
GlState.disableTexture2D();
GlState.disableLighting();
@ -361,16 +252,16 @@ public class RenderManager
GlState.disableBlend();
float f = entityIn.width / 2.0F;
BoundingBox axisalignedbb = entityIn.getEntityBoundingBox();
BoundingBox axisalignedbb1 = new BoundingBox(axisalignedbb.minX - entityIn.posX + x, axisalignedbb.minY - entityIn.posY + y, axisalignedbb.minZ - entityIn.posZ + z, axisalignedbb.maxX - entityIn.posX + x, axisalignedbb.maxY - entityIn.posY + y, axisalignedbb.maxZ - entityIn.posZ + z);
RenderGlobal.drawOutlinedBoundingBox(axisalignedbb1, 255, 255, 255, 255);
BoundingBox axisalignedbb1 = new BoundingBox(axisalignedbb.minX - entityIn.posX + x, axisalignedbb.minY - entityIn.posY + y, axisalignedbb.minZ - entityIn.posZ + z,
axisalignedbb.maxX - entityIn.posX + x, axisalignedbb.maxY - entityIn.posY + y, axisalignedbb.maxZ - entityIn.posZ + z);
Renderer.drawOutlinedBoundingBox(axisalignedbb1, 255, 255, 255, 255);
if (entityIn instanceof EntityLiving)
{
if(entityIn instanceof EntityLiving) {
float f1 = 0.01F;
RenderGlobal.drawOutlinedBoundingBox(new BoundingBox(x - (double)f, y + (double)entityIn.getEyeHeight() - 0.009999999776482582D, z - (double)f, x + (double)f, y + (double)entityIn.getEyeHeight() + 0.009999999776482582D, z + (double)f), 255, 0, 0, 255);
Renderer.drawOutlinedBoundingBox(new BoundingBox(x - (double)f, y + (double)entityIn.getEyeHeight() - 0.009999999776482582D, z - (double)f, x + (double)f,
y + (double)entityIn.getEyeHeight() + 0.009999999776482582D, z + (double)f), 255, 0, 0, 255);
}
// Tessellator tessellator = Tessellator.getInstance();
RenderBuffer worldrenderer = Tessellator.getBuffer();
Vec3 vec3 = entityIn.getLook(partialTicks);
worldrenderer.begin(GL11.GL_LINE_STRIP, DefaultVertexFormats.POSITION_COLOR);
@ -385,7 +276,7 @@ public class RenderManager
}
public boolean renderBox(Entity entity, float partialTicks) {
if(this.debugBoundingBox) { // && !entity.isInvisible()) {
if(this.debugBoundingBox) {
if(entity.ticksExisted == 0) {
entity.lastTickPosX = entity.posX;
entity.lastTickPosY = entity.posY;
@ -399,33 +290,4 @@ public class RenderManager
}
return false;
}
/**
* World sets this RenderManager's worldObj to the world provided
*/
public void set(World worldIn)
{
this.worldObj = worldIn;
}
// public double getDistanceToCamera(double x, double y, double z)
// {
// double d0 = x - this.viewerPosX;
// double d1 = y - this.viewerPosY;
// double d2 = z - this.viewerPosZ;
// return d0 * d0 + d1 * d1 + d2 * d2;
// }
// /**
// * Returns the font renderer
// */
// public FontRenderer getFontRenderer()
// {
// return this.textRenderer;
// }
public void setRenderOutlines(boolean renderOutlinesIn)
{
this.renderOutlines = renderOutlinesIn;
}
}

View file

@ -124,7 +124,7 @@ public class RenderMinecart<T extends EntityCart> extends Render<T>
protected void func_180560_a(T minecart, float partialTicks, State state)
{
GL11.glPushMatrix();
Client.CLIENT.getBlockRendererDispatcher().renderBlockEntity(state, minecart.getBrightness(partialTicks));
Client.CLIENT.renderer.renderBlockEntity(state, minecart.getBrightness(partialTicks));
GL11.glPopMatrix();
}
}

View file

@ -3,7 +3,6 @@ package client.renderer.entity;
import org.lwjgl.opengl.GL11;
import client.Client;
import client.renderer.BlockRenderer;
import client.renderer.GlState;
import common.entity.item.EntityTntCart;
import common.init.Blocks;
@ -35,14 +34,13 @@ public class RenderTntMinecart extends RenderMinecart<EntityTntCart>
if (i > -1 && i / 5 % 2 == 0)
{
BlockRenderer blockrendererdispatcher = Client.CLIENT.getBlockRendererDispatcher();
GlState.disableTexture2D();
GlState.disableLighting();
GlState.enableBlend();
GlState.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA);
GlState.color(1.0F, 1.0F, 1.0F, (1.0F - ((float)i - partialTicks + 1.0F) / 100.0F) * 0.8F);
GL11.glPushMatrix();
blockrendererdispatcher.renderBlockEntity(Blocks.tnt.getState(), 1.0F);
Client.CLIENT.renderer.renderBlockEntity(Blocks.tnt.getState(), 1.0F);
GL11.glPopMatrix();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
GlState.disableBlend();

View file

@ -3,8 +3,8 @@ package client.renderer.entity;
import org.lwjgl.opengl.GL11;
import client.Client;
import client.renderer.BlockRenderer;
import client.renderer.GlState;
import client.renderer.Renderer;
import client.renderer.texture.TextureMap;
import common.block.Block;
import common.entity.item.EntityTnt;
@ -21,7 +21,7 @@ public class RenderTntPrimed extends Render<EntityTnt>
public void doRender(EntityTnt entity, double x, double y, double z, float partialTicks)
{
BlockRenderer blockrendererdispatcher = Client.CLIENT.getBlockRendererDispatcher();
Renderer renderer = Client.CLIENT.renderer;
GL11.glPushMatrix();
GL11.glTranslatef((float)x, (float)y + 0.5F, (float)z);
@ -39,7 +39,7 @@ public class RenderTntPrimed extends Render<EntityTnt>
this.bindEntityTexture(entity);
GL11.glTranslatef(-0.5F, -0.5F, 0.5F);
Block tnt = BlockRegistry.byName("tnt" + (entity.explosionSize <= 0 || entity.explosionSize >= 8 ? "" : "_" + entity.explosionSize));
blockrendererdispatcher.renderBlockEntity(tnt.getState(), entity.getBrightness(partialTicks));
renderer.renderBlockEntity(tnt.getState(), entity.getBrightness(partialTicks));
GL11.glTranslatef(0.0F, 0.0F, 1.0F);
if (entity.fuse / 5 % 2 == 0)
@ -51,7 +51,7 @@ public class RenderTntPrimed extends Render<EntityTnt>
GlState.color(1.0F, 1.0F, 1.0F, f2);
GlState.doPolygonOffset(-3.0F, -3.0F);
GlState.enablePolygonOffset();
blockrendererdispatcher.renderBlockEntity(tnt.getState(), 1.0F);
renderer.renderBlockEntity(tnt.getState(), 1.0F);
GlState.doPolygonOffset(0.0F, 0.0F);
GlState.disablePolygonOffset();
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);

View file

@ -109,7 +109,7 @@ public class PlayerController {
this.stack = this.gm.player.getHeldItem();
this.damage = 0.0F;
this.stepCounter = 0.0F;
this.gm.renderGlobal.sendBlockBreakProgress(this.gm.player.getId(), this.position, (int)(this.damage * 10.0F) - 1);
this.gm.renderer.setBreakProgress(this.gm.player.getId(), this.position, (int)(this.damage * 10.0F) - 1);
}
}
@ -122,7 +122,7 @@ public class PlayerController {
this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.ABORT_DESTROY_BLOCK, this.position, Facing.DOWN));
this.hitting = false;
this.damage = 0.0F;
this.gm.renderGlobal.sendBlockBreakProgress(this.gm.player.getId(), this.position, -1);
this.gm.renderer.setBreakProgress(this.gm.player.getId(), this.position, -1);
}
}
@ -165,7 +165,7 @@ public class PlayerController {
this.delay = 5;
}
this.gm.renderGlobal.sendBlockBreakProgress(this.gm.player.getId(), this.position, (int)(this.damage * 10.0F) - 1);
this.gm.renderer.setBreakProgress(this.gm.player.getId(), this.position, (int)(this.damage * 10.0F) - 1);
return true;
}
}