From c67bb8ad3aef58b7d40ff7ef31a088a3fb4fd0a8 Mon Sep 17 00:00:00 2001 From: Boblet Date: Fri, 5 May 2023 14:39:34 +0200 Subject: [PATCH] i am in spain without the s --- .../hbm/blocks/rail/RailStandardCurve.java | 40 ++++++++++++++++-- .../hbm/entity/train/EntityRailCarBase.java | 11 +++-- .../entity/train/EntityRailCarRidable.java | 2 +- .../textures/blocks/stone_biome.desert.png | Bin 0 -> 377 bytes .../blocks/stone_biome_layer.desert.png | Bin 0 -> 390 bytes .../blocks/stone_biome_top.desert.png | Bin 0 -> 331 bytes 6 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 src/main/resources/assets/hbm/textures/blocks/stone_biome.desert.png create mode 100644 src/main/resources/assets/hbm/textures/blocks/stone_biome_layer.desert.png create mode 100644 src/main/resources/assets/hbm/textures/blocks/stone_biome_top.desert.png 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 0000000000000000000000000000000000000000..5d121421f906507d8caf3468c3e96ea747f0b4c1 GIT binary patch literal 377 zcmV-<0fzpGP)t+{VScN2)^+Eq_Y&?c=~JNs@?P9v3Nc_$@D#ZIs8ymEt};8 zfNZyldb{5im!GcmQB*BJ7!)tQzS%4%(WdU4-&ilkVc?wK09Y@^p%yRejzu+V@YSL}}l zaI(eP_Q^i=^m`NE_(6k)`uZm=%E9IE6TMw|=wI76K0Mjwr)%W9YI-^l`LEjj=er>9 zWubB--B}{vg`#T1pbe1fZ8m@Bz-Hb0odJ5H4VAuw93<0p;5Wn}>hnPkYzFLRR{*at1EJ;$rZIL1>srl~^FUgHjZ<%Z)0oi%HVyMrIW1Q|Y>&?EemK3hX^cHtr@PZM z?}I!5hkyF|FWw1qPYS6U=CusSJCT>IZIl9{ze%DW9Z0Q9z7qgEQHqLoqys-xBfbGw kM8kNb1E~QyOy(rM0Z}pnk8>f5R{#J207*qoM6N<$f?d_8<^TWy literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..1c05ff0d1fc67d0560edf35385575c1af38be751 GIT binary patch literal 331 zcmV-R0kr;!P)gzh+SIs9G8;FPq*K_=|HZ`9ExaO$ql6ETT&{&?5cEuSYB4dM+YmN%2Ig+t{xVfag z5v`|^cH(~9LB@J`!%xYQu*G);0uUm*Rd13cLg!a;jPSN=_*@U(?b-0o5r z0FK&7OYGL}3=RmpMM)(cAYK^uqyl3@8)bIOofSvd4|dH?h_yU>teHU*iJx>}+?;>o d**YW&_6sbA35V46ElmIb002ovPDHLkV1oF~h<5-0 literal 0 HcmV?d00001