diff --git a/src/main/java/com/hbm/blocks/rail/RailStandardCurve.java b/src/main/java/com/hbm/blocks/rail/RailStandardCurve.java index de7a478a1..08b824df4 100644 --- a/src/main/java/com/hbm/blocks/rail/RailStandardCurve.java +++ b/src/main/java/com/hbm/blocks/rail/RailStandardCurve.java @@ -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 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); } diff --git a/src/main/java/com/hbm/entity/train/EntityRailCarBase.java b/src/main/java/com/hbm/entity/train/EntityRailCarBase.java index 00d27e963..79df30ca0 100644 --- a/src/main/java/com/hbm/entity/train/EntityRailCarBase.java +++ b/src/main/java/com/hbm/entity/train/EntityRailCarBase.java @@ -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) diff --git a/src/main/java/com/hbm/entity/train/EntityRailCarRidable.java b/src/main/java/com/hbm/entity/train/EntityRailCarRidable.java index 837fcceb2..615db63b0 100644 --- a/src/main/java/com/hbm/entity/train/EntityRailCarRidable.java +++ b/src/main/java/com/hbm/entity/train/EntityRailCarRidable.java @@ -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); diff --git a/src/main/resources/assets/hbm/textures/blocks/stone_biome.desert.png b/src/main/resources/assets/hbm/textures/blocks/stone_biome.desert.png new file mode 100644 index 000000000..5d121421f Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/stone_biome.desert.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/stone_biome_layer.desert.png b/src/main/resources/assets/hbm/textures/blocks/stone_biome_layer.desert.png new file mode 100644 index 000000000..ab84f7807 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/stone_biome_layer.desert.png differ diff --git a/src/main/resources/assets/hbm/textures/blocks/stone_biome_top.desert.png b/src/main/resources/assets/hbm/textures/blocks/stone_biome_top.desert.png new file mode 100644 index 000000000..1c05ff0d1 Binary files /dev/null and b/src/main/resources/assets/hbm/textures/blocks/stone_biome_top.desert.png differ