mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
why is it called a quarternion when you quarter in the cold food out hot
eat the food?
This commit is contained in:
parent
0412ac6154
commit
68efe9f28e
@ -2,6 +2,7 @@ package com.hbm.animloader;
|
|||||||
|
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
|
|
||||||
|
import org.lwjgl.opengl.GL11;
|
||||||
import org.lwjgl.util.vector.Matrix4f;
|
import org.lwjgl.util.vector.Matrix4f;
|
||||||
import org.lwjgl.util.vector.Quaternion;
|
import org.lwjgl.util.vector.Quaternion;
|
||||||
|
|
||||||
@ -10,6 +11,15 @@ import com.hbm.util.BobMathUtil;
|
|||||||
import net.minecraft.client.renderer.GLAllocation;
|
import net.minecraft.client.renderer.GLAllocation;
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bob:
|
||||||
|
* Ported from 1.12.2.
|
||||||
|
* Mostly gibberish to me, probably written in the ancient egyptian language.
|
||||||
|
* Any unmarked code comments are probably from Drillgon or code I had to throw out myself.
|
||||||
|
*
|
||||||
|
* @author Drillgon200 for the most part
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class Transform {
|
public class Transform {
|
||||||
|
|
||||||
protected static FloatBuffer auxGLMatrix = GLAllocation.createDirectFloatBuffer(16);
|
protected static FloatBuffer auxGLMatrix = GLAllocation.createDirectFloatBuffer(16);
|
||||||
@ -49,37 +59,70 @@ public class Transform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void interpolateAndApply(Transform other, float inter){
|
public void interpolateAndApply(Transform other, float inter){
|
||||||
Vec3 trans = BobMathUtil.interpVec(this.translation, other.translation, inter); //ORIGINAL: translation.interpolate(other.translation, inter);
|
Vec3 trans = BobMathUtil.interpVec(this.translation, other.translation, inter);
|
||||||
Vec3 scale = BobMathUtil.interpVec(this.scale, other.scale, inter); //ORIGINAL: this.scale.interpolate(other.scale, inter);
|
Vec3 scale = BobMathUtil.interpVec(this.scale, other.scale, inter);
|
||||||
Quaternion rot = slerp(rotation, other.rotation, inter);
|
Quaternion rot = slerp(rotation, other.rotation, inter);
|
||||||
//GlStateManager.quatToGlMatrix(auxGLMatrix, rot); TODO: find implementation
|
quatToGlMatrix(auxGLMatrix, rot);
|
||||||
scale(auxGLMatrix, scale);
|
scale(auxGLMatrix, scale);
|
||||||
auxGLMatrix.put(12, (float) trans.xCoord);
|
auxGLMatrix.put(12, (float) trans.xCoord);
|
||||||
auxGLMatrix.put(13, (float) trans.yCoord);
|
auxGLMatrix.put(13, (float) trans.yCoord);
|
||||||
auxGLMatrix.put(14, (float) trans.zCoord);
|
auxGLMatrix.put(14, (float) trans.zCoord);
|
||||||
|
|
||||||
//for(int i = 0; i < 16; i ++){
|
GL11.glMultMatrix(auxGLMatrix);
|
||||||
//System.out.print(auxGLMatrix.get(i) + " ");
|
|
||||||
//}
|
|
||||||
//System.out.println();
|
|
||||||
//GlStateManager.multMatrix(auxGLMatrix); TODO: find implementation
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scale(FloatBuffer matrix, Vec3 scale){
|
public static FloatBuffer quatToGlMatrix(FloatBuffer buf, Quaternion q) {
|
||||||
matrix.put(0, (float) (matrix.get(0)*scale.xCoord));
|
buf.clear();
|
||||||
matrix.put(4, (float) (matrix.get(4)*scale.xCoord));
|
float xx = q.x * q.x;
|
||||||
matrix.put(8, (float) (matrix.get(8)*scale.xCoord));
|
float xy = q.x * q.y;
|
||||||
matrix.put(12, (float) (matrix.get(12)*scale.xCoord));
|
float xz = q.x * q.z;
|
||||||
|
float xw = q.x * q.w;
|
||||||
|
float yy = q.y * q.y;
|
||||||
|
float yz = q.y * q.z;
|
||||||
|
float yw = q.y * q.w;
|
||||||
|
float zz = q.z * q.z;
|
||||||
|
float zw = q.z * q.w;
|
||||||
|
|
||||||
matrix.put(1, (float) (matrix.get(1)*scale.yCoord));
|
//Bob: i may not know what a quarternion is but grouping these in parts of 4 looks nice
|
||||||
matrix.put(5, (float) (matrix.get(5)*scale.yCoord));
|
buf.put(1.0F - 2.0F * (yy + zz));
|
||||||
matrix.put(9, (float) (matrix.get(9)*scale.yCoord));
|
buf.put(2.0F * (xy + zw));
|
||||||
matrix.put(13, (float) (matrix.get(13)*scale.yCoord));
|
buf.put(2.0F * (xz - yw));
|
||||||
|
buf.put(0.0F);
|
||||||
|
|
||||||
matrix.put(2, (float) (matrix.get(2)*scale.zCoord));
|
buf.put(2.0F * (xy - zw));
|
||||||
matrix.put(6, (float) (matrix.get(6)*scale.zCoord));
|
buf.put(1.0F - 2.0F * (xx + zz));
|
||||||
matrix.put(10, (float) (matrix.get(10)*scale.zCoord));
|
buf.put(2.0F * (yz + xw));
|
||||||
matrix.put(14, (float) (matrix.get(14)*scale.zCoord));
|
buf.put(0.0F);
|
||||||
|
|
||||||
|
buf.put(2.0F * (xz + yw));
|
||||||
|
buf.put(2.0F * (yz - xw));
|
||||||
|
buf.put(1.0F - 2.0F * (xx + yy));
|
||||||
|
buf.put(0.0F);
|
||||||
|
|
||||||
|
buf.put(0.0F);
|
||||||
|
buf.put(0.0F);
|
||||||
|
buf.put(0.0F);
|
||||||
|
buf.put(1.0F);
|
||||||
|
|
||||||
|
buf.rewind();
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scale(FloatBuffer matrix, Vec3 scale) {
|
||||||
|
matrix.put(0, (float) (matrix.get(0) * scale.xCoord));
|
||||||
|
matrix.put(4, (float) (matrix.get(4) * scale.xCoord));
|
||||||
|
matrix.put(8, (float) (matrix.get(8) * scale.xCoord));
|
||||||
|
matrix.put(12, (float) (matrix.get(12) * scale.xCoord));
|
||||||
|
|
||||||
|
matrix.put(1, (float) (matrix.get(1) * scale.yCoord));
|
||||||
|
matrix.put(5, (float) (matrix.get(5) * scale.yCoord));
|
||||||
|
matrix.put(9, (float) (matrix.get(9) * scale.yCoord));
|
||||||
|
matrix.put(13, (float) (matrix.get(13) * scale.yCoord));
|
||||||
|
|
||||||
|
matrix.put(2, (float) (matrix.get(2) * scale.zCoord));
|
||||||
|
matrix.put(6, (float) (matrix.get(6) * scale.zCoord));
|
||||||
|
matrix.put(10, (float) (matrix.get(10) * scale.zCoord));
|
||||||
|
matrix.put(14, (float) (matrix.get(14) * scale.zCoord));
|
||||||
}
|
}
|
||||||
|
|
||||||
//Thanks, wikipedia
|
//Thanks, wikipedia
|
||||||
@ -116,18 +159,18 @@ public class Transform {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Since dot is in range [0, DOT_THRESHOLD], acos is safe
|
// Since dot is in range [0, DOT_THRESHOLD], acos is safe
|
||||||
double theta_0 = Math.acos(dot); // theta_0 = angle between input vectors
|
double theta_0 = Math.acos(dot); // theta_0 = angle between input vectors
|
||||||
double theta = theta_0*t; // theta = angle between v0 and result
|
double theta = theta_0*t; // theta = angle between v0 and result
|
||||||
double sin_theta = Math.sin(theta); // compute this value only once
|
double sin_theta = Math.sin(theta); // compute this value only once
|
||||||
double sin_theta_0 = Math.sin(theta_0); // compute this value only once
|
double sin_theta_0 = Math.sin(theta_0); // compute this value only once
|
||||||
|
|
||||||
float s0 = (float) (Math.cos(theta) - dot * sin_theta / sin_theta_0); // == sin(theta_0 - theta) / sin(theta_0)
|
float s0 = (float) (Math.cos(theta) - dot * sin_theta / sin_theta_0); // == sin(theta_0 - theta) / sin(theta_0)
|
||||||
float s1 = (float) (sin_theta / sin_theta_0);
|
float s1 = (float) (sin_theta / sin_theta_0);
|
||||||
|
|
||||||
return new Quaternion(s0*v0.x + s1*v1.x,
|
return new Quaternion(s0 * v0.x + s1 * v1.x,
|
||||||
s0*v0.y + s1*v1.y,
|
s0 * v0.y + s1 * v1.y,
|
||||||
s0*v0.z + s1*v1.z,
|
s0 * v0.z + s1 * v1.z,
|
||||||
s0*v0.w + s1*v1.w);
|
s0 * v0.w + s1 * v1.w);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -57,6 +57,8 @@ public class MachineChungus extends BlockDummyable {
|
|||||||
|
|
||||||
if(!world.isRemote) {
|
if(!world.isRemote) {
|
||||||
FluidType type = entity.tanks[0].getTankType();
|
FluidType type = entity.tanks[0].getTankType();
|
||||||
|
entity.onLeverPull(type);
|
||||||
|
|
||||||
if(type == Fluids.STEAM) {
|
if(type == Fluids.STEAM) {
|
||||||
entity.tanks[0].setTankType(Fluids.HOTSTEAM);
|
entity.tanks[0].setTankType(Fluids.HOTSTEAM);
|
||||||
entity.tanks[1].setTankType(Fluids.STEAM);
|
entity.tanks[1].setTankType(Fluids.STEAM);
|
||||||
@ -78,7 +80,6 @@ public class MachineChungus extends BlockDummyable {
|
|||||||
entity.tanks[0].setFill(Math.min(entity.tanks[0].getFill() * 1000, entity.tanks[0].getMaxFill()));
|
entity.tanks[0].setFill(Math.min(entity.tanks[0].getFill() * 1000, entity.tanks[0].getMaxFill()));
|
||||||
entity.tanks[1].setFill(0);
|
entity.tanks[1].setFill(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
entity.markDirty();
|
entity.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,10 +109,10 @@ public class MachineChungus extends BlockDummyable {
|
|||||||
MultiblockHandlerXR.fillSpace(world, x + dir.offsetX * o , y + dir.offsetY * o, z + dir.offsetZ * o, new int[] {2, 0, 10, -7, 1, 1}, this, dir);
|
MultiblockHandlerXR.fillSpace(world, x + dir.offsetX * o , y + dir.offsetY * o, z + dir.offsetZ * o, new int[] {2, 0, 10, -7, 1, 1}, this, dir);
|
||||||
world.setBlock(x + dir.offsetX, y + 2, z + dir.offsetZ, this, dir.ordinal(), 3);
|
world.setBlock(x + dir.offsetX, y + 2, z + dir.offsetZ, this, dir.ordinal(), 3);
|
||||||
|
|
||||||
this.makeExtra(world, x + dir.offsetX, y + 2, z + dir.offsetZ);
|
this.makeExtra(world, x + dir.offsetX, y + 2, z + dir.offsetZ); //front connector
|
||||||
this.makeExtra(world, x + dir.offsetX * (o - 10), y, z + dir.offsetZ * (o - 10));
|
this.makeExtra(world, x + dir.offsetX * (o - 10), y, z + dir.offsetZ * (o - 10)); //back connector
|
||||||
ForgeDirection side = dir.getRotation(ForgeDirection.UP);
|
ForgeDirection side = dir.getRotation(ForgeDirection.UP);
|
||||||
this.makeExtra(world, x + dir.offsetX * o + side.offsetX * 2 , y, z + dir.offsetZ * o + side.offsetZ * 2);
|
this.makeExtra(world, x + dir.offsetX * o + side.offsetX * 2 , y, z + dir.offsetZ * o + side.offsetZ * 2); //side connectors
|
||||||
this.makeExtra(world, x + dir.offsetX * o - side.offsetX * 2 , y, z + dir.offsetZ * o - side.offsetZ * 2);
|
this.makeExtra(world, x + dir.offsetX * o - side.offsetX * 2 , y, z + dir.offsetZ * o - side.offsetZ * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -16,8 +16,10 @@ import com.hbm.packet.NBTPacket;
|
|||||||
import com.hbm.packet.PacketDispatcher;
|
import com.hbm.packet.PacketDispatcher;
|
||||||
import com.hbm.tileentity.INBTPacketReceiver;
|
import com.hbm.tileentity.INBTPacketReceiver;
|
||||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||||
|
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||||
|
|
||||||
import api.hbm.energy.IEnergyGenerator;
|
import api.hbm.energy.IEnergyGenerator;
|
||||||
|
import api.hbm.fluid.IFluidStandardTransceiver;
|
||||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
@ -26,7 +28,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||||||
import net.minecraft.util.AxisAlignedBB;
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcceptor, IFluidSource, IEnergyGenerator, INBTPacketReceiver {
|
public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcceptor, IFluidSource, IEnergyGenerator, INBTPacketReceiver, IFluidStandardTransceiver {
|
||||||
|
|
||||||
public long power;
|
public long power;
|
||||||
public static final long maxPower = 100000000000L;
|
public static final long maxPower = 100000000000L;
|
||||||
@ -75,6 +77,11 @@ public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcc
|
|||||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
||||||
this.sendPower(worldObj, xCoord - dir.offsetX * 11, yCoord, zCoord - dir.offsetZ * 11, dir);
|
this.sendPower(worldObj, xCoord - dir.offsetX * 11, yCoord, zCoord - dir.offsetZ * 11, dir);
|
||||||
|
|
||||||
|
for(BlockPos pos : this.getConPos()) {
|
||||||
|
this.sendFluid(tanks[1].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), dir); //TODO: there's no directions for this yet because idc
|
||||||
|
this.trySubscribe(tanks[0].getTankType(), worldObj, pos.getX(), pos.getY(), pos.getZ(), dir);
|
||||||
|
}
|
||||||
|
|
||||||
if(power > maxPower)
|
if(power > maxPower)
|
||||||
power = maxPower;
|
power = maxPower;
|
||||||
|
|
||||||
@ -119,6 +126,22 @@ public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onLeverPull(FluidType previous) {
|
||||||
|
for(BlockPos pos : getConPos()) {
|
||||||
|
this.tryUnsubscribe(previous, worldObj, pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockPos[] getConPos() {
|
||||||
|
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
|
||||||
|
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||||
|
return new BlockPos[] {
|
||||||
|
new BlockPos(xCoord - dir.offsetX * 4, yCoord + 2, zCoord - dir.offsetZ * 4),
|
||||||
|
new BlockPos(xCoord + rot.offsetX * 3, yCoord, zCoord + rot.offsetZ * 3),
|
||||||
|
new BlockPos(xCoord - rot.offsetZ * 3, yCoord, zCoord - rot.offsetZ * 3)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public void networkPack(NBTTagCompound nbt, int range) {
|
public void networkPack(NBTTagCompound nbt, int range) {
|
||||||
PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
|
PacketDispatcher.wrapper.sendToAllAround(new NBTPacket(nbt, xCoord, yCoord, zCoord), new TargetPoint(this.worldObj.provider.dimensionId, xCoord, yCoord, zCoord, range));
|
||||||
}
|
}
|
||||||
@ -168,17 +191,17 @@ public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcc
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setFluidFill(int i, FluidType type) {
|
public void setFluidFill(int i, FluidType type) {
|
||||||
if(type.name().equals(tanks[0].getTankType().name()))
|
if(type == tanks[0].getTankType())
|
||||||
tanks[0].setFill(i);
|
tanks[0].setFill(i);
|
||||||
else if(type.name().equals(tanks[1].getTankType().name()))
|
else if(type == tanks[1].getTankType())
|
||||||
tanks[1].setFill(i);
|
tanks[1].setFill(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getFluidFill(FluidType type) {
|
public int getFluidFill(FluidType type) {
|
||||||
if(type.name().equals(tanks[0].getTankType().name()))
|
if(type == tanks[0].getTankType())
|
||||||
return tanks[0].getFill();
|
return tanks[0].getFill();
|
||||||
else if(type.name().equals(tanks[1].getTankType().name()))
|
else if(type == tanks[1].getTankType())
|
||||||
return tanks[1].getFill();
|
return tanks[1].getFill();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -186,7 +209,7 @@ public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcc
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxFluidFill(FluidType type) {
|
public int getMaxFluidFill(FluidType type) {
|
||||||
if(type.name().equals(tanks[0].getTankType().name()))
|
if(type == tanks[0].getTankType())
|
||||||
return tanks[0].getMaxFill();
|
return tanks[0].getMaxFill();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -244,4 +267,14 @@ public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcc
|
|||||||
public void setPower(long power) {
|
public void setPower(long power) {
|
||||||
this.power = power;
|
this.power = power;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidTank[] getSendingTanks() {
|
||||||
|
return new FluidTank[] {tanks[1]};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidTank[] getReceivingTanks() {
|
||||||
|
return new FluidTank[] {tanks[0]};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user