-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from anatawa12/no-train-entity-on-client
クライアント側に車両が反映されない問題
- Loading branch information
Showing
10 changed files
with
379 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
33
src/main/java/com/anatawa12/fixRtm/VehicleTrackerEntryFix.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} |
Oops, something went wrong.