why is it called a quarternion when you quarter in the cold food out hot

eat the food?
This commit is contained in:
Boblet 2022-04-19 14:28:41 +02:00
parent 0412ac6154
commit 68efe9f28e
3 changed files with 116 additions and 39 deletions

View File

@ -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,20 +59,53 @@ 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(); public static FloatBuffer quatToGlMatrix(FloatBuffer buf, Quaternion q) {
//GlStateManager.multMatrix(auxGLMatrix); TODO: find implementation buf.clear();
float xx = q.x * q.x;
float xy = q.x * q.y;
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;
//Bob: i may not know what a quarternion is but grouping these in parts of 4 looks nice
buf.put(1.0F - 2.0F * (yy + zz));
buf.put(2.0F * (xy + zw));
buf.put(2.0F * (xz - yw));
buf.put(0.0F);
buf.put(2.0F * (xy - zw));
buf.put(1.0F - 2.0F * (xx + zz));
buf.put(2.0F * (yz + xw));
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) { private void scale(FloatBuffer matrix, Vec3 scale) {

View File

@ -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);
} }

View File

@ -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]};
}
} }