Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

クライアント側に車両が反映されない問題 #47

Merged
merged 10 commits into from
May 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
modGroup=com.anatawa12.fixRtm
modVersion=2.0.3
modVersion=SNAPSHOT-2020-05-12-16-32-30
modBaseName=fixRtm
forgeVersion=1.12.2-14.23.5.2847
mcpVersion=stable_39
268 changes: 261 additions & 7 deletions patches/rtm.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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 <init> (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
Expand Down Expand Up @@ -64,11 +87,100 @@ 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
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<TT;>;" from L_0000 to L_0003
@@ -1068,48 +1070,50 @@ L_0004:
astore 4
L_000b:
.line 365
Expand Down Expand Up @@ -126,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
Expand Down Expand Up @@ -178,11 +290,124 @@ 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..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:
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/<init> (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
@@ -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_0087:
.end method

.method public isVisibleTo (Lnet/minecraft/entity/player/EntityPlayerMP;)Z
- .limit stack 1
+ .limit stack 4
.limit local 2
L_0000:
.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 jp/ngt/rtm/entity/vehicle/VehicleTrackerEntry
+ locals Object net/minecraft/entity/player/EntityPlayerMP
+ .end stack
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
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:
Expand Down Expand Up @@ -575,6 +800,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
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/anatawa12/fixRtm/FixRtm.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/anatawa12/fixRtm/Proxy.kt
Original file line number Diff line number Diff line change
@@ -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()
}
}
33 changes: 33 additions & 0 deletions src/main/java/com/anatawa12/fixRtm/VehicleTrackerEntryFix.kt
Original file line number Diff line number Diff line change
@@ -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<Entity>(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")
}
Loading