Skip to content

Commit

Permalink
update webAura.java
Browse files Browse the repository at this point in the history
- fixed crash
  • Loading branch information
user93390 committed Nov 28, 2024
1 parent 6e4f173 commit 9aa8d1e
Showing 1 changed file with 39 additions and 30 deletions.
69 changes: 39 additions & 30 deletions src/main/java/org/snail/plus/modules/combat/webAura.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,13 @@ public void onTick(TickEvent.Post event) {
if (entity == mc.player || entity.isDead() || entity.distanceTo(mc.player) > range.get() || Friends.get().isFriend(entity))
continue;
if (onlySurround.get() && !CombatUtils.isSurrounded(entity)) continue;
for (BlockPos blockPos : positions(entity)) {

BestTarget = entity;
for (BlockPos blockPos : positions(BestTarget)) {
placed = !WorldUtils.isAir(blockPos);
placeWeb(blockPos);
if (doublePlace.get()) {
placeWeb(blockPos.up(1));
BestTarget = entity;
}
}
}
Expand All @@ -193,10 +194,13 @@ public void placeWeb(BlockPos pos) {
long currentTime = System.currentTimeMillis();
if (currentTime - lastPlacedTime < (1000 / speed.get())) return;
if (!placed) {
FindItemResult web = InvUtils.findInHotbar(Items.COBWEB);
if (web.found()) {
WorldUtils.placeBlock(web, pos, hand.get(), direction.get(), true, swapMode.get(), rotate.get());
FindItemResult web = InvUtils.find(Items.COBWEB);
if (!web.found()) {
error("No webs in hotbar... disabling.");
toggle();
return;
}
WorldUtils.placeBlock(web, pos, hand.get(), direction.get(), true, swapMode.get(), rotate.get());
}
lastPlacedTime = currentTime;
} finally {
Expand All @@ -208,36 +212,41 @@ public void placeWeb(BlockPos pos) {
public void onRender(Render3DEvent event) {
switch (mode.get()) {
case smooth -> {
for (BlockPos pos : positions(BestTarget)) {
if (renderBoxTwo instanceof IBox) {
((IBox) renderBoxTwo).set(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1,
pos.getY() + 1, pos.getZ() + 1);
}
if (BestTarget != null) {

if (renderBoxOne == null) {
renderBoxOne = new Box(pos);
}
if (renderBoxTwo == null) {
renderBoxTwo = new Box(pos);
}
for (BlockPos pos : positions(BestTarget)) {
if (renderBoxTwo instanceof IBox) {
((IBox) renderBoxTwo).set(pos.getX(), pos.getY(), pos.getZ(), pos.getX() + 1,
pos.getY() + 1, pos.getZ() + 1);
}

double offsetX = (renderBoxTwo.minX - renderBoxOne.minX) / Smoothness.get();
double offsetY = (renderBoxTwo.minY - renderBoxOne.minY) / Smoothness.get();
double offsetZ = (renderBoxTwo.minZ - renderBoxOne.minZ) / Smoothness.get();

((IBox) renderBoxOne).set(
renderBoxOne.minX + offsetX,
renderBoxOne.minY + offsetY,
renderBoxOne.minZ + offsetZ,
renderBoxOne.maxX + offsetX,
renderBoxOne.maxY + offsetY,
renderBoxOne.maxZ + offsetZ);
event.renderer.box(renderBoxOne, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
if (renderBoxOne == null) {
renderBoxOne = new Box(pos);
}
if (renderBoxTwo == null) {
renderBoxTwo = new Box(pos);
}

double offsetX = (renderBoxTwo.minX - renderBoxOne.minX) / Smoothness.get();
double offsetY = (renderBoxTwo.minY - renderBoxOne.minY) / Smoothness.get();
double offsetZ = (renderBoxTwo.minZ - renderBoxOne.minZ) / Smoothness.get();

((IBox) renderBoxOne).set(
renderBoxOne.minX + offsetX,
renderBoxOne.minY + offsetY,
renderBoxOne.minZ + offsetZ,
renderBoxOne.maxX + offsetX,
renderBoxOne.maxY + offsetY,
renderBoxOne.maxZ + offsetZ);
event.renderer.box(renderBoxOne, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
}
}
}
case normal -> {
for (BlockPos pos : positions(BestTarget)) {
event.renderer.box(pos, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
if (BestTarget != null) {
for (BlockPos pos : positions(BestTarget)) {
event.renderer.box(pos, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
}
}
}
}
Expand Down

0 comments on commit 9aa8d1e

Please sign in to comment.