mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-23 21:49:58 +00:00
Initial cut of labels for travel anchors.
This commit is contained in:
1 parent
9190bb7f58
commit
584ead10bb
9 files changed
+215
-124
No files matched your search
@@ -42,15 +42,9 @@ public class EnderIoRenderer extends TileEntitySpecialRenderer implements IItemR
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) {
|
||||
|
||||
//System.out.println("EnderIoRenderer.renderTileEntityAt: " + x + "," + y + "," + z);
|
||||
|
||||
|
||||
EntityLivingBase entityPlayer = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
Vector3d playerEye = new Vector3d(entityPlayer.posX, entityPlayer.posY + 1.62 - entityPlayer.yOffset, entityPlayer.posZ);
|
||||
Vector3d blockOrigin = new Vector3d(te.xCoord + 0.5, te.yCoord + 0.5, te.zCoord + 0.5);
|
||||
Matrix4d lookMat = VecmathUtil.createMatrixAsLookAt(blockOrigin, playerEye, RenderUtil.UP_V);
|
||||
lookMat.setTranslation(new Vector3d());
|
||||
lookMat.invert();
|
||||
Matrix4d lookMat = RenderUtil.createBillboardMatrix(te, entityPlayer);
|
||||
|
||||
int brightness = RenderUtil.setTesselatorBrightness(entityPlayer.worldObj, te.xCoord, te.yCoord, te.zCoord);
|
||||
render(x, y, z, lookMat, brightness);
|
||||
@@ -73,7 +67,7 @@ public class EnderIoRenderer extends TileEntitySpecialRenderer implements IItemR
|
||||
//GL11.glDisable(GL11.GL_CULL_FACE);
|
||||
GL11.glDepthMask(false);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
renderBillboard(lookMat, minU, maxU, minV, maxV, 0.8, brightness);
|
||||
RenderUtil.renderBillboard(lookMat, minU, maxU, minV, maxV, 0.8, brightness);
|
||||
|
||||
// Glint
|
||||
float maxUV = 32;
|
||||
@@ -92,7 +86,7 @@ public class EnderIoRenderer extends TileEntitySpecialRenderer implements IItemR
|
||||
float tans = Minecraft.getSystemTime() % 3000L / 3000.0F * 8.0F;
|
||||
GL11.glTranslatef(tans, 0.0F, 0.0F);
|
||||
GL11.glRotatef(-50.0F, 0.0F, 0.0F, 1.0F);
|
||||
renderBillboard(lookMat, 0, maxUV, 0, maxUV, 0.8, brightness);
|
||||
RenderUtil.renderBillboard(lookMat, 0, maxUV, 0, maxUV, 0.8, brightness);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glPushMatrix();
|
||||
@@ -100,7 +94,7 @@ public class EnderIoRenderer extends TileEntitySpecialRenderer implements IItemR
|
||||
tans = Minecraft.getSystemTime() % 4873L / 4873.0F * 8.0F;
|
||||
GL11.glTranslatef(-tans, 0.0F, 0.0F);
|
||||
GL11.glRotatef(10.0F, 0.0F, 0.0F, 1.0F);
|
||||
renderBillboard(lookMat, 0, maxUV, 0, maxUV, 0.8, brightness);
|
||||
RenderUtil.renderBillboard(lookMat, 0, maxUV, 0, maxUV, 0.8, brightness);
|
||||
GL11.glPopMatrix();
|
||||
|
||||
GL11.glMatrixMode(GL11.GL_MODELVIEW);
|
||||
@@ -135,29 +129,6 @@ public class EnderIoRenderer extends TileEntitySpecialRenderer implements IItemR
|
||||
|
||||
}
|
||||
|
||||
private void renderBillboard(Matrix4d lookMat, float minU, float maxU, float minV, float maxV, double size, int brightness) {
|
||||
|
||||
Tessellator tes = Tessellator.instance;
|
||||
tes.startDrawingQuads();
|
||||
tes.setBrightness(brightness);
|
||||
|
||||
double s = size / 2;
|
||||
Vector3d v = new Vector3d();
|
||||
v.set(-s, s, 0);
|
||||
lookMat.transform(v);
|
||||
tes.addVertexWithUV(v.x, v.y, v.z, minU, maxV);
|
||||
v.set(s, s, 0);
|
||||
lookMat.transform(v);
|
||||
tes.addVertexWithUV(v.x, v.y, v.z, maxU, maxV);
|
||||
v.set(s, -s, 0);
|
||||
lookMat.transform(v);
|
||||
tes.addVertexWithUV(v.x, v.y, v.z, maxU, minV);
|
||||
v.set(-s, -s, 0);
|
||||
lookMat.transform(v);
|
||||
tes.addVertexWithUV(v.x, v.y, v.z, minU, minV);
|
||||
tes.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType(ItemStack item, ItemRenderType type) {
|
||||
return true;
|
||||
|
||||
@@ -170,7 +170,6 @@ public class PacketOpenRemoteUi implements IPacketEio {
|
||||
@Override
|
||||
public Object intercept(Object o, Method method, Object[] objects, MethodProxy methodProxy) throws Throwable {
|
||||
|
||||
System.out.println("PacketOpenRemoteUi.PlayerProxy.intercept: 1 " + method.getName());
|
||||
if(interceptNames.contains(method.getName())) {
|
||||
|
||||
Object res = method.invoke(realObj, objects);
|
||||
|
||||
@@ -14,90 +14,38 @@ public class ContainerTravelAccessable extends Container {
|
||||
|
||||
private ITravelAccessable ta;
|
||||
private TileEntity te;
|
||||
private World world;
|
||||
|
||||
public ContainerTravelAccessable(InventoryPlayer playerInv, final ITravelAccessable travelAccessable, final World world) {
|
||||
public ContainerTravelAccessable(InventoryPlayer playerInv, final ITravelAccessable travelAccessable, World world) {
|
||||
ta = travelAccessable;
|
||||
this.world = world;
|
||||
if(ta instanceof TileEntity) {
|
||||
te = ((TileEntity) ta);
|
||||
}
|
||||
|
||||
ArrayInventory arrInv = new ArrayInventory(ta.getPassword()) {
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
super.markDirty();
|
||||
if(!world.isRemote && te != null) {
|
||||
ta.clearAuthorisedUsers();
|
||||
world.markBlockForUpdate(te.xCoord, te.yCoord, te.zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return items.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
if(i < 0 || i >= items.length) {
|
||||
return null;
|
||||
}
|
||||
return items[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int fromSlot, int amount) {
|
||||
ItemStack item = items[fromSlot];
|
||||
items[fromSlot] = null;
|
||||
if(item == null) {
|
||||
return null;
|
||||
}
|
||||
item.stackSize = 0;
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
if(itemstack != null) {
|
||||
items[i] = itemstack.copy();
|
||||
items[i].stackSize = 0;
|
||||
} else {
|
||||
items[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "Password";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
};
|
||||
ArrayInventory arrInv = new PasswordInventory(ta.getPassword(), true);
|
||||
int x = 44;
|
||||
int y = 43;
|
||||
int y = 73;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
addSlotToContainer(new TemplateSlot(arrInv, i, x, y));
|
||||
x += 18;
|
||||
}
|
||||
|
||||
arrInv = new PasswordInventory(new ItemStack[] {ta.getItemLabel()}, false);
|
||||
x = 80;
|
||||
y = 10;
|
||||
addSlotToContainer(new TemplateSlot(arrInv, 0, x, y));
|
||||
|
||||
|
||||
// add players inventory
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 73 + i * 18));
|
||||
addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 103 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 131));
|
||||
addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 161));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,4 +60,76 @@ public class ContainerTravelAccessable extends Container {
|
||||
return null;
|
||||
}
|
||||
|
||||
private class PasswordInventory extends ArrayInventory {
|
||||
|
||||
boolean isAuth;
|
||||
|
||||
public PasswordInventory(ItemStack[] items, boolean isAuth) {
|
||||
super(items);
|
||||
this.isAuth = isAuth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
super.markDirty();
|
||||
if(!world.isRemote && te != null) {
|
||||
if(isAuth) {
|
||||
ta.clearAuthorisedUsers();
|
||||
}
|
||||
world.markBlockForUpdate(te.xCoord, te.yCoord, te.zCoord);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return items.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
if(i < 0 || i >= items.length) {
|
||||
return null;
|
||||
}
|
||||
return items[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int fromSlot, int amount) {
|
||||
ItemStack item = items[fromSlot];
|
||||
items[fromSlot] = null;
|
||||
if(item == null) {
|
||||
return null;
|
||||
}
|
||||
item.stackSize = 0;
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
if(itemstack != null) {
|
||||
items[i] = itemstack.copy();
|
||||
items[i].stackSize = 0;
|
||||
} else {
|
||||
items[i] = null;
|
||||
}
|
||||
ta.setItemLabel(items[i]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "Password";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public class GuiTravelAccessable extends GuiContainerBase {
|
||||
col2x += (176 - col2x) / 2;
|
||||
|
||||
int x = 0;
|
||||
int y = 20;
|
||||
int y = 50;
|
||||
|
||||
x = col0x - 8;
|
||||
privateCB = new CheckBoxEIO(this, ID_PRIVATE, x, y);
|
||||
@@ -72,6 +72,7 @@ public class GuiTravelAccessable extends GuiContainerBase {
|
||||
publicCB = new CheckBoxEIO(this, ID_PUBLIC, x, y);
|
||||
publicCB.setSelected(te.getAccessMode() == AccessMode.PUBLIC);
|
||||
|
||||
ySize = 185;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -110,7 +111,7 @@ public class GuiTravelAccessable extends GuiContainerBase {
|
||||
|
||||
int col = ColorUtil.getRGB(Color.white);
|
||||
int x = sx;
|
||||
int y = sy + 8;
|
||||
int y = sy + 38;
|
||||
|
||||
FontRenderer fontRenderer = getFontRenderer();
|
||||
x = sx + col0x - fontRenderer.getStringWidth(privateStr) / 2;
|
||||
@@ -135,7 +136,7 @@ public class GuiTravelAccessable extends GuiContainerBase {
|
||||
GL11.glColor4f(1, 1, 1, 0.75f);
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||
drawTexturedModalRect(43, 42, 5, 5, 90, 18);
|
||||
drawTexturedModalRect(43, 72, 5, 35, 90, 18);
|
||||
GL11.glDisable(GL11.GL_BLEND);
|
||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||
GL11.glColor4f(1, 1, 1, 1);
|
||||
|
||||
@@ -24,6 +24,10 @@ public interface ITravelAccessable {
|
||||
ItemStack[] getPassword();
|
||||
|
||||
void setPassword(ItemStack[] password);
|
||||
|
||||
ItemStack getItemLabel();
|
||||
|
||||
void setItemLabel(ItemStack lableIcon);
|
||||
|
||||
String getPlacedBy();
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ public class TileTravelAnchor extends TileEntityEio implements ITravelAccessable
|
||||
private AccessMode accessMode = AccessMode.PUBLIC;
|
||||
|
||||
private ItemStack[] password = new ItemStack[5];
|
||||
|
||||
private ItemStack itemLabel;
|
||||
|
||||
private String placedBy;
|
||||
|
||||
@@ -120,6 +122,14 @@ public class TileTravelAnchor extends TileEntityEio implements ITravelAccessable
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public ItemStack getItemLabel() {
|
||||
return itemLabel;
|
||||
}
|
||||
|
||||
public void setItemLabel(ItemStack lableIcon) {
|
||||
this.itemLabel = lableIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlacedBy() {
|
||||
return placedBy;
|
||||
@@ -180,18 +190,13 @@ public class TileTravelAnchor extends TileEntityEio implements ITravelAccessable
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeCustomNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
readCustomNBT(pkt.func_148857_g());
|
||||
if(root.hasKey("itemLabel")) {
|
||||
NBTTagCompound stackRoot = (NBTTagCompound) root.getTag("itemLabel");
|
||||
itemLabel = ItemStack.loadItemStackFromNBT(stackRoot);
|
||||
} else {
|
||||
itemLabel = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -218,5 +223,22 @@ public class TileTravelAnchor extends TileEntityEio implements ITravelAccessable
|
||||
if(authorisedUsers.size() > 0) {
|
||||
root.setString("authorisedUsers", userStr.toString());
|
||||
}
|
||||
if(itemLabel != null) {
|
||||
NBTTagCompound labelRoot = new NBTTagCompound();
|
||||
itemLabel.writeToNBT(labelRoot);
|
||||
root.setTag("itemLabel", labelRoot);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Packet getDescriptionPacket() {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
writeCustomNBT(tag);
|
||||
return new S35PacketUpdateTileEntity(xCoord, yCoord, zCoord, 1, tag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) {
|
||||
readCustomNBT(pkt.func_148857_g());
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,30 @@
|
||||
package crazypants.enderio.teleport;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
import org.lwjgl.opengl.GL14;
|
||||
|
||||
import crazypants.enderio.EnderIO;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.render.ColorUtil;
|
||||
import crazypants.render.CubeRenderer;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.Util;
|
||||
import crazypants.vecmath.Matrix4d;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
import crazypants.vecmath.Vector4f;
|
||||
|
||||
@@ -35,7 +45,6 @@ public class TravelEntitySpecialRenderer extends TileEntitySpecialRenderer {
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) {
|
||||
|
||||
|
||||
if(!TravelController.instance.showTargets()) {
|
||||
return;
|
||||
}
|
||||
@@ -58,6 +67,8 @@ public class TravelEntitySpecialRenderer extends TileEntitySpecialRenderer {
|
||||
BlockCoord bc = new BlockCoord(tileentity);
|
||||
TravelController.instance.addCandidate(bc);
|
||||
|
||||
Minecraft.getMinecraft().entityRenderer.disableLightmap(0);
|
||||
|
||||
RenderUtil.bindBlockTexture();
|
||||
GL11.glPushAttrib(GL11.GL_ENABLE_BIT);
|
||||
GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
|
||||
@@ -71,12 +82,11 @@ public class TravelEntitySpecialRenderer extends TileEntitySpecialRenderer {
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
||||
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x, y, z);
|
||||
GL11.glColor3f(1, 1, 1);
|
||||
|
||||
Minecraft.getMinecraft().entityRenderer.disableLightmap(0);
|
||||
|
||||
|
||||
Tessellator.instance.startDrawingQuads();
|
||||
renderBlock(sf);
|
||||
@@ -84,7 +94,6 @@ public class TravelEntitySpecialRenderer extends TileEntitySpecialRenderer {
|
||||
|
||||
Tessellator.instance.startDrawingQuads();
|
||||
if(TravelController.instance.isBlockSelected(bc)) {
|
||||
|
||||
Tessellator.instance.setColorRGBA_F(selectedColor.x, selectedColor.y, selectedColor.z, selectedColor.w);
|
||||
CubeRenderer.render(BoundingBox.UNIT_CUBE.scale(sf + 0.05, sf + 0.05, sf + 0.05), getSelectedIcon());
|
||||
} else {
|
||||
@@ -92,13 +101,41 @@ public class TravelEntitySpecialRenderer extends TileEntitySpecialRenderer {
|
||||
CubeRenderer.render(BoundingBox.UNIT_CUBE.scale(sf + 0.05, sf + 0.05, sf + 0.05), getHighlightIcon());
|
||||
}
|
||||
Tessellator.instance.draw();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
|
||||
renderLabel(tileentity, x, y, z, ta, sf);
|
||||
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopAttrib();
|
||||
|
||||
Minecraft.getMinecraft().entityRenderer.enableLightmap(0);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
GL11.glPopAttrib();
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
private void renderLabel(TileEntity tileentity, double x, double y, double z, ITravelAccessable ta, double sf) {
|
||||
ItemStack itemLabel = ta.getItemLabel();
|
||||
if(itemLabel != null) {
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_CONSTANT_COLOR);
|
||||
GL14.glBlendColor(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
|
||||
IIcon tex = itemLabel.getIconIndex();
|
||||
if(itemLabel.getItemSpriteNumber() == 0) {
|
||||
RenderUtil.bindBlockTexture();
|
||||
} else {
|
||||
RenderUtil.bindItemTexture();
|
||||
}
|
||||
|
||||
Matrix4d lookMat = RenderUtil.createBillboardMatrix(tileentity, Minecraft.getMinecraft().thePlayer);
|
||||
RenderUtil.renderBillboard(lookMat, tex.getMinU(), tex.getMaxU(), tex.getMaxV(), tex.getMinV(), sf * 0.75, 0);
|
||||
|
||||
GL11.glPopMatrix();
|
||||
|
||||
RenderUtil.bindBlockTexture();
|
||||
}
|
||||
}
|
||||
|
||||
protected void renderBlock(double sf) {
|
||||
|
||||
@@ -19,7 +19,9 @@ import net.minecraft.client.renderer.GLAllocation;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.texture.TextureManager;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
@@ -175,6 +177,41 @@ public class RenderUtil {
|
||||
tessellator.draw();
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
public static Matrix4d createBillboardMatrix(TileEntity te, EntityLivingBase entityPlayer) {
|
||||
return createBillboardMatrix(new Vector3d(te.xCoord + 0.5, te.yCoord + 0.5, te.zCoord + 0.5), entityPlayer);
|
||||
}
|
||||
|
||||
public static Matrix4d createBillboardMatrix(Vector3d lookAt, EntityLivingBase entityPlayer) {
|
||||
Vector3d playerEye = new Vector3d(entityPlayer.posX, entityPlayer.posY + 1.62 - entityPlayer.yOffset, entityPlayer.posZ);
|
||||
Vector3d blockOrigin = new Vector3d(lookAt.x, lookAt.y, lookAt.z);
|
||||
Matrix4d lookMat = VecmathUtil.createMatrixAsLookAt(blockOrigin, playerEye, RenderUtil.UP_V);
|
||||
lookMat.setTranslation(new Vector3d());
|
||||
lookMat.invert();
|
||||
return lookMat;
|
||||
}
|
||||
|
||||
public static void renderBillboard(Matrix4d lookMat, float minU, float maxU, float minV, float maxV, double size, int brightness) {
|
||||
Tessellator tes = Tessellator.instance;
|
||||
tes.startDrawingQuads();
|
||||
tes.setBrightness(brightness);
|
||||
|
||||
double s = size / 2;
|
||||
Vector3d v = new Vector3d();
|
||||
v.set(-s, s, 0);
|
||||
lookMat.transform(v);
|
||||
tes.addVertexWithUV(v.x, v.y, v.z, minU, maxV);
|
||||
v.set(s, s, 0);
|
||||
lookMat.transform(v);
|
||||
tes.addVertexWithUV(v.x, v.y, v.z, maxU, maxV);
|
||||
v.set(s, -s, 0);
|
||||
lookMat.transform(v);
|
||||
tes.addVertexWithUV(v.x, v.y, v.z, maxU, minV);
|
||||
v.set(-s, -s, 0);
|
||||
lookMat.transform(v);
|
||||
tes.addVertexWithUV(v.x, v.y, v.z, minU, minV);
|
||||
tes.draw();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user