Skip to content

Commit

Permalink
Some fixes and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Wide-Cat committed Jan 21, 2025
1 parent 6ed0163 commit b4b30a6
Showing 1 changed file with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public enum BlockadeType {
.name("place-range")
.description("The maximum distance at which you can place blocks.")
.defaultValue(4.5)
.max(5.5)
.sliderMax(5.5)
.build()
);

Expand Down Expand Up @@ -469,7 +469,6 @@ public HighwayBuilder() {
- separate digging and paving more effectively
- separate walking forwards from the current state to speed up actions
- scan one block behind you to ensure the highway is still valid
- investigate inventory desync when tools break with double mine?
- do something about god damn lava flowing in
*/

Expand Down Expand Up @@ -591,17 +590,15 @@ private void onGameLeave(GameLeftEvent event) {

@EventHandler
private void onRender2d(Render2DEvent event) {
if (suspended) return;
if (!renderMine.get()) return;
if (suspended || !renderMine.get()) return;

if (normalMining != null) normalMining.renderLetter();
if (packetMining != null) packetMining.renderLetter();
}

@EventHandler
private void onRender3D(Render3DEvent event) {
if (suspended) return;
if (blockPosProvider == null) return; // prevents a fascinating crash
if (suspended || blockPosProvider == null) return; // prevents a fascinating crash

if (renderMine.get()) {
render(event, blockPosProvider.getFront(), mBlockPos -> canMine(mBlockPos, true), true);
Expand Down Expand Up @@ -946,9 +943,16 @@ private int findAcceptablePlacementBlock(HighwayBuilder b) {
return b.trashItems.get().contains(itemStack.getItem());
});

// next we prioritise placement blocks
if (slot == -1) slot = findAndMoveToHotbar(b, itemStack -> {
if (!(itemStack.getItem() instanceof BlockItem bi)) return false;
return b.blocksToPlace.get().contains(bi.getBlock());
});

// falling is an emergency; in this case only, we allow access to any whole block in your inventory
return slot != -1 ? slot : findAndMoveToHotbar(b, itemStack -> {
if (!(itemStack.getItem() instanceof BlockItem bi)) return false;
if (Utils.isShulker(bi)) return false;
Block block = bi.getBlock();

if (!Block.isShapeFullCube(block.getDefaultState().getCollisionShape(b.mc.world, pos))) return false;
Expand Down Expand Up @@ -2013,7 +2017,7 @@ private int findHotbarSlot(HighwayBuilder b, boolean replaceTools) {
if (thrashSlot != -1) return thrashSlot;

// If there are more than 1 slots with building blocks return the slot with the lowest amount of blocks
if (slotsWithBlocks > 1) return slotWithLeastBlocks;
if (slotsWithBlocks > 0) return slotWithLeastBlocks;

// No space found in hotbar
b.error("No empty space in hotbar.");
Expand Down Expand Up @@ -2061,10 +2065,6 @@ protected int findAndMoveToHotbar(HighwayBuilder b, Predicate<ItemStack> predica
}

protected int findAndMoveBestToolToHotbar(HighwayBuilder b, BlockState blockState, boolean noSilkTouch) {
return findAndMoveBestToolToHotbar(b, blockState, noSilkTouch, true);
}

protected int findAndMoveBestToolToHotbar(HighwayBuilder b, BlockState blockState, boolean noSilkTouch, boolean error) {
// Check for creative
if (b.mc.player.isCreative()) return b.mc.player.getInventory().selectedSlot;

Expand Down Expand Up @@ -2096,7 +2096,7 @@ protected int findAndMoveBestToolToHotbar(HighwayBuilder b, BlockState blockStat
if (!b.restockTask.pickaxes && (b.searchEnderChest.get() || b.searchShulkers.get())) {
b.restockTask.setPickaxes();
}
else if (error) {
else {
b.error("Found less than the minimum amount of pickaxes required: " + count + "/" + (b.savePickaxes.get() + 1));
}

Expand Down

0 comments on commit b4b30a6

Please sign in to comment.