Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected override void RenderTile(int index) {
- if (BlockInfo.Draw[curBlock] == DrawType.Sprite) {
- this.fullBright = BlockInfo.FullBright[curBlock];
- this.tinted = BlockInfo.Tinted[curBlock];
- int count = counts[index + Side.Top];
- if (count != 0) DrawSprite(count);
- return;
- }
- int leftCount = counts[index++], rightCount = counts[index++],
- frontCount = counts[index++], backCount = counts[index++],
- bottomCount = counts[index++], topCount = counts[index++];
- if (leftCount == 0 && rightCount == 0 && frontCount == 0 &&
- backCount == 0 && bottomCount == 0 && topCount == 0) return;
- bool fullBright = BlockInfo.FullBright[curBlock];
- bool isTranslucent = BlockInfo.Draw[curBlock] == DrawType.Translucent;
- bool isLava = IsBlockLiquid(curBlock);
- #if ALPHA
- bool isCactus = (curBlock == Block.Cactus);
- bool isRedstone = (curBlock == Block.Redstone);
- bool isRedstoneTorch = (curBlock == Block.RedstoneTorchOn);
- bool leftRedstone = (game.World.SafeGetBlock(X + 1, Y, Z) == Block.Redstone);
- bool rightRedstone = (game.World.SafeGetBlock(X - 1, Y, Z) == Block.Redstone);
- bool frontRedstone = (game.World.SafeGetBlock(X, Y, Z + 1) == Block.Redstone);
- bool backRedstone = (game.World.SafeGetBlock(X, Y, Z - 1) == Block.Redstone);
- #endif
- int lightFlags = BlockInfo.LightOffset[curBlock];
- drawer.minBB = BlockInfo.MinBB[curBlock]; drawer.minBB.Y = 1 - drawer.minBB.Y;
- drawer.maxBB = BlockInfo.MaxBB[curBlock]; drawer.maxBB.Y = 1 - drawer.maxBB.Y;
- Vector3 min = BlockInfo.RenderMinBB[curBlock], max = BlockInfo.RenderMaxBB[curBlock];
- drawer.x1 = X + min.X; drawer.y1 = Y + min.Y; drawer.z1 = Z + min.Z;
- drawer.x2 = X + max.X; drawer.y2 = Y + max.Y; drawer.z2 = Z + max.Z;
- drawer.Tinted = BlockInfo.Tinted[curBlock];
- drawer.TintColour = BlockInfo.FogColour[curBlock];
- if (leftCount != 0) {
- int texLoc = BlockInfo.textures[curBlock * Side.Sides + Side.Left];
- int i = texLoc / elementsPerAtlas1D;
- int offset = (lightFlags >> Side.Left) & 1;
- DrawInfo part;
- if (isLava && !isTranslucent) {
- part = liquidParts[i];
- } else {
- part = isTranslucent ? translucentParts[i] : normalParts[i];
- }
- #if ALPHA
- if (isCactus) {
- drawer.z1 -= 1/16f;
- drawer.z2 += 1/16f;
- drawer.minBB.Z -= 1/16f;
- drawer.maxBB.Z += 1/16f;
- } else if (isRedstoneTorch) {
- drawer.z1 -= 1/16f;
- drawer.z2 += 1/16f;
- drawer.y2 += 1/16f;
- drawer.minBB.Z -= 1/16f;
- drawer.maxBB.Z += 1/16f;
- drawer.maxBB.Y -= 1/16f;
- }
- #endif
- int col = fullBright ? FastColour.WhitePacked :
- X >= offset ? light.LightCol_XSide_Fast(X - offset, Y, Z) : light.OutsideXSide;
- drawer.Left(leftCount, col, texLoc, part.vertices, ref part.vIndex[Side.Left]);
- /*drawer.z1 += 1;
- drawer.z2 += 1;
- drawer.Left(leftCount, col, texLoc, part.vertices, ref part.vIndex[Side.Left]);
- drawer.z1 -= 1;
- drawer.z2 -= 1;*/
- #if ALPHA
- if (isCactus) {
- drawer.z1 += 1/16f;
- drawer.z2 -= 1/16f;
- drawer.minBB.Z += 1/16f;
- drawer.maxBB.Z -= 1/16f;
- } else if (isRedstoneTorch) {
- drawer.z1 += 1/16f;
- drawer.z2 -= 1/16f;
- drawer.y2 -= 1/16f;
- drawer.minBB.Z += 1/16f;
- drawer.maxBB.Z -= 1/16f;
- drawer.maxBB.Y += 1/16f;
- }
- #endif
- }
- if (rightCount != 0) {
- int texLoc = BlockInfo.textures[curBlock * Side.Sides + Side.Right];
- int i = texLoc / elementsPerAtlas1D;
- int offset = (lightFlags >> Side.Right) & 1;
- DrawInfo part;
- if (isLava && !isTranslucent) {
- part = liquidParts[i];
- } else {
- part = isTranslucent ? translucentParts[i] : normalParts[i];
- }
- #if ALPHA
- if (isCactus) {
- drawer.z1 -= 1/16f;
- drawer.z2 += 1/16f;
- drawer.minBB.Z -= 1/16f;
- drawer.maxBB.Z += 1/16f;
- } else if (isRedstoneTorch) {
- drawer.z1 -= 1/16f;
- drawer.z2 += 1/16f;
- drawer.y2 += 1/16f;
- drawer.minBB.Z -= 1/16f;
- drawer.maxBB.Z += 1/16f;
- drawer.maxBB.Y -= 1/16f;
- }
- #endif
- int col = fullBright ? FastColour.WhitePacked :
- X <= (maxX - offset) ? light.LightCol_XSide_Fast(X + offset, Y, Z) : light.OutsideXSide;
- drawer.Right(rightCount, col, texLoc, part.vertices, ref part.vIndex[Side.Right]);
- #if ALPHA
- if (isCactus) {
- drawer.z1 += 1/16f;
- drawer.z2 -= 1/16f;
- drawer.minBB.Z += 1/16f;
- drawer.maxBB.Z -= 1/16f;
- } else if (isRedstoneTorch) {
- drawer.z1 += 1/16f;
- drawer.z2 -= 1/16f;
- drawer.y2 -= 1/16f;
- drawer.minBB.Z += 1/16f;
- drawer.maxBB.Z -= 1/16f;
- drawer.maxBB.Y += 1/16f;
- }
- #endif
- }
- if (frontCount != 0) {
- int texLoc = BlockInfo.textures[curBlock * Side.Sides + Side.Front];
- int i = texLoc / elementsPerAtlas1D;
- int offset = (lightFlags >> Side.Front) & 1;
- DrawInfo part;
- if (isLava && !isTranslucent) {
- part = liquidParts[i];
- } else {
- part = isTranslucent ? translucentParts[i] : normalParts[i];
- }
- #if ALPHA
- if (isCactus) {
- drawer.x1 -= 1/16f;
- drawer.x2 += 1/16f;
- drawer.minBB.X -= 1/16f;
- drawer.maxBB.X += 1/16f;
- } else if (isRedstoneTorch) {
- drawer.x1 -= 1/16f;
- drawer.x2 += 1/16f;
- drawer.y2 += 1/16f;
- drawer.minBB.X -= 1/16f;
- drawer.maxBB.X += 1/16f;
- drawer.maxBB.Y -= 1/16f;
- }
- #endif
- int col = fullBright ? FastColour.WhitePacked :
- Z >= offset ? light.LightCol_ZSide_Fast(X, Y, Z - offset) : light.OutsideZSide;
- drawer.Front(frontCount, col, texLoc, part.vertices, ref part.vIndex[Side.Front]);
- #if ALPHA
- if (isCactus) {
- drawer.x1 += 1/16f;
- drawer.x2 -= 1/16f;
- drawer.minBB.X += 1/16f;
- drawer.maxBB.X -= 1/16f;
- } else if (isRedstoneTorch) {
- drawer.x1 += 1/16f;
- drawer.x2 -= 1/16f;
- drawer.y2 -= 1/16f;
- drawer.minBB.X += 1/16f;
- drawer.maxBB.X -= 1/16f;
- drawer.maxBB.Y += 1/16f;
- }
- #endif
- }
- if (backCount != 0) {
- int texLoc = BlockInfo.textures[curBlock * Side.Sides + Side.Back];
- int i = texLoc / elementsPerAtlas1D;
- int offset = (lightFlags >> Side.Back) & 1;
- DrawInfo part;
- if (isLava && !isTranslucent) {
- part = liquidParts[i];
- } else {
- part = isTranslucent ? translucentParts[i] : normalParts[i];
- }
- #if ALPHA
- if (isCactus) {
- drawer.x1 -= 1/16f;
- drawer.x2 += 1/16f;
- drawer.minBB.X -= 1/16f;
- drawer.maxBB.X += 1/16f;
- } else if (isRedstoneTorch) {
- drawer.x1 -= 1/16f;
- drawer.x2 += 1/16f;
- drawer.y2 += 1/16f;
- drawer.minBB.X -= 1/16f;
- drawer.maxBB.X += 1/16f;
- drawer.maxBB.Y -= 1/16f;
- }
- #endif
- int col = fullBright ? FastColour.WhitePacked :
- Z <= (maxZ - offset) ? light.LightCol_ZSide_Fast(X, Y, Z + offset) : light.OutsideZSide;
- drawer.Back(backCount, col, texLoc, part.vertices, ref part.vIndex[Side.Back]);
- #if ALPHA
- if (isCactus) {
- drawer.x1 += 1/16f;
- drawer.x2 -= 1/16f;
- drawer.minBB.X += 1/16f;
- drawer.maxBB.X -= 1/16f;
- } else if (isRedstoneTorch) {
- drawer.x1 += 1/16f;
- drawer.x2 -= 1/16f;
- drawer.y2 -= 1/16f;
- drawer.minBB.X += 1/16f;
- drawer.maxBB.X -= 1/16f;
- drawer.maxBB.Y += 1/16f;
- }
- #endif
- }
- if (bottomCount != 0) {
- int texLoc = BlockInfo.textures[curBlock * Side.Sides + Side.Bottom];
- int i = texLoc / elementsPerAtlas1D;
- int offset = (lightFlags >> Side.Bottom) & 1;
- DrawInfo part;
- if (isLava && !isTranslucent) {
- part = liquidParts[i];
- } else {
- part = isTranslucent ? translucentParts[i] : normalParts[i];
- }
- int col = fullBright ? FastColour.WhitePacked : light.LightCol_YBottom_Fast(X, Y - offset, Z);
- drawer.Bottom(bottomCount, col, texLoc, part.vertices, ref part.vIndex[Side.Bottom]);
- }
- if (topCount != 0) {
- int texLoc = BlockInfo.textures[curBlock * Side.Sides + Side.Top];
- int i = texLoc / elementsPerAtlas1D;
- int offset = (lightFlags >> Side.Top) & 1;
- DrawInfo part;
- if (isLava && !isTranslucent) {
- part = liquidParts[i];
- } else {
- part = isTranslucent ? translucentParts[i] : normalParts[i];
- }
- #if ALPHA
- if (isRedstoneTorch || curBlock == Block.RedstoneTorchOff || curBlock == Block.Torch) {
- drawer.minBB.Z -= 1/16f;
- drawer.maxBB.Z -= 1/16f;
- } else if (isRedstone) {
- int numRedstone = (leftRedstone? 1:0) + (rightRedstone? 1:0) + (frontRedstone? 1:0) +
- (backRedstone? 1:0);
- if (numRedstone == 2) {
- Console.WriteLine("line");
- Console.WriteLine(rightRedstone);
- Console.WriteLine(leftRedstone);
- Console.WriteLine(X);
- if (leftRedstone) {
- drawer.maxBB.X -= 5/16f;
- drawer.x2 -= 5/16f;
- }
- }
- }
- #endif
- int col = fullBright ? FastColour.WhitePacked : light.LightCol_YTop_Fast(X, (Y + 1) - offset, Z);
- drawer.Top(topCount, col, texLoc, part.vertices, ref part.vIndex[Side.Top]);
- #if ALPHA
- if (isRedstoneTorch || curBlock == Block.RedstoneTorchOff || curBlock == Block.Torch) {
- drawer.minBB.Z += 1/16f;
- drawer.maxBB.Z += 1/16f;
- } else if (isRedstone) {
- int numRedstone = (leftRedstone? 1:0) + (rightRedstone? 1:0) + (frontRedstone? 1:0) +
- (backRedstone? 1:0);
- if (numRedstone == 2) {
- if (leftRedstone) {
- drawer.maxBB.X += 5/16f;
- drawer.x2 += 5/16f;
- }
- }
- }
- #endif
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement