mirror of
https://github.com/Wurst-Imperium/Wurst7.git
synced 2024-09-19 17:02:13 +02:00
Refactor NukerHack block filtering logic
This commit is contained in:
parent
f4fff81594
commit
7878c65ebb
@ -26,7 +26,6 @@ import net.minecraft.util.hit.BlockHitResult;
|
|||||||
import net.minecraft.util.hit.HitResult;
|
import net.minecraft.util.hit.HitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.util.math.Vec3i;
|
|
||||||
import net.wurstclient.Category;
|
import net.wurstclient.Category;
|
||||||
import net.wurstclient.events.LeftClickListener;
|
import net.wurstclient.events.LeftClickListener;
|
||||||
import net.wurstclient.events.RenderListener;
|
import net.wurstclient.events.RenderListener;
|
||||||
@ -149,47 +148,41 @@ public final class NukerHack extends Hack
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ClientPlayerEntity player = MC.player;
|
ClientPlayerEntity player = MC.player;
|
||||||
Vec3d eyesPos = RotationUtils.getEyesPos().subtract(0.5, 0.5, 0.5);
|
Vec3d eyesVec = RotationUtils.getEyesPos();
|
||||||
BlockPos eyesBlock = BlockPos.ofFloored(RotationUtils.getEyesPos());
|
BlockPos eyesBlock = BlockPos.ofFloored(eyesVec);
|
||||||
double rangeSq = Math.pow(range.getValue(), 2);
|
double rangeSq = range.getValueSq();
|
||||||
int blockRange = (int)Math.ceil(range.getValue());
|
int blockRange = range.getValueCeil();
|
||||||
|
|
||||||
Vec3i rangeVec = new Vec3i(blockRange, blockRange, blockRange);
|
ArrayList<BlockPos> blocks =
|
||||||
BlockPos min = eyesBlock.subtract(rangeVec);
|
BlockUtils.getAllInBoxStream(eyesBlock, blockRange)
|
||||||
BlockPos max = eyesBlock.add(rangeVec);
|
.filter(pos -> pos.getSquaredDistance(eyesVec) <= rangeSq)
|
||||||
|
.filter(BlockUtils::canBeClicked)
|
||||||
ArrayList<BlockPos> blocks = BlockUtils.getAllInBox(min, max);
|
.filter(mode.getSelected().getValidator(this))
|
||||||
Stream<BlockPos> stream = blocks.parallelStream();
|
.sorted(Comparator
|
||||||
|
.comparingDouble(pos -> pos.getSquaredDistance(eyesVec)))
|
||||||
List<BlockPos> blocks2 = stream
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
.filter(pos -> eyesPos.squaredDistanceTo(Vec3d.of(pos)) <= rangeSq)
|
|
||||||
.filter(BlockUtils::canBeClicked)
|
|
||||||
.filter(mode.getSelected().getValidator(this))
|
|
||||||
.sorted(Comparator.comparingDouble(
|
|
||||||
pos -> eyesPos.squaredDistanceTo(Vec3d.of(pos))))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
|
|
||||||
if(player.getAbilities().creativeMode)
|
if(player.getAbilities().creativeMode)
|
||||||
{
|
{
|
||||||
Stream<BlockPos> stream2 = blocks2.parallelStream();
|
Stream<BlockPos> stream2 = blocks.parallelStream();
|
||||||
for(Set<BlockPos> set : prevBlocks)
|
for(Set<BlockPos> set : prevBlocks)
|
||||||
stream2 = stream2.filter(pos -> !set.contains(pos));
|
stream2 = stream2.filter(pos -> !set.contains(pos));
|
||||||
List<BlockPos> blocks3 = stream2.collect(Collectors.toList());
|
List<BlockPos> blocks2 = stream2.collect(Collectors.toList());
|
||||||
|
|
||||||
prevBlocks.addLast(new HashSet<>(blocks3));
|
prevBlocks.addLast(new HashSet<>(blocks2));
|
||||||
while(prevBlocks.size() > 5)
|
while(prevBlocks.size() > 5)
|
||||||
prevBlocks.removeFirst();
|
prevBlocks.removeFirst();
|
||||||
|
|
||||||
if(!blocks3.isEmpty())
|
if(!blocks2.isEmpty())
|
||||||
currentBlock = blocks3.get(0);
|
currentBlock = blocks2.get(0);
|
||||||
|
|
||||||
MC.interactionManager.cancelBlockBreaking();
|
MC.interactionManager.cancelBlockBreaking();
|
||||||
renderer.resetProgress();
|
renderer.resetProgress();
|
||||||
BlockBreaker.breakBlocksWithPacketSpam(blocks3);
|
BlockBreaker.breakBlocksWithPacketSpam(blocks2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(BlockPos pos : blocks2)
|
for(BlockPos pos : blocks)
|
||||||
if(BlockBreaker.breakOneBlock(pos))
|
if(BlockBreaker.breakOneBlock(pos))
|
||||||
{
|
{
|
||||||
currentBlock = pos;
|
currentBlock = pos;
|
||||||
|
Loading…
Reference in New Issue
Block a user