Search in sources :

Example 16 with Vec3i

use of net.minecraft.util.math.Vec3i in project BuildCraft by BuildCraft.

the class Box method expand.

@Override
public Box expand(int amount) {
    if (!isInitialized())
        return this;
    Vec3i am = new BlockPos(amount, amount, amount);
    setMin(min().subtract(am));
    setMax(max().add(am));
    return this;
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) BlockPos(net.minecraft.util.math.BlockPos)

Example 17 with Vec3i

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

the class ClientRendererUtils 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(GLConstants.QUADS, DefaultVertexFormats.ITEM);
        vertexbuffer.addVertexData(bakedquad.getVertexData());
        if (bakedquad.hasTintIndex()) {
            ClientRendererUtils.putColorRGB_F4(vertexbuffer, red * brightness, green * brightness, blue * brightness);
        } else {
            ClientRendererUtils.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 18 with Vec3i

use of net.minecraft.util.math.Vec3i in project GregTech by GregTechCE.

the class MetaTileEntityTank method setTankController.

private void setTankController(MetaTileEntityTank controller) {
    if (controller == this) {
        return;
    }
    MetaTileEntityTank oldController = getControllerEntity();
    if (oldController == controller) {
        // do not pointlessly update controller
        return;
    }
    if (oldController != null) {
        oldController.removeTankFromMultiblock(this);
    }
    if (controller != null) {
        // we are controlled by somebody now, remove our own controlled tanks
        clearConnectedTanks();
        controller.addTankToMultiblock(this);
    } else {
        // we are controller ourselves now
        setTankControllerInternal(null);
        // reset multiblock size anyway
        this.multiblockSize = new Vec3i(1, 1, 1);
    }
}
Also used : Vec3i(net.minecraft.util.math.Vec3i)

Example 19 with Vec3i

use of net.minecraft.util.math.Vec3i in project GregTech by GregTechCE.

the class MetaTileEntityTank method checkScanMultiblockSelf.

private void checkScanMultiblockSelf(Set<BlockPos> visitedSet) {
    Map<BlockPos, MetaTileEntityTank> tankMap = findConnectedTanks(this, visitedSet);
    if (tankMap.isEmpty())
        return;
    Comparator<BlockPos> comparator = Comparator.comparing(it -> it.getX() + it.getY() + it.getZ());
    BlockPos lowestCorner = tankMap.keySet().stream().min(comparator).get();
    BlockPos highestCorner = tankMap.keySet().stream().max(comparator).get();
    int expectedSizeX = Math.min(highestCorner.getX() - lowestCorner.getX() + 1, maxSizeHorizontal);
    int expectedSizeY = Math.min(highestCorner.getY() - lowestCorner.getY() + 1, maxSizeVertical);
    int expectedSizeZ = Math.min(highestCorner.getZ() - lowestCorner.getZ() + 1, maxSizeHorizontal);
    boolean multiblockAssembled = checkMultiblockValid(tankMap, lowestCorner, expectedSizeX, expectedSizeY, expectedSizeZ);
    MetaTileEntityTank newController = multiblockAssembled ? tankMap.get(lowestCorner) : null;
    if (newController != null) {
        Vec3i multiblockSize = new Vec3i(expectedSizeX, expectedSizeY, expectedSizeZ);
        newController.setTankController(null);
        newController.updateControllerSize(multiblockSize);
    }
    tankMap.values().forEach(it -> it.setTankController(newController));
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) MutableBlockPos(net.minecraft.util.math.BlockPos.MutableBlockPos) BlockPos(net.minecraft.util.math.BlockPos)

Example 20 with Vec3i

use of net.minecraft.util.math.Vec3i in project GregTech by GregTechCE.

the class MetaTileEntityTank method receiveCustomData.

@Override
public void receiveCustomData(int dataId, PacketBuffer buf) {
    super.receiveCustomData(dataId, buf);
    if (dataId == 1) {
        this.controllerPos = buf.readBlockPos();
        this.controllerCache = new WeakReference<>(null);
        this.multiblockFluidTank.setFluid(null);
    } else if (dataId == 2) {
        this.controllerPos = null;
        this.controllerCache = new WeakReference<>(null);
        this.multiblockFluidTank.setFluid(null);
        this.connectedTanks.clear();
        this.multiblockSize = new Vec3i(1, 1, 1);
    } else if (dataId == 3) {
        if (controllerPos == null) {
            FluidStack fluidStack = ByteBufUtils.readFluidStackDelta(buf, multiblockFluidTank.getFluid());
            this.multiblockFluidTank.setFluid(fluidStack);
        }
    } else if (dataId == 4) {
        this.connectedTanks = ByteBufUtils.readRelativeBlockList(buf, getPos());
        this.multiblockSize = buf.readBlockPos();
        recomputeTankSizeNow(true);
    }
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) FluidStack(net.minecraftforge.fluids.FluidStack) WeakReference(java.lang.ref.WeakReference)

Aggregations

Vec3i (net.minecraft.util.math.Vec3i)75 BlockPos (net.minecraft.util.math.BlockPos)40 IBlockState (net.minecraft.block.state.IBlockState)17 World (net.minecraft.world.World)10 EnumFacing (net.minecraft.util.EnumFacing)9 Vec3d (net.minecraft.util.math.Vec3d)8 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)7 Tessellator (net.minecraft.client.renderer.Tessellator)5 IBeeModifier (forestry.api.apiculture.IBeeModifier)4 Random (java.util.Random)4 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)3 TileEntity (net.minecraft.tileentity.TileEntity)3 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)3 IStructure (com.teamwizardry.wizardry.api.block.IStructure)2 IvBlockCollection (ivorius.ivtoolkit.blocks.IvBlockCollection)2 IvWorldData (ivorius.ivtoolkit.tools.IvWorldData)2 ArrayList (java.util.ArrayList)2 Block (net.minecraft.block.Block)2 BufferBuilder (net.minecraft.client.renderer.BufferBuilder)2 ItemStack (net.minecraft.item.ItemStack)2