Skip to content

Commit

Permalink
Merge pull request #95 from anatawa12/train-chunk-loader
Browse files Browse the repository at this point in the history
chunk loader
  • Loading branch information
anatawa12 authored Jun 20, 2020
2 parents 464a0a3 + 4794722 commit d36a099
Show file tree
Hide file tree
Showing 2 changed files with 390 additions and 0 deletions.
366 changes: 366 additions & 0 deletions patches/rtm.patch
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,257 @@ index 5ca3be3..92dcff4 100644

.method public onBogieUpdate ()V
.limit stack 2
diff --git a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/train/EntityTrainBase.jasm b/src/main/rtm/jp/ngt/rtm/entity/train/EntityTrainBase.jasm
index 50ba737..796060f 100644
--- a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/entity/train/EntityTrainBase.jasm
+++ b/src/main/rtm/jp/ngt/rtm/entity/train/EntityTrainBase.jasm
@@ -66,20 +66,23 @@
.field private final loadedChunks Ljava/util/Set;
.signature "Ljava/util/Set<Lnet/minecraft/util/math/ChunkPos;>;"
.end field

.field private prevChunkCoordX I
.end field

.field private prevChunkCoordZ I
.end field

+.field private prevChunkLoaderRadius I
+.end field
+
.method public <init> (Lnet/minecraft/world/World;)V
.limit stack 3
.limit local 2
L_0000:
.line 89
.var 0 is this Ljp/ngt/rtm/entity/train/EntityTrainBase; from L_0000 to L_0030
.var 1 is world Lnet/minecraft/world/World; from L_0000 to L_0030
aload 0
aload 1
invokespecial jp/ngt/rtm/entity/vehicle/EntityVehicleBase/<init> (Lnet/minecraft/world/World;)V
@@ -101,23 +104,23 @@ L_0011:
iconst_1
putfield jp/ngt/rtm/entity/train/EntityTrainBase/onRail Z
L_0016:
.line 81
aload 0
sipush 2880
putfield jp/ngt/rtm/entity/train/EntityTrainBase/brakeAirCount I
L_001b:
.line 1180
aload 0
- new java/util/HashSet
+ new java/util/LinkedHashSet
dup
- invokespecial java/util/HashSet/<init> ()V
+ invokespecial java/util/LinkedHashSet/<init> ()V
putfield jp/ngt/rtm/entity/train/EntityTrainBase/loadedChunks Ljava/util/Set;
L_0022:
.line 90
aload 0
ldc 2.75f
ldc 1.1875f
invokevirtual jp/ngt/rtm/entity/train/EntityTrainBase/setSize (FF)V
L_0028:
.line 91
aload 0
@@ -4649,21 +4652,21 @@ L_0000:
.line 1174
.var 0 is this Ljp/ngt/rtm/entity/train/EntityTrainBase; from L_0000 to L_0005
.var 1 is target Lnet/minecraft/util/math/RayTraceResult; from L_0000 to L_0005
aload 0
invokestatic jp/ngt/rtm/item/ItemTrain/convertFormationAsItem (Ljp/ngt/rtm/entity/train/EntityTrainBase;)Lnet/minecraft/item/ItemStack;
areturn
L_0005:
.end method

.method private updateChunks ()V
- .limit stack 2
+ .limit stack 3
.limit local 1
L_0000:
.line 1187
.var 0 is this Ljp/ngt/rtm/entity/train/EntityTrainBase; from L_0000 to L_001f
aload 0
invokevirtual jp/ngt/rtm/entity/train/EntityTrainBase/isChunkLoaderEnable ()Z
ifeq L_000a
L_0005:
.line 1189
aload 0
@@ -4683,20 +4686,28 @@ L_000f:
aload 0
aload 0
getfield jp/ngt/rtm/entity/train/EntityTrainBase/chunkCoordX I
putfield jp/ngt/rtm/entity/train/EntityTrainBase/prevChunkCoordX I
L_0016:
.line 1197
aload 0
aload 0
getfield jp/ngt/rtm/entity/train/EntityTrainBase/chunkCoordZ I
putfield jp/ngt/rtm/entity/train/EntityTrainBase/prevChunkCoordZ I
+
+ .line 11197
+ aload 0
+ aload 0
+ getstatic jp/ngt/rtm/entity/train/util/TrainState$TrainStateType/ChunkLoader Ljp/ngt/rtm/entity/train/util/TrainState$TrainStateType;
+ invokevirtual jp/ngt/rtm/entity/train/EntityTrainBase/getVehicleState (Ljp/ngt/rtm/entity/train/util/TrainState$TrainStateType;)B
+ putfield jp/ngt/rtm/entity/train/EntityTrainBase/prevChunkLoaderRadius I
+
L_001c:
.line 1198
return
L_001f:
.end method

.method public isChunkLoaderEnable ()Z
.limit stack 2
.limit local 1
L_0000:
@@ -4776,25 +4787,20 @@ L_000c:
aload 0
getstatic jp/ngt/rtm/entity/train/util/TrainState$TrainStateType/ChunkLoader Ljp/ngt/rtm/entity/train/util/TrainState$TrainStateType;
invokevirtual jp/ngt/rtm/entity/train/EntityTrainBase/getVehicleState (Ljp/ngt/rtm/entity/train/util/TrainState$TrainStateType;)B
istore 2
L_0012:
.line 1222
.var 2 is depth I from L_0012 to L_002a
aload 1
invokevirtual net/minecraftforge/common/ForgeChunkManager$Ticket/getModData ()Lnet/minecraft/nbt/NBTTagCompound;
pop
-L_0017:
- .line 1223
- aload 1
- iload 2
- invokevirtual net/minecraftforge/common/ForgeChunkManager$Ticket/setChunkListDepth (I)V
L_001c:
.line 1224
aload 1
aload 0
invokevirtual net/minecraftforge/common/ForgeChunkManager$Ticket/bindEntity (Lnet/minecraft/entity/Entity;)V
L_0021:
.line 1225
aload 0
aload 1
invokevirtual jp/ngt/rtm/entity/train/EntityTrainBase/setChunkTicket (Lnet/minecraftforge/common/ForgeChunkManager$Ticket;)V
@@ -4890,36 +4896,62 @@ L_0007:
getfield jp/ngt/rtm/entity/train/EntityTrainBase/ticket Lnet/minecraftforge/common/ForgeChunkManager$Ticket;
ifnonnull L_0011
aload 0
invokespecial jp/ngt/rtm/entity/train/EntityTrainBase/requestTicket ()Z
ifne L_0011
return
L_0011:
.line 1259
.stack use locals
.end stack
+
+ aload 0
+ getstatic jp/ngt/rtm/entity/train/util/TrainState$TrainStateType/ChunkLoader Ljp/ngt/rtm/entity/train/util/TrainState$TrainStateType;
+ invokevirtual jp/ngt/rtm/entity/train/EntityTrainBase/getVehicleState (Ljp/ngt/rtm/entity/train/util/TrainState$TrainStateType;)B
+ aload 0
+ getfield jp/ngt/rtm/entity/train/EntityTrainBase/prevChunkLoaderRadius I
+ if_icmpne L_should_setupChunks
+
iload 1
aload 0
getfield jp/ngt/rtm/entity/train/EntityTrainBase/prevChunkCoordX I
if_icmpne L_001c
iload 2
aload 0
getfield jp/ngt/rtm/entity/train/EntityTrainBase/prevChunkCoordZ I
if_icmpeq L_0023
+L_should_setupChunks:
L_001c:
.line 1261
.stack use locals
.end stack
aload 0
iload 1
iload 2
invokespecial jp/ngt/rtm/entity/train/EntityTrainBase/setupChunks (II)V
+
+ aload 0
+ getfield jp/ngt/rtm/entity/train/EntityTrainBase/ticket Lnet/minecraftforge/common/ForgeChunkManager$Ticket;
+ aload 0
+ getstatic jp/ngt/rtm/entity/train/util/TrainState$TrainStateType/ChunkLoader Ljp/ngt/rtm/entity/train/util/TrainState$TrainStateType;
+ invokevirtual jp/ngt/rtm/entity/train/EntityTrainBase/getVehicleState (Ljp/ngt/rtm/entity/train/util/TrainState$TrainStateType;)B
+ iconst_2
+ imul
+ iconst_1
+ iadd
+ dup
+ imul
+ ldc "rtm"
+ invokestatic net/minecraftforge/common/ForgeChunkManager/getMaxChunkDepthFor (Ljava/lang/String;)I
+ invokestatic java/lang/Math/min (II)I
+ invokevirtual net/minecraftforge/common/ForgeChunkManager$Ticket/setChunkListDepth (I)V
+
L_0023:
.line 1264
.stack use locals
.end stack
aload 0
getfield jp/ngt/rtm/entity/train/EntityTrainBase/loadedChunks Ljava/util/Set;
invokeinterface java/util/Set/iterator ()Ljava/util/Iterator;
astore 3
L_002a:
.stack
@@ -4935,20 +4967,27 @@ L_002a:
invokeinterface java/util/Iterator/next ()Ljava/lang/Object;
checkcast net/minecraft/util/math/ChunkPos
astore 4
L_0033:
.line 1266
.var 4 is chunk Lnet/minecraft/util/math/ChunkPos; from L_0033 to L_0039
aload 0
getfield jp/ngt/rtm/entity/train/EntityTrainBase/ticket Lnet/minecraftforge/common/ForgeChunkManager$Ticket;
aload 4
invokestatic net/minecraftforge/common/ForgeChunkManager/forceChunk (Lnet/minecraftforge/common/ForgeChunkManager$Ticket;Lnet/minecraft/util/math/ChunkPos;)V
+
+ .line 11266
+ aload 0
+ getfield jp/ngt/rtm/entity/train/EntityTrainBase/ticket Lnet/minecraftforge/common/ForgeChunkManager$Ticket;
+ aload 4
+ invokestatic net/minecraftforge/common/ForgeChunkManager/reorderChunk (Lnet/minecraftforge/common/ForgeChunkManager$Ticket;Lnet/minecraft/util/math/ChunkPos;)V
+
L_0039:
.line 1268
goto L_002a
L_003c:
.line 1269
.stack
locals Object jp/ngt/rtm/entity/train/EntityTrainBase
locals Integer
locals Integer
.end stack
@@ -4958,20 +4997,27 @@ L_003c:
iload 2
invokespecial net/minecraft/util/math/ChunkPos/<init> (II)V
astore 3
L_0045:
.line 1270
.var 3 is myChunk Lnet/minecraft/util/math/ChunkPos; from L_0045 to L_004b
aload 0
getfield jp/ngt/rtm/entity/train/EntityTrainBase/ticket Lnet/minecraftforge/common/ForgeChunkManager$Ticket;
aload 3
invokestatic net/minecraftforge/common/ForgeChunkManager/forceChunk (Lnet/minecraftforge/common/ForgeChunkManager$Ticket;Lnet/minecraft/util/math/ChunkPos;)V
+
+ .line 11270
+ aload 0
+ getfield jp/ngt/rtm/entity/train/EntityTrainBase/ticket Lnet/minecraftforge/common/ForgeChunkManager$Ticket;
+ aload 3
+ invokestatic net/minecraftforge/common/ForgeChunkManager/reorderChunk (Lnet/minecraftforge/common/ForgeChunkManager$Ticket;Lnet/minecraft/util/math/ChunkPos;)V
+
L_004b:
.line 1272
.stack use locals
.end stack
return
L_004f:
.end method

.method private setupChunks (II)V
.limit stack 5
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
Expand Down Expand Up @@ -1471,3 +1722,118 @@ index 34f470e..019c243 100644
locals Object java/lang/String
locals Object java/util/Map
locals Object java/util/Iterator
diff --git a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/world/RTMChunkManager.jasm b/src/main/rtm/jp/ngt/rtm/world/RTMChunkManager.jasm
index 478c0e0..02bf660 100644
--- a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/world/RTMChunkManager.jasm
+++ b/src/main/rtm/jp/ngt/rtm/world/RTMChunkManager.jasm
@@ -66,108 +66,33 @@ L_0019:
locals Object jp/ngt/rtm/world/RTMChunkManager
locals Object net/minecraftforge/event/entity/EntityEvent$EnteringChunk
.end stack
return
L_001d:
.end method

.method public getChunksAround (Ljava/util/Set;III)V
.signature "(Ljava/util/Set<Lnet/minecraft/util/math/ChunkPos;>;III)V"
.limit stack 5
- .limit local 7
+ .limit local 5
L_0000:
.line 50
.var 0 is this Ljp/ngt/rtm/world/RTMChunkManager; from L_0000 to L_0035
.var 1 is set Ljava/util/Set; signature "Ljava/util/Set<Lnet/minecraft/util/math/ChunkPos;>;" from L_0000 to L_0035
.var 2 is xChunk I from L_0000 to L_0035
.var 3 is zChunk I from L_0000 to L_0035
.var 4 is radius I from L_0000 to L_0035
aload 1
- invokeinterface java/util/Set/clear ()V
-L_0004:
- .line 51
- iload 2
- iload 4
- isub
- istore 5
-L_000a:
- .var 5 is xx I from L_000a to L_0031
- .stack
- locals Object jp/ngt/rtm/world/RTMChunkManager
- locals Object java/util/Set
- locals Integer
- locals Integer
- locals Integer
- locals Integer
- .end stack
- iload 5
iload 2
- iload 4
- iadd
- if_icmpgt L_0031
-L_0011:
- .line 53
- iload 3
- iload 4
- isub
- istore 6
-L_0017:
- .var 6 is zz I from L_0017 to L_002c
- .stack
- locals Object jp/ngt/rtm/world/RTMChunkManager
- locals Object java/util/Set
- locals Integer
- locals Integer
- locals Integer
- locals Integer
- locals Integer
- .end stack
- iload 6
iload 3
iload 4
- iadd
- if_icmpgt L_002c
-L_001e:
- .line 55
- aload 1
- new net/minecraft/util/math/ChunkPos
- dup
- iload 5
- iload 6
- invokespecial net/minecraft/util/math/ChunkPos/<init> (II)V
- invokeinterface java/util/Set/add (Ljava/lang/Object;)Z
- pop
-L_0028:
- .line 53
- iinc 6 1
- goto L_0017
-L_002c:
- .line 51
- .stack
- locals Object jp/ngt/rtm/world/RTMChunkManager
- locals Object java/util/Set
- locals Integer
- locals Integer
- locals Integer
- locals Integer
- .end stack
- iinc 5 1
- goto L_000a
-L_0031:
- .line 58
- .stack
- locals Object jp/ngt/rtm/world/RTMChunkManager
- locals Object java/util/Set
- locals Integer
- locals Integer
- locals Integer
- .end stack
+ invokestatic com/anatawa12/fixRtm/rtm/world/RTMChunkManagerKt/getChunksAround (Ljava/util/Set;III)V
return
L_0035:
.end method

.method public getNewTicket (Lnet/minecraft/world/World;Lnet/minecraftforge/common/ForgeChunkManager$Type;)Lnet/minecraftforge/common/ForgeChunkManager$Ticket;
.limit stack 3
.limit local 3
L_0000:
.line 62
.var 0 is this Ljp/ngt/rtm/world/RTMChunkManager; from L_0000 to L_0007
Loading

0 comments on commit d36a099

Please sign in to comment.