Search in sources :

Example 81 with Vec3i

use of net.minecraft.util.math.Vec3i in project 3arthh4ck by 3arthqu4ke.

the class InvalidationHoleManager method invalidate.

private void invalidate(Vec3i... offsets) {
    for (Vec3i vec3i : offsets) {
        mut_pos.incrementX(vec3i.getX());
        mut_pos.incrementY(vec3i.getY());
        mut_pos.incrementZ(vec3i.getZ());
        Hole hole = holes.get(mut_pos);
        if (hole != null && (hole.isAirPart(mut_pos))) {
            holes.remove(mut_pos);
            hole.invalidate();
        }
    }
}
Also used : Vec3i(net.minecraft.util.math.Vec3i)

Example 82 with Vec3i

use of net.minecraft.util.math.Vec3i in project 3arthh4ck by 3arthqu4ke.

the class AntiTrap method getCrystalPositions.

protected List<BlockPos> getCrystalPositions() {
    List<BlockPos> result = new ArrayList<>();
    BlockPos playerPos = PositionUtil.getPosition();
    if (!mc.world.getEntitiesWithinAABB(EntityEnderCrystal.class, new AxisAlignedBB(playerPos, playerPos.up().add(1, 2, 1))).isEmpty()) {
        this.disable();
        return result;
    }
    for (Vec3i vec : AntiTrapMode.Crystal.getOffsets()) {
        BlockPos pos = playerPos.add(vec);
        if (BlockUtil.canPlaceCrystal(pos, false, false)) {
            result.add(pos);
        }
    }
    return result;
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Vec3i(net.minecraft.util.math.Vec3i) ArrayList(java.util.ArrayList) BlockPos(net.minecraft.util.math.BlockPos)

Example 83 with Vec3i

use of net.minecraft.util.math.Vec3i in project 3arthh4ck by 3arthqu4ke.

the class ListenerMotion method doObby.

private void doObby(MotionUpdateEvent event, Vec3i[] offsets) {
    if (event.getStage() == Stage.PRE) {
        // TODO: this looks very similar to AutoTrap,
        // maybe its possible to abstract this even further?
        module.rotations = null;
        module.blocksPlaced = 0;
        for (BlockPos confirmed : module.confirmed) {
            module.placed.remove(confirmed);
        }
        module.placed.entrySet().removeIf(entry -> System.currentTimeMillis() - entry.getValue() >= module.confirm.getValue());
        BlockPos playerPos = PositionUtil.getPosition();
        BlockPos[] positions = new BlockPos[offsets.length];
        for (int i = 0; i < offsets.length; i++) {
            Vec3i offset = offsets[i];
            if (module.mode.getValue() == AntiTrapMode.Fill) {
                if (mc.world.getBlockState(playerPos.add(offset.getX() / 2, 0, offset.getZ() / 2)).getBlock() == Blocks.BEDROCK) {
                    continue;
                }
            }
            positions[i] = playerPos.add(offset);
        }
        if (module.offhand.getValue()) {
            if (!InventoryUtil.isHolding(Blocks.OBSIDIAN)) {
                module.previous = OFFHAND.returnIfPresent(Offhand::getMode, null);
                OFFHAND.computeIfPresent(o -> o.setMode(OffhandMode.CRYSTAL));
                return;
            }
        } else {
            module.slot = InventoryUtil.findHotbarBlock(Blocks.OBSIDIAN);
            if (module.slot == -1) {
                ModuleUtil.disable(module, TextColor.RED + "No Obsidian found.");
                return;
            }
        }
        boolean done = true;
        List<BlockPos> toPlace = new LinkedList<>();
        for (BlockPos pos : positions) {
            if (pos == null) {
                continue;
            }
            if (module.mode.getValue() == AntiTrapMode.Fill && !module.highFill.getValue() && pos.getY() > playerPos.getY()) {
                continue;
            }
            if (mc.world.getBlockState(pos).getMaterial().isReplaceable()) {
                toPlace.add(pos);
                done = false;
            }
        }
        if (done) {
            module.disable();
            return;
        }
        boolean hasPlaced = false;
        Optional<BlockPos> crystalPos = toPlace.stream().filter(pos -> !mc.world.getEntitiesWithinAABB(EntityEnderCrystal.class, new AxisAlignedBB(pos)).isEmpty() && mc.world.getBlockState(pos).getMaterial().isReplaceable()).findFirst();
        if (crystalPos.isPresent()) {
            BlockPos pos = crystalPos.get();
            hasPlaced = module.placeBlock(pos);
        }
        // Only after here we need to use the Helper to get the BlockStates.
        if (!hasPlaced) {
            for (BlockPos pos : toPlace) {
                if (!module.placed.containsKey(pos) && HELPER.getBlockState(pos).getMaterial().isReplaceable()) {
                    module.confirmed.remove(pos);
                    if (module.placeBlock(pos)) {
                        break;
                    }
                }
            }
        }
        if (module.rotate.getValue() != Rotate.None) {
            if (module.rotations != null) {
                event.setYaw(module.rotations[0]);
                event.setPitch(module.rotations[1]);
            }
        } else {
            Locks.acquire(Locks.PLACE_SWITCH_LOCK, module::execute);
        }
    } else {
        Locks.acquire(Locks.PLACE_SWITCH_LOCK, module::execute);
    }
}
Also used : RayTraceUtil(me.earth.earthhack.impl.util.math.RayTraceUtil) Blocks(net.minecraft.init.Blocks) EntityEnderCrystal(net.minecraft.entity.item.EntityEnderCrystal) Rotate(me.earth.earthhack.impl.util.helpers.blocks.modes.Rotate) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ModuleCache(me.earth.earthhack.api.cache.ModuleCache) RotationUtil(me.earth.earthhack.impl.util.math.rotation.RotationUtil) BlockUtil(me.earth.earthhack.impl.util.minecraft.blocks.BlockUtil) EnumHand(net.minecraft.util.EnumHand) MotionUpdateEvent(me.earth.earthhack.impl.event.events.network.MotionUpdateEvent) PositionUtil(me.earth.earthhack.impl.util.math.position.PositionUtil) CPacketPlayerTryUseItemOnBlock(net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock) Vec3i(net.minecraft.util.math.Vec3i) CPacketAnimation(net.minecraft.network.play.client.CPacketAnimation) Stage(me.earth.earthhack.api.event.events.Stage) AntiTrapMode(me.earth.earthhack.impl.modules.combat.antitrap.util.AntiTrapMode) Caches(me.earth.earthhack.impl.modules.Caches) InventoryUtil(me.earth.earthhack.impl.util.minecraft.InventoryUtil) ModuleUtil(me.earth.earthhack.impl.util.client.ModuleUtil) LinkedList(java.util.LinkedList) HELPER(me.earth.earthhack.impl.util.helpers.blocks.ObbyModule.HELPER) ModuleListener(me.earth.earthhack.impl.event.listeners.ModuleListener) TextColor(me.earth.earthhack.impl.util.text.TextColor) Items(net.minecraft.init.Items) BlockPos(net.minecraft.util.math.BlockPos) OffhandMode(me.earth.earthhack.impl.modules.combat.offhand.modes.OffhandMode) List(java.util.List) Swing(me.earth.earthhack.impl.util.minecraft.Swing) Offhand(me.earth.earthhack.impl.modules.combat.offhand.Offhand) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Optional(java.util.Optional) CPacketPlayer(net.minecraft.network.play.client.CPacketPlayer) Comparator(java.util.Comparator) EntityUtil(me.earth.earthhack.impl.util.minecraft.entity.EntityUtil) Locks(me.earth.earthhack.impl.util.thread.Locks) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) Vec3i(net.minecraft.util.math.Vec3i) EntityEnderCrystal(net.minecraft.entity.item.EntityEnderCrystal) BlockPos(net.minecraft.util.math.BlockPos) LinkedList(java.util.LinkedList)

Example 84 with Vec3i

use of net.minecraft.util.math.Vec3i in project 3arthh4ck by 3arthqu4ke.

the class AbstractGeoCache method cache.

@Override
public void cache() {
    Vec3i dummy = new Vec3i(Integer.MAX_VALUE, 0, 0);
    this.cache[this.cache.length - 1] = dummy;
    fill(this.cache, this.indices);
    if (this.cache[this.cache.length - 1] == dummy) {
        throw new IllegalStateException("Cache was not filled!");
    }
}
Also used : Vec3i(net.minecraft.util.math.Vec3i)

Example 85 with Vec3i

use of net.minecraft.util.math.Vec3i in project 3arthh4ck by 3arthqu4ke.

the class HoleRunnable method runSafely.

@Override
public void runSafely() {
    try {
        BlockPos middle = PositionUtil.getPosition();
        int mX = middle.getX();
        int mY = middle.getY();
        int mZ = middle.getZ();
        int maxRadius = Sphere.getRadius(holeRange);
        BlockPos.MutableBlockPos mPos = new BlockPos.MutableBlockPos();
        for (int i = 0; i < maxRadius; i++) {
            Vec3i vec3i = Sphere.get(i);
            mPos.setPos(mX + vec3i.getX(), mY + vec3i.getY(), mZ + vec3i.getZ());
            boolean done = true;
            if (safe.size() < safes || unsafe.size() < unsafes) {
                done = false;
                boolean[] isHole = HoleUtil.isHole(mPos, true);
                if (isHole[0]) {
                    if (isHole[1]) {
                        safe.add(mPos.toImmutable());
                    } else {
                        unsafe.add(mPos.toImmutable());
                    }
                    continue;
                }
            }
            if (longOnes.size() < longs) {
                done = false;
                if (HoleUtil.is2x1(mPos.toImmutable())) {
                    longOnes.add(mPos.toImmutable());
                    continue;
                }
            }
            if (bigHoles.size() < big) {
                done = false;
                if (HoleUtil.is2x2Partial(mPos.toImmutable())) {
                    bigHoles.add(mPos.toImmutable());
                    continue;
                }
            }
            if (done) {
                break;
            }
        }
        manager.setSafe(safe);
        manager.setUnsafe(unsafe);
        manager.setLongHoles(longOnes);
        manager.setBigHoles(bigHoles);
    } finally {
        manager.setFinished();
    }
}
Also used : 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