Search in sources :

Example 71 with Vec3i

use of net.minecraft.util.math.Vec3i in project Wurst7 by Wurst-Imperium.

the class TreeBotHack method breakBlock.

private boolean breakBlock(BlockPos pos) {
    Direction side = TreeBotUtils.getLineOfSightSide(RotationUtils.getEyesPos(), pos);
    Vec3d relCenter = BlockUtils.getBoundingBox(pos).offset(-pos.getX(), -pos.getY(), -pos.getZ()).getCenter();
    Vec3d center = Vec3d.of(pos).add(relCenter);
    Vec3i dirVec = side.getVector();
    Vec3d relHitVec = new Vec3d(relCenter.x * dirVec.getX(), relCenter.y * dirVec.getY(), relCenter.z * dirVec.getZ());
    Vec3d hitVec = center.add(relHitVec);
    // face block
    WURST.getRotationFaker().faceVectorPacket(hitVec);
    // damage block
    if (!MC.interactionManager.updateBlockBreakingProgress(pos, side))
        return false;
    // swing arm
    MC.player.networkHandler.sendPacket(new HandSwingC2SPacket(Hand.MAIN_HAND));
    return true;
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) HandSwingC2SPacket(net.minecraft.network.packet.c2s.play.HandSwingC2SPacket) Direction(net.minecraft.util.math.Direction) Vec3d(net.minecraft.util.math.Vec3d)

Example 72 with Vec3i

use of net.minecraft.util.math.Vec3i in project Spelunker by Leximon.

the class ChunkOres method remapToWorldCoordinates.

/**
 * remaps all local coordinates to world coordinates
 * @param bottomSectionCord the bottom section cord of the world
 * @return this
 */
public ChunkOres remapToWorldCoordinates(int bottomSectionCord) {
    remapped = true;
    HashMap<Vec3i, Block> clone = new HashMap<>(this);
    clear();
    for (Map.Entry<Vec3i, Block> pair : clone.entrySet()) {
        Vec3i p = pair.getKey();
        put(new Vec3i(ChunkSectionPos.getBlockCoord(pos.getX()) + p.getX(), ChunkSectionPos.getBlockCoord(pos.getY() + bottomSectionCord) + p.getY(), ChunkSectionPos.getBlockCoord(pos.getZ()) + p.getZ()), pair.getValue());
    }
    return this;
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) HashMap(java.util.HashMap) Block(net.minecraft.block.Block) Map(java.util.Map) HashMap(java.util.HashMap)

Example 73 with Vec3i

use of net.minecraft.util.math.Vec3i in project Spelunker by Leximon.

the class PlayerEntityMixin method moveEndInject.

@Inject(method = "tick", at = @At("HEAD"))
private void moveEndInject(CallbackInfo ci) {
    if (!hasStatusEffect(SpelunkerMod.STATUS_EFFECT_SPELUNKER)) {
        if (!spelunkerEffectChunks.isEmpty())
            spelunkerEffectChunks.clear();
        forceOreChunkUpdate = true;
        return;
    }
    if (SpelunkerConfig.serverValidating && world.isClient())
        return;
    int cx = ChunkSectionPos.getSectionCoord(getX());
    int cy = ChunkSectionPos.getSectionCoord(getY());
    int cz = ChunkSectionPos.getSectionCoord(getZ());
    // update if player crosses chunk border
    if (cx != lastCx || cy != lastCy || cz != lastCz || forceOreChunkUpdate) {
        forceOreChunkUpdate = false;
        HashMap<Vec3i, ChunkSection> newChunks = SpelunkerEffectManager.getSurroundingChunkSections(world, getPos());
        // calc difference and find ores
        HashSet<Vec3i> remove = new HashSet<>();
        spelunkerEffectChunks.removeIf(p -> {
            if (!newChunks.containsKey(p)) {
                remove.add(p);
                return true;
            }
            return false;
        });
        ArrayList<ChunkOres> add = new ArrayList<>();
        for (Map.Entry<Vec3i, ChunkSection> section : newChunks.entrySet()) {
            Vec3i pos = section.getKey();
            if (!spelunkerEffectChunks.contains(pos)) {
                add.add(SpelunkerEffectManager.findOresInChunk(world, pos));
                spelunkerEffectChunks.add(pos);
            }
        }
        // handle new and removed chunk sections
        if (world.isClient()) {
            SpelunkerModClient.spelunkerEffectRenderer.updateChunks(world, remove, add);
        } else if (SpelunkerConfig.serverValidating) {
            PacketByteBuf buf = SpelunkerEffectManager.writePacket(world, true, remove, add);
            ServerPlayNetworking.send((ServerPlayerEntity) (Object) this, SpelunkerMod.PACKET_ORE_CHUNKS, buf);
        }
    }
    lastCx = cx;
    lastCy = cy;
    lastCz = cz;
}
Also used : Vec3i(net.minecraft.util.math.Vec3i) ChunkOres(de.leximon.spelunker.core.ChunkOres) ArrayList(java.util.ArrayList) ServerPlayerEntity(net.minecraft.server.network.ServerPlayerEntity) PacketByteBuf(net.minecraft.network.PacketByteBuf) ChunkSection(net.minecraft.world.chunk.ChunkSection) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 74 with Vec3i

use of net.minecraft.util.math.Vec3i in project Zone by wje5.

the class ObjHandler method renderQuads.

public static void renderQuads(List<BakedQuad> listQuads) {
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferbuilder = tessellator.getBuffer();
    int i = 0;
    for (int j = listQuads.size(); i < j; ++i) {
        BakedQuad bakedquad = listQuads.get(i);
        bufferbuilder.begin(GL11.GL_QUADS, DefaultVertexFormats.ITEM);
        bufferbuilder.addVertexData(bakedquad.getVertexData());
        // if (bakedquad.hasTintIndex()) {
        // bufferbuilder.putColorRGB_F4(red * brightness, green * brightness, blue * brightness);
        // } else {
        // bufferbuilder.putColorRGB_F4(brightness, brightness, brightness);
        // }
        Vec3i vec3i = bakedquad.getFace().getDirectionVec();
        bufferbuilder.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 75 with Vec3i

use of net.minecraft.util.math.Vec3i in project tetra by mickelus.

the class ExtendedStructureTESR method renderChild.

private void renderChild(FeatureChild featureChild, MatrixStack matrixStack, IVertexBuilder vertexBuilder, double x, double y, double z) {
    Tessellator tessellator = Tessellator.getInstance();
    BufferBuilder bufferBuilder = tessellator.getBuffer();
    BlockPos offset = featureChild.offset;
    AxisAlignedBB aabb = new AxisAlignedBB(x + offset.getX() + 0.5, y + offset.getY() + 0.5, z + offset.getZ() + 0.5, x + offset.getX() + 0.5, y + offset.getY() + 0.5, z + offset.getZ() + 0.5);
    // build outline box
    WorldRenderer.drawBoundingBox(matrixStack, vertexBuilder, aabb.grow(0.5020000000949949026D), 1, 1, 0, 1);
    // build arrow
    bufferBuilder.begin(3, DefaultVertexFormats.POSITION_COLOR);
    Vec3i facing = featureChild.facing.getDirectionVec();
    bufferBuilder.pos(x + offset.getX() + 0.5, y + offset.getY() + 0.5, z + offset.getZ() + 0.5).color(0.0F, 0.0F, 0.0F, 0.0F).endVertex();
    bufferBuilder.pos(x + offset.getX() + 0.5 + 0.3 * facing.getX(), y + offset.getY() + 0.5 + 0.3 * facing.getY(), z + offset.getZ() + 0.5 + 0.3 * facing.getZ()).color(1, 1, 1, 1.0F).endVertex();
    tessellator.draw();
    // draw middle block
    DebugRenderer.renderBox(aabb.grow(0.1), 0, 0, 0, 0.8f);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Vec3i(net.minecraft.util.math.Vec3i) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

Vec3i (net.minecraft.util.math.Vec3i)161 BlockPos (net.minecraft.util.math.BlockPos)88 IBlockState (net.minecraft.block.state.IBlockState)29 Vec3d (net.minecraft.util.math.Vec3d)25 EnumFacing (net.minecraft.util.EnumFacing)18 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)15 Block (net.minecraft.block.Block)12 Entity (net.minecraft.entity.Entity)11 ArrayList (java.util.ArrayList)10 World (net.minecraft.world.World)10 TileEntity (net.minecraft.tileentity.TileEntity)8 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)7 HashSet (java.util.HashSet)6 Tessellator (net.minecraft.client.renderer.Tessellator)6 EntityEnderCrystal (net.minecraft.entity.item.EntityEnderCrystal)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)6 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)6 HashMap (java.util.HashMap)5 Random (java.util.Random)5 Direction (net.minecraft.util.math.Direction)5