add RUDIMENTARY displays
This commit is contained in:
parent
f6b036b517
commit
e18a151f6c
31 changed files with 795 additions and 483 deletions
|
@ -960,32 +960,31 @@ public class Client implements IThreadListener {
|
|||
|
||||
public void renderHud() {
|
||||
this.setupOverlay();
|
||||
if(this.world != null && this.open == null && this.thirdPersonView == 0 && this.viewEntity != null) {
|
||||
if(this.drawDebug) {
|
||||
this.renderWorldDirections((float)this.tick_fraction);
|
||||
}
|
||||
else if(this.crosshairSize > 0) {
|
||||
Drawing.drawRect(this.fb_x / 2 - 1, this.fb_y / 2 - this.crosshairSize, 2, this.crosshairSize * 2, this.pointed != null && this.pointed.type != ObjectType.MISS ? this.crosshairColorTarget : this.crosshairColorBase);
|
||||
Drawing.drawRect(this.fb_x / 2 - this.crosshairSize, this.fb_y / 2 - 1, this.crosshairSize * 2, 2, this.pointed != null && this.pointed.type != ObjectType.MISS ? this.crosshairColorTarget : this.crosshairColorBase);
|
||||
}
|
||||
}
|
||||
if(this.world != null && this.open == null) {
|
||||
int selected = // this.getRenderViewEntity() != null && this.getRenderViewEntity().isPlayer() ? 9 : 0,
|
||||
this.getRenderViewEntity() != null && this.getRenderViewEntity().isPlayer() ?
|
||||
((EntityNPC)this.getRenderViewEntity()).inventory.currentItem : -1;
|
||||
for(int n = 0; n < 9; n++) {
|
||||
int x = this.fb_x / 2 - 180 + n * 40 + 4;
|
||||
int y = this.fb_y - 40;
|
||||
// Drawing.drawRect2Border(x - 1, y - 1, 36, 36, 0xff6f6f6f, selected == n ? 0xffffffff : 0xffafafaf);
|
||||
Drawing.drawRectBorder(x - 1, y - 1, 36, 36, 0xff6f6f6f, selected == n ? 0xffffffff : 0xff000000, 0xffafafaf, 0xff4f4f4f);
|
||||
}
|
||||
if(this.world != null && !(this.open instanceof GuiConsole) && this.player != null && this.viewEntity == this.player) {
|
||||
if(this.open == null) {
|
||||
if(this.thirdPersonView == 0) {
|
||||
if(this.drawDebug) {
|
||||
this.renderWorldDirections((float)this.tick_fraction);
|
||||
}
|
||||
else if(this.crosshairSize > 0) {
|
||||
Drawing.drawRect(this.fb_x / 2 - 1, this.fb_y / 2 - this.crosshairSize, 2, this.crosshairSize * 2, this.pointed != null && this.pointed.type != ObjectType.MISS ? this.crosshairColorTarget : this.crosshairColorBase);
|
||||
Drawing.drawRect(this.fb_x / 2 - this.crosshairSize, this.fb_y / 2 - 1, this.crosshairSize * 2, 2, this.pointed != null && this.pointed.type != ObjectType.MISS ? this.crosshairColorTarget : this.crosshairColorBase);
|
||||
}
|
||||
}
|
||||
|
||||
int selected = this.player.inventory.currentItem;
|
||||
for(int n = 0; n < 9; n++) {
|
||||
int x = this.fb_x / 2 - 180 + n * 40 + 4;
|
||||
int y = this.fb_y - 40;
|
||||
Drawing.drawRectBorder(x - 1, y - 1, 36, 36, 0xff6f6f6f, selected == n ? 0xffffffff : 0xff000000, 0xffafafaf, 0xff4f4f4f);
|
||||
}
|
||||
|
||||
ItemStack itemstack = this.player != null ? this.player.inventory.getCurrentItem() : null;
|
||||
String current = itemstack != null ? itemstack.getItem().getHotbarText(this.player, itemstack) : "";
|
||||
if(!current.isEmpty())
|
||||
Drawing.drawTextUpward(current, this.fb_x / 2, this.fb_y - 60, 0xffffffff);
|
||||
}
|
||||
if(this.world != null && !(this.open instanceof GuiConsole)) {
|
||||
ItemStack itemstack = this.player.inventory.getCurrentItem();
|
||||
String current = itemstack != null ? itemstack.getItem().getHotbarText(this.player, itemstack) : "";
|
||||
if(!current.isEmpty())
|
||||
Drawing.drawTextUpward(current, this.fb_x / 2, this.fb_y - 60, 0xffffffff);
|
||||
}
|
||||
|
||||
int x = this.fb_x / 2;
|
||||
int y = 0;
|
||||
Iterator<Entry<Integer, Long>> iter = this.bars.entrySet().iterator();
|
||||
|
@ -1011,7 +1010,7 @@ public class Client implements IThreadListener {
|
|||
}
|
||||
}
|
||||
|
||||
if(this.player != null && (!this.drawDebug || this.open != null)) {
|
||||
if(!this.drawDebug || this.open != null) {
|
||||
x = 40;
|
||||
y = 40;
|
||||
for(PotionEffect effect : this.player.getEffects()) {
|
||||
|
@ -1028,61 +1027,50 @@ public class Client implements IThreadListener {
|
|||
}
|
||||
}
|
||||
|
||||
if(this.getRenderViewEntity() instanceof EntityLiving) {
|
||||
EntityLiving entity = (EntityLiving)this.getRenderViewEntity();
|
||||
int absorb = entity.getAbsorptionAmount();
|
||||
int armor = entity.getTotalArmorValue();
|
||||
int stats = 1 + (absorb > 0 ? 1 : 0) + (armor > 0 ? 1 : 0) + (entity.vehicle instanceof EntityLiving ? 1 : 0)
|
||||
+ (entity instanceof EntityNPC npc && npc.getManaPoints() > 0 ? 1 : 0);
|
||||
for(Energy energy : Energy.values()) {
|
||||
if(entity.getEnergy(energy) > 0)
|
||||
stats += 1;
|
||||
}
|
||||
x = this.fb_x - 40 - 250;
|
||||
y = this.fb_y - 40 - stats * 40;
|
||||
int hp = entity.getHealth();
|
||||
int max = entity.getMaxHealth();
|
||||
y = stats(x, y, TextColor.RED + "Schaden", hp, max, 0xff0000);
|
||||
if(absorb > 0)
|
||||
y = stats(x, y, TextColor.YELLOW + "Schadenspuffer", absorb, 1024, 0xffff00);
|
||||
if(armor > 0)
|
||||
y = stats(x, y, TextColor.GRAY + "Rüstung", armor, 1024, 0x707070);
|
||||
if(entity.vehicle instanceof EntityLiving) {
|
||||
EntityLiving living = (EntityLiving)entity.vehicle;
|
||||
int vh = living.getHealth();
|
||||
int vhMax = living.getMaxHealth();
|
||||
y = stats(x, y, living.getDisplayName() /* + " (Reittier)" */, vh, vhMax, 0xff6060);
|
||||
}
|
||||
if(entity instanceof EntityNPC npc && npc.getManaPoints() > 0) {
|
||||
int mana = npc.getManaPoints();
|
||||
int maxm = npc.getMaxMana();
|
||||
y = stats(x, y, TextColor.CYAN + "Mana", mana, maxm, 0x0000ff);
|
||||
}
|
||||
for(int z = 0; z < Energy.values().length; z++) {
|
||||
Energy type = Energy.values()[z];
|
||||
int energy = entity.getEnergy(type);
|
||||
if(energy > 0) {
|
||||
int emax = entity.getEnergyCap(type);
|
||||
y = stats(x, y, TextColor.LGRAY + type.display, energy, emax, entity.hasEnergyEffect(type) ? type.effect : type.color);
|
||||
}
|
||||
EntityNPC entity = this.player;
|
||||
int absorb = entity.getAbsorptionAmount();
|
||||
int armor = entity.getTotalArmorValue();
|
||||
int stats = 1 + (absorb > 0 ? 1 : 0) + (armor > 0 ? 1 : 0) + (entity.vehicle instanceof EntityLiving ? 1 : 0)
|
||||
+ (entity instanceof EntityNPC npc && npc.getManaPoints() > 0 ? 1 : 0);
|
||||
for(Energy energy : Energy.values()) {
|
||||
if(entity.getEnergy(energy) > 0)
|
||||
stats += 1;
|
||||
}
|
||||
x = this.fb_x - 40 - 250;
|
||||
y = this.fb_y - 40 - stats * 40;
|
||||
int hp = entity.getHealth();
|
||||
int max = entity.getMaxHealth();
|
||||
y = stats(x, y, TextColor.RED + "Schaden", hp, max, 0xff0000);
|
||||
if(absorb > 0)
|
||||
y = stats(x, y, TextColor.YELLOW + "Schadenspuffer", absorb, 1024, 0xffff00);
|
||||
if(armor > 0)
|
||||
y = stats(x, y, TextColor.GRAY + "Rüstung", armor, 1024, 0x707070);
|
||||
if(entity.vehicle instanceof EntityLiving) {
|
||||
EntityLiving living = (EntityLiving)entity.vehicle;
|
||||
int vh = living.getHealth();
|
||||
int vhMax = living.getMaxHealth();
|
||||
y = stats(x, y, living.getDisplayName() /* + " (Reittier)" */, vh, vhMax, 0xff6060);
|
||||
}
|
||||
if(entity instanceof EntityNPC npc && npc.getManaPoints() > 0) {
|
||||
int mana = npc.getManaPoints();
|
||||
int maxm = npc.getMaxMana();
|
||||
y = stats(x, y, TextColor.CYAN + "Mana", mana, maxm, 0x0000ff);
|
||||
}
|
||||
for(int z = 0; z < Energy.values().length; z++) {
|
||||
Energy type = Energy.values()[z];
|
||||
int energy = entity.getEnergy(type);
|
||||
if(energy > 0) {
|
||||
int emax = entity.getEnergyCap(type);
|
||||
y = stats(x, y, TextColor.LGRAY + type.display, energy, emax, entity.hasEnergyEffect(type) ? type.effect : type.color);
|
||||
}
|
||||
}
|
||||
|
||||
if(this.player != null) {
|
||||
x = 40;
|
||||
y = this.fb_y - 40 - (this.player.isRidingHorse() && this.player.getHorseJumpPower() != 0.0f ? 2 : 1) * 40;
|
||||
if(this.player.isRidingHorse() && this.player.getHorseJumpPower() != 0.0f) // {
|
||||
y = bar(x, y, String.format(TextColor.NEON + "Sprungkraft: " + TextColor.CYAN + "%d %%", (int)(this.player.getHorseJumpPower() * 100.0f)),
|
||||
this.player.getHorseJumpPower(), 0x4040ff);
|
||||
// }
|
||||
// else {
|
||||
y = bar(x, y, String.format(TextColor.ACID + "EXP: " + TextColor.GREEN + "Level %d, %d/%d", this.player.experienceLevel, (int)((float)this.player.xpBarCap() * this.player.experience), this.player.xpBarCap()), this.player.experience, 0x40ff40);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
// SKC.pointed(this.pointed != null && this.pointed.type != ObjectType.MISS);
|
||||
// SKC.crosshair(this.thirdPersonView == 0);
|
||||
|
||||
x = 40;
|
||||
y = this.fb_y - 40 - (this.player.isRidingHorse() && this.player.getHorseJumpPower() != 0.0f ? 2 : 1) * 40;
|
||||
if(this.player.isRidingHorse() && this.player.getHorseJumpPower() != 0.0f) // {
|
||||
y = bar(x, y, String.format(TextColor.NEON + "Sprungkraft: " + TextColor.CYAN + "%d %%", (int)(this.player.getHorseJumpPower() * 100.0f)),
|
||||
this.player.getHorseJumpPower(), 0x4040ff);
|
||||
y = bar(x, y, String.format(TextColor.ACID + "EXP: " + TextColor.GREEN + "Level %d, %d/%d", this.player.experienceLevel, (int)((float)this.player.xpBarCap() * this.player.experience), this.player.xpBarCap()), this.player.experience, 0x40ff40);
|
||||
}
|
||||
|
||||
// gdr.shader = 0;
|
||||
|
@ -1098,8 +1086,7 @@ public class Client implements IThreadListener {
|
|||
GlState.setActiveTexture(GL13.GL_TEXTURE0);
|
||||
GlState.enableTexture2D();
|
||||
// GlState.disableDepth();
|
||||
if(this.open == null && this.getRenderViewEntity() != null && this.getRenderViewEntity().isPlayer()) {
|
||||
EntityNPC player = (EntityNPC)this.getRenderViewEntity();
|
||||
if(this.world != null && this.open == null && this.player != null && this.viewEntity == this.player) {
|
||||
GlState.enableRescaleNormal();
|
||||
GlState.enableBlend();
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
@ -1113,7 +1100,7 @@ public class Client implements IThreadListener {
|
|||
for(int index = 0; index < 9; ++index) {
|
||||
int xPos = index * 20;
|
||||
// int yPos = this.fb_y - 40;
|
||||
ItemStack itemstack = player.inventory.mainInventory[index];
|
||||
ItemStack itemstack = this.player.inventory.mainInventory[index];
|
||||
if(itemstack != null) {
|
||||
GlState.enableDepth();
|
||||
this.renderItem.renderItemAndEffectIntoGUI(itemstack, xPos, 0);
|
||||
|
@ -1135,10 +1122,9 @@ public class Client implements IThreadListener {
|
|||
// java_check_exc();
|
||||
GlState.disableDepth();
|
||||
// SKC.foreground();
|
||||
if(this.open == null && this.getRenderViewEntity() != null && this.getRenderViewEntity().isPlayer()) {
|
||||
EntityNPC player = (EntityNPC)this.getRenderViewEntity();
|
||||
if(this.world != null && this.open == null && this.player != null && this.viewEntity == this.player) {
|
||||
for(int index = 0; index < 9; ++index) {
|
||||
ItemStack itemstack = player.inventory.mainInventory[index];
|
||||
ItemStack itemstack = this.player.inventory.mainInventory[index];
|
||||
if(itemstack != null) {
|
||||
GuiContainer.renderItemOverlay(itemstack,
|
||||
this.fb_x / 2 - 180 + 4 + 1 + index * 40, this.fb_y - 40 + 1, null);
|
||||
|
@ -1158,9 +1144,19 @@ public class Client implements IThreadListener {
|
|||
this.drawOverlay(this.chat, this.chatSize, true, -1, this.fb_x, this.fb_y);
|
||||
}
|
||||
if(this.drawFps) { // && !(this.open instanceof GuiConsole)
|
||||
if(this.drawDebug && this.open == null) {
|
||||
this.renderStats();
|
||||
this.renderLagometer();
|
||||
if(this.drawDebug) {
|
||||
if(this.open == null) {
|
||||
this.renderStats();
|
||||
this.renderLagometer();
|
||||
}
|
||||
else {
|
||||
Drawing.drawText(String.format("%s%.2f" + TextColor.RESET + " %s [%s" + TextColor.RESET + "], %.3f ms, W %d x %d%s",
|
||||
this.framecode(), this.framerate < 1.0f ? 1.0f / this.framerate : this.framerate, this.framerate < 1.0f ? "SPF" : "FPS",
|
||||
this.vsync ? TextColor.DGRAY + "VSYNC" : (this.syncLimited ? TextColor.GREEN + "" + this.syncLimit : TextColor.RED + "UNL"),
|
||||
(float)PerfSection.getTotal(false) / 1000.0f, this.fb_raw_x, this.fb_raw_y,
|
||||
this.fullscreen ? " @ " + (this.vidMode == null ? "?" : this.vidMode.refresh()) + " Hz" : ""),
|
||||
0, 0, 0xffffffff);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Drawing.drawText(String.format("%s%.2f", framecode(), this.framerate), 0, 0, 0xffffffff);
|
||||
|
|
|
@ -115,6 +115,7 @@ import common.packet.SPacketSpawnObject;
|
|||
import common.packet.SPacketSpawnPlayer;
|
||||
import common.packet.SPacketTimeUpdate;
|
||||
import common.packet.SPacketTrades;
|
||||
import common.packet.SPacketUpdateDisplay;
|
||||
import common.packet.SPacketUpdateHealth;
|
||||
import common.packet.SPacketWorld;
|
||||
import common.potion.PotionEffect;
|
||||
|
@ -122,6 +123,7 @@ import common.rng.Random;
|
|||
import common.sound.Sound;
|
||||
import common.tileentity.TileEntity;
|
||||
import common.tileentity.TileEntityDevice;
|
||||
import common.tileentity.TileEntityDisplay;
|
||||
import common.tileentity.TileEntitySign;
|
||||
import common.village.MerchantRecipeList;
|
||||
import common.world.Explosion;
|
||||
|
@ -1314,6 +1316,20 @@ public class ClientPlayer implements IClientPlayer
|
|||
// }
|
||||
}
|
||||
|
||||
public void handleUpdateDisplay(SPacketUpdateDisplay packet) {
|
||||
NetHandler.checkThread(packet, this, this.gm, this.world);
|
||||
|
||||
if(this.gm.world.isBlockLoaded(packet.getPos())) {
|
||||
TileEntity tileentity = this.gm.world.getTileEntity(packet.getPos());
|
||||
|
||||
if(tileentity instanceof TileEntityDisplay display) {
|
||||
System.arraycopy(packet.getPixels(), 0, display.data, 0, 256);
|
||||
display.lastUpdated = System.currentTimeMillis();
|
||||
display.markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the metadata of instances of the following entitytypes: Mob spawners, command blocks,
|
||||
* beacons, skulls, flowerpot
|
||||
|
|
|
@ -28,19 +28,6 @@ public abstract class Drawing {
|
|||
this.offset = off;
|
||||
}
|
||||
}
|
||||
|
||||
// public static void drawTexturedModalRect(int tw, int th, int x, int y, int textureX, int textureY, int width, int height)
|
||||
// {
|
||||
// float xs = 1.0f / (float)tw; // 0.00390625F;
|
||||
// float ys = 1.0f / (float)th; // 0.00390625F;
|
||||
// RenderBuffer rb = Tessellator.getBuffer();
|
||||
// rb.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
||||
// rb.pos((double)(x + 0), (double)(y + height), 0.0).tex((double)((float)(textureX + 0) * xs), (double)((float)(textureY + height) * ys)).endVertex();
|
||||
// rb.pos((double)(x + width), (double)(y + height), 0.0).tex((double)((float)(textureX + width) * xs), (double)((float)(textureY + height) * ys)).endVertex();
|
||||
// rb.pos((double)(x + width), (double)(y + 0), 0.0).tex((double)((float)(textureX + width) * xs), (double)((float)(textureY + 0) * ys)).endVertex();
|
||||
// rb.pos((double)(x + 0), (double)(y + 0), 0.0).tex((double)((float)(textureX + 0) * xs), (double)((float)(textureY + 0) * ys)).endVertex();
|
||||
// Tessellator.draw();
|
||||
// }
|
||||
|
||||
public static void txt_draw(int x, int y, int x1, int y1, int x2, int y2, int color, String str) {
|
||||
GlState.enableTexture2D();
|
||||
|
@ -586,4 +573,29 @@ public abstract class Drawing {
|
|||
GlState.disableTexture2D();
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
public static void drawTexturedRect(Client gm, String texture, int texWidth, int texHeight, int x, int y, int u, int v, int width, int height)
|
||||
{
|
||||
GlState.enableTexture2D();
|
||||
// GlState.disableFog();
|
||||
RenderBuffer buf = Tessellator.getBuffer();
|
||||
gm.getTextureManager().bindTexture(texture);
|
||||
// GlState.color(color);
|
||||
float xs = 1.0f / (float)texWidth; // 0.00390625F;
|
||||
float ys = 1.0f / (float)texHeight; // 0.00390625F;
|
||||
buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
||||
buf.pos((double)(x + 0), (double)(y + height), 0.0).tex((double)((float)(u + 0) * xs), (double)((float)(v + height) * ys)).endVertex();
|
||||
buf.pos((double)(x + width), (double)(y + height), 0.0).tex((double)((float)(u + width) * xs), (double)((float)(v + height) * ys)).endVertex();
|
||||
buf.pos((double)(x + width), (double)(y + 0), 0.0).tex((double)((float)(u + width) * xs), (double)((float)(v + 0) * ys)).endVertex();
|
||||
buf.pos((double)(x + 0), (double)(y + 0), 0.0).tex((double)((float)(u + 0) * xs), (double)((float)(v + 0) * ys)).endVertex();
|
||||
// double scale = 32.0;
|
||||
// buf.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
|
||||
// buf.pos((double)x, (double)y + (double)height, 0.0D).tex(0.0D, (double)height / scale).endVertex();
|
||||
// buf.pos((double)x + (double)width, (double)y + (double)height, 0.0D).tex((double)width / scale, (double)height / scale).endVertex();
|
||||
// buf.pos((double)x + (double)width, (double)y, 0.0D).tex((double)width / scale, 0.0).endVertex();
|
||||
// buf.pos((double)x, (double)y, 0.0D).tex(0.0D, 0.0).endVertex();
|
||||
Tessellator.draw();
|
||||
// GlState.disableTexture2D();
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,142 +20,123 @@ import common.util.BlockPos;
|
|||
import common.util.ExtMath;
|
||||
import common.world.State;
|
||||
|
||||
public class TileEntityBannerRenderer extends TileEntitySpecialRenderer<TileEntityBanner>
|
||||
{
|
||||
private static final Map<String, TileEntityBannerRenderer.TimedBannerTexture> DESIGNS = Maps.<String, TileEntityBannerRenderer.TimedBannerTexture>newHashMap();
|
||||
private static final String BANNERTEXTURES = "textures/blocks/banner.png";
|
||||
private ModelBanner bannerModel = new ModelBanner();
|
||||
public class TileEntityBannerRenderer extends TileEntitySpecialRenderer<TileEntityBanner> {
|
||||
private static class TimedTexture {
|
||||
public long time;
|
||||
public String texture;
|
||||
|
||||
public void renderTileEntityAt(TileEntityBanner te, double x, double y, double z, float partialTicks, int destroyStage)
|
||||
{
|
||||
boolean flag = te.getWorld() != null;
|
||||
boolean flag1 = !flag || te.getBlockType() == Blocks.banner;
|
||||
int i = 0;
|
||||
if(flag) {
|
||||
State state = te.getBlockState();
|
||||
if(state.getBlock() == Blocks.banner)
|
||||
i = state.getValue(BlockBannerStanding.ROTATION);
|
||||
}
|
||||
private TimedTexture() {
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<String, TimedTexture> DESIGNS = Maps.<String, TimedTexture>newHashMap();
|
||||
private static final String BANNERTEXTURES = "textures/blocks/banner.png";
|
||||
private ModelBanner bannerModel = new ModelBanner();
|
||||
|
||||
public void renderTileEntityAt(TileEntityBanner te, double x, double y, double z, float partialTicks, int destroyStage) {
|
||||
boolean flag = te.getWorld() != null;
|
||||
boolean flag1 = !flag || te.getBlockType() == Blocks.banner;
|
||||
int i = 0;
|
||||
if(flag) {
|
||||
State state = te.getBlockState();
|
||||
if(state.getBlock() == Blocks.banner)
|
||||
i = state.getValue(BlockBannerStanding.ROTATION);
|
||||
}
|
||||
// long j = flag ? te.getWorld().getTime() : 0L;
|
||||
double j = flag ? (double)(System.nanoTime() / 1000L) / 50000.0 /* te.getWorld().getTime() */ : (double)partialTicks;
|
||||
GL11.glPushMatrix();
|
||||
float f = 0.6666667F;
|
||||
double j = flag ? (double)(System.nanoTime() / 1000L) / 50000.0 /* te.getWorld().getTime() */ : (double)partialTicks;
|
||||
GL11.glPushMatrix();
|
||||
float f = 0.6666667F;
|
||||
|
||||
if (flag1)
|
||||
{
|
||||
GL11.glTranslatef((float)x + 0.5F, (float)y + 0.75F * f, (float)z + 0.5F);
|
||||
float f1 = (float)(i * 360) / 16.0F;
|
||||
GL11.glRotatef(-f1, 0.0F, 1.0F, 0.0F);
|
||||
this.bannerModel.bannerStand.showModel = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
float f2 = 0.0F;
|
||||
if(flag1) {
|
||||
GL11.glTranslatef((float)x + 0.5F, (float)y + 0.75F * f, (float)z + 0.5F);
|
||||
float f1 = (float)(i * 360) / 16.0F;
|
||||
GL11.glRotatef(-f1, 0.0F, 1.0F, 0.0F);
|
||||
this.bannerModel.bannerStand.showModel = true;
|
||||
}
|
||||
else {
|
||||
float f2 = 0.0F;
|
||||
|
||||
if (i == 2)
|
||||
{
|
||||
f2 = 180.0F;
|
||||
}
|
||||
if(i == 2) {
|
||||
f2 = 180.0F;
|
||||
}
|
||||
|
||||
if (i == 4)
|
||||
{
|
||||
f2 = 90.0F;
|
||||
}
|
||||
if(i == 4) {
|
||||
f2 = 90.0F;
|
||||
}
|
||||
|
||||
if (i == 5)
|
||||
{
|
||||
f2 = -90.0F;
|
||||
}
|
||||
if(i == 5) {
|
||||
f2 = -90.0F;
|
||||
}
|
||||
|
||||
GL11.glTranslatef((float)x + 0.5F, (float)y - 0.25F * f, (float)z + 0.5F);
|
||||
GL11.glRotatef(-f2, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(0.0F, -0.3125F, -0.4375F);
|
||||
this.bannerModel.bannerStand.showModel = false;
|
||||
}
|
||||
GL11.glTranslatef((float)x + 0.5F, (float)y - 0.25F * f, (float)z + 0.5F);
|
||||
GL11.glRotatef(-f2, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(0.0F, -0.3125F, -0.4375F);
|
||||
this.bannerModel.bannerStand.showModel = false;
|
||||
}
|
||||
|
||||
BlockPos blockpos = te.getPos();
|
||||
float f3 = (float)(blockpos.getX() * 7 + blockpos.getY() * 9 + blockpos.getZ() * 13) + (float)j; // + partialTicks;
|
||||
this.bannerModel.bannerSlate.rotateAngleX = (-0.0125F + 0.01F * ExtMath.cos(f3 * (float)Math.PI * 0.02F)) * (float)Math.PI;
|
||||
GlState.enableRescaleNormal();
|
||||
String resourcelocation = this.func_178463_a(te);
|
||||
BlockPos blockpos = te.getPos();
|
||||
float f3 = (float)(blockpos.getX() * 7 + blockpos.getY() * 9 + blockpos.getZ() * 13) + (float)j; // + partialTicks;
|
||||
this.bannerModel.bannerSlate.rotateAngleX = (-0.0125F + 0.01F * ExtMath.cos(f3 * (float)Math.PI * 0.02F)) * (float)Math.PI;
|
||||
GlState.enableRescaleNormal();
|
||||
String resourcelocation = this.getTexture(te);
|
||||
|
||||
if (resourcelocation != null)
|
||||
{
|
||||
this.bindTexture(resourcelocation);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(f, -f, -f);
|
||||
this.bannerModel.renderBanner();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
if(resourcelocation != null) {
|
||||
this.bindTexture(resourcelocation);
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScalef(f, -f, -f);
|
||||
this.bannerModel.renderBanner();
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
|
||||
private String func_178463_a(TileEntityBanner bannerObj)
|
||||
{
|
||||
String s = bannerObj.getPatternResourceLocation();
|
||||
private String getTexture(TileEntityBanner te) {
|
||||
String s = te.getPatternResourceLocation();
|
||||
|
||||
if (s.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
TileEntityBannerRenderer.TimedBannerTexture tileentitybannerrenderer$timedbannertexture = (TileEntityBannerRenderer.TimedBannerTexture)DESIGNS.get(s);
|
||||
if(s.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
TimedTexture tex = (TimedTexture)DESIGNS.get(s);
|
||||
|
||||
if (tileentitybannerrenderer$timedbannertexture == null)
|
||||
{
|
||||
if (DESIGNS.size() >= 256)
|
||||
{
|
||||
long i = System.currentTimeMillis();
|
||||
Iterator<String> iterator = DESIGNS.keySet().iterator();
|
||||
if(tex == null) {
|
||||
if(DESIGNS.size() >= 256) {
|
||||
long i = System.currentTimeMillis();
|
||||
Iterator<String> iterator = DESIGNS.keySet().iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
String s1 = (String)iterator.next();
|
||||
TileEntityBannerRenderer.TimedBannerTexture tileentitybannerrenderer$timedbannertexture1 = (TileEntityBannerRenderer.TimedBannerTexture)DESIGNS.get(s1);
|
||||
while(iterator.hasNext()) {
|
||||
String s1 = (String)iterator.next();
|
||||
TimedTexture tileentitybannerrenderer$timedbannertexture1 = (TimedTexture)DESIGNS.get(s1);
|
||||
|
||||
if (i - tileentitybannerrenderer$timedbannertexture1.systemTime > 60000L)
|
||||
{
|
||||
Client.CLIENT.getTextureManager().deleteTexture(tileentitybannerrenderer$timedbannertexture1.bannerTexture);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
if(i - tileentitybannerrenderer$timedbannertexture1.time > 60000L) {
|
||||
Client.CLIENT.getTextureManager().deleteTexture(tileentitybannerrenderer$timedbannertexture1.texture);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
if (DESIGNS.size() >= 256)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if(DESIGNS.size() >= 256) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
List<TileEntityBanner.EnumBannerPattern> list1 = bannerObj.getPatternList();
|
||||
List<DyeColor> list = bannerObj.getColorList();
|
||||
List<String> list2 = Lists.<String>newArrayList();
|
||||
List<TileEntityBanner.EnumBannerPattern> list1 = te.getPatternList();
|
||||
List<DyeColor> list = te.getColorList();
|
||||
List<String> list2 = Lists.<String>newArrayList();
|
||||
|
||||
for (TileEntityBanner.EnumBannerPattern tileentitybanner$enumbannerpattern : list1)
|
||||
{
|
||||
list2.add("textures/blocks/banner_" + tileentitybanner$enumbannerpattern.getPatternName() + ".png");
|
||||
}
|
||||
for(TileEntityBanner.EnumBannerPattern tileentitybanner$enumbannerpattern : list1) {
|
||||
list2.add("textures/blocks/banner_" + tileentitybanner$enumbannerpattern.getPatternName() + ".png");
|
||||
}
|
||||
|
||||
tileentitybannerrenderer$timedbannertexture = new TileEntityBannerRenderer.TimedBannerTexture();
|
||||
tileentitybannerrenderer$timedbannertexture.bannerTexture = s;
|
||||
Client.CLIENT.getTextureManager().loadTexture(tileentitybannerrenderer$timedbannertexture.bannerTexture, new LayeredColorMaskTexture(BANNERTEXTURES, list2, list));
|
||||
DESIGNS.put(s, tileentitybannerrenderer$timedbannertexture);
|
||||
}
|
||||
tex = new TimedTexture();
|
||||
tex.texture = s;
|
||||
Client.CLIENT.getTextureManager().loadTexture(tex.texture, new LayeredColorMaskTexture(BANNERTEXTURES, list2, list));
|
||||
DESIGNS.put(s, tex);
|
||||
}
|
||||
|
||||
tileentitybannerrenderer$timedbannertexture.systemTime = System.currentTimeMillis();
|
||||
return tileentitybannerrenderer$timedbannertexture.bannerTexture;
|
||||
}
|
||||
}
|
||||
|
||||
static class TimedBannerTexture
|
||||
{
|
||||
public long systemTime;
|
||||
public String bannerTexture;
|
||||
|
||||
private TimedBannerTexture()
|
||||
{
|
||||
}
|
||||
}
|
||||
tex.time = System.currentTimeMillis();
|
||||
return tex.texture;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
package client.renderer.tileentity;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import client.Client;
|
||||
import client.renderer.Drawing;
|
||||
import client.renderer.GlState;
|
||||
import client.renderer.texture.DynamicTexture;
|
||||
import common.block.Block;
|
||||
import common.block.tech.BlockDisplay;
|
||||
import common.collect.Maps;
|
||||
import common.tileentity.TileEntityDisplay;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Facing;
|
||||
import common.world.State;
|
||||
|
||||
public class TileEntityDisplayRenderer extends TileEntitySpecialRenderer<TileEntityDisplay> {
|
||||
private static class TimedTexture {
|
||||
public long time;
|
||||
public long updated;
|
||||
public String texture;
|
||||
}
|
||||
|
||||
private static final Map<String, TimedTexture> DISPLAYS = Maps.<String, TimedTexture>newHashMap();
|
||||
|
||||
private static String getTextureLocation(BlockPos pos) {
|
||||
return "display/" + pos.getX() + "," + pos.getY() + "," + pos.getZ();
|
||||
}
|
||||
|
||||
private static String getTexture(TileEntityDisplay te) {
|
||||
String id = getTextureLocation(te.getPos());
|
||||
TimedTexture tex = DISPLAYS.get(id);
|
||||
|
||||
if(tex == null) {
|
||||
if(DISPLAYS.size() >= 256) {
|
||||
long i = System.currentTimeMillis();
|
||||
Iterator<String> iterator = DISPLAYS.keySet().iterator();
|
||||
|
||||
while(iterator.hasNext()) {
|
||||
String oid = iterator.next();
|
||||
TimedTexture ttex = DISPLAYS.get(oid);
|
||||
|
||||
if(i - ttex.time > 60000L) {
|
||||
Client.CLIENT.getTextureManager().deleteTexture(ttex.texture);
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
if(DISPLAYS.size() >= 256) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
tex = new TimedTexture();
|
||||
tex.texture = id;
|
||||
tex.updated = te.lastUpdated;
|
||||
DynamicTexture dtex = new DynamicTexture(16, 16);
|
||||
System.arraycopy(te.data, 0, dtex.getData(), 0, 256);
|
||||
dtex.updateTexture();
|
||||
Client.CLIENT.getTextureManager().loadTexture(tex.texture, dtex);
|
||||
DISPLAYS.put(id, tex);
|
||||
}
|
||||
else if(te.lastUpdated != tex.updated) {
|
||||
tex.updated = te.lastUpdated;
|
||||
if(Client.CLIENT.getTextureManager().getTexture(tex.texture) instanceof DynamicTexture dtex) {
|
||||
System.arraycopy(te.data, 0, dtex.getData(), 0, 256);
|
||||
dtex.updateTexture();
|
||||
}
|
||||
}
|
||||
|
||||
tex.time = System.currentTimeMillis();
|
||||
return tex.texture;
|
||||
}
|
||||
|
||||
public void renderTileEntityAt(TileEntityDisplay te, double x, double y, double z, float partialTicks, int destroyStage) {
|
||||
Block block = te.getBlockType();
|
||||
|
||||
State state = te.getBlockState();
|
||||
Facing dir = state.getBlock() instanceof BlockDisplay ? state.getValue(BlockDisplay.FACING) : Facing.SOUTH;
|
||||
float rot = 0.0F;
|
||||
if(dir == Facing.NORTH)
|
||||
rot = 180.0F;
|
||||
else if(dir == Facing.WEST)
|
||||
rot = 90.0F;
|
||||
else if(dir == Facing.EAST)
|
||||
rot = -90.0F;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float)x + 0.5F, (float)y + 1.0f, (float)z + 0.5F);
|
||||
GL11.glRotatef(-rot, 0.0F, 1.0F, 0.0F);
|
||||
GL11.glTranslatef(-0.5F, 0.0f, -0.5f + 0.0625f + 0.005f);
|
||||
GL11.glScalef(0.0625f, -0.0625f, 0.0625f);
|
||||
|
||||
GlState.disableLighting();
|
||||
Drawing.drawTexturedRect(Client.CLIENT, getTexture(te), 16, 16, 0, 0, 0, 0, 16, 16);
|
||||
GlState.enableLighting();
|
||||
|
||||
GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ import common.entity.Entity;
|
|||
import common.tileentity.TileEntity;
|
||||
import common.tileentity.TileEntityBanner;
|
||||
import common.tileentity.TileEntityChest;
|
||||
import common.tileentity.TileEntityDisplay;
|
||||
import common.tileentity.TileEntityPiston;
|
||||
import common.tileentity.TileEntitySign;
|
||||
import common.util.BlockPos;
|
||||
|
@ -46,6 +47,7 @@ public class TileEntityRendererDispatcher
|
|||
private TileEntityRendererDispatcher()
|
||||
{
|
||||
this.mapSpecialRenderers.put(TileEntitySign.class, new TileEntitySignRenderer());
|
||||
this.mapSpecialRenderers.put(TileEntityDisplay.class, new TileEntityDisplayRenderer());
|
||||
this.mapSpecialRenderers.put(TileEntityPiston.class, new TileEntityPistonRenderer());
|
||||
this.mapSpecialRenderers.put(TileEntityChest.class, new TileEntityChestRenderer());
|
||||
this.mapSpecialRenderers.put(TileEntityBanner.class, new TileEntityBannerRenderer());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue