From 63a406782512491e576852ee40a9a0a216daaa77 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Wed, 6 May 2020 23:25:45 +0900 Subject: [PATCH 01/10] test fix --- patches/rtm.patch | 61 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/patches/rtm.patch b/patches/rtm.patch index 1e536a22..69827ab0 100644 --- a/patches/rtm.patch +++ b/patches/rtm.patch @@ -178,6 +178,67 @@ index 5298b6c..b941866 100644 .line 76 .stack locals Object jp/ngt/rtm/entity/vehicle/RenderVehicleBase +diff --git a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry.jasm b/src/main/rtm/jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry.jasm +index 137db20..c06076c 100644 +--- a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry.jasm ++++ b/src/main/rtm/jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry.jasm +@@ -616,20 +616,30 @@ L_0051: + new net/minecraft/network/play/server/SPacketEntityAttach + dup + aload 0 + getfield jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry/trackedEntity Lnet/minecraft/entity/Entity; + aload 0 + getfield jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry/trackedEntity Lnet/minecraft/entity/Entity; + invokevirtual net/minecraft/entity/Entity/getRidingEntity ()Lnet/minecraft/entity/Entity; + invokespecial net/minecraft/network/play/server/SPacketEntityAttach/ (Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/Entity;)V + invokevirtual net/minecraft/network/NetHandlerPlayServer/sendPacket (Lnet/minecraft/network/Packet;)V + L_005e: ++ ++ .stack use locals ++ .end stack ++ ++ .line 1195 ++ aload 1 ++ aload 0 ++ getfield jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry/trackedEntity Lnet/minecraft/entity/Entity; ++ invokevirtual net/minecraft/entity/player/EntityPlayerMP/addEntity (Lnet/minecraft/entity/Entity;)V ++ + .line 195 + .stack use locals + .end stack + aload 0 + getfield jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry/trackedEntity Lnet/minecraft/entity/Entity; + aload 1 + invokestatic net/minecraftforge/event/ForgeEventFactory/onStartEntityTracking (Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/player/EntityPlayer;)V + L_0065: + .line 196 + goto L_0083 +@@ -747,20 +757,25 @@ L_0016: + return + L_001a: + .end method + + .method public static trackingVehicle (Lnet/minecraft/entity/Entity;)Z + .limit stack 3 + .limit local 7 + L_0000: + .line 232 + .var 0 is par1 Lnet/minecraft/entity/Entity; from L_0000 to L_0079 ++ iconst_1 ++ ireturn ++ .stack ++ locals Object net/minecraft/entity/Entity ++ .end stack + aload 0 + instanceof jp/ngt/rtm/entity/vehicle/EntityVehicleBase + ifne L_000f + aload 0 + instanceof jp/ngt/rtm/entity/train/EntityBogie + ifne L_000f + L_0008: + .line 234 + new java/lang/IllegalArgumentException + dup diff --git a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/vehicle/WeatherEffectDummy.jasm b/src/main/rtm/jp/ngt/rtm/entity/vehicle/WeatherEffectDummy.jasm index d0e484a..ab9a52f 100644 --- a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/vehicle/WeatherEffectDummy.jasm From 17e771bd3a014e8e501f1bd6b9830b9ad9ca272b Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Thu, 7 May 2020 21:56:20 +0900 Subject: [PATCH 02/10] SNAPSHOT-2020-05-07-21-55-07 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 05ba2d56..5c34dd2f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ modGroup=com.anatawa12.fixRtm -modVersion=2.0.3 +modVersion=SNAPSHOT-2020-05-07-21-55-07 modBaseName=fixRtm forgeVersion=1.12.2-14.23.5.2847 mcpVersion=stable_39 From 6e71d7aecec63dbd6ef74bdd8ea362c16b53ecd6 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Fri, 8 May 2020 17:44:16 +0900 Subject: [PATCH 03/10] test fix 2 --- patches/rtm.patch | 67 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/patches/rtm.patch b/patches/rtm.patch index 69827ab0..f6d0245c 100644 --- a/patches/rtm.patch +++ b/patches/rtm.patch @@ -179,7 +179,7 @@ index 5298b6c..b941866 100644 .stack locals Object jp/ngt/rtm/entity/vehicle/RenderVehicleBase diff --git a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry.jasm b/src/main/rtm/jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry.jasm -index 137db20..c06076c 100644 +index 137db20..730442e 100644 --- a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry.jasm +++ b/src/main/rtm/jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry.jasm @@ -616,20 +616,30 @@ L_0051: @@ -213,32 +213,59 @@ index 137db20..c06076c 100644 L_0065: .line 196 goto L_0083 -@@ -747,20 +757,25 @@ L_0016: +@@ -665,26 +675,51 @@ L_007d: + invokestatic net/minecraftforge/event/ForgeEventFactory/onStopEntityTracking (Lnet/minecraft/entity/Entity;Lnet/minecraft/entity/player/EntityPlayer;)V + L_0083: + .line 205 + .stack use locals + .end stack return - L_001a: + L_0087: .end method - .method public static trackingVehicle (Lnet/minecraft/entity/Entity;)Z - .limit stack 3 - .limit local 7 + .method public isVisibleTo (Lnet/minecraft/entity/player/EntityPlayerMP;)Z +- .limit stack 1 ++ .limit stack 4 + .limit local 2 L_0000: - .line 232 - .var 0 is par1 Lnet/minecraft/entity/Entity; from L_0000 to L_0079 -+ iconst_1 + .line 210 + .var 0 is this Ljp/ngt/rtm/entity/vehicle/VehicleTrackerEntry; from L_0000 to L_0004 + .var 1 is playerMP Lnet/minecraft/entity/player/EntityPlayerMP; from L_0000 to L_0004 ++ aload 1 ++ aload 0 ++ getfield jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry/trackedEntity Lnet/minecraft/entity/Entity; ++ getfield net/minecraft/entity/Entity/posX D ++ aload 0 ++ getfield jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry/trackedEntity Lnet/minecraft/entity/Entity; ++ getfield net/minecraft/entity/Entity/posY D ++ aload 0 ++ getfield jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry/trackedEntity Lnet/minecraft/entity/Entity; ++ getfield net/minecraft/entity/Entity/posZ D ++ invokevirtual net/minecraft/entity/Entity/getDistanceSq (DDD)D ++ ldc 16.0 ++ ldc 32.0 ++ dmul ++ dup2 ++ dmul ++ dcmpl ++ iflt JMP ++ iconst_0 + ireturn ++JMP: + .stack -+ locals Object net/minecraft/entity/Entity ++ locals Object jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry ++ locals Object net/minecraft/entity/player/EntityPlayerMP + .end stack - aload 0 - instanceof jp/ngt/rtm/entity/vehicle/EntityVehicleBase - ifne L_000f - aload 0 - instanceof jp/ngt/rtm/entity/train/EntityBogie - ifne L_000f - L_0008: - .line 234 - new java/lang/IllegalArgumentException - dup + iconst_1 + ireturn + L_0004: + .end method + + .method private isPlayerWatchingThisChunk (Lnet/minecraft/entity/player/EntityPlayerMP;)Z + .limit stack 4 + .limit local 2 + L_0000: + .line 215 diff --git a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/vehicle/WeatherEffectDummy.jasm b/src/main/rtm/jp/ngt/rtm/entity/vehicle/WeatherEffectDummy.jasm index d0e484a..ab9a52f 100644 --- a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/vehicle/WeatherEffectDummy.jasm From 02c3606c548b2692519853a44fca3a44492dc853 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Fri, 8 May 2020 17:45:28 +0900 Subject: [PATCH 04/10] SNAPSHOT-2020-05-08-17-45-17 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 5c34dd2f..c258ebee 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ modGroup=com.anatawa12.fixRtm -modVersion=SNAPSHOT-2020-05-07-21-55-07 +modVersion=SNAPSHOT-2020-05-08-17-45-17 modBaseName=fixRtm forgeVersion=1.12.2-14.23.5.2847 mcpVersion=stable_39 From 5cd632e06f611a2381652fb5e601f317a34e427e Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Fri, 8 May 2020 21:48:47 +0900 Subject: [PATCH 05/10] test fix 3 --- patches/rtm.patch | 29 +++++++++++++++++-- .../rtm/entity/vehicle/WeatherEffectDummy.kt | 15 ++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/anatawa12/fixRtm/rtm/entity/vehicle/WeatherEffectDummy.kt diff --git a/patches/rtm.patch b/patches/rtm.patch index f6d0245c..f8a8d6c7 100644 --- a/patches/rtm.patch +++ b/patches/rtm.patch @@ -267,10 +267,35 @@ index 137db20..730442e 100644 L_0000: .line 215 diff --git a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/vehicle/WeatherEffectDummy.jasm b/src/main/rtm/jp/ngt/rtm/entity/vehicle/WeatherEffectDummy.jasm -index d0e484a..ab9a52f 100644 +index d0e484a..b7325e4 100644 --- a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/vehicle/WeatherEffectDummy.jasm +++ b/src/main/rtm/jp/ngt/rtm/entity/vehicle/WeatherEffectDummy.jasm -@@ -226,10 +226,21 @@ L_0003: +@@ -110,22 +110,23 @@ L_002b: + L_0032: + .line 36 + aload 0 + aload 0 + getfield jp/ngt/rtm/entity/vehicle/WeatherEffectDummy/parent Ljp/ngt/rtm/entity/vehicle/EntityVehicleBase; + getfield jp/ngt/rtm/entity/vehicle/EntityVehicleBase/rotationPitch F + putfield jp/ngt/rtm/entity/vehicle/WeatherEffectDummy/rotationPitch F + L_0039: + .line 38 + aload 0 ++ aload 0 + getfield jp/ngt/rtm/entity/vehicle/WeatherEffectDummy/parent Ljp/ngt/rtm/entity/vehicle/EntityVehicleBase; +- getfield jp/ngt/rtm/entity/vehicle/EntityVehicleBase/isDead Z ++ invokestatic com/anatawa12/fixRtm/rtm/entity/vehicle/WeatherEffectDummyKt/shouldDead (Ljp/ngt/rtm/entity/vehicle/WeatherEffectDummy;Ljp/ngt/rtm/entity/vehicle/EntityVehicleBase;)Z + ifeq L_0050 + L_003f: + .line 40 + aload 0 + invokevirtual jp/ngt/rtm/entity/vehicle/WeatherEffectDummy/setDead ()V + L_0043: + .line 41 + ldc "[WED] Remove %d" + iconst_1 + anewarray java/lang/Object +@@ -226,10 +227,21 @@ L_0003: .limit stack 0 .limit local 2 L_0000: diff --git a/src/main/java/com/anatawa12/fixRtm/rtm/entity/vehicle/WeatherEffectDummy.kt b/src/main/java/com/anatawa12/fixRtm/rtm/entity/vehicle/WeatherEffectDummy.kt new file mode 100644 index 00000000..9c6228c0 --- /dev/null +++ b/src/main/java/com/anatawa12/fixRtm/rtm/entity/vehicle/WeatherEffectDummy.kt @@ -0,0 +1,15 @@ +@file:JvmName("WeatherEffectDummyKt") + +package com.anatawa12.fixRtm.rtm.entity.vehicle + +import jp.ngt.rtm.entity.vehicle.EntityVehicleBase +import jp.ngt.rtm.entity.vehicle.WeatherEffectDummy + +fun WeatherEffectDummy.shouldDead(parent: EntityVehicleBase<*>): Boolean { + if (this.parent.isDead) return true + if (world.getEntityByID(parent.entityId) == null) { + println("WeatherEffectDummy.shouldDead return true with world.getEntityByID(parent.entityId) == null") + return true + } + return false +} From 633bce6cf3b7ff0892acef66bcd6361cebc115a2 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Fri, 8 May 2020 21:51:03 +0900 Subject: [PATCH 06/10] SNAPSHOT-2020-05-08-21-49-00 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index c258ebee..02522cf1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ modGroup=com.anatawa12.fixRtm -modVersion=SNAPSHOT-2020-05-08-17-45-17 +modVersion=SNAPSHOT-2020-05-08-21-49-00 modBaseName=fixRtm forgeVersion=1.12.2-14.23.5.2847 mcpVersion=stable_39 From 473d5c1c8fc0af486c74a955e8fb3231321e86f9 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 10 May 2020 16:40:00 +0900 Subject: [PATCH 07/10] test fix 4 --- patches/rtm.patch | 95 +++++++++++++++++++ .../renderer/model/CachedPolygonModel.kt | 3 +- .../rtm/network/PacketVehicleMovement.kt | 20 ++++ 3 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/anatawa12/fixRtm/rtm/network/PacketVehicleMovement.kt diff --git a/patches/rtm.patch b/patches/rtm.patch index f8a8d6c7..4a8e30eb 100644 --- a/patches/rtm.patch +++ b/patches/rtm.patch @@ -64,6 +64,72 @@ index 5ca3be3..aa70ce9 100644 .method public onBogieUpdate ()V .limit stack 2 +diff --git a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/train/util/Formation.jasm b/src/main/rtm/jp/ngt/rtm/entity/train/util/Formation.jasm +index 08fdfe9..a7f5e63 100644 +--- a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/train/util/Formation.jasm ++++ b/src/main/rtm/jp/ngt/rtm/entity/train/util/Formation.jasm +@@ -1843,46 +1843,57 @@ L_0000: + .line 397 + .var 0 is this Ljp/ngt/rtm/entity/train/util/Formation; from L_0000 to L_001f + .var 1 is train Ljp/ngt/rtm/entity/train/EntityTrainBase; from L_0000 to L_001f + aload 0 + getfield jp/ngt/rtm/entity/train/util/Formation/direction B + ifne L_000b + aload 0 + getfield jp/ngt/rtm/entity/train/util/Formation/entries "[Ljp/ngt/rtm/entity/train/util/FormationEntry;" + iconst_0 + aaload +- getfield jp/ngt/rtm/entity/train/util/FormationEntry/train Ljp/ngt/rtm/entity/train/EntityTrainBase; + goto L_0016 + L_000b: + .stack + locals Object jp/ngt/rtm/entity/train/util/Formation + locals Object jp/ngt/rtm/entity/train/EntityTrainBase + .end stack + aload 0 + getfield jp/ngt/rtm/entity/train/util/Formation/entries "[Ljp/ngt/rtm/entity/train/util/FormationEntry;" + aload 0 + getfield jp/ngt/rtm/entity/train/util/Formation/entries "[Ljp/ngt/rtm/entity/train/util/FormationEntry;" + arraylength + iconst_1 + isub + aaload +- getfield jp/ngt/rtm/entity/train/util/FormationEntry/train Ljp/ngt/rtm/entity/train/EntityTrainBase; + L_0016: + .stack use locals +- stacks Object jp/ngt/rtm/entity/train/EntityTrainBase ++ stacks Object jp/ngt/rtm/entity/train/util/FormationEntry + .end stack + astore 2 + L_0019: + .line 398 +- .var 2 is front Ljp/ngt/rtm/entity/train/EntityTrainBase; from L_0019 to L_001f ++ .var 2 is front Ljp/ngt/rtm/entity/train/util/FormationEntry; from L_0019 to L_001f ++ ++ aload 2 ++ ifnonnull L_nonnull ++ iconst_0 ++ ireturn ++L_nonnull: ++ .stack ++ locals Object jp/ngt/rtm/entity/train/util/Formation ++ locals Object jp/ngt/rtm/entity/train/EntityTrainBase ++ locals Object jp/ngt/rtm/entity/train/util/FormationEntry ++ .end stack ++ + aload 1 + aload 2 ++ getfield jp/ngt/rtm/entity/train/util/FormationEntry/train Ljp/ngt/rtm/entity/train/EntityTrainBase; + invokevirtual jp/ngt/rtm/entity/train/EntityTrainBase/equals (Ljava/lang/Object;)Z + ireturn + L_001f: + .end method + + .method public updateTrainMovement ()V + .limit stack 5 + .limit local 6 + L_0000: + .line 404 diff --git a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/vehicle/EntityVehicleBase.jasm b/src/main/rtm/jp/ngt/rtm/entity/vehicle/EntityVehicleBase.jasm index b252a06..0c0db45 100644 --- a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/vehicle/EntityVehicleBase.jasm @@ -688,6 +754,35 @@ index 2945cc2..a90bdee 100644 L_001a: .line 120 aload 0 +diff --git a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/network/PacketVehicleMovement.jasm b/src/main/rtm/jp/ngt/rtm/network/PacketVehicleMovement.jasm +index 6e5c39c..e670ca1 100644 +--- a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/network/PacketVehicleMovement.jasm ++++ b/src/main/rtm/jp/ngt/rtm/network/PacketVehicleMovement.jasm +@@ -357,20 +357,24 @@ L_001b: + L_0023: + .line 97 + .var 4 is entity Lnet/minecraft/entity/Entity; from L_0023 to L_008e + aload 4 + ifnull L_007c + aload 4 + getfield net/minecraft/entity/Entity/isDead Z + ifne L_007c + L_002a: + .line 99 ++ ++ aload 4 ++ invokestatic com/anatawa12/fixRtm/rtm/network/PacketVehicleMovementKt/addEntityIfNotExits (Lnet/minecraft/entity/Entity;)V ++ + aload 1 + getfield jp/ngt/rtm/network/PacketVehicleMovement/vehicleX I + i2d + ldc 0.03125 + dmul + dstore 5 + L_0032: + .line 100 + .var 5 is x D from L_0032 to L_0078 + aload 1 diff --git a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/rail/BlockMarker.jasm b/src/main/rtm/jp/ngt/rtm/rail/BlockMarker.jasm index d2c0e4b..6ffb4cc 100644 --- a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/rail/BlockMarker.jasm diff --git a/src/main/java/com/anatawa12/fixRtm/ngtlib/renderer/model/CachedPolygonModel.kt b/src/main/java/com/anatawa12/fixRtm/ngtlib/renderer/model/CachedPolygonModel.kt index bfa97c08..83cbb618 100644 --- a/src/main/java/com/anatawa12/fixRtm/ngtlib/renderer/model/CachedPolygonModel.kt +++ b/src/main/java/com/anatawa12/fixRtm/ngtlib/renderer/model/CachedPolygonModel.kt @@ -5,6 +5,7 @@ import com.anatawa12.fixRtm.io.FIXFileLoader import com.anatawa12.fixRtm.io.FIXModelPack import jp.ngt.ngtlib.io.FileType import jp.ngt.ngtlib.renderer.model.* +import net.minecraft.client.Minecraft import net.minecraft.util.ResourceLocation import org.apache.commons.codec.digest.DigestUtils import java.io.* @@ -32,7 +33,7 @@ object CachedPolygonModel { for (modelPack in FIXFileLoader.allModelPacks) { val cache = FileCache( baseDir.resolve(modelPack.file.name), - DigestUtils.sha1Hex(modelPack.file.inputStream().buffered()), + modelPack.sha1Hash, executor, { out, v -> CachedModelWriter.writeCachedModel(DataOutputStream(out), v) }, ::CachedModel, diff --git a/src/main/java/com/anatawa12/fixRtm/rtm/network/PacketVehicleMovement.kt b/src/main/java/com/anatawa12/fixRtm/rtm/network/PacketVehicleMovement.kt new file mode 100644 index 00000000..69ef3c91 --- /dev/null +++ b/src/main/java/com/anatawa12/fixRtm/rtm/network/PacketVehicleMovement.kt @@ -0,0 +1,20 @@ +@file:JvmName("PacketVehicleMovementKt") + +package com.anatawa12.fixRtm.rtm.network + +import com.anatawa12.fixRtm.Loggers +import net.minecraft.client.Minecraft +import net.minecraft.entity.Entity + +fun addEntityIfNotExits(entity: Entity) { + val world = Minecraft.getMinecraft().world + if ((!entity.addedToChunk || !entity.isAddedToWorld) + && world.isBlockLoaded(entity.position, false)) { + Minecraft.getMinecraft().addScheduledTask { + logger.info("the entity: $entity is not added") + world.spawnEntity(entity) + } + } +} + +private val logger = Loggers.getLogger("PacketVehicleMovementKt") From 40e442dd0bff9f8a05dbe63cf08cc71b2d3e98a5 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Sun, 10 May 2020 16:40:36 +0900 Subject: [PATCH 08/10] SNAPSHOT-2020-05-09-16-40-30 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 02522cf1..cdb73ad2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ modGroup=com.anatawa12.fixRtm -modVersion=SNAPSHOT-2020-05-08-21-49-00 +modVersion=SNAPSHOT-2020-05-09-16-40-30 modBaseName=fixRtm forgeVersion=1.12.2-14.23.5.2847 mcpVersion=stable_39 From 36d7f165dd68e06dc374e32ed365086bd266b252 Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 12 May 2020 16:22:11 +0900 Subject: [PATCH 09/10] fix --- patches/rtm.patch | 56 +++++++++++++++++-- src/main/java/com/anatawa12/fixRtm/FixRtm.kt | 9 +++ src/main/java/com/anatawa12/fixRtm/Proxy.kt | 18 ++++++ .../fixRtm/VehicleTrackerEntryFix.kt | 33 +++++++++++ .../fixRtm/rtm/entity/train/EntityBogie.kt | 10 ++++ .../rtm/entity/vehicle/EntityVehicleBase.kt | 10 ++++ .../rtm/network/PacketVehicleMovement.kt | 2 +- 7 files changed, 132 insertions(+), 6 deletions(-) create mode 100644 src/main/java/com/anatawa12/fixRtm/Proxy.kt create mode 100644 src/main/java/com/anatawa12/fixRtm/VehicleTrackerEntryFix.kt create mode 100644 src/main/java/com/anatawa12/fixRtm/rtm/entity/train/EntityBogie.kt create mode 100644 src/main/java/com/anatawa12/fixRtm/rtm/entity/vehicle/EntityVehicleBase.kt diff --git a/patches/rtm.patch b/patches/rtm.patch index 4a8e30eb..499649c3 100644 --- a/patches/rtm.patch +++ b/patches/rtm.patch @@ -26,10 +26,33 @@ index 2297030..17edb7e 100644 .line 156 getstatic jp/ngt/rtm/RTMItem/itemMotorman Lnet/minecraft/item/Item; diff --git a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/train/EntityBogie.jasm b/src/main/rtm/jp/ngt/rtm/entity/train/EntityBogie.jasm -index 5ca3be3..aa70ce9 100644 +index 5ca3be3..92dcff4 100644 --- a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/train/EntityBogie.jasm +++ b/src/main/rtm/jp/ngt/rtm/entity/train/EntityBogie.jasm -@@ -1547,24 +1547,34 @@ L_0012: +@@ -128,20 +128,22 @@ L_0020: + iconst_1 + putfield jp/ngt/rtm/entity/train/EntityBogie/preventEntitySpawning Z + L_0025: + .line 81 + aload 0 + ldc 2.75f + ldc 1.1875f + invokevirtual jp/ngt/rtm/entity/train/EntityBogie/setBogieSize (FF)V + L_002b: + .line 82 ++ aload 0 ++ invokestatic com/anatawa12/fixRtm/rtm/entity/train/EntityBogieKt/constructor (Ljp/ngt/rtm/entity/train/EntityBogie;)V + return + L_002e: + .end method + + .method public (Lnet/minecraft/world/World;BLjp/ngt/rtm/entity/train/EntityTrainBase;)V + .limit stack 2 + .limit local 4 + L_0000: + .line 86 + .var 0 is this Ljp/ngt/rtm/entity/train/EntityBogie; from L_0000 to L_0012 +@@ -1547,24 +1549,34 @@ L_0012: .end stack iconst_0 istore 1 @@ -131,10 +154,33 @@ index 08fdfe9..a7f5e63 100644 L_0000: .line 404 diff --git a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/vehicle/EntityVehicleBase.jasm b/src/main/rtm/jp/ngt/rtm/entity/vehicle/EntityVehicleBase.jasm -index b252a06..0c0db45 100644 +index b252a06..595c970 100644 --- a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/vehicle/EntityVehicleBase.jasm +++ b/src/main/rtm/jp/ngt/rtm/entity/vehicle/EntityVehicleBase.jasm -@@ -1068,48 +1068,50 @@ L_0004: +@@ -271,20 +271,22 @@ L_0061: + L_0068: + .line 96 + iinc 4 1 + goto L_0058 + L_006c: + .line 100 + .stack + locals Object jp/ngt/rtm/entity/vehicle/EntityVehicleBase + locals Object net/minecraft/world/World + .end stack ++ aload 0 ++ invokestatic com/anatawa12/fixRtm/rtm/entity/vehicle/EntityVehicleBaseKt/constructor (Ljp/ngt/rtm/entity/vehicle/EntityVehicleBase;)V + return + L_0070: + .end method + + .method protected entityInit ()V + .limit stack 0 + .limit local 1 + L_0000: + .line 105 + .var 0 is this Ljp/ngt/rtm/entity/vehicle/EntityVehicleBase; signature "Ljp/ngt/rtm/entity/vehicle/EntityVehicleBase;" from L_0000 to L_0003 +@@ -1068,48 +1070,50 @@ L_0004: astore 4 L_000b: .line 365 @@ -192,7 +238,7 @@ index b252a06..0c0db45 100644 getfield jp/ngt/rtm/entity/vehicle/EntityVehicleBase/posX D dsub aload 2 -@@ -1228,21 +1230,21 @@ L_0092: +@@ -1228,21 +1232,21 @@ L_0092: .line 387 .var 12 is z D from L_0092 to L_00b1 aload 0 diff --git a/src/main/java/com/anatawa12/fixRtm/FixRtm.kt b/src/main/java/com/anatawa12/fixRtm/FixRtm.kt index 546277d4..0a4a768a 100644 --- a/src/main/java/com/anatawa12/fixRtm/FixRtm.kt +++ b/src/main/java/com/anatawa12/fixRtm/FixRtm.kt @@ -19,10 +19,12 @@ import net.minecraftforge.event.RegistryEvent import net.minecraftforge.fml.client.registry.ClientRegistry import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.ModMetadata +import net.minecraftforge.fml.common.SidedProxy import net.minecraftforge.fml.common.event.FMLConstructionEvent import net.minecraftforge.fml.common.event.FMLInitializationEvent import net.minecraftforge.fml.common.event.FMLPreInitializationEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent +import net.minecraftforge.fml.common.gameevent.TickEvent import net.minecraftforge.fml.common.network.NetworkCheckHandler import net.minecraftforge.fml.relauncher.Side import java.awt.Color @@ -144,7 +146,14 @@ object FixRtm { } } + @SubscribeEvent + fun tick(e: TickEvent.ClientTickEvent) { + if (e.phase == TickEvent.Phase.END) + proxy.tick() + } + @field:SidedProxy(clientSide = "com.anatawa12.fixRtm.ClientProxy", serverSide = "com.anatawa12.fixRtm.ServerProxy") + lateinit var proxy: CommonProxy @Mod.InstanceFactory @JvmStatic diff --git a/src/main/java/com/anatawa12/fixRtm/Proxy.kt b/src/main/java/com/anatawa12/fixRtm/Proxy.kt new file mode 100644 index 00000000..377cdffd --- /dev/null +++ b/src/main/java/com/anatawa12/fixRtm/Proxy.kt @@ -0,0 +1,18 @@ +package com.anatawa12.fixRtm + +import net.minecraft.client.Minecraft + +abstract class CommonProxy { + open fun tick() {} + + +} + +class ServerProxy : CommonProxy() + +class ClientProxy : CommonProxy() { + override fun tick() { + if (Minecraft.getMinecraft().world != null) + VehicleTrackerEntryFix.tick() + } +} diff --git a/src/main/java/com/anatawa12/fixRtm/VehicleTrackerEntryFix.kt b/src/main/java/com/anatawa12/fixRtm/VehicleTrackerEntryFix.kt new file mode 100644 index 00000000..8d8e4231 --- /dev/null +++ b/src/main/java/com/anatawa12/fixRtm/VehicleTrackerEntryFix.kt @@ -0,0 +1,33 @@ +package com.anatawa12.fixRtm + +import net.minecraft.client.Minecraft +import net.minecraft.entity.Entity +import java.util.* + +object VehicleTrackerEntryFix { + private val instances = Collections.newSetFromMap(WeakHashMap()) + + fun addInstance(instance: Entity) { + instances.add(instance) + } + + fun tick() { + val mc = Minecraft.getMinecraft() + val iter = instances.iterator() + while (iter.hasNext()) { + val instance = iter.next() ?: continue + if (instance.world != mc.world) { + iter.remove() + continue + } + if (instance.isDead) continue + if ((!instance.isAddedToWorld || !instance.addedToChunk) + && mc.world.isBlockLoaded(instance.position, false)) { + logger.trace("the entity: $instance is not added") + mc.world.spawnEntity(instance) + } + } + } + + private val logger = Loggers.getLogger("VehicleTrackerEntryFix") +} diff --git a/src/main/java/com/anatawa12/fixRtm/rtm/entity/train/EntityBogie.kt b/src/main/java/com/anatawa12/fixRtm/rtm/entity/train/EntityBogie.kt new file mode 100644 index 00000000..73fb73b2 --- /dev/null +++ b/src/main/java/com/anatawa12/fixRtm/rtm/entity/train/EntityBogie.kt @@ -0,0 +1,10 @@ +@file:JvmName("EntityBogieKt") + +package com.anatawa12.fixRtm.rtm.entity.train + +import com.anatawa12.fixRtm.VehicleTrackerEntryFix +import jp.ngt.rtm.entity.train.EntityBogie + +fun EntityBogie.constructor() { + VehicleTrackerEntryFix.addInstance(this) +} diff --git a/src/main/java/com/anatawa12/fixRtm/rtm/entity/vehicle/EntityVehicleBase.kt b/src/main/java/com/anatawa12/fixRtm/rtm/entity/vehicle/EntityVehicleBase.kt new file mode 100644 index 00000000..2f8bacba --- /dev/null +++ b/src/main/java/com/anatawa12/fixRtm/rtm/entity/vehicle/EntityVehicleBase.kt @@ -0,0 +1,10 @@ +@file:JvmName("EntityVehicleBaseKt") + +package com.anatawa12.fixRtm.rtm.entity.vehicle + +import com.anatawa12.fixRtm.VehicleTrackerEntryFix +import jp.ngt.rtm.entity.vehicle.EntityVehicleBase + +fun EntityVehicleBase<*>.constructor() { + VehicleTrackerEntryFix.addInstance(this) +} diff --git a/src/main/java/com/anatawa12/fixRtm/rtm/network/PacketVehicleMovement.kt b/src/main/java/com/anatawa12/fixRtm/rtm/network/PacketVehicleMovement.kt index 69ef3c91..be73c533 100644 --- a/src/main/java/com/anatawa12/fixRtm/rtm/network/PacketVehicleMovement.kt +++ b/src/main/java/com/anatawa12/fixRtm/rtm/network/PacketVehicleMovement.kt @@ -11,7 +11,7 @@ fun addEntityIfNotExits(entity: Entity) { if ((!entity.addedToChunk || !entity.isAddedToWorld) && world.isBlockLoaded(entity.position, false)) { Minecraft.getMinecraft().addScheduledTask { - logger.info("the entity: $entity is not added") + logger.trace("the entity: $entity is not added") world.spawnEntity(entity) } } From 9fc0ac6a67095388c29d4e7c6ee50795ae7d546a Mon Sep 17 00:00:00 2001 From: anatawa12 Date: Tue, 12 May 2020 16:32:29 +0900 Subject: [PATCH 10/10] SNAPSHOT-2020-05-12-16-32-30 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index cdb73ad2..36aeb5d2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ modGroup=com.anatawa12.fixRtm -modVersion=SNAPSHOT-2020-05-09-16-40-30 +modVersion=SNAPSHOT-2020-05-12-16-32-30 modBaseName=fixRtm forgeVersion=1.12.2-14.23.5.2847 mcpVersion=stable_39