Search in sources :

Example 31 with Vector3d

use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.

the class BlockCapBank method getSelectedBoundingBox.

@Override
@SideOnly(Side.CLIENT)
@Deprecated
@Nonnull
public AxisAlignedBB getSelectedBoundingBox(@Nonnull IBlockState bs, @Nonnull World world, @Nonnull BlockPos pos) {
    TileCapBank tr = getTileEntity(world, pos);
    if (tr == null) {
        return super.getSelectedBoundingBox(bs, world, pos);
    }
    ICapBankNetwork network = tr.getNetwork();
    if (!tr.getType().isMultiblock() || network == null) {
        return super.getSelectedBoundingBox(bs, world, pos);
    }
    Vector3d min = new Vector3d(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE);
    Vector3d max = new Vector3d(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE);
    for (TileCapBank bc : network.getMembers()) {
        int x = bc.getPos().getX();
        int y = bc.getPos().getY();
        int z = bc.getPos().getZ();
        min.x = Math.min(min.x, x);
        max.x = Math.max(max.x, x + 1);
        min.y = Math.min(min.y, y);
        max.y = Math.max(max.y, y + 1);
        min.z = Math.min(min.z, z);
        max.z = Math.max(max.z, z + 1);
    }
    return new AxisAlignedBB(min.x, min.y, min.z, max.x, max.y, max.z);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Vector3d(com.enderio.core.common.vecmath.Vector3d) ICapBankNetwork(crazypants.enderio.powertools.machine.capbank.network.ICapBankNetwork) Nonnull(javax.annotation.Nonnull) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 32 with Vector3d

use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.

the class TravelEntitySpecialRenderer method renderTileEntity.

@Override
public void renderTileEntity(@Nonnull T te, @Nonnull IBlockState blockState, float partialTicks, int destroyStage) {
    Vector3d eye = Util.getEyePositionEio(Minecraft.getMinecraft().player);
    Vector3d loc = new Vector3d(te.getPos().getX() + 0.5, te.getPos().getY() + 0.5, te.getPos().getZ() + 0.5);
    double maxDistance = TravelController.instance.isTravelItemActiveForRendering(Minecraft.getMinecraft().player) ? TravelSource.STAFF.getMaxDistanceTravelledSq() : TravelSource.BLOCK.getMaxDistanceTravelledSq();
    if (eye.distanceSquared(loc) > maxDistance) {
        return;
    }
    double sf = TravelController.instance.getScaleForCandidate(loc);
    boolean highlight = TravelController.instance.isBlockSelected(te.getLocation());
    TravelController.instance.addCandidate(te.getLocation());
    Minecraft.getMinecraft().entityRenderer.disableLightmap();
    GlStateManager.enableRescaleNormal();
    GlStateManager.disableDepth();
    GlStateManager.disableLighting();
    renderBlock(te.getPos(), te.getWorld(), sf, highlight);
    renderItemLabel(te.getItemLabel(), sf);
    renderLabel(te.getLabel(), sf, highlight);
    GlStateManager.disableRescaleNormal();
    GlStateManager.enableDepth();
    Minecraft.getMinecraft().entityRenderer.enableLightmap();
}
Also used : Vector3d(com.enderio.core.common.vecmath.Vector3d)

Example 33 with Vector3d

use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.

the class IoConfigRenderer method doTileEntityRenderPass.

private void doTileEntityRenderPass(@Nonnull NNList<BlockPos> blocks, final int pass) {
    blocks.apply(new Callback<BlockPos>() {

        @Override
        public void apply(@Nonnull BlockPos pos) {
            TileEntity tile = world.getTileEntity(pos);
            if (tile != null) {
                if (tile.shouldRenderInPass(pass)) {
                    Vector3d at = new Vector3d(eye.x, eye.y, eye.z);
                    at.x += pos.getX() - origin.x;
                    at.y += pos.getY() - origin.y;
                    at.z += pos.getZ() - origin.z;
                    if (tile.getClass() == TileEntityChest.class) {
                        TileEntityChest chest = (TileEntityChest) tile;
                        if (NullHelper.untrust(chest.adjacentChestXNeg) != null) {
                            tile = chest.adjacentChestXNeg;
                            at.x--;
                        } else if (NullHelper.untrust(chest.adjacentChestZNeg) != null) {
                            tile = chest.adjacentChestZNeg;
                            at.z--;
                        }
                    }
                    TileEntityRendererDispatcher.instance.render(tile, at.x, at.y, at.z, 0);
                }
            }
        }
    });
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityChest(net.minecraft.tileentity.TileEntityChest) Vector3d(com.enderio.core.common.vecmath.Vector3d) BlockPos(net.minecraft.util.math.BlockPos)

Example 34 with Vector3d

use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.

the class IoConfigRenderer method renderScene.

private void renderScene() {
    GlStateManager.enableCull();
    GlStateManager.enableRescaleNormal();
    RenderHelper.disableStandardItemLighting();
    mc.entityRenderer.disableLightmap();
    RenderUtil.bindBlockTexture();
    GlStateManager.disableLighting();
    GlStateManager.enableTexture2D();
    GlStateManager.enableAlpha();
    final Vector3d trans = new Vector3d((-origin.x) + eye.x, (-origin.y) + eye.y, (-origin.z) + eye.z);
    BlockRenderLayer oldRenderLayer = MinecraftForgeClient.getRenderLayer();
    try {
        NNList.of(BlockRenderLayer.class).apply(new Callback<BlockRenderLayer>() {

            @Override
            public void apply(@Nonnull BlockRenderLayer layer) {
                ForgeHooksClient.setRenderLayer(layer);
                setGlStateForPass(layer, false);
                doWorldRenderPass(trans, configurables, layer);
            }
        });
        if (renderNeighbours) {
            NNList.of(BlockRenderLayer.class).apply(new Callback<BlockRenderLayer>() {

                @Override
                public void apply(@Nonnull BlockRenderLayer layer) {
                    ForgeHooksClient.setRenderLayer(layer);
                    setGlStateForPass(layer, true);
                    doWorldRenderPass(trans, neighbours, layer);
                }
            });
        }
    } finally {
        ForgeHooksClient.setRenderLayer(oldRenderLayer);
    }
    RenderHelper.enableStandardItemLighting();
    GlStateManager.enableLighting();
    TileEntityRendererDispatcher.instance.entityX = origin.x - eye.x;
    TileEntityRendererDispatcher.instance.entityY = origin.y - eye.y;
    TileEntityRendererDispatcher.instance.entityZ = origin.z - eye.z;
    TileEntityRendererDispatcher.staticPlayerX = origin.x - eye.x;
    TileEntityRendererDispatcher.staticPlayerY = origin.y - eye.y;
    TileEntityRendererDispatcher.staticPlayerZ = origin.z - eye.z;
    for (int pass = 0; pass < 2; pass++) {
        ForgeHooksClient.setRenderPass(pass);
        setGlStateForPass(pass, false);
        doTileEntityRenderPass(configurables, pass);
        if (renderNeighbours) {
            setGlStateForPass(pass, true);
            doTileEntityRenderPass(neighbours, pass);
        }
    }
    ForgeHooksClient.setRenderPass(-1);
    setGlStateForPass(0, false);
}
Also used : Vector3d(com.enderio.core.common.vecmath.Vector3d) BlockRenderLayer(net.minecraft.util.BlockRenderLayer)

Example 35 with Vector3d

use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.

the class BlockSceneRenderer method renderScene.

private void renderScene() {
    GlStateManager.enableCull();
    GlStateManager.enableRescaleNormal();
    RenderHelper.disableStandardItemLighting();
    mc.entityRenderer.disableLightmap();
    RenderUtil.bindBlockTexture();
    GlStateManager.disableLighting();
    GlStateManager.enableTexture2D();
    GlStateManager.enableAlpha();
    final LayerRenderer layerRenderer = new LayerRenderer(new Vector3d((-origin.x) + eye.x, (-origin.y) + eye.y, (-origin.z) + eye.z));
    BlockRenderLayer oldRenderLayer = MinecraftForgeClient.getRenderLayer();
    try {
        NNList.of(BlockRenderLayer.class).apply(layerRenderer);
    } finally {
        ForgeHooksClient.setRenderLayer(oldRenderLayer);
        GlStateManager.depthMask(true);
    }
}
Also used : Vector3d(com.enderio.core.common.vecmath.Vector3d) BlockRenderLayer(net.minecraft.util.BlockRenderLayer)

Aggregations

Vector3d (com.enderio.core.common.vecmath.Vector3d)35 BoundingBox (com.enderio.core.client.render.BoundingBox)9 EnumFacing (net.minecraft.util.EnumFacing)7 BlockPos (net.minecraft.util.math.BlockPos)7 Nonnull (javax.annotation.Nonnull)6 Vertex (com.enderio.core.common.vecmath.Vertex)4 ArrayList (java.util.ArrayList)4 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)4 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)3 TileEntity (net.minecraft.tileentity.TileEntity)3 RayTraceResult (net.minecraft.util.math.RayTraceResult)3 Vec3d (net.minecraft.util.math.Vec3d)3 VertexRotationFacing (com.enderio.core.client.render.VertexRotationFacing)2 Vector2d (com.enderio.core.common.vecmath.Vector2d)2 Vector4f (com.enderio.core.common.vecmath.Vector4f)2 IBlockState (net.minecraft.block.state.IBlockState)2 Minecraft (net.minecraft.client.Minecraft)2 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)2 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2