Skip to content

Commit

Permalink
Merge pull request #146 from fixrtm/crash-due-to-accessing-func_174822_a
Browse files Browse the repository at this point in the history
fix crash due to accessing client-only method, func_174822_a
  • Loading branch information
anatawa12 authored Feb 25, 2021
2 parents bd4e84b + 824b0b1 commit 2a0b2c1
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
27 changes: 27 additions & 0 deletions patches/rtm.patch
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,33 @@ index aefff78..27c3d26 100644
iconst_1
invokestatic jp/ngt/rtm/sound/SpeakerSounds/getInstance (Z)Ljp/ngt/rtm/sound/SpeakerSounds;
invokevirtual jp/ngt/rtm/sound/SpeakerSounds/syncSoundList ()V
diff --git a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/item/ItemPaintTool.jasm b/src/main/rtm/jp/ngt/rtm/item/ItemPaintTool.jasm
index 6b219b0..a3fe52d 100644
--- a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/item/ItemPaintTool.jasm
+++ b/src/main/rtm/jp/ngt/rtm/item/ItemPaintTool.jasm
@@ -606,21 +606,21 @@ L_0015:
stacks Float
.end stack
fstore 5
L_0018:
.line 108
.var 5 is f0 F from L_0018 to L_0065
aload 4
fload 5
f2d
fconst_0
- invokevirtual net/minecraft/entity/player/EntityPlayer/rayTrace (DF)Lnet/minecraft/util/math/RayTraceResult;
+ invokestatic com/anatawa12/fixRtm/UtilsKt/rayTraceBothSide (Lnet/minecraft/entity/Entity;DF)Lnet/minecraft/util/math/RayTraceResult;
astore 6
L_0020:
.line 109
.var 6 is mop Lnet/minecraft/util/math/RayTraceResult; from L_0020 to L_0065
aload 6
ifnull L_0065
L_0024:
.line 111
aload 6
invokevirtual net/minecraft/util/math/RayTraceResult/getBlockPos ()Lnet/minecraft/util/math/BlockPos;
diff --git a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/modelpack/ModelPackManager.jasm b/src/main/rtm/jp/ngt/rtm/modelpack/ModelPackManager.jasm
index 79fab25..0d592e0 100644
--- a/mods/rtm.deobf.jar.src.processed/jp/ngt/rtm/modelpack/ModelPackManager.jasm
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/anatawa12/fixRtm/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import com.anatawa12.fixRtm.utils.ArrayPool
import com.anatawa12.fixRtm.utils.closeScope
import com.anatawa12.fixRtm.utils.sortedWalk
import com.google.common.collect.Iterators
import net.minecraft.entity.Entity
import net.minecraft.entity.player.EntityPlayerMP
import net.minecraft.util.math.RayTraceResult
import net.minecraftforge.fml.common.Loader
import net.minecraftforge.fml.common.network.handshake.NetworkDispatcher
import java.io.*
Expand All @@ -13,6 +15,7 @@ import java.util.concurrent.Executors
import java.util.concurrent.ThreadFactory
import java.util.concurrent.atomic.AtomicInteger


fun getThreadGroup() = System.getSecurityManager()?.threadGroup ?: Thread.currentThread().threadGroup!!

fun threadFactoryWithPrefix(prefix: String, group: ThreadGroup = getThreadGroup()) = object : ThreadFactory {
Expand Down Expand Up @@ -140,3 +143,13 @@ fun File.mkParent(): File = apply { parentFile.mkdirs() }

val EntityPlayerMP.modList get() = NetworkDispatcher.get(this.connection.netManager).modList
val EntityPlayerMP.hasFixRTM get() = modList.containsKey(FixRtm.MODID)

@Suppress("unused")
fun Entity.rayTraceBothSide(blockReachDistance: Double, partialTicks: Float): RayTraceResult? {
val eyePosition = getPositionEyes(partialTicks)
val lookDir = getLook(partialTicks)
val endPosition = eyePosition
.add(lookDir.x * blockReachDistance, lookDir.y * blockReachDistance, lookDir.z * blockReachDistance)
return world.rayTraceBlocks(eyePosition, endPosition,
false, false, true)
}

0 comments on commit 2a0b2c1

Please sign in to comment.