use of net.minecraft.util.math.Vec3d in project Charset by CharsetMC.
the class AudioSinkBlock method readData.
@Override
public void readData(ByteBuf buf) {
super.readData(buf);
int dimId = buf.readInt();
double xPos = buf.readDouble();
double yPos = buf.readDouble();
double zPos = buf.readDouble();
world = Utils.getLocalWorld(dimId);
pos = new Vec3d(xPos, yPos, zPos);
}
use of net.minecraft.util.math.Vec3d in project Charset by CharsetMC.
the class RenderUtils method drawSelectionBoundingBox.
public static void drawSelectionBoundingBox(AxisAlignedBB box, int lineMask) {
EntityPlayer player = Minecraft.getMinecraft().player;
float partialTicks = Minecraft.getMinecraft().getRenderPartialTicks();
Vec3d cameraPos = EntityUtils.interpolate(player, partialTicks);
AxisAlignedBB boundingBox = box.grow(0.002).offset(cameraPos.scale(-1));
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
GlStateManager.color(0.0F, 0.0F, 0.0F, 0.4F);
GL11.glLineWidth(2.0F);
GlStateManager.disableTexture2D();
GlStateManager.depthMask(false);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder worldrenderer = tessellator.getBuffer();
worldrenderer.begin(GL11.GL_LINES, DefaultVertexFormats.POSITION);
if ((lineMask & /* getSelectionMask(0, 0, 0) */
0x001) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.minX, boundingBox.minY, boundingBox.minZ, boundingBox.maxX, boundingBox.minY, boundingBox.minZ);
}
if ((lineMask & /* getSelectionMask(0, 0, 1) */
0x002) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.minX, boundingBox.minY, boundingBox.maxZ, boundingBox.maxX, boundingBox.minY, boundingBox.maxZ);
}
if ((lineMask & /* getSelectionMask(0, 1, 0) */
0x004) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.minX, boundingBox.minY, boundingBox.minZ, boundingBox.minX, boundingBox.minY, boundingBox.maxZ);
}
if ((lineMask & /* getSelectionMask(0, 1, 1) */
0x008) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.maxX, boundingBox.minY, boundingBox.minZ, boundingBox.maxX, boundingBox.minY, boundingBox.maxZ);
}
if ((lineMask & /* getSelectionMask(1, 0, 0) */
0x010) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.minX, boundingBox.minY, boundingBox.minZ, boundingBox.minX, boundingBox.maxY, boundingBox.minZ);
}
if ((lineMask & /* getSelectionMask(1, 0, 1) */
0x020) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.minX, boundingBox.minY, boundingBox.maxZ, boundingBox.minX, boundingBox.maxY, boundingBox.maxZ);
}
if ((lineMask & /* getSelectionMask(1, 1, 0) */
0x040) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.maxX, boundingBox.minY, boundingBox.minZ, boundingBox.maxX, boundingBox.maxY, boundingBox.minZ);
}
if ((lineMask & /* getSelectionMask(1, 1, 1) */
0x080) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.maxX, boundingBox.minY, boundingBox.maxZ, boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ);
}
if ((lineMask & /* getSelectionMask(2, 0, 0) */
0x100) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.minX, boundingBox.maxY, boundingBox.minZ, boundingBox.maxX, boundingBox.maxY, boundingBox.minZ);
}
if ((lineMask & /* getSelectionMask(2, 0, 1) */
0x200) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.minX, boundingBox.maxY, boundingBox.maxZ, boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ);
}
if ((lineMask & /* getSelectionMask(2, 1, 0) */
0x400) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.minX, boundingBox.maxY, boundingBox.minZ, boundingBox.minX, boundingBox.maxY, boundingBox.maxZ);
}
if ((lineMask & /* getSelectionMask(2, 1, 1) */
0x800) != 0) {
drawLine(worldrenderer, tessellator, boundingBox.maxX, boundingBox.maxY, boundingBox.minZ, boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ);
}
tessellator.draw();
GlStateManager.depthMask(true);
GlStateManager.enableTexture2D();
GlStateManager.disableBlend();
}
use of net.minecraft.util.math.Vec3d in project Charset by CharsetMC.
the class NotifyImplementation method doSend.
void doSend(EntityPlayer player, Object where, World world, EnumSet<NoticeStyle> style, ItemStack item, ITextComponent message) {
if (where == null) {
return;
}
int baseRange = 32;
if (player != null && EntityUtils.isPlayerFake(player)) {
player = null;
}
if ((player != null && player.world.isRemote) || (world != null && world.isRemote)) {
proxy.addMessage(where, item, style, message);
} else {
TargetPoint target = null;
if (player == null) {
final int range = style.contains(NoticeStyle.DRAWFAR) ? (baseRange * 4) : baseRange;
int x = 0, y = 0, z = 0;
boolean failed = false;
BlockPos pos = null;
if (where instanceof NotificationCoord) {
NotificationCoord c = (NotificationCoord) where;
pos = c.getPos();
world = c.getWorld();
} else if (where instanceof TileEntity) {
TileEntity te = (TileEntity) where;
world = te.getWorld();
pos = te.getPos();
} else if (where instanceof Entity) {
Entity ent = (Entity) where;
world = ent.world;
x = (int) ent.posX;
y = (int) ent.posY;
z = (int) ent.posZ;
} else if (where instanceof Vec3d) {
Vec3d vec = (Vec3d) where;
x = (int) vec.x;
y = (int) vec.y;
z = (int) vec.z;
} else if (where instanceof BlockPos) {
pos = (BlockPos) where;
} else {
failed = true;
}
if (pos != null) {
x = pos.getX();
y = pos.getY();
z = pos.getZ();
}
if (world != null && !failed) {
int dimension = world.provider.getDimension();
target = new TargetPoint(dimension, x, y, z, range);
}
}
if (player != null) {
CharsetLib.packet.sendTo(PacketNotification.createNotify(where, item, style, message), player);
} else {
CharsetLib.packet.sendToAllAround(PacketNotification.createNotify(where, item, style, message), target);
}
}
}
use of net.minecraft.util.math.Vec3d in project Charset by CharsetMC.
the class NotifyProxyClient method renderMessages0.
void renderMessages0(RenderWorldLastEvent event) {
World w = Minecraft.getMinecraft().world;
if (w == null) {
return;
}
if (messages.size() == 0) {
return;
}
// TODO
// RenderUtil.checkGLError("A mod has a rendering error");
Iterator<ClientMessage> it = messages.iterator();
long approximateNow = System.currentTimeMillis();
Entity camera = Minecraft.getMinecraft().getRenderViewEntity();
Vec3d cameraPos = EntityUtils.interpolate(camera, event.getPartialTicks());
GlStateManager.pushMatrix();
GlStateManager.translate(-cameraPos.x, -cameraPos.y, -cameraPos.z);
GlStateManager.depthMask(false);
GlStateManager.disableDepth();
GlStateManager.disableLighting();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.color(1, 1, 1, 1);
if (renderItem == null) {
renderItem = Minecraft.getMinecraft().getRenderItem();
}
while (it.hasNext()) {
ClientMessage m = it.next();
long timeExisted = approximateNow - m.creationTime;
if (timeExisted > m.lifeTime || m.world != w || !m.stillValid()) {
it.remove();
continue;
}
if (!m.style.contains(NoticeStyle.DRAWFAR)) {
Vec3d pos = m.getPosition(event.getPartialTicks());
double dist = camera.getDistance(pos.x, pos.y, pos.z);
if (dist > 8) {
continue;
}
}
float lifeLeft = (m.lifeTime - timeExisted) / 1000F;
float opacity = 1F;
if (lifeLeft < 1) {
opacity = lifeLeft / 1F;
}
opacity = (float) Math.sin(opacity);
if (opacity > 0.12) {
renderMessage(m, event.getPartialTicks(), opacity, cameraPos);
}
}
GlStateManager.disableBlend();
GlStateManager.enableDepth();
// GlStateManager.enableLighting();
GlStateManager.depthMask(true);
GlStateManager.color(1, 1, 1, 1);
GlStateManager.popMatrix();
// RenderUtil.checkGLError("Notification render error!"); TODO
}
use of net.minecraft.util.math.Vec3d in project Charset by CharsetMC.
the class NotifyProxyClient method addMessage0.
private void addMessage0(Object locus, ItemStack item, Collection<NoticeStyle> style, ITextComponent cmsg) {
EntityPlayer player = Minecraft.getMinecraft().player;
if (player == null || player.world == null) {
return;
}
ClientMessage msg = new ClientMessage(player.world, locus, item, style, cmsg);
if (msg.style.contains(NoticeStyle.CLEAR)) {
messages.clear();
if (msg.msg == null || msg.msg.equals(""))
return;
}
if (msg.style.contains(NoticeStyle.UPDATE) || msg.style.contains(NoticeStyle.UPDATE_SAME_ITEM)) {
updateMessage(msg);
return;
}
boolean force_position = msg.style.contains(NoticeStyle.FORCE);
if (messages.size() > 4 && !force_position) {
messages.remove(0);
}
Vec3d testPos = msg.getPosition(0);
if (testPos == null) {
return;
}
for (ClientMessage m : messages) {
if (m.getPosition(0).distanceTo(testPos) < 1.05 && !force_position) {
m.creationTime = 0;
}
}
if (msg.msg == null || msg.msgRendered.trim().length() == 0) {
if (!(msg.show_item && msg.item != null)) {
return;
}
}
messages.add(msg);
}
Aggregations