Add a method for generating a list of every vector3
This commit is contained in:
parent
5fe283f745
commit
78b5a5f790
5 changed files with 102 additions and 4 deletions
|
@ -5,4 +5,4 @@ org.gradle.daemon=false
|
|||
|
||||
mc_version=1.19.2
|
||||
forge_version=43.2.3
|
||||
myversion=1.0.2.3
|
||||
myversion=1.0.2.4
|
|
@ -3,7 +3,6 @@ package dev.zontreck.libzontreck.vectors;
|
|||
import dev.zontreck.libzontreck.exceptions.InvalidDeserialization;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class Vector2
|
||||
{
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package dev.zontreck.libzontreck.vectors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.zontreck.libzontreck.exceptions.InvalidDeserialization;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
|
@ -71,6 +74,103 @@ public class Vector3
|
|||
}
|
||||
}
|
||||
|
||||
public List<Vector3> makeCube(Vector3 other)
|
||||
{
|
||||
List<Vector3> vecs = new ArrayList<>();
|
||||
Vector3 work = new Vector3();
|
||||
|
||||
double xx = x;
|
||||
double yy = y;
|
||||
double zz = z;
|
||||
|
||||
int yState = 0;
|
||||
int zState = 0;
|
||||
int xState = 0;
|
||||
|
||||
for(xx = Math.round(x); (xx != Math.round(other.x) && xState != 2);)
|
||||
{
|
||||
for(zz = Math.round(z); (zz != Math.round(other.z) && zState != 2);)
|
||||
{
|
||||
for(yy = Math.round(y); (yy != Math.round(other.y) && yState != 2);)
|
||||
{
|
||||
work = new Vector3(xx, yy, zz);
|
||||
|
||||
if(!vecs.contains(work)) vecs.add(work);
|
||||
|
||||
if(yy > other.y)
|
||||
{
|
||||
yy -= 1.0;
|
||||
if(yy == Math.round(other.y) && yState == 0)
|
||||
{
|
||||
yState++;
|
||||
}else{
|
||||
if(yState == 1)
|
||||
{
|
||||
yState ++;
|
||||
}
|
||||
}
|
||||
} else if(yy < other.y)
|
||||
{
|
||||
yy += 1.0;
|
||||
if(yy == Math.round(other.y) && yState == 0){
|
||||
yState ++;
|
||||
}else {
|
||||
if(yState == 1)yState++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
yState=0;
|
||||
work = new Vector3(xx,yy,zz);
|
||||
|
||||
if(!vecs.contains(work)) vecs.add(work);
|
||||
|
||||
if(zz > other.z)
|
||||
{
|
||||
zz -= 1.0;
|
||||
|
||||
if(zz == Math.round(other.z) && zState == 0)zState++;
|
||||
else{
|
||||
if(zState == 1)zState++;
|
||||
}
|
||||
}else if(zz < other.z)
|
||||
{
|
||||
zz += 1.0;
|
||||
|
||||
if(zz == Math.round(other.z) && zState == 0)zState++;
|
||||
else {
|
||||
if(zState==1)zState++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zState=0;
|
||||
work = new Vector3(xx,yy,zz);
|
||||
|
||||
if(!vecs.contains(work)) vecs.add(work);
|
||||
|
||||
if(xx > other.x)
|
||||
{
|
||||
xx -= 1.0;
|
||||
|
||||
if(xx == Math.round(other.x) && xState == 0) xState++;
|
||||
else{
|
||||
if(xState == 1)xState++;
|
||||
}
|
||||
}else if(xx < other.x)
|
||||
{
|
||||
xx += 1.0;
|
||||
|
||||
if(xx == Math.round(other.x) && xState==0)xState++;
|
||||
else{
|
||||
if(xState==1)xState++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return vecs;
|
||||
}
|
||||
|
||||
public Vector3 subtract(Vector3 other)
|
||||
{
|
||||
return new Vector3(x-other.x, y-other.y, z-other.z);
|
||||
|
|
|
@ -5,7 +5,6 @@ import dev.zontreck.libzontreck.exceptions.InvalidDeserialization;
|
|||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.NbtUtils;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
|
||||
public class WorldPosition
|
||||
|
|
|
@ -19,7 +19,7 @@ modId="libzontreck" #mandatory
|
|||
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
||||
# ${file.jarVersion} will substitute the value of the Implementation-Version as read from the mod's JAR file metadata
|
||||
# see the associated build.gradle script for how to populate this completely automatically during a build
|
||||
version="1.0.2.3" #mandatory
|
||||
version="1.0.2.4" #mandatory
|
||||
# A display name for the mod
|
||||
displayName="LibZontreck" #mandatory
|
||||
# A URL to query for updates for this mod. See the JSON update specification https://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/
|
||||
|
|
Reference in a new issue