mirror of
https://github.com/GTNewHorizons/BetterP2P.git
synced 2026-11-21 12:32:21 +00:00
Render only p2p outlines within the same dimension as the player (#44)
This commit is contained in:
1 parent
198a2bead6
commit
4f9b548906
3 files changed
+26
-8
No files matched your search
@@ -3,12 +3,16 @@ package com.projecturanus.betterp2p.client
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
object ClientCache {
|
||||
const val NO_DIMENSION = Int.MIN_VALUE
|
||||
|
||||
val positions = mutableListOf<Pair<List<Int?>, ForgeDirection>>()
|
||||
var overlayDimension: Int = NO_DIMENSION
|
||||
var selectedPosition: List<Int?>? = null
|
||||
var selectedFacing: ForgeDirection? = null
|
||||
var searchText: String= ""
|
||||
fun clear() {
|
||||
positions.clear()
|
||||
overlayDimension = NO_DIMENSION
|
||||
selectedPosition = null
|
||||
selectedFacing = null
|
||||
}
|
||||
|
||||
@@ -465,19 +465,22 @@ class GuiAdvancedMemoryCard(msg: S2COpenGui) : GuiScreen(), TextureBound {
|
||||
}
|
||||
|
||||
private fun refreshOverlay() {
|
||||
if (selectedInfo == null) {
|
||||
val playerDimension = mc.thePlayer.dimension
|
||||
val selectedLoc = selectedInfo?.loc
|
||||
if (selectedLoc == null || selectedLoc.dim != playerDimension) {
|
||||
ClientCache.selectedPosition = null
|
||||
ClientCache.selectedFacing = null
|
||||
}
|
||||
else {
|
||||
ClientCache.selectedPosition = arrayListOf(selectedInfo?.loc?.x, selectedInfo?.loc?.y, selectedInfo?.loc?.z)
|
||||
ClientCache.selectedFacing = selectedInfo?.loc?.facing
|
||||
ClientCache.selectedPosition = arrayListOf(selectedLoc.x, selectedLoc.y, selectedLoc.z)
|
||||
ClientCache.selectedFacing = selectedLoc.facing
|
||||
}
|
||||
ClientCache.positions.clear()
|
||||
ClientCache.overlayDimension = playerDimension
|
||||
ClientCache.positions.addAll(infos.sorted.filter {
|
||||
it.frequency == selectedInfo?.frequency &&
|
||||
it != selectedInfo &&
|
||||
it.loc.dim == mc.thePlayer.dimension
|
||||
it.loc.dim == playerDimension
|
||||
}.map { arrayListOf(it.loc.x, it.loc.y, it.loc.z) to it.loc.facing })
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,12 @@ public class RenderHandler {
|
||||
public void renderOverlays(RenderWorldLastEvent event) {
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
if (player.getHeldItem() != null && player.getHeldItem().getItem() == ItemAdvancedMemoryCard.INSTANCE) {
|
||||
if (!ClientCache.INSTANCE.getPositions().isEmpty() || ClientCache.INSTANCE.getSelectedPosition() != null) {
|
||||
if (ClientCache.INSTANCE.getSelectedPosition() != null) {
|
||||
int playerDimension = player.dimension;
|
||||
boolean isCurrentDimension = ClientCache.INSTANCE.getOverlayDimension() == playerDimension;
|
||||
boolean hasPositions = !ClientCache.INSTANCE.getPositions().isEmpty() && isCurrentDimension;
|
||||
boolean hasSelectedPosition = ClientCache.INSTANCE.getSelectedPosition() != null && isCurrentDimension;
|
||||
if (hasPositions || hasSelectedPosition) {
|
||||
if (hasSelectedPosition) {
|
||||
List<Pair<List<Integer>, ForgeDirection>> tmp = new ArrayList<>();
|
||||
tmp.add(
|
||||
new Pair<>(
|
||||
@@ -31,8 +35,15 @@ public class RenderHandler {
|
||||
ClientCache.INSTANCE.getSelectedFacing()));
|
||||
OutlineRenderer.renderOutlinesWithFacing(event, player, tmp, 0x45, 0xDA, 0x75);
|
||||
}
|
||||
OutlineRenderer
|
||||
.renderOutlinesWithFacing(event, player, ClientCache.INSTANCE.getPositions(), 0x66, 0xCC, 0xFF);
|
||||
if (hasPositions) {
|
||||
OutlineRenderer.renderOutlinesWithFacing(
|
||||
event,
|
||||
player,
|
||||
ClientCache.INSTANCE.getPositions(),
|
||||
0x66,
|
||||
0xCC,
|
||||
0xFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user