Skip to content

Commit

Permalink
Groundwork for diagonal mining
Browse files Browse the repository at this point in the history
  • Loading branch information
kyrptonaught committed Oct 1, 2019
1 parent 99d4cd8 commit c0ca002
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx4G
org.gradle.jvmargs=-Xmx2G

# Fabric Properties
# check these on https://fabricmc.net/use
Expand Down
59 changes: 52 additions & 7 deletions src/main/java/net/kyrptonaught/diggusmaximus/Excavate.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package net.kyrptonaught.diggusmaximus;

import net.kyrptonaught.diggusmaximus.config.ConfigOptions;
import net.minecraft.block.Block;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.stat.Stats;
import net.minecraft.util.CuboidBlockIterator;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3i;
import net.minecraft.world.World;

import java.util.ArrayDeque;
Expand Down Expand Up @@ -40,14 +43,56 @@ void startExcavate() {
}

private void spiral(BlockPos pos) {
point(pos.offset(Direction.NORTH));
point(pos.offset(Direction.EAST));
point(pos.offset(Direction.SOUTH));
point(pos.offset(Direction.WEST));
point(pos.offset(Direction.UP));
point(pos.offset(Direction.DOWN));
}
point(pos.north());
point(pos.east());
point(pos.south());
point(pos.west());
point(pos.up());
point(pos.down());
/* BlockPos.stream(-1,-1,-1,1,1,1).forEach(testPos ->{
if(isValidPos(testPos))
point(testPos);
});
*/
point(pos.add(1,0,0));
point(pos.add(0,0,1));
point(pos.add(-1,0,0));
point(pos.add(0,0,-1));
point(pos.add(0,1,0));
point(pos.add(0,-1,0));

if (DiggusMaximusMod.getOptions().mineDiag) {
point(pos.add(1, 0, 1));
point(pos.add(1, 0, -1));
point(pos.add(-1, 0, 1));
point(pos.add(-1, 0, -1));

point(pos.add(1,1,0));
point(pos.add(-1,1,0));
point(pos.add(1,-1,0));
point(pos.add(-1,-1,0));

point(pos.add(0,1,1));
point(pos.add(0,1,-1));
point(pos.add(0,-1,1));
point(pos.add(0,-1,-1));

point(pos.add(1, 1, 1));
point(pos.add(1, -1, 1));
point(pos.add(-1, 1, 1));
point(pos.add(-1, -1, 1));

point(pos.add(1, 1, -1));
point(pos.add(1, -1, -1));
point(pos.add(-1, 1, -1));
point(pos.add(-1, -1, -1));
}
}
private boolean isValidPos(BlockPos pos){
if(DiggusMaximusMod.getOptions().mineDiag)
return true;
return Math.abs(pos.getX()) + Math.abs(pos.getY()) + Math.abs(pos.getZ()) == 1;
}
private void point(BlockPos pos) {
if (player.getEntityWorld().getBlockState(pos).getBlock().equals(startBlock) && canMine(pos)) {
points.add(pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ public class ConfigOptions {
@Comment("Activation key")
public String keybinding = "key.keyboard.grave.accent";

@Comment("Should mine diagonally")
public boolean mineDiag = true;

@Comment("Maximum number of blocks to mine")
public int maxMinedBlocks = 40;

Expand Down

0 comments on commit c0ca002

Please sign in to comment.