add color, support for multiple faces
This commit is contained in:
parent
b32276278e
commit
bcd5fdd962
42
src/main/java/io/github/cottonmc/slopetest/SpriteSet.java
Normal file
42
src/main/java/io/github/cottonmc/slopetest/SpriteSet.java
Normal file
@ -0,0 +1,42 @@
|
||||
package io.github.cottonmc.slopetest;
|
||||
|
||||
import net.minecraft.client.render.model.BakedModel;
|
||||
import net.minecraft.client.render.model.BakedQuad;
|
||||
import net.minecraft.client.texture.Sprite;
|
||||
import net.minecraft.util.math.Direction;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
public class SpriteSet {
|
||||
Sprite global;
|
||||
Map<Direction, BakedQuad> quads = new HashMap<>();
|
||||
boolean singleSprite = false;
|
||||
boolean globalHasColor = false;
|
||||
|
||||
public SpriteSet(Sprite allSprite, boolean hasColor) {
|
||||
this.global = allSprite;
|
||||
singleSprite = true;
|
||||
globalHasColor = hasColor;
|
||||
}
|
||||
|
||||
public SpriteSet(BakedModel model) {
|
||||
Random rand = new Random();
|
||||
for (Direction dir : Direction.values()) {
|
||||
List<BakedQuad> quads = model.getQuads(null, dir, rand);
|
||||
this.quads.put(dir, quads.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
public Sprite getSprite(Direction dir) {
|
||||
if (singleSprite) return global;
|
||||
else return quads.get(dir).getSprite();
|
||||
}
|
||||
|
||||
public boolean hasColor(Direction dir) {
|
||||
if (singleSprite) return globalHasColor;
|
||||
else return quads.get(dir).hasColor();
|
||||
}
|
||||
}
|
@ -1,10 +1,13 @@
|
||||
package io.github.cottonmc.slopetest.block.entity.render;
|
||||
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import io.github.cottonmc.slopetest.SpriteSet;
|
||||
import io.github.cottonmc.slopetest.block.entity.SlopeTestEntity;
|
||||
import net.fabricmc.fabric.api.client.render.ColorProviderRegistry;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.color.block.BlockColorProvider;
|
||||
import net.minecraft.client.render.BufferBuilder;
|
||||
import net.minecraft.client.render.Tessellator;
|
||||
import net.minecraft.client.render.VertexFormats;
|
||||
@ -30,154 +33,172 @@ public class SlopeTestRenderer extends BlockEntityRenderer<SlopeTestEntity> {
|
||||
renderManager.textureManager.bindTexture(SpriteAtlasTexture.BLOCK_ATLAS_TEX);
|
||||
BlockState state = getWorld().getBlockState(be.getPos());
|
||||
Direction dir = state.get(Properties.HORIZONTAL_FACING);
|
||||
Sprite sprite;
|
||||
SpriteSet sprites;
|
||||
int color = 0xffffff;
|
||||
if (be.getRenderedBlock() != Blocks.AIR) {
|
||||
BlockState blockDefaultState = be.getRenderedBlock().getDefaultState();
|
||||
BakedModel model = minecraft.getBlockRenderManager().getModel(blockDefaultState);
|
||||
sprite = model.getSprite();
|
||||
} else {
|
||||
sprite = minecraft.getSpriteAtlas().getSprite("minecraft:block/scaffolding_top");
|
||||
sprites = new SpriteSet(model);
|
||||
BlockColorProvider blockColor = ColorProviderRegistry.BLOCK.get(be.getRenderedBlock());
|
||||
if (blockColor != null) {
|
||||
color = blockColor.getColor(blockDefaultState, be.getWorld(), be.getPos(), 1);
|
||||
}
|
||||
} else {
|
||||
sprites = new SpriteSet(minecraft.getSpriteAtlas().getSprite("minecraft:block/scaffolding_top"), false);
|
||||
}
|
||||
if (sprite != null) {
|
||||
buffer.begin(GL11.GL_QUADS, VertexFormats.POSITION_UV_COLOR);
|
||||
drawSlope(dir, sprite, buffer);
|
||||
drawLeftSide(dir, sprite, buffer);
|
||||
drawRightSide(dir, sprite, buffer);
|
||||
drawBack(dir, sprite, buffer);
|
||||
drawBottom(sprite, buffer);
|
||||
drawSlope(dir, sprites.getSprite(Direction.UP), buffer, sprites.hasColor(Direction.UP)? color : 0xffffff);
|
||||
drawLeftSide(dir, sprites.getSprite(dir.rotateYCounterclockwise()), buffer, sprites.hasColor(dir.rotateYCounterclockwise())? color : 0xffffff);
|
||||
drawRightSide(dir, sprites.getSprite(dir.rotateYClockwise()), buffer, sprites.hasColor(dir.rotateYClockwise())? color: 0xffffff);
|
||||
drawBack(dir, sprites.getSprite(dir), buffer, sprites.hasColor(dir)? color : 0xffffff);
|
||||
drawBottom(sprites.getSprite(Direction.DOWN), buffer, sprites.hasColor(Direction.DOWN)? color : 0xffffff);
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
tessellator.draw();
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableAlphaTest();
|
||||
}
|
||||
buffer.setOffset(0.0d, 0.0d, 0.0d);
|
||||
super.render(be, x, y, z, partialTicks, destroyStage);
|
||||
}
|
||||
|
||||
public static void drawSlope(Direction dir, Sprite sprite, BufferBuilder buffer) {
|
||||
public static void drawSlope(Direction dir, Sprite sprite, BufferBuilder buffer, int color) {
|
||||
float r = (float)(color >> 16 & 255) / 255.0F;
|
||||
float g = (float)(color >> 8 & 255) / 255.0F;
|
||||
float b = (float)(color & 255) / 255.0F;
|
||||
switch (dir) {
|
||||
case NORTH:
|
||||
buffer.vertex(0f, 1f, 0f).texture(sprite.getMinU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMinU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 1f, 0f).texture(sprite.getMaxU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 1f, 0f).texture(sprite.getMinU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMinU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 1f, 0f).texture(sprite.getMaxU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
break;
|
||||
case SOUTH:
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 1f, 1f).texture(sprite.getMaxU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 1f, 1f).texture(sprite.getMinU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMinU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 1f, 1f).texture(sprite.getMaxU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 1f, 1f).texture(sprite.getMinU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMinU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
break;
|
||||
case EAST:
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMinU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 1f, 1f).texture(sprite.getMaxU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 1f, 0f).texture(sprite.getMinU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMinU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 1f, 1f).texture(sprite.getMaxU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 1f, 0f).texture(sprite.getMinU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
break;
|
||||
case WEST:
|
||||
buffer.vertex(0f, 1f, 0f).texture(sprite.getMaxU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 1f, 1f).texture(sprite.getMinU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMinU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 1f, 0f).texture(sprite.getMaxU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 1f, 1f).texture(sprite.getMinU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMinU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawLeftSide(Direction dir, Sprite sprite, BufferBuilder buffer) {
|
||||
public static void drawLeftSide(Direction dir, Sprite sprite, BufferBuilder buffer, int color) {
|
||||
float r = (float)(color >> 16 & 255) / 255.0F;
|
||||
float g = (float)(color >> 8 & 255) / 255.0F;
|
||||
float b = (float)(color & 255) / 255.0F;
|
||||
switch(dir) {
|
||||
case NORTH:
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMinU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 1f, 0f).texture(sprite.getMinU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMinU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 1f, 0f).texture(sprite.getMinU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
break;
|
||||
case SOUTH:
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 1f, 1f).texture(sprite.getMinU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMinU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 1f, 1f).texture(sprite.getMinU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMinU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
break;
|
||||
case EAST:
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMinU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 1f, 0f).texture(sprite.getMinU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMinU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 1f, 0f).texture(sprite.getMinU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
break;
|
||||
case WEST:
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMinU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 1f, 1f).texture(sprite.getMinU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMinU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 1f, 1f).texture(sprite.getMinU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawRightSide(Direction dir, Sprite sprite, BufferBuilder buffer) {
|
||||
public static void drawRightSide(Direction dir, Sprite sprite, BufferBuilder buffer, int color) {
|
||||
float r = (float)(color >> 16 & 255) / 255.0F;
|
||||
float g = (float)(color >> 8 & 255) / 255.0F;
|
||||
float b = (float)(color & 255) / 255.0F;
|
||||
switch(dir) {
|
||||
case NORTH:
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 1f, 0f).texture(sprite.getMaxU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMinU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMinU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 1f, 0f).texture(sprite.getMaxU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMinU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMinU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
break;
|
||||
case SOUTH:
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMinU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMinU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 1f, 1f).texture(sprite.getMaxU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMinU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMinU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 1f, 1f).texture(sprite.getMaxU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
break;
|
||||
case EAST:
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMinU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMinU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 1f, 1f).texture(sprite.getMaxU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMinU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMinU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 1f, 1f).texture(sprite.getMaxU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
break;
|
||||
case WEST:
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 1f, 0f).texture(sprite.getMaxU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMinU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMinU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 1f, 0f).texture(sprite.getMaxU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMinU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMinU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawBack(Direction dir, Sprite sprite, BufferBuilder buffer) {
|
||||
public static void drawBack(Direction dir, Sprite sprite, BufferBuilder buffer, int color) {
|
||||
float r = (float)(color >> 16 & 255) / 255.0F;
|
||||
float g = (float)(color >> 8 & 255) / 255.0F;
|
||||
float b = (float)(color & 255) / 255.0F;
|
||||
switch(dir) {
|
||||
case NORTH:
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 1f, 0f).texture(sprite.getMaxU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 1f, 0f).texture(sprite.getMinU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMinU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 1f, 0f).texture(sprite.getMaxU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 1f, 0f).texture(sprite.getMinU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMinU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
break;
|
||||
case SOUTH:
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMinU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 1f, 1f).texture(sprite.getMaxU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 1f, 1f).texture(sprite.getMinU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMinU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 1f, 1f).texture(sprite.getMaxU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 1f, 1f).texture(sprite.getMinU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
break;
|
||||
case EAST:
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 1f, 0f).texture(sprite.getMaxU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 1f, 1f).texture(sprite.getMinU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMinU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 1f, 0f).texture(sprite.getMaxU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 1f, 1f).texture(sprite.getMinU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMinU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
break;
|
||||
case WEST:
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMinU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 1f, 1f).texture(sprite.getMaxU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 1f, 0f).texture(sprite.getMinU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMinU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 1f, 1f).texture(sprite.getMaxU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 1f, 0f).texture(sprite.getMinU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void drawBottom(Sprite sprite, BufferBuilder buffer) {
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMinU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMaxV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMinU(), sprite.getMinV()).color(1f, 1f, 1f, 1f).next();
|
||||
public static void drawBottom(Sprite sprite, BufferBuilder buffer, int color) {
|
||||
float r = (float)(color >> 16 & 255) / 255.0F;
|
||||
float g = (float)(color >> 8 & 255) / 255.0F;
|
||||
float b = (float)(color & 255) / 255.0F;
|
||||
buffer.vertex(0f, 0f, 0f).texture(sprite.getMinU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 0f, 0f).texture(sprite.getMaxU(), sprite.getMaxV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(1f, 0f, 1f).texture(sprite.getMaxU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
buffer.vertex(0f, 0f, 1f).texture(sprite.getMinU(), sprite.getMinV()).color(r, g, b, 1f).next();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user