mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
i am in spain without the s
This commit is contained in:
parent
b38a7daafd
commit
c67bb8ad3a
@ -1,12 +1,20 @@
|
||||
package com.hbm.blocks.rail;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.packet.PlayerInformPacket;
|
||||
import com.hbm.util.ParticleUtil;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.ChatComponentText;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
@ -49,6 +57,11 @@ public class RailStandardCurve extends BlockDummyable implements IRailNTM {
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(meta);
|
||||
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
|
||||
|
||||
List<String> context = new ArrayList();
|
||||
context.add("=========================");
|
||||
|
||||
boolean debug = Math.abs(speed) < 2;
|
||||
|
||||
double turnRadius = 4.5D;
|
||||
|
||||
Vec3 vec = Vec3.createVectorHelper(trainX, trainY, trainZ);
|
||||
@ -65,10 +78,16 @@ public class RailStandardCurve extends BlockDummyable implements IRailNTM {
|
||||
return Vec3.createVectorHelper(axisX + dist.xCoord, y, axisZ + dist.zCoord);
|
||||
}
|
||||
|
||||
context.add("Speed: " + speed);
|
||||
|
||||
double angleDeg = -Math.atan(dist.zCoord / dist.xCoord) * 180D / Math.PI;
|
||||
double length90Deg = turnRadius * Math.PI / 2D;
|
||||
double angularChange = speed / length90Deg * 90D;
|
||||
|
||||
context.add("angleDeg: " + angleDeg);
|
||||
context.add("length90Deg: " + length90Deg);
|
||||
context.add("angularChange: " + angularChange);
|
||||
|
||||
ForgeDirection moveDir = ForgeDirection.UNKNOWN;
|
||||
|
||||
if(Math.abs(motionX) > Math.abs(motionZ)) {
|
||||
@ -77,29 +96,44 @@ public class RailStandardCurve extends BlockDummyable implements IRailNTM {
|
||||
moveDir = motionZ > 0 ? Library.POS_Z : Library.NEG_Z;
|
||||
}
|
||||
|
||||
if(moveDir == dir || moveDir == rot.getOpposite()) {
|
||||
context.add("moveDir: " + moveDir);
|
||||
|
||||
if(moveDir == dir || moveDir == rot) {
|
||||
angularChange *= -1;
|
||||
}
|
||||
|
||||
context.add("angularChange: " + angularChange);
|
||||
|
||||
double effAngle = angleDeg + angularChange;
|
||||
|
||||
context.add("effAngle: " + effAngle);
|
||||
|
||||
if(effAngle > 90) {
|
||||
double angleOvershoot = effAngle - 90D;
|
||||
double lengthOvershoot = angleOvershoot * length90Deg / 90D;
|
||||
info.dist(lengthOvershoot).pos(new BlockPos(cX - dir.offsetX * 4 + rot.offsetX * 4, y, cZ - dir.offsetZ * 4 + rot.offsetZ * 4));
|
||||
context.add("angleOvershoot: " + angleOvershoot);
|
||||
context.add("lengthOvershoot: " + lengthOvershoot);
|
||||
info.dist(lengthOvershoot).pos(new BlockPos(cX - dir.offsetX * 4 + rot.offsetX * 5, y, cZ - dir.offsetZ * 4 + rot.offsetZ * 5));
|
||||
if(debug) for(String s : context) System.out.println(s);
|
||||
return Vec3.createVectorHelper(axisX - dir.offsetX * turnRadius + rot.offsetX * turnRadius, y, axisZ - dir.offsetZ * turnRadius + rot.offsetZ * turnRadius);
|
||||
}
|
||||
|
||||
if(effAngle < 0) {
|
||||
double angleOvershoot = -effAngle;
|
||||
double lengthOvershoot = angleOvershoot * length90Deg / 90D;
|
||||
context.add("angleOvershoot: " + angleOvershoot);
|
||||
context.add("lengthOvershoot: " + lengthOvershoot);
|
||||
info.dist(lengthOvershoot).pos(new BlockPos(cX + dir.offsetX , y, cZ + dir.offsetZ));
|
||||
ParticleUtil.spawnGasFlame(world, axisX + 0.5 + dir.offsetX * 0.5, y, axisZ * 0.5 + dir.offsetZ * 0.5, 0, 0.2, 0);
|
||||
if(debug) for(String s : context) System.out.println(s);
|
||||
return Vec3.createVectorHelper(axisX + 0.5 + dir.offsetX * 0.5, y, axisZ * 0.5 + dir.offsetZ * 0.5);
|
||||
}
|
||||
|
||||
double radianChange = angularChange * Math.PI / 180D;
|
||||
dist.rotateAroundY((float) -radianChange);
|
||||
dist.rotateAroundY((float) radianChange);
|
||||
|
||||
context.add("radianChange: " + radianChange);
|
||||
if(debug) for(String s : context) System.out.println(s);
|
||||
return Vec3.createVectorHelper(axisX + dist.xCoord, y, axisZ + dist.zCoord);
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package com.hbm.entity.train;
|
||||
import com.hbm.blocks.rail.IRailNTM;
|
||||
import com.hbm.blocks.rail.IRailNTM.RailLeaveInfo;
|
||||
import com.hbm.blocks.rail.IRailNTM.TrackGauge;
|
||||
import com.hbm.util.ParticleUtil;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@ -71,6 +72,9 @@ public abstract class EntityRailCarBase extends Entity {
|
||||
if(corePos == null) {
|
||||
this.derail();
|
||||
} else {
|
||||
this.prevPosX = this.posX;
|
||||
this.prevPosY = this.posY;
|
||||
this.prevPosZ = this.posZ;
|
||||
this.setPosition(corePos.xCoord, corePos.yCoord, corePos.zCoord);
|
||||
|
||||
anchor = this.getCurentAnchorPos(); //reset origin to new position
|
||||
@ -80,7 +84,7 @@ public abstract class EntityRailCarBase extends Entity {
|
||||
if(frontPos == null || backPos == null) {
|
||||
this.derail();
|
||||
} else {
|
||||
this.rotationYaw = generateYaw(frontPos, backPos);
|
||||
//this.rotationYaw = generateYaw(frontPos, backPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -99,6 +103,7 @@ public abstract class EntityRailCarBase extends Entity {
|
||||
it++;
|
||||
|
||||
if(it > 30) {
|
||||
worldObj.createExplosion(this, posX, posY, posZ, 5F, false);
|
||||
this.derail();
|
||||
return null;
|
||||
}
|
||||
@ -109,7 +114,8 @@ public abstract class EntityRailCarBase extends Entity {
|
||||
Block block = worldObj.getBlock(x, y, z);
|
||||
|
||||
Vec3 rot = Vec3.createVectorHelper(0, 0, 1);
|
||||
rot.rotateAroundY(yaw);
|
||||
rot.rotateAroundY((float) (yaw * Math.PI / 180D));
|
||||
|
||||
|
||||
if(block instanceof IRailNTM) {
|
||||
IRailNTM rail = (IRailNTM) block;
|
||||
@ -156,7 +162,6 @@ public abstract class EntityRailCarBase extends Entity {
|
||||
public void derail() {
|
||||
isOnRail = false;
|
||||
this.setDead();
|
||||
worldObj.createExplosion(this, posX, posY, posZ, 1F, false);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
|
||||
@ -31,7 +31,7 @@ public abstract class EntityRailCarRidable extends EntityRailCarBase {
|
||||
public void updateRiderPosition() {
|
||||
|
||||
Vec3 offset = getRiderSeatPosition();
|
||||
offset.rotateAroundY(this.rotationYaw);
|
||||
offset.rotateAroundY((float) (this.rotationYaw * Math.PI / 180));
|
||||
|
||||
if(this.riddenByEntity != null) {
|
||||
this.riddenByEntity.setPosition(this.posX + offset.xCoord, this.posY + offset.yCoord, this.posZ + offset.zCoord);
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 377 B |
Binary file not shown.
|
After Width: | Height: | Size: 390 B |
Binary file not shown.
|
After Width: | Height: | Size: 331 B |
Loading…
x
Reference in New Issue
Block a user