Skip to content

Commit

Permalink
fixed vein mining not working properly, also fixed sneak not being im…
Browse files Browse the repository at this point in the history
…plemented when vein mining
  • Loading branch information
CrossVas committed Sep 30, 2024
1 parent ad2cfe7 commit e68787a
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 58 deletions.
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ dependencies {
modImplementation files("libs/extrautils - 0.2.4g.zip")
modImplementation files("libs/Biomes-O-Plenty-0.5.7-1.5.2.zip")
modImplementation files("libs/ModularPowersuits-1.5.2-0.7.1-635.jar")
modImplementation files("libs/ModularPowersuits-1.5.2-0.7.1-635.jar")
coremodImplementation files("libs/[1.5.2]TreeCapitator.Forge.1.5.2.r14.Uni.CoreMod.jar")

implementation group: 'it.unimi.dsi', name: 'fastutil', version: '8.2.1'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import reforged.mods.gravisuite.items.tools.base.ItemToolElectric;
import reforged.mods.gravisuite.utils.Helpers;
import reforged.mods.gravisuite.utils.Refs;
import reforged.mods.gravisuite.utils.BlockPos;
import reforged.mods.gravisuite.utils.pos.BlockPos;

import java.util.ArrayList;
import java.util.HashSet;
Expand Down Expand Up @@ -130,7 +130,7 @@ public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPla

if (isLog) {
BlockPos origin = new BlockPos(x, y, z);
Set<BlockPos> vein = Helpers.veinPos(world, origin, 128);
Set<BlockPos> vein = Helpers.veinPos(world, origin, player.isSneaking() ? 0 : 256);
for (BlockPos coord : vein) {
if (coord.equals(origin)) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import reforged.mods.gravisuite.utils.Helpers;
import reforged.mods.gravisuite.utils.Refs;
import reforged.mods.gravisuite.utils.TextFormatter;
import reforged.mods.gravisuite.utils.BlockPos;
import reforged.mods.gravisuite.utils.pos.BlockPos;

import java.util.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
import reforged.mods.gravisuite.items.tools.base.ItemToolElectric;
import reforged.mods.gravisuite.utils.Helpers;
import reforged.mods.gravisuite.utils.Refs;
import reforged.mods.gravisuite.utils.BlockPos;
import reforged.mods.gravisuite.utils.pos.BlockPos;

import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class ItemVajra extends ItemToolElectric {

Expand Down Expand Up @@ -131,7 +132,8 @@ public boolean onBlockStartBreak(ItemStack stack, int x, int y, int z, EntityPla
boolean veinGeneral = ((mode == VajraMode.VEIN && isOre) || mode == VajraMode.VEIN_EXTENDED);
if (veinGeneral) {
BlockPos origin = new BlockPos(x, y, z);
for (BlockPos coord : Helpers.veinPos(world, origin, 128)) {
Set<BlockPos> vein = Helpers.veinPos(world, origin, player.isSneaking() ? 0 : 128);
for (BlockPos coord : vein) {
if (coord.equals(origin)) {
continue;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/reforged/mods/gravisuite/utils/Helpers.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import net.minecraft.world.World;
import net.minecraftforge.oredict.OreDictionary;
import org.lwjgl.input.Keyboard;
import reforged.mods.gravisuite.utils.pos.BlockPos;

import java.lang.reflect.Array;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,79 +1,39 @@
package reforged.mods.gravisuite.utils;
package reforged.mods.gravisuite.utils.pos;

import com.google.common.base.Objects;
import com.google.common.collect.AbstractIterator;
import net.jcip.annotations.Immutable;
import org.jetbrains.annotations.NotNull;

import java.util.Iterator;

@Immutable
public class BlockPos implements Comparable<BlockPos> {

/**
* X coordinate
*/
private final int x;
/**
* Y coordinate
*/
private final int y;
/**
* Z coordinate
*/
private final int z;
public class BlockPos extends Vec3i {

public BlockPos(int x, int y, int z) {
this.x = x;
this.y = y;
this.z = z;
super(x, y, z);
}

public BlockPos(BlockPos source) {
this(source.getX(), source.getY(), source.getZ());
}

/**
* Gets the X coordinate.
*/
public int getX() {
return this.x;
public BlockPos(double x, double y, double z) {
super(x, y, z);
}

/**
* Gets the Y coordinate.
*/
public int getY() {
return this.y;
public BlockPos(Vec3i source) {
this(source.getX(), source.getY(), source.getZ());
}

/**
* Gets the Z coordinate.
*/
public int getZ() {
return this.z;
public BlockPos add(double x, double y, double z) {
return x == 0.0D && y == 0.0D && z == 0.0D ? this : new BlockPos((double) this.getX() + x, (double) this.getY() + y, (double) this.getZ() + z);
}

public BlockPos add(int x, int y, int z) {
return x == 0 && y == 0 && z == 0 ? this : new BlockPos(this.getX() + x, this.getY() + y, this.getZ() + z);
}

public BlockPos toImmutable() {
return this;
}

@Override
public int compareTo(@NotNull BlockPos anotherPos) {
if (this.getY() == anotherPos.getY()) {
return this.getZ() == anotherPos.getZ() ? this.getX() - anotherPos.getX() : this.getZ() - anotherPos.getZ();
} else {
return this.getY() - anotherPos.getY();
}
public BlockPos add(Vec3i vec) {
return this.add(vec.getX(), vec.getY(), vec.getZ());
}

@Override
public String toString() {
return Objects.toStringHelper(this).add("x", this.getX()).add("y", this.getY()).add("z", this.getZ()).toString();
public BlockPos toImmutable() {
return this;
}

public static Iterable<MutableBlockPos> getAllInBoxMutable(BlockPos from, BlockPos to) {
Expand Down Expand Up @@ -124,6 +84,10 @@ public MutableBlockPos(int x, int y, int z) {
this.z = z;
}

public BlockPos add(double x, double y, double z) {
return super.add(x, y, z).toImmutable();
}

public BlockPos add(int x, int y, int z) {
return super.add(x, y, z).toImmutable();
}
Expand Down
90 changes: 90 additions & 0 deletions src/main/java/reforged/mods/gravisuite/utils/pos/Vec3i.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package reforged.mods.gravisuite.utils.pos;

import com.google.common.base.Objects;
import net.jcip.annotations.Immutable;
import net.minecraft.util.MathHelper;

@Immutable
public class Vec3i implements Comparable<Vec3i> {
/**
* X coordinate
*/
private final int x;
/**
* Y coordinate
*/
private final int y;
/**
* Z coordinate
*/
private final int z;

public Vec3i(int xIn, int yIn, int zIn) {
this.x = xIn;
this.y = yIn;
this.z = zIn;
}

public Vec3i(double xIn, double yIn, double zIn) {
this(MathHelper.floor_double(xIn), MathHelper.floor_double(yIn), MathHelper.floor_double(zIn));
}

/**
* Gets the X coordinate.
*/
public int getX() {
return this.x;
}

/**
* Gets the Y coordinate.
*/
public int getY() {
return this.y;
}

/**
* Gets the Z coordinate.
*/
public int getZ() {
return this.z;
}

@Override
public boolean equals(Object p_equals_1_) {
if (this == p_equals_1_) {
return true;
} else if (!(p_equals_1_ instanceof Vec3i)) {
return false;
} else {
Vec3i vec3i = (Vec3i) p_equals_1_;

if (this.getX() != vec3i.getX()) {
return false;
} else if (this.getY() != vec3i.getY()) {
return false;
} else {
return this.getZ() == vec3i.getZ();
}
}
}

@Override
public int hashCode() {
return (this.getY() + this.getZ() * 31) * 31 + this.getX();
}

@Override
public int compareTo(Vec3i p_compareTo_1_) {
if (this.getY() == p_compareTo_1_.getY()) {
return this.getZ() == p_compareTo_1_.getZ() ? this.getX() - p_compareTo_1_.getX() : this.getZ() - p_compareTo_1_.getZ();
} else {
return this.getY() - p_compareTo_1_.getY();
}
}

@Override
public String toString() {
return Objects.toStringHelper(this).add("x", this.getX()).add("y", this.getY()).add("z", this.getZ()).toString();
}
}

0 comments on commit e68787a

Please sign in to comment.