Search in sources :

Example 6 with Vec3i

use of net.minecraft.util.math.Vec3i in project ImmersiveEngineering by BluSunrize.

the class ClientUtils method renderQuads.

public static void renderQuads(Collection<BakedQuad> quads, float brightness, float red, float green, float blue) {
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();
    for (BakedQuad bakedquad : quads) {
        vertexbuffer.begin(7, DefaultVertexFormats.ITEM);
        vertexbuffer.addVertexData(bakedquad.getVertexData());
        if (bakedquad.hasTintIndex())
            vertexbuffer.putColorRGB_F4(red * brightness, green * brightness, blue * brightness);
        else
            vertexbuffer.putColorRGB_F4(brightness, brightness, brightness);
        Vec3i vec3i = bakedquad.getFace().getDirectionVec();
        vertexbuffer.putNormal((float) vec3i.getX(), (float) vec3i.getY(), (float) vec3i.getZ());
        tessellator.draw();
    }
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) UnpackedBakedQuad(net.minecraftforge.client.model.pipeline.UnpackedBakedQuad) Vec3i(net.minecraft.util.math.Vec3i)

Example 7 with Vec3i

use of net.minecraft.util.math.Vec3i in project malmo by Microsoft.

the class BuildBattleDecoratorImplementation method parseParameters.

/**
 * Attempt to parse the given object as a set of parameters for this handler.
 *
 * @param params the parameter block to parse
 * @return true if the object made sense for this handler; false otherwise.
 */
@Override
public boolean parseParameters(Object params) {
    if (params == null || !(params instanceof BuildBattleDecorator))
        return false;
    this.params = (BuildBattleDecorator) params;
    this.sourceBounds = this.params.getGoalStructureBounds();
    this.destBounds = this.params.getPlayerStructureBounds();
    this.delta = new Vec3i(destBounds.getMin().getX() - sourceBounds.getMin().getX(), destBounds.getMin().getY() - sourceBounds.getMin().getY(), destBounds.getMin().getZ() - sourceBounds.getMin().getZ());
    this.structureVolume = volumeOfBounds(this.sourceBounds);
    assert (this.structureVolume == volumeOfBounds(this.destBounds));
    this.dest = new ArrayList<IBlockState>(Collections.nCopies(this.structureVolume, (IBlockState) null));
    this.source = new ArrayList<IBlockState>(Collections.nCopies(this.structureVolume, (IBlockState) null));
    DrawBlockBasedObjectType tickBlock = this.params.getBlockTypeOnCorrectPlacement();
    DrawBlockBasedObjectType crossBlock = this.params.getBlockTypeOnIncorrectPlacement();
    this.blockTypeOnCorrectPlacement = (tickBlock != null) ? new XMLBlockState(tickBlock.getType(), tickBlock.getColour(), tickBlock.getFace(), tickBlock.getVariant()) : null;
    this.blockTypeOnIncorrectPlacement = (crossBlock != null) ? new XMLBlockState(crossBlock.getType(), crossBlock.getColour(), crossBlock.getFace(), crossBlock.getVariant()) : null;
    return true;
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) IBlockState(net.minecraft.block.state.IBlockState) DrawBlockBasedObjectType(com.microsoft.Malmo.Schemas.DrawBlockBasedObjectType) BuildBattleDecorator(com.microsoft.Malmo.Schemas.BuildBattleDecorator) XMLBlockState(com.microsoft.Malmo.Utils.BlockDrawingHelper.XMLBlockState)

Example 8 with Vec3i

use of net.minecraft.util.math.Vec3i in project MorePlanets by SteveKunG.

the class ClientRendererUtil method renderModelBrightnessColorQuads.

private static void renderModelBrightnessColorQuads(float brightness, float red, float green, float blue, List<BakedQuad> listQuads) {
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder vertexbuffer = tessellator.getBuffer();
    int i = 0;
    for (int j = listQuads.size(); i < j; ++i) {
        BakedQuad bakedquad = listQuads.get(i);
        vertexbuffer.begin(7, DefaultVertexFormats.ITEM);
        vertexbuffer.addVertexData(bakedquad.getVertexData());
        if (bakedquad.hasTintIndex()) {
            ClientRendererUtil.putColorRGB_F4(vertexbuffer, red * brightness, green * brightness, blue * brightness);
        } else {
            ClientRendererUtil.putColorRGB_F4(vertexbuffer, brightness, brightness, brightness);
        }
        Vec3i vec3i = bakedquad.getFace().getDirectionVec();
        vertexbuffer.putNormal(vec3i.getX(), vec3i.getY(), vec3i.getZ());
        tessellator.draw();
    }
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Vec3i(net.minecraft.util.math.Vec3i) Tessellator(net.minecraft.client.renderer.Tessellator) BufferBuilder(net.minecraft.client.renderer.BufferBuilder)

Example 9 with Vec3i

use of net.minecraft.util.math.Vec3i in project Overloaded by CJ-MC-Mods.

the class ItemMultiTool method rightClickWithItem.

public void rightClickWithItem(@Nonnull World worldIn, @Nonnull EntityPlayerMP player, @Nonnull BlockPos pos, @Nonnull EnumFacing sideHit, float hitX, float hitY, float hitZ) {
    ItemStack multiTool = player.getHeldItemMainhand();
    if (multiTool.getItem() != this) {
        return;
    }
    NBTTagCompound tagCompound = multiTool.getTagCompound();
    if (tagCompound == null || !tagCompound.hasKey("Item")) {
        player.sendStatusMessage(new TextComponentString("No block type selected to place."), true);
        return;
    }
    NBTTagCompound itemTag = tagCompound.getCompoundTag("Item");
    ItemStack blockStack = new ItemStack(itemTag);
    if (!(blockStack.getItem() instanceof ItemBlock)) {
        player.sendStatusMessage(new TextComponentString("No valid block type selected to place."), true);
        return;
    }
    IEnergyStorage energy = multiTool.getCapability(ENERGY, null);
    Vec3i sideVector = sideHit.getDirectionVec();
    BlockPos.MutableBlockPos newPosition = new BlockPos.MutableBlockPos(pos.add(sideVector));
    if (!placeBlock(blockStack, player, worldIn, newPosition, sideHit, energy, hitX, hitY, hitZ))
        return;
    if (player.isSneaking()) {
        BlockPos playerPos = player.getPosition();
        switch(sideHit) {
            case UP:
                while (newPosition.getY() < playerPos.getY()) {
                    newPosition.move(sideHit);
                    if (!placeBlock(blockStack, player, worldIn, newPosition, sideHit, energy, hitX, hitY, hitZ))
                        break;
                }
                break;
            case DOWN:
                while (newPosition.getY() > playerPos.getY()) {
                    newPosition.move(sideHit);
                    if (!placeBlock(blockStack, player, worldIn, newPosition, sideHit, energy, hitX, hitY, hitZ))
                        break;
                }
                break;
            case NORTH:
                while (newPosition.getZ() > playerPos.getZ()) {
                    newPosition.move(sideHit);
                    if (!placeBlock(blockStack, player, worldIn, newPosition, sideHit, energy, hitX, hitY, hitZ))
                        break;
                }
                break;
            case SOUTH:
                while (newPosition.getZ() < playerPos.getZ()) {
                    newPosition.move(sideHit);
                    if (!placeBlock(blockStack, player, worldIn, newPosition, sideHit, energy, hitX, hitY, hitZ))
                        break;
                }
                break;
            case EAST:
                while (newPosition.getX() < playerPos.getX()) {
                    newPosition.move(sideHit);
                    if (!placeBlock(blockStack, player, worldIn, newPosition, sideHit, energy, hitX, hitY, hitZ))
                        break;
                }
                break;
            case WEST:
                while (newPosition.getX() > playerPos.getX()) {
                    newPosition.move(sideHit);
                    if (!placeBlock(blockStack, player, worldIn, newPosition, sideHit, energy, hitX, hitY, hitZ))
                        break;
                }
                break;
        }
    }
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IEnergyStorage(net.minecraftforge.energy.IEnergyStorage) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) ItemBlock(net.minecraft.item.ItemBlock) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 10 with Vec3i

use of net.minecraft.util.math.Vec3i in project Overloaded by CJ-MC-Mods.

the class ModelUtils method renderQuadsARGB.

public static void renderQuadsARGB(List<BakedQuad> listQuads, int ARGB_Hex) {
    Tessellator tessellator = Tessellator.getInstance();
    VertexBuffer vertexbuffer = tessellator.getBuffer();
    int i = 0;
    for (int j = listQuads.size(); i < j; ++i) {
        BakedQuad bakedquad = (BakedQuad) listQuads.get(i);
        vertexbuffer.begin(7, DefaultVertexFormats.ITEM);
        vertexbuffer.addVertexData(bakedquad.getVertexData());
        vertexbuffer.putColor4(ARGB_Hex);
        Vec3i vec3i = bakedquad.getFace().getDirectionVec();
        vertexbuffer.putNormal((float) vec3i.getX(), (float) vec3i.getY(), (float) vec3i.getZ());
        tessellator.draw();
    }
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) Vec3i(net.minecraft.util.math.Vec3i) Tessellator(net.minecraft.client.renderer.Tessellator) VertexBuffer(net.minecraft.client.renderer.VertexBuffer)

Aggregations

Vec3i (net.minecraft.util.math.Vec3i)13 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)5 IBlockState (net.minecraft.block.state.IBlockState)4 Tessellator (net.minecraft.client.renderer.Tessellator)4 BlockPos (net.minecraft.util.math.BlockPos)4 BlockArea (ivorius.ivtoolkit.blocks.BlockArea)2 IvBlockCollection (ivorius.ivtoolkit.blocks.IvBlockCollection)2 IvWorldData (ivorius.ivtoolkit.tools.IvWorldData)2 HashSet (java.util.HashSet)2 VertexBuffer (net.minecraft.client.renderer.VertexBuffer)2 WorldServer (net.minecraft.world.WorldServer)2 Connection (blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection)1 com.google.gson (com.google.gson)1 BuildBattleDecorator (com.microsoft.Malmo.Schemas.BuildBattleDecorator)1 DrawBlockBasedObjectType (com.microsoft.Malmo.Schemas.DrawBlockBasedObjectType)1 XMLBlockState (com.microsoft.Malmo.Utils.BlockDrawingHelper.XMLBlockState)1 BlockAreas (ivorius.ivtoolkit.blocks.BlockAreas)1 BlockSurfacePos (ivorius.ivtoolkit.blocks.BlockSurfacePos)1 IvMutableBlockPos (ivorius.ivtoolkit.blocks.IvMutableBlockPos)1 MCRegistry (ivorius.ivtoolkit.tools.MCRegistry)1