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();
}
}
}
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;
}
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);
}
}
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!");
}
}
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();
}
}
Aggregations