Removed momussCore
This commit is contained in:
parent
44d8f09746
commit
d522d10c95
22 changed files with 966 additions and 46 deletions
|
@ -85,7 +85,6 @@ dependencies {
|
|||
compile "codechicken:ForgeMultipart:1.7.10-1.1.2.331:dev"
|
||||
compile "mcp.mobius.waila:Waila:1.5.10_1.7.10:dev"
|
||||
compile 'com.mod-buildcraft:buildcraft:6.4.8:dev'
|
||||
compile "ModmussCore-17:ModmussCore-1.7:1.1.+:dev"
|
||||
compile "qmunity:QmunityLib:0.1.+:deobf"
|
||||
grabDep('ThermalFoundation-[1.7.10]1.0.0-81.jar', 'http://addons-origin.cursecdn.com/files/2233/780/ThermalFoundation-[1.7.10]1.0.0-81.jar')
|
||||
grabDep('CoFHCore-[1.7.10]3.0.2-262.jar', 'http://addons-origin.cursecdn.com/files/2234/198/CoFHCore-[1.7.10]3.0.2-262.jar')
|
||||
|
|
45
src/main/java/techreborn/lib/Functions.java
Normal file
45
src/main/java/techreborn/lib/Functions.java
Normal file
|
@ -0,0 +1,45 @@
|
|||
package techreborn.lib;
|
||||
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class Functions {
|
||||
public static int getIntDirFromDirection(ForgeDirection dir) {
|
||||
switch (dir) {
|
||||
case DOWN:
|
||||
return 0;
|
||||
case EAST:
|
||||
return 5;
|
||||
case NORTH:
|
||||
return 2;
|
||||
case SOUTH:
|
||||
return 3;
|
||||
case UNKNOWN:
|
||||
return 0;
|
||||
case UP:
|
||||
return 1;
|
||||
case WEST:
|
||||
return 4;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static ForgeDirection getDirectionFromInt(int dir) {
|
||||
int metaDataToSet = 0;
|
||||
switch (dir) {
|
||||
case 0:
|
||||
metaDataToSet = 2;
|
||||
break;
|
||||
case 1:
|
||||
metaDataToSet = 4;
|
||||
break;
|
||||
case 2:
|
||||
metaDataToSet = 3;
|
||||
break;
|
||||
case 3:
|
||||
metaDataToSet = 5;
|
||||
break;
|
||||
}
|
||||
return ForgeDirection.getOrientation(metaDataToSet);
|
||||
}
|
||||
}
|
271
src/main/java/techreborn/lib/Location.java
Normal file
271
src/main/java/techreborn/lib/Location.java
Normal file
|
@ -0,0 +1,271 @@
|
|||
package techreborn.lib;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.MovingObjectPosition;
|
||||
import net.minecraft.world.ChunkPosition;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class Location {
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
public int depth;
|
||||
|
||||
public Location(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public Location(int x, int y, int z, int depth) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.depth = depth;
|
||||
}
|
||||
|
||||
|
||||
public Location(int xCoord, int yCoord, int zCoord, ForgeDirection dir) {
|
||||
this.x = xCoord + dir.offsetX;
|
||||
this.y = yCoord + dir.offsetY;
|
||||
this.z = zCoord + dir.offsetZ;
|
||||
}
|
||||
|
||||
public Location(int[] coords) {
|
||||
if (coords.length >= 2) {
|
||||
this.x = coords[0];
|
||||
this.y = coords[1];
|
||||
this.z = coords[2];
|
||||
}
|
||||
}
|
||||
|
||||
public Location(ChunkPosition pos) {
|
||||
if (pos != null) {
|
||||
this.x = pos.chunkPosX;
|
||||
this.y = pos.chunkPosY;
|
||||
this.z = pos.chunkPosZ;
|
||||
}
|
||||
}
|
||||
|
||||
public Location(MovingObjectPosition blockLookedAt) {
|
||||
if (blockLookedAt != null) {
|
||||
this.x = blockLookedAt.blockX;
|
||||
this.y = blockLookedAt.blockY;
|
||||
this.z = blockLookedAt.blockZ;
|
||||
}
|
||||
}
|
||||
|
||||
public Location(TileEntity par1)
|
||||
{
|
||||
this.x = par1.xCoord;
|
||||
this.y = par1.yCoord;
|
||||
this.z = par1.zCoord;
|
||||
}
|
||||
|
||||
public boolean equals(Location toTest) {
|
||||
if (this.x == toTest.x && this.y == toTest.y && this.z == toTest.z) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setLocation(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public void setX(int newX) {
|
||||
this.x = newX;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return this.y;
|
||||
}
|
||||
|
||||
public void setY(int newY) {
|
||||
this.y = newY;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return this.z;
|
||||
}
|
||||
|
||||
public void setZ(int newZ) {
|
||||
this.z = newZ;
|
||||
}
|
||||
|
||||
public int[] getLocation() {
|
||||
int[] ret = new int[3];
|
||||
ret[0] = this.x;
|
||||
ret[1] = this.y;
|
||||
ret[2] = this.z;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public void setLocation(int[] coords) {
|
||||
this.x = coords[0];
|
||||
this.y = coords[1];
|
||||
this.z = coords[2];
|
||||
}
|
||||
|
||||
public int getDifference(Location otherLoc) {
|
||||
return (int) Math.sqrt(Math.pow(this.x - otherLoc.x, 2) + Math.pow(this.y - otherLoc.y, 2) + Math.pow(this.z - otherLoc.z, 2));
|
||||
}
|
||||
|
||||
public String printLocation() {
|
||||
return "X: " + this.x + " Y: " + this.y + " Z: " + this.z;
|
||||
}
|
||||
|
||||
public String printCoords() {
|
||||
return this.x + ", " + this.y + ", " + this.z;
|
||||
}
|
||||
|
||||
public boolean compare(int x, int y, int z) {
|
||||
return (this.x == x && this.y == y && this.z == z);
|
||||
}
|
||||
|
||||
public Location getLocation(ForgeDirection dir) {
|
||||
return new Location(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
|
||||
}
|
||||
|
||||
public Location modifyPositionFromSide(ForgeDirection side, int amount)
|
||||
{
|
||||
switch (side.ordinal())
|
||||
{
|
||||
case 0:
|
||||
this.y -= amount;
|
||||
break;
|
||||
case 1:
|
||||
this.y += amount;
|
||||
break;
|
||||
case 2:
|
||||
this.z -= amount;
|
||||
break;
|
||||
case 3:
|
||||
this.z += amount;
|
||||
break;
|
||||
case 4:
|
||||
this.x -= amount;
|
||||
break;
|
||||
case 5:
|
||||
this.x += amount;
|
||||
break;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public Location modifyPositionFromSide(ForgeDirection side)
|
||||
{
|
||||
return this.modifyPositionFromSide(side, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* This will load the chunk.
|
||||
*/
|
||||
public TileEntity getTileEntity(IBlockAccess world)
|
||||
{
|
||||
return world.getTileEntity(this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
public final Location clone()
|
||||
{
|
||||
return new Location(this.x, this.y, this.z);
|
||||
}
|
||||
|
||||
/**
|
||||
* No chunk load: returns null if chunk to side is unloaded
|
||||
*/
|
||||
public TileEntity getTileEntityOnSide(World world, ForgeDirection side)
|
||||
{
|
||||
int x = this.x;
|
||||
int y = this.y;
|
||||
int z = this.z;
|
||||
switch (side.ordinal())
|
||||
{
|
||||
case 0:
|
||||
y--;
|
||||
break;
|
||||
case 1:
|
||||
y++;
|
||||
break;
|
||||
case 2:
|
||||
z--;
|
||||
break;
|
||||
case 3:
|
||||
z++;
|
||||
break;
|
||||
case 4:
|
||||
x--;
|
||||
break;
|
||||
case 5:
|
||||
x++;
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
if (world.blockExists(x, y, z))
|
||||
{
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* No chunk load: returns null if chunk to side is unloaded
|
||||
*/
|
||||
public TileEntity getTileEntityOnSide(World world, int side)
|
||||
{
|
||||
int x = this.x;
|
||||
int y = this.y;
|
||||
int z = this.z;
|
||||
switch (side)
|
||||
{
|
||||
case 0:
|
||||
y--;
|
||||
break;
|
||||
case 1:
|
||||
y++;
|
||||
break;
|
||||
case 2:
|
||||
z--;
|
||||
break;
|
||||
case 3:
|
||||
z++;
|
||||
break;
|
||||
case 4:
|
||||
x--;
|
||||
break;
|
||||
case 5:
|
||||
x++;
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
if (world.blockExists(x, y, z))
|
||||
{
|
||||
return world.getTileEntity(x, y, z);
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public int getDepth() {
|
||||
return depth;
|
||||
}
|
||||
|
||||
public int compareTo(Location o) {
|
||||
return ((Integer)depth).compareTo(o.depth);
|
||||
}
|
||||
}
|
431
src/main/java/techreborn/lib/vecmath/Vecs3d.java
Normal file
431
src/main/java/techreborn/lib/vecmath/Vecs3d.java
Normal file
|
@ -0,0 +1,431 @@
|
|||
package techreborn.lib.vecmath;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
public class Vecs3d {
|
||||
protected double x, y, z;
|
||||
protected World w = null;
|
||||
|
||||
public Vecs3d(double x, double y, double z) {
|
||||
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public Vecs3d(double x, double y, double z, World w) {
|
||||
|
||||
this(x, y, z);
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
public Vecs3d(TileEntity te) {
|
||||
|
||||
this(te.xCoord, te.yCoord, te.zCoord, te.getWorldObj());
|
||||
}
|
||||
|
||||
public Vecs3d(Vec3 vec) {
|
||||
|
||||
this(vec.xCoord, vec.yCoord, vec.zCoord);
|
||||
}
|
||||
|
||||
public Vecs3d(Vec3 vec, World w) {
|
||||
|
||||
this(vec.xCoord, vec.yCoord, vec.zCoord);
|
||||
this.w = w;
|
||||
}
|
||||
|
||||
public boolean hasWorld() {
|
||||
|
||||
return w != null;
|
||||
}
|
||||
|
||||
public Vecs3d add(double x, double y, double z) {
|
||||
|
||||
this.x += x;
|
||||
this.y += y;
|
||||
this.z += z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vecs3d add(ForgeDirection dir) {
|
||||
|
||||
return add(dir.offsetX, dir.offsetY, dir.offsetZ);
|
||||
}
|
||||
|
||||
public Vecs3d add(Vecs3d vec) {
|
||||
|
||||
return add(vec.x, vec.y, vec.z);
|
||||
}
|
||||
|
||||
public Vecs3d sub(double x, double y, double z) {
|
||||
|
||||
this.x -= x;
|
||||
this.y -= y;
|
||||
this.z -= z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vecs3d sub(ForgeDirection dir) {
|
||||
|
||||
return sub(dir.offsetX, dir.offsetY, dir.offsetZ);
|
||||
}
|
||||
|
||||
public Vecs3d sub(Vecs3d vec) {
|
||||
|
||||
return sub(vec.x, vec.y, vec.z);
|
||||
}
|
||||
|
||||
public Vecs3d mul(double x, double y, double z) {
|
||||
|
||||
this.x *= x;
|
||||
this.y *= y;
|
||||
this.z *= z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vecs3d mul(double multiplier) {
|
||||
|
||||
return mul(multiplier, multiplier, multiplier);
|
||||
}
|
||||
|
||||
public Vecs3d mul(ForgeDirection direction) {
|
||||
|
||||
return mul(direction.offsetX, direction.offsetY, direction.offsetZ);
|
||||
}
|
||||
|
||||
public Vecs3d multiply(Vecs3d v) {
|
||||
|
||||
return mul(v.getX(), v.getY(), v.getZ());
|
||||
}
|
||||
|
||||
public Vecs3d div(double x, double y, double z) {
|
||||
|
||||
this.x /= x;
|
||||
this.y /= y;
|
||||
this.z /= z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vecs3d div(double multiplier) {
|
||||
|
||||
return div(multiplier, multiplier, multiplier);
|
||||
}
|
||||
|
||||
public Vecs3d div(ForgeDirection direction) {
|
||||
|
||||
return div(direction.offsetX, direction.offsetY, direction.offsetZ);
|
||||
}
|
||||
|
||||
public double length() {
|
||||
|
||||
return Math.sqrt(x * x + y * y + z * z);
|
||||
}
|
||||
|
||||
public Vecs3d normalize() {
|
||||
|
||||
Vecs3d v = clone();
|
||||
|
||||
double len = length();
|
||||
|
||||
if (len == 0)
|
||||
return v;
|
||||
|
||||
v.x /= len;
|
||||
v.y /= len;
|
||||
v.z /= len;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public Vecs3d abs() {
|
||||
|
||||
return new Vecs3d(Math.abs(x), Math.abs(y), Math.abs(z));
|
||||
}
|
||||
|
||||
public double dot(Vecs3d v) {
|
||||
|
||||
return x * v.getX() + y * v.getY() + z * v.getZ();
|
||||
}
|
||||
|
||||
public Vecs3d cross(Vecs3d v) {
|
||||
|
||||
return new Vecs3d(y * v.getZ() - z * v.getY(), x * v.getZ() - z * v.getX(), x * v.getY() - y * v.getX());
|
||||
}
|
||||
|
||||
public Vecs3d getRelative(double x, double y, double z) {
|
||||
|
||||
return clone().add(x, y, z);
|
||||
}
|
||||
|
||||
public Vecs3d getRelative(ForgeDirection dir) {
|
||||
|
||||
return getRelative(dir.offsetX, dir.offsetY, dir.offsetZ);
|
||||
}
|
||||
|
||||
public ForgeDirection getDirectionTo(Vecs3d vec) {
|
||||
|
||||
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS)
|
||||
if (getBlockX() + d.offsetX == vec.getBlockX() && getBlockY() + d.offsetY == vec.getBlockY()
|
||||
&& getBlockZ() + d.offsetZ == vec.getBlockZ())
|
||||
return d;
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isZero() {
|
||||
|
||||
return x == 0 && y == 0 && z == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vecs3d clone() {
|
||||
|
||||
return new Vecs3d(x, y, z, w);
|
||||
}
|
||||
|
||||
public boolean hasTileEntity() {
|
||||
|
||||
if (hasWorld()) {
|
||||
return w.getTileEntity((int) x, (int) y, (int) z) != null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public TileEntity getTileEntity() {
|
||||
|
||||
if (hasTileEntity()) {
|
||||
return w.getTileEntity((int) x, (int) y, (int) z);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isBlock(Block b) {
|
||||
|
||||
return isBlock(b, false);
|
||||
}
|
||||
|
||||
public boolean isBlock(Block b, boolean checkAir) {
|
||||
|
||||
if (hasWorld()) {
|
||||
Block bl = w.getBlock((int) x, (int) y, (int) z);
|
||||
|
||||
if (b == null && bl == Blocks.air)
|
||||
return true;
|
||||
if (b == null && checkAir && bl.getMaterial() == Material.air)
|
||||
return true;
|
||||
if (b == null && checkAir && bl.isAir(w, (int) x, (int) y, (int) z))
|
||||
return true;
|
||||
|
||||
return bl.getClass().isInstance(b);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getBlockMeta() {
|
||||
|
||||
if (hasWorld()) {
|
||||
return w.getBlockMetadata((int) x, (int) y, (int) z);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
|
||||
return getBlock(false);
|
||||
}
|
||||
|
||||
public Block getBlock(boolean airIsNull) {
|
||||
|
||||
if (hasWorld()) {
|
||||
if (airIsNull && isBlock(null, true))
|
||||
return null;
|
||||
return w.getBlock((int) x, (int) y, (int) z);
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
public Vecs3d setWorld(World world) {
|
||||
|
||||
w = world;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
|
||||
return y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
|
||||
return z;
|
||||
}
|
||||
|
||||
public int getBlockX() {
|
||||
|
||||
return (int) Math.floor(x);
|
||||
}
|
||||
|
||||
public int getBlockY() {
|
||||
|
||||
return (int) Math.floor(y);
|
||||
}
|
||||
|
||||
public int getBlockZ() {
|
||||
|
||||
return (int) Math.floor(z);
|
||||
}
|
||||
|
||||
public double distanceTo(Vecs3d vec) {
|
||||
|
||||
return distanceTo(vec.x, vec.y, vec.z);
|
||||
}
|
||||
|
||||
public double distanceTo(double x, double y, double z) {
|
||||
|
||||
double dx = x - this.x;
|
||||
double dy = y - this.y;
|
||||
double dz = z - this.z;
|
||||
return dx * dx + dy * dy + dz * dz;
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public void setZ(double z) {
|
||||
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (obj instanceof Vecs3d) {
|
||||
Vecs3d vec = (Vecs3d) obj;
|
||||
return vec.w == w && vec.x == x && vec.y == y && vec.z == z;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
return new Double(x).hashCode() + new Double(y).hashCode() << 8 + new Double(z).hashCode() << 16;
|
||||
}
|
||||
|
||||
public Vec3 toVec3() {
|
||||
|
||||
return Vec3.createVectorHelper(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
String s = "Vector3{";
|
||||
if (hasWorld())
|
||||
s += "w=" + w.provider.dimensionId + ";";
|
||||
s += "x=" + x + ";y=" + y + ";z=" + z + "}";
|
||||
return s;
|
||||
}
|
||||
|
||||
public ForgeDirection toForgeDirection() {
|
||||
|
||||
if (z == 1)
|
||||
return ForgeDirection.SOUTH;
|
||||
if (z == -1)
|
||||
return ForgeDirection.NORTH;
|
||||
|
||||
if (x == 1)
|
||||
return ForgeDirection.EAST;
|
||||
if (x == -1)
|
||||
return ForgeDirection.WEST;
|
||||
|
||||
if (y == 1)
|
||||
return ForgeDirection.UP;
|
||||
if (y == -1)
|
||||
return ForgeDirection.DOWN;
|
||||
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
public static Vecs3d fromString(String s) {
|
||||
|
||||
if (s.startsWith("Vector3{") && s.endsWith("}")) {
|
||||
World w = null;
|
||||
double x = 0, y = 0, z = 0;
|
||||
String s2 = s.substring(s.indexOf("{") + 1, s.lastIndexOf("}"));
|
||||
StringTokenizer st = new StringTokenizer(s2, ";");
|
||||
while (st.hasMoreTokens()) {
|
||||
String t = st.nextToken();
|
||||
|
||||
if (t.toLowerCase().startsWith("w")) {
|
||||
int world = Integer.parseInt(t.split("=")[1]);
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
|
||||
for (World wo : MinecraftServer.getServer().worldServers) {
|
||||
if (wo.provider.dimensionId == world) {
|
||||
w = wo;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
w = getClientWorld(world);
|
||||
}
|
||||
}
|
||||
|
||||
if (t.toLowerCase().startsWith("x"))
|
||||
x = Double.parseDouble(t.split("=")[1]);
|
||||
if (t.toLowerCase().startsWith("y"))
|
||||
y = Double.parseDouble(t.split("=")[1]);
|
||||
if (t.toLowerCase().startsWith("z"))
|
||||
z = Double.parseDouble(t.split("=")[1]);
|
||||
}
|
||||
|
||||
if (w != null) {
|
||||
return new Vecs3d(x, y, z, w);
|
||||
} else {
|
||||
return new Vecs3d(x, y, z);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static World getClientWorld(int world) {
|
||||
|
||||
if (Minecraft.getMinecraft().theWorld.provider.dimensionId != world)
|
||||
return null;
|
||||
return Minecraft.getMinecraft().theWorld;
|
||||
}
|
||||
|
||||
}
|
161
src/main/java/techreborn/lib/vecmath/Vecs3dCube.java
Normal file
161
src/main/java/techreborn/lib/vecmath/Vecs3dCube.java
Normal file
|
@ -0,0 +1,161 @@
|
|||
package techreborn.lib.vecmath;
|
||||
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Vecs3dCube {
|
||||
|
||||
private Vecs3d min, max;
|
||||
|
||||
public Vecs3dCube(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
|
||||
|
||||
this(minX, minY, minZ, maxX, maxY, maxZ, (World) null);
|
||||
}
|
||||
|
||||
public Vecs3dCube(double minX, double minY, double minZ, double maxX, double maxY, double maxZ, World world) {
|
||||
|
||||
this(new Vecs3d(minX, minY, minZ, world), new Vecs3d(maxX, maxY, maxZ, world));
|
||||
}
|
||||
|
||||
public Vecs3dCube(Vecs3d a, Vecs3d b) {
|
||||
|
||||
World w = a.getWorld();
|
||||
if (w == null)
|
||||
w = b.getWorld();
|
||||
|
||||
min = a;
|
||||
max = b;
|
||||
|
||||
fix();
|
||||
}
|
||||
|
||||
|
||||
public Vecs3dCube(AxisAlignedBB aabb) {
|
||||
|
||||
this(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ);
|
||||
}
|
||||
|
||||
public Vecs3d getMin() {
|
||||
|
||||
return min;
|
||||
}
|
||||
|
||||
public Vecs3d getMax() {
|
||||
|
||||
return max;
|
||||
}
|
||||
|
||||
public Vecs3d getCenter() {
|
||||
|
||||
return new Vecs3d((getMinX() + getMaxX()) / 2D, (getMinY() + getMaxY()) / 2D, (getMinZ() + getMaxZ()) / 2D, getMin().getWorld());
|
||||
}
|
||||
|
||||
public double getMinX() {
|
||||
|
||||
return min.getX();
|
||||
}
|
||||
|
||||
public double getMinY() {
|
||||
|
||||
return min.getY();
|
||||
}
|
||||
|
||||
public double getMinZ() {
|
||||
|
||||
return min.getZ();
|
||||
}
|
||||
|
||||
public double getMaxX() {
|
||||
|
||||
return max.getX();
|
||||
}
|
||||
|
||||
public double getMaxY() {
|
||||
|
||||
return max.getY();
|
||||
}
|
||||
|
||||
public double getMaxZ() {
|
||||
|
||||
return max.getZ();
|
||||
}
|
||||
|
||||
public AxisAlignedBB toAABB() {
|
||||
|
||||
return AxisAlignedBB.getBoundingBox(getMinX(), getMinY(), getMinZ(), getMaxX(), getMaxY(), getMaxZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vecs3dCube clone() {
|
||||
|
||||
return new Vecs3dCube(min.clone(), max.clone());
|
||||
}
|
||||
|
||||
public Vecs3dCube expand(double size) {
|
||||
|
||||
min.sub(size, size, size);
|
||||
max.add(size, size, size);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vecs3dCube fix() {
|
||||
|
||||
Vecs3d a = min.clone();
|
||||
Vecs3d b = max.clone();
|
||||
|
||||
double minX = Math.min(a.getX(), b.getX());
|
||||
double minY = Math.min(a.getY(), b.getY());
|
||||
double minZ = Math.min(a.getZ(), b.getZ());
|
||||
|
||||
double maxX = Math.max(a.getX(), b.getX());
|
||||
double maxY = Math.max(a.getY(), b.getY());
|
||||
double maxZ = Math.max(a.getZ(), b.getZ());
|
||||
|
||||
min = new Vecs3d(minX, minY, minZ, a.w);
|
||||
max = new Vecs3d(maxX, maxY, maxZ, b.w);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vecs3dCube add(double x, double y, double z) {
|
||||
|
||||
min.add(x, y, z);
|
||||
max.add(x, y, z);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public static final Vecs3dCube merge(List<Vecs3dCube> cubes) {
|
||||
|
||||
double minx = Double.MAX_VALUE;
|
||||
double miny = Double.MAX_VALUE;
|
||||
double minz = Double.MAX_VALUE;
|
||||
double maxx = Double.MIN_VALUE;
|
||||
double maxy = Double.MIN_VALUE;
|
||||
double maxz = Double.MIN_VALUE;
|
||||
|
||||
for (Vecs3dCube c : cubes) {
|
||||
minx = Math.min(minx, c.getMinX());
|
||||
miny = Math.min(miny, c.getMinY());
|
||||
minz = Math.min(minz, c.getMinZ());
|
||||
maxx = Math.max(maxx, c.getMaxX());
|
||||
maxy = Math.max(maxy, c.getMaxY());
|
||||
maxz = Math.max(maxz, c.getMaxZ());
|
||||
}
|
||||
|
||||
if (cubes.size() == 0)
|
||||
return new Vecs3dCube(0, 0, 0, 0, 0, 0);
|
||||
|
||||
return new Vecs3dCube(minx, miny, minz, maxx, maxy, maxz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
return min.hashCode() << 8 + max.hashCode();
|
||||
}
|
||||
}
|
13
src/main/java/techreborn/partSystem/ICustomHighlight.java
Normal file
13
src/main/java/techreborn/partSystem/ICustomHighlight.java
Normal file
|
@ -0,0 +1,13 @@
|
|||
package techreborn.partSystem;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface ICustomHighlight {
|
||||
|
||||
ArrayList<AxisAlignedBB> getBoxes(World world, int x, int y, int z, EntityPlayer player);
|
||||
|
||||
}
|
|
@ -6,12 +6,12 @@ package techreborn.partSystem;
|
|||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3d;
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3dCube;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.lib.vecmath.Vecs3d;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
|
||||
package techreborn.partSystem;
|
||||
|
||||
import me.modmuss50.mods.lib.Location;
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3dCube;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.lib.Location;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
|
||||
|
||||
public interface IPartProvider {
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
package techreborn.partSystem;
|
||||
|
||||
|
||||
import me.modmuss50.mods.lib.Location;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.lib.Location;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
|
||||
package techreborn.partSystem;
|
||||
|
||||
import me.modmuss50.mods.lib.Location;
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3dCube;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.lib.Location;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
package techreborn.partSystem.QLib;
|
||||
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3d;
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.lib.vecmath.Vecs3d;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
import uk.co.qmunity.lib.vec.Vec3d;
|
||||
import uk.co.qmunity.lib.vec.Vec3dCube;
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
package techreborn.partSystem.QLib;
|
||||
|
||||
import me.modmuss50.mods.lib.Location;
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.lib.Location;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.ModPart;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
|
|
@ -4,11 +4,7 @@
|
|||
|
||||
package techreborn.partSystem.QLib;
|
||||
|
||||
import me.modmuss50.mods.lib.Location;
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.IPartProvider;
|
||||
import techreborn.partSystem.ModPart;
|
||||
import techreborn.partSystem.ModPartRegistry;
|
||||
import techreborn.lib.Location;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
@ -16,6 +12,10 @@ import net.minecraft.util.MovingObjectPosition;
|
|||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.IPartProvider;
|
||||
import techreborn.partSystem.ModPart;
|
||||
import techreborn.partSystem.ModPartRegistry;
|
||||
import uk.co.qmunity.lib.QLModInfo;
|
||||
import uk.co.qmunity.lib.part.IPart;
|
||||
import uk.co.qmunity.lib.part.IPartFactory;
|
||||
|
|
|
@ -4,10 +4,6 @@
|
|||
|
||||
package techreborn.partSystem.block;
|
||||
|
||||
import me.modmuss50.mods.lib.client.ICustomHighlight;
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.IModPart;
|
||||
import techreborn.partSystem.ModPart;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.Material;
|
||||
|
@ -20,6 +16,10 @@ import net.minecraft.util.MovingObjectPosition;
|
|||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.ICustomHighlight;
|
||||
import techreborn.partSystem.IModPart;
|
||||
import techreborn.partSystem.ModPart;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
@ -5,11 +5,11 @@
|
|||
package techreborn.partSystem.block;
|
||||
|
||||
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3d;
|
||||
import techreborn.partSystem.ModPart;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import techreborn.lib.vecmath.Vecs3d;
|
||||
import techreborn.partSystem.ModPart;
|
||||
|
||||
public class RenderModPart extends TileEntitySpecialRenderer {
|
||||
@Override
|
||||
|
|
|
@ -4,11 +4,6 @@
|
|||
|
||||
package techreborn.partSystem.block;
|
||||
|
||||
import me.modmuss50.mods.lib.Location;
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.ModPart;
|
||||
import techreborn.partSystem.ModPartRegistry;
|
||||
import techreborn.partSystem.parts.NullPart;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
@ -18,6 +13,11 @@ import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.lib.Location;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.ModPart;
|
||||
import techreborn.partSystem.ModPartRegistry;
|
||||
import techreborn.partSystem.parts.NullPart;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
|
|
@ -6,8 +6,8 @@ package techreborn.partSystem.block;
|
|||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import me.modmuss50.mods.lib.Location;
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.lib.Location;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.IPartProvider;
|
||||
import techreborn.partSystem.ModPart;
|
||||
import net.minecraft.block.Block;
|
||||
|
|
|
@ -3,10 +3,6 @@ package techreborn.partSystem.client;
|
|||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import me.modmuss50.mods.lib.Location;
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3d;
|
||||
import techreborn.partSystem.IModPart;
|
||||
import techreborn.partSystem.ModPartItem;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
|
@ -18,6 +14,10 @@ import net.minecraft.util.Vec3;
|
|||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import techreborn.lib.Location;
|
||||
import techreborn.lib.vecmath.Vecs3d;
|
||||
import techreborn.partSystem.IModPart;
|
||||
import techreborn.partSystem.ModPartItem;
|
||||
|
||||
/**
|
||||
* This is based of https://github.com/Qmunity/QmunityLib/blob/master/src%2Fmain%2Fjava%2Fuk%2Fco%2Fqmunity%2Flib%2Fclient%2Frender%2FRenderPartPlacement.java
|
||||
|
|
|
@ -10,8 +10,8 @@ import codechicken.multipart.MultiPartRegistry;
|
|||
import codechicken.multipart.NormallyOccludedPart;
|
||||
import codechicken.multipart.TMultiPart;
|
||||
import codechicken.multipart.TileMultipart;
|
||||
import me.modmuss50.mods.lib.Location;
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.lib.Location;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.IPartProvider;
|
||||
import techreborn.partSystem.ModPart;
|
||||
import techreborn.partSystem.ModPartRegistry;
|
||||
|
|
|
@ -15,13 +15,13 @@ import codechicken.multipart.TMultiPart;
|
|||
import codechicken.multipart.TSlottedPart;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import me.modmuss50.mods.lib.Location;
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3d;
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.ModPart;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.lib.Location;
|
||||
import techreborn.lib.vecmath.Vecs3d;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.ModPart;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
@ -5,9 +5,6 @@ import ic2.api.energy.event.EnergyTileUnloadEvent;
|
|||
import ic2.api.energy.tile.IEnergyConductor;
|
||||
import ic2.api.energy.tile.IEnergyTile;
|
||||
import ic2.core.IC2;
|
||||
import me.modmuss50.mods.lib.Functions;
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3d;
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3dCube;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
@ -15,6 +12,9 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import techreborn.lib.Functions;
|
||||
import techreborn.lib.vecmath.Vecs3d;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.ModPart;
|
||||
import techreborn.partSystem.ModPartUtils;
|
||||
|
||||
|
|
|
@ -4,12 +4,12 @@
|
|||
|
||||
package techreborn.partSystem.parts;
|
||||
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3d;
|
||||
import me.modmuss50.mods.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.ModPart;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import techreborn.lib.vecmath.Vecs3d;
|
||||
import techreborn.lib.vecmath.Vecs3dCube;
|
||||
import techreborn.partSystem.ModPart;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
Loading…
Reference in a new issue