From e27418a946f0bb0b1376189a04aaa7b6d6aea0db Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 6 Dec 2024 14:41:23 +0800 Subject: [PATCH 1/2] copy over missing changes to cargo rocket in #4 launch controller now teleports the rocket to the destination instead of having it to actually fly around. some changes was made to the rocket class as well. however the original author did not notice that cargo rocket is on another branch of the class hierarchy and did not adjust cargo rocket class. this commit copies over those changes to cargo rocket class --- .../mars/entities/EntityCargoRocket.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/main/java/micdoodle8/mods/galacticraft/planets/mars/entities/EntityCargoRocket.java b/src/main/java/micdoodle8/mods/galacticraft/planets/mars/entities/EntityCargoRocket.java index 93410b39be..3d0d4797ba 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/planets/mars/entities/EntityCargoRocket.java +++ b/src/main/java/micdoodle8/mods/galacticraft/planets/mars/entities/EntityCargoRocket.java @@ -111,12 +111,16 @@ public void onUpdate() { if (this.rumble < 0) { this.rumble++; } + final boolean isIgnited = this.launchPhase == EnumLaunchPhase.IGNITED.ordinal(); + final boolean isLaunched = this.launchPhase == EnumLaunchPhase.LAUNCHED.ordinal(); - if (this.launchPhase == EnumLaunchPhase.IGNITED.ordinal() - || this.launchPhase == EnumLaunchPhase.LAUNCHED.ordinal()) { + if (isIgnited || isLaunched) { this.performHurtAnimation(); - this.rumble = (float) this.rand.nextInt(3) - 3; + + if (this.destinationFrequency != -1 && !this.landing && isLaunched) { + this.onReachAtmosphere(); + } } int i; @@ -256,7 +260,7 @@ public void onReachAtmosphere() { final WorldProvider targetDim = WorldUtil.getProviderForDimensionServer(this.targetDimension); if (targetDim != null && targetDim.worldObj instanceof WorldServer) { GCLog.debug("Loaded destination dimension " + this.targetDimension); - this.setPosition(this.targetVec.x + 0.5F, this.targetVec.y + 800, this.targetVec.z + 0.5F); + this.moveToDestination(800); final Entity e = WorldUtil.transferEntityToDimension( this, this.targetDimension, @@ -266,7 +270,7 @@ public void onReachAtmosphere() { if (e instanceof EntityCargoRocket) { GCLog.debug("Cargo rocket arrived at destination dimension, going into landing mode."); - e.setPosition(this.targetVec.x + 0.5F, this.targetVec.y + 800, this.targetVec.z + 0.5F); + this.moveToDestination(800); ((EntityCargoRocket) e).landing = true; // No setDead() following successful transferEntityToDimension() - see javadoc // on that @@ -282,7 +286,7 @@ public void onReachAtmosphere() { this.setDead(); } else { GCLog.debug("Cargo rocket going into landing mode in same destination."); - this.setPosition(this.targetVec.x + 0.5F, this.targetVec.y + 800, this.targetVec.z + 0.5F); + this.moveToDestination(800); this.landing = true; } return; @@ -330,13 +334,20 @@ public int getSizeInventory() { @Override public void onWorldTransferred(World world) { if (this.targetVec != null) { - this.setPosition(this.targetVec.x + 0.5F, this.targetVec.y + 2, this.targetVec.z + 0.5F); + moveToDestination(2); this.landing = true; } else { this.setDead(); } } + private void moveToDestination(int reentryHeight) { + if (this.destinationFrequency != 1){ + reentryHeight = 0; + } + this.setPosition(this.targetVec.x + 0.5F, this.targetVec.y + reentryHeight, this.targetVec.z + 0.5F); + } + @Override public void onPadDestroyed() { if (!this.isDead && this.launchPhase != EnumLaunchPhase.LAUNCHED.ordinal()) { From c24dc1af793567e96a00416b72b64b0a3b7421f6 Mon Sep 17 00:00:00 2001 From: Glease <4586901+Glease@users.noreply.github.com> Date: Fri, 6 Dec 2024 14:50:37 +0800 Subject: [PATCH 2/2] spotless --- .../galacticraft/planets/mars/entities/EntityCargoRocket.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/micdoodle8/mods/galacticraft/planets/mars/entities/EntityCargoRocket.java b/src/main/java/micdoodle8/mods/galacticraft/planets/mars/entities/EntityCargoRocket.java index 3d0d4797ba..77ffadf89a 100644 --- a/src/main/java/micdoodle8/mods/galacticraft/planets/mars/entities/EntityCargoRocket.java +++ b/src/main/java/micdoodle8/mods/galacticraft/planets/mars/entities/EntityCargoRocket.java @@ -342,7 +342,7 @@ public void onWorldTransferred(World world) { } private void moveToDestination(int reentryHeight) { - if (this.destinationFrequency != 1){ + if (this.destinationFrequency != 1) { reentryHeight = 0; } this.setPosition(this.targetVec.x + 0.5F, this.targetVec.y + reentryHeight, this.targetVec.z + 0.5F);