mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-19 03:39:17 +00:00
Some net stuff for later
This commit is contained in:
2 files changed
+24
No files matched your search
@@ -16,6 +16,25 @@ import vazkii.botania.api.internal.VanillaPacketDispatcher;
|
||||
|
||||
public final class MathHelper {
|
||||
|
||||
public static int[] doubleArrayToIntArray(double[] doubles) {
|
||||
int[] ret = new int[doubles.length * 2];
|
||||
for (int i = 0; i < doubles.length; i++) {
|
||||
long l = Double.doubleToLongBits(doubles[i]);
|
||||
ret[i] = (int) (l >>> 32);
|
||||
ret[i + 1] = (int) l;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static double[] intArrayToDoubleArray(int[] ints) {
|
||||
double[] ret = new double[ints.length / 2];
|
||||
for (int i = 0; i < ints.length; i += 2) {
|
||||
long l = ((long) ints[i]) << 32 | ints[i + 1];
|
||||
ret[i / 2] = Double.longBitsToDouble(l);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static float pointDistanceSpace(BlockPos p1, BlockPos p2) {
|
||||
return pointDistanceSpace(p1.getX(), p1.getY(), p1.getZ(), p2.getX(), p2.getY(), p2.getZ());
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
||||
import vazkii.botania.client.core.handler.LightningHandler;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
import vazkii.botania.common.core.helper.MathHelper;
|
||||
import vazkii.botania.common.core.helper.Vector3;
|
||||
import vazkii.botania.common.entity.EntityDoppleganger;
|
||||
|
||||
@@ -35,6 +36,10 @@ public class PacketBotaniaEffect implements IMessage {
|
||||
this.args = args;
|
||||
}
|
||||
|
||||
public PacketBotaniaEffect(EffectType type, double x, double y, double z, double... args) {
|
||||
this(type, x, y, z, MathHelper.doubleArrayToIntArray(args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
type = EffectType.values()[buf.readShort()];
|
||||
|
||||
Reference in new issue
Block a user