use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.
the class IoConfigRenderer method renderSelection.
private void renderSelection() {
if (selection == null) {
return;
}
BoundingBox bb = new BoundingBox(selection.config.getLocation());
TextureAtlasSprite icon = selectedFaceIcon.get(TextureAtlasSprite.class);
List<Vertex> corners = bb.getCornersWithUvForFace(selection.face, icon.getMinU(), icon.getMaxU(), icon.getMinV(), icon.getMaxV());
GlStateManager.disableDepth();
GlStateManager.disableLighting();
RenderUtil.bindBlockTexture();
BufferBuilder tes = Tessellator.getInstance().getBuffer();
GlStateManager.color(1, 1, 1);
Vector3d trans = new Vector3d((-origin.x) + eye.x, (-origin.y) + eye.y, (-origin.z) + eye.z);
tes.setTranslation(trans.x, trans.y, trans.z);
RenderUtil.addVerticesToTessellator(corners, DefaultVertexFormats.POSITION_TEX, true);
Tessellator.getInstance().draw();
tes.setTranslation(0, 0, 0);
}
use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.
the class DefaultConduitRenderer method setupVertices.
protected void setupVertices(BoundingBox bound, VertexTransform xForm) {
verts[0].set(bound.minX, bound.minY, bound.minZ);
verts[1].set(bound.maxX, bound.minY, bound.minZ);
verts[2].set(bound.maxX, bound.maxY, bound.minZ);
verts[3].set(bound.minX, bound.maxY, bound.minZ);
verts[4].set(bound.minX, bound.minY, bound.maxZ);
verts[5].set(bound.maxX, bound.minY, bound.maxZ);
verts[6].set(bound.maxX, bound.maxY, bound.maxZ);
verts[7].set(bound.minX, bound.maxY, bound.maxZ);
if (xForm != null) {
for (Vector3d vec : verts) {
xForm.apply(vec);
}
}
}
use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.
the class TESRPowerMonitor method renderTileEntity.
@Override
protected void renderTileEntity(@Nonnull TilePowerMonitor te, @Nonnull IBlockState blockState, float partialTicks, int destroyStage) {
boolean isPainted = te.getPaintSource() != null;
VertexRotationFacing xform = new VertexRotationFacing(te.getFacing());
xform.setCenter(new Vector3d(0.5, 0.5, 0.5));
xform.setRotation(EnumFacing.SOUTH);
te.bindTexture();
Helper helper = threadLocalHelper.get();
BufferBuilder tes = Tessellator.getInstance().getBuffer();
tes.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX_COLOR_NORMAL);
if (isPainted) {
helper.setupVertices(bb2, xform);
helper.renderSingleFace(tes, EnumFacing.SOUTH, 0 * px, 14 * px, 0 * px, 14 * px, xform, Helper.stdBrightness, false);
} else {
helper.setupVertices(bb1, xform);
helper.renderSingleFace(tes, EnumFacing.SOUTH, 1 * px, 15 * px, 1 * px, 15 * px, xform, Helper.stdBrightness, false);
}
Tessellator.getInstance().draw();
}
use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.
the class TeleportUtil method serverTeleport.
public static boolean serverTeleport(@Nonnull Entity entity, @Nonnull BlockPos pos, int targetDim, boolean conserveMotion, @Nonnull TravelSource source) {
TeleportEntityEvent evt = new TeleportEntityEvent(entity, source, pos, targetDim);
if (MinecraftForge.EVENT_BUS.post(evt)) {
return false;
}
EntityPlayerMP player = null;
if (entity instanceof EntityPlayerMP) {
player = (EntityPlayerMP) entity;
}
int x = pos.getX();
int y = pos.getY();
int z = pos.getZ();
int from = entity.dimension;
if (from != targetDim) {
MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance();
WorldServer fromDim = server.getWorld(from);
WorldServer toDim = server.getWorld(targetDim);
Teleporter teleporter = new TeleporterEIO(toDim);
// play sound at the dimension we are leaving for others to hear
SoundHelper.playSound(server.getWorld(entity.dimension), entity, source.sound, 1.0F, 1.0F);
if (player != null) {
server.getPlayerList().transferPlayerToDimension(player, targetDim, teleporter);
if (from == 1 && entity.isEntityAlive()) {
// get around vanilla End
// hacks
toDim.spawnEntity(entity);
toDim.updateEntityWithOptionalForce(entity, false);
}
} else {
NBTTagCompound tagCompound = new NBTTagCompound();
float rotationYaw = entity.rotationYaw;
float rotationPitch = entity.rotationPitch;
entity.writeToNBT(tagCompound);
Class<? extends Entity> entityClass = entity.getClass();
fromDim.removeEntity(entity);
try {
Entity newEntity = entityClass.getConstructor(World.class).newInstance(toDim);
newEntity.readFromNBT(tagCompound);
newEntity.setLocationAndAngles(x, y, z, rotationYaw, rotationPitch);
newEntity.forceSpawn = true;
toDim.spawnEntity(newEntity);
// necessary?
newEntity.forceSpawn = false;
} catch (Exception e) {
// Throwables.propagate(e);
Log.error("serverTeleport: Error creating a entity to be created in new dimension.");
return false;
}
}
}
// Force the chunk to load
if (!entity.world.isBlockLoaded(pos)) {
entity.world.getChunkFromBlockCoords(pos);
}
if (player != null) {
player.connection.setPlayerLocation(x + 0.5, y + 1.1, z + 0.5, player.rotationYaw, player.rotationPitch);
} else {
entity.setPositionAndUpdate(x + 0.5, y + 1.1, z + 0.5);
}
entity.fallDistance = 0;
SoundHelper.playSound(entity.world, entity, source.sound, 1.0F, 1.0F);
if (player != null) {
if (conserveMotion) {
Vector3d velocityVex = Util.getLookVecEio(player);
SPacketEntityVelocity p = new SPacketEntityVelocity(entity.getEntityId(), velocityVex.x, velocityVex.y, velocityVex.z);
player.connection.sendPacket(p);
}
}
return true;
}
use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.
the class TravelController method updateSelectedTarget.
@SideOnly(Side.CLIENT)
private void updateSelectedTarget(@Nonnull EntityPlayerSP player) {
selectedCoord = null;
if (candidates.isEmpty()) {
return;
}
double closestDistance = Double.MAX_VALUE;
for (BlockPos bc : candidates.keySet()) {
if (!bc.equals(onBlockCoord)) {
double d = addRatio(bc);
if (d < closestDistance) {
selectedCoord = bc;
closestDistance = d;
}
}
}
if (selectedCoord != null) {
Vector3d blockCenter = new Vector3d(selectedCoord.getX() + 0.5, selectedCoord.getY() + 0.5, selectedCoord.getZ() + 0.5);
Vector2d blockCenterPixel = currentView.getScreenPoint(blockCenter);
Vector2d screenMidPixel = new Vector2d(Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
screenMidPixel.scale(0.5);
double pixDist = blockCenterPixel.distance(screenMidPixel);
double rat = pixDist / Minecraft.getMinecraft().displayHeight;
if (rat != rat) {
rat = 0;
}
if (rat > 0.07) {
selectedCoord = null;
}
}
}
Aggregations