mirror of
https://github.com/GTNewHorizons/BetterP2P.git
synced 2026-11-13 00:37:28 +00:00
Merge pull request #14 from GTNewHorizons/extradata
display me p2p used channels
This commit is contained in:
12 files changed
+61
-46
No files matched your search
+1
-1
@@ -35,7 +35,7 @@ buildscript {
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.7'
|
||||
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.13'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.projecturanus.betterp2p.client
|
||||
|
||||
import net.minecraft.util.EnumFacing
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
object ClientCache {
|
||||
val positions = mutableListOf<Pair<List<Int?>, EnumFacing>>()
|
||||
val positions = mutableListOf<Pair<List<Int?>, ForgeDirection>>()
|
||||
var selectedPosition: List<Int?>? = null
|
||||
var selectedFacing: EnumFacing? = null
|
||||
var selectedFacing: ForgeDirection? = null
|
||||
var searchText: String= ""
|
||||
fun clear() {
|
||||
positions.clear()
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.*
|
||||
class GuiAdvancedMemoryCard(msg: S2CListP2P) : GuiScreen(), TextureBound {
|
||||
|
||||
private val xSize = 288
|
||||
private val ySize = 206
|
||||
private val ySize = 242
|
||||
private val guiLeft: Int by lazy { (width - this.xSize) / 2 }
|
||||
private val guiTop: Int by lazy { (height - this.ySize) / 2 }
|
||||
|
||||
@@ -55,7 +55,7 @@ class GuiAdvancedMemoryCard(msg: S2CListP2P) : GuiScreen(), TextureBound {
|
||||
private val descriptionLines: MutableList<String> = mutableListOf()
|
||||
private var mode = msg.memoryInfo.mode
|
||||
private var modeString = getModeString()
|
||||
private val modeButton by lazy { GuiButton(0, guiLeft + 8, guiTop + 154, 256, 20, modeString) }
|
||||
private val modeButton by lazy { GuiButton(0, guiLeft + 8, guiTop + 190, 256, 20, modeString) }
|
||||
|
||||
init {
|
||||
selectInfo(msg.memoryInfo.selectedIndex)
|
||||
@@ -81,12 +81,12 @@ class GuiAdvancedMemoryCard(msg: S2CListP2P) : GuiScreen(), TextureBound {
|
||||
searchBar.y = guiTop + 5
|
||||
scrollBar.displayX = guiLeft + 268
|
||||
scrollBar.displayY = guiTop + 19
|
||||
scrollBar.height = 114
|
||||
scrollBar.height = 150
|
||||
scrollBar.setRange(0, infos.size.coerceIn(0..(infos.size - 4).coerceAtLeast(0)), 23)
|
||||
|
||||
for (i in 0..3) {
|
||||
widgetDevices[i].x = guiLeft + tableX
|
||||
widgetDevices[i].y = guiTop + tableY + 33 * i
|
||||
widgetDevices[i].y = guiTop + tableY + 42 * i
|
||||
}
|
||||
searchBar.text = ClientCache.searchText
|
||||
reGenInfoFromText()
|
||||
@@ -152,7 +152,7 @@ class GuiAdvancedMemoryCard(msg: S2CListP2P) : GuiScreen(), TextureBound {
|
||||
|
||||
private fun drawInformation() {
|
||||
val x = 8
|
||||
var y = 178
|
||||
var y = 214
|
||||
for (line in descriptionLines) {
|
||||
fontRendererObj.drawString(line, guiLeft + x, guiTop + y, 0)
|
||||
y += fontRendererObj.FONT_HEIGHT
|
||||
@@ -226,11 +226,11 @@ class GuiAdvancedMemoryCard(msg: S2CListP2P) : GuiScreen(), TextureBound {
|
||||
selectInfo(info.index)
|
||||
}
|
||||
private fun onRenameButtonClicked(info:InfoWrapper,index: Int){
|
||||
if(isShiftKeyDown()){
|
||||
if(isShiftKeyDown()) {
|
||||
return transportPlayer(info)
|
||||
}
|
||||
renameBar.isVisible = true
|
||||
renameBar.y = (this.guiTop + 6) + (index + 1) * 33
|
||||
renameBar.y = (this.guiTop + this.tableY) + index * 42 + 19
|
||||
renameBar.x = this.guiLeft + 60
|
||||
renameBar.w = 120
|
||||
renameBar.h = 12
|
||||
@@ -285,9 +285,9 @@ class GuiAdvancedMemoryCard(msg: S2CListP2P) : GuiScreen(), TextureBound {
|
||||
val info = widget.infoSupplier()
|
||||
if (info?.selectButton?.mousePressed(mc, mouseX, mouseY) == true) {
|
||||
onSelectButtonClicked(widget.infoSupplier()!!)
|
||||
}else if (info?.bindButton?.mousePressed(mc, mouseX, mouseY) == true) {
|
||||
} else if (info?.bindButton?.mousePressed(mc, mouseX, mouseY) == true) {
|
||||
onBindButtonClicked(widget.infoSupplier()!!)
|
||||
}else if (info?.renameButton?.mousePressed(mc, mouseX,mouseY) == true) {
|
||||
} else if (info?.renameButton?.mousePressed(mc, mouseX,mouseY) == true) {
|
||||
if(renameBar.info != widget.infoSupplier()!!)
|
||||
saveP2PChannel()
|
||||
widget.renderNameTextField = false
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.projecturanus.betterp2p.client.gui
|
||||
import com.projecturanus.betterp2p.network.P2PInfo
|
||||
import net.minecraft.client.gui.GuiButton
|
||||
import net.minecraft.client.resources.I18n
|
||||
import net.minecraft.util.EnumFacing
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import java.util.*
|
||||
|
||||
class InfoWrapper(info: P2PInfo) {
|
||||
@@ -15,7 +15,7 @@ class InfoWrapper(info: P2PInfo) {
|
||||
val posY: Int = info.posY
|
||||
val posZ: Int = info.posZ
|
||||
val world: Int = info.world
|
||||
val facing: EnumFacing = info.facing
|
||||
val facing: ForgeDirection = info.facing
|
||||
val description: String
|
||||
val output: Boolean = info.output
|
||||
var name: String = info.name
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
package com.projecturanus.betterp2p.client.gui.widget
|
||||
|
||||
import appeng.me.GridNode
|
||||
import appeng.parts.p2p.PartP2PTunnelME
|
||||
import appeng.tile.networking.TileCableBus
|
||||
import com.projecturanus.betterp2p.client.gui.InfoWrapper
|
||||
import com.projecturanus.betterp2p.item.BetterMemoryCardModes
|
||||
import net.minecraft.client.gui.GuiScreen
|
||||
import net.minecraft.client.resources.I18n
|
||||
import net.minecraftforge.common.DimensionManager
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
import java.awt.Color
|
||||
import kotlin.reflect.KMutableProperty0
|
||||
|
||||
@@ -14,8 +19,8 @@ class WidgetP2PDevice(private val selectedInfoProperty: KMutableProperty0<InfoWr
|
||||
private val inactiveColor = 0x45FFEA05
|
||||
|
||||
private val rowWidth = 254
|
||||
private val rowHeight = 32
|
||||
public var renderNameTextField = true
|
||||
private val rowHeight = 41
|
||||
var renderNameTextField = true
|
||||
|
||||
private var selectedInfo: InfoWrapper?
|
||||
get() = selectedInfoProperty.get()
|
||||
@@ -44,11 +49,12 @@ class WidgetP2PDevice(private val selectedInfoProperty: KMutableProperty0<InfoWr
|
||||
|
||||
fontRenderer.drawString(info.description, x + 24, y + 3, 0)
|
||||
fontRenderer.drawString(I18n.format("gui.advanced_memory_card.pos", info.posX, info.posY, info.posZ, info.facing.name), x + 24, y + 12, 0)
|
||||
if(renderNameTextField){
|
||||
if(renderNameTextField) {
|
||||
fontRenderer.drawString(I18n.format("gui.advanced_memory_card.name", info.name), x + 24, y + 21, 0)
|
||||
}else{
|
||||
} else {
|
||||
fontRenderer.drawString(I18n.format("gui.advanced_memory_card.name", ""), x + 24, y + 21, 0)
|
||||
}
|
||||
fontRenderer.drawString(getExtraInfo(info.world, info.posX, info.posY, info.posZ, info.facing), x + 24, y + 30, 0)
|
||||
|
||||
if (selectedInfo == null) {
|
||||
info.bindButton.enabled = false
|
||||
@@ -56,7 +62,6 @@ class WidgetP2PDevice(private val selectedInfoProperty: KMutableProperty0<InfoWr
|
||||
} else if (info.index != selectedInfo?.index) {
|
||||
info.bindButton.enabled = true
|
||||
info.selectButton.enabled = true
|
||||
|
||||
} else {
|
||||
// TODO Unbind
|
||||
info.bindButton.enabled = false
|
||||
@@ -122,3 +127,14 @@ class WidgetP2PDevice(private val selectedInfoProperty: KMutableProperty0<InfoWr
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun getExtraInfo(world: Int, posX: Int, poxY: Int, posZ: Int, face: ForgeDirection): String {
|
||||
val tile = DimensionManager.getWorld(world)?.getTileEntity(posX, poxY, posZ)
|
||||
if (tile is TileCableBus) {
|
||||
val used = ((tile.getPart(face) as? PartP2PTunnelME)?.externalFacingNode as? GridNode)?.usedChannels()
|
||||
if (used != null) {
|
||||
return I18n.format("gui.advanced_memory_card.extra.channel", used)
|
||||
}
|
||||
}
|
||||
return I18n.format("gui.advanced_memory_card.extra.none")
|
||||
}
|
||||
@@ -4,8 +4,8 @@ import com.projecturanus.betterp2p.util.GlStateManager;
|
||||
import kotlin.Pair;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -88,7 +88,7 @@ public class OutlineRenderer {
|
||||
}
|
||||
|
||||
|
||||
public static void renderOutlinesWithFacing(RenderWorldLastEvent evt, EntityPlayer p, Collection<Pair<List<Integer>, EnumFacing>> coordinates, int r, int g, int b) {
|
||||
public static void renderOutlinesWithFacing(RenderWorldLastEvent evt, EntityPlayer p, Collection<Pair<List<Integer>, ForgeDirection>> coordinates, int r, int g, int b) {
|
||||
|
||||
double doubleX = p.lastTickPosX + (p.posX - p.lastTickPosX);
|
||||
double doubleY = p.lastTickPosY + (p.posY - p.lastTickPosY);
|
||||
@@ -107,13 +107,13 @@ public class OutlineRenderer {
|
||||
GlStateManager.depthMask(true);
|
||||
}
|
||||
|
||||
private static void renderOutlinesWithFacing(Collection<Pair<List<Integer>, EnumFacing>> coordinates, double x, double y, double z, int r, int g, int b, int thickness) {
|
||||
private static void renderOutlinesWithFacing(Collection<Pair<List<Integer>, ForgeDirection>> coordinates, double x, double y, double z, int r, int g, int b, int thickness) {
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
//BufferBuilder buffer = tessellator.getBuffer();
|
||||
|
||||
for (Pair<List<Integer>, EnumFacing> coordinate : coordinates) {
|
||||
for (Pair<List<Integer>, ForgeDirection> coordinate : coordinates) {
|
||||
List<Integer> pos = coordinate.component1();
|
||||
EnumFacing facing = coordinate.component2();
|
||||
ForgeDirection facing = coordinate.component2();
|
||||
if (pos == null || facing == null || pos.size() != 3)
|
||||
continue;
|
||||
GlStateManager.pushMatrix();
|
||||
|
||||
@@ -7,9 +7,9 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import kotlin.Pair;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.client.event.RenderWorldLastEvent;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -23,7 +23,7 @@ public class RenderHandler {
|
||||
if (player.getHeldItem() != null && player.getHeldItem().getItem() == ItemAdvancedMemoryCard.INSTANCE) {
|
||||
if (!ClientCache.INSTANCE.getPositions().isEmpty() || ClientCache.INSTANCE.getSelectedPosition() != null) {
|
||||
if (ClientCache.INSTANCE.getSelectedPosition() != null) {
|
||||
List<Pair<List<Integer>, EnumFacing>> tmp = new ArrayList<>();
|
||||
List<Pair<List<Integer>, ForgeDirection>> tmp = new ArrayList<>();
|
||||
tmp.add(new Pair<>(ClientCache.INSTANCE.getSelectedPosition(), ClientCache.INSTANCE.getSelectedFacing()));
|
||||
OutlineRenderer.renderOutlinesWithFacing(
|
||||
event,
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
package com.projecturanus.betterp2p.network
|
||||
|
||||
import net.minecraft.util.EnumFacing
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
class P2PInfo(val index: Int, val frequency: Long, val posX: Int, val posY: Int, val posZ: Int,val world: Int, val facing: EnumFacing, val name: String, val output: Boolean, val hasChannel: Boolean) {
|
||||
}
|
||||
class P2PInfo(val index: Int,
|
||||
val frequency: Long,
|
||||
val posX: Int,
|
||||
val posY: Int,
|
||||
val posZ: Int,
|
||||
val world: Int,
|
||||
val facing: ForgeDirection,
|
||||
val name: String,
|
||||
val output: Boolean,
|
||||
val hasChannel: Boolean)
|
||||
@@ -2,7 +2,7 @@ package com.projecturanus.betterp2p.network
|
||||
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage
|
||||
import io.netty.buffer.ByteBuf
|
||||
import net.minecraft.util.EnumFacing
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
fun readInfo(buf: ByteBuf): P2PInfo {
|
||||
val index = buf.readInt()
|
||||
@@ -11,7 +11,7 @@ fun readInfo(buf: ByteBuf): P2PInfo {
|
||||
val posY = buf.readInt()
|
||||
val posZ = buf.readInt()
|
||||
val world = buf.readInt()
|
||||
val facing = EnumFacing.values()[buf.readInt()]
|
||||
val facing = ForgeDirection.values()[buf.readInt()]
|
||||
val nameLength = buf.readShort() - 1
|
||||
var name = ""
|
||||
for (i in 0..nameLength) {
|
||||
@@ -30,7 +30,7 @@ fun writeInfo(buf: ByteBuf, info: P2PInfo) {
|
||||
buf.writeInt(info.facing.ordinal)
|
||||
buf.writeShort(info.name.length)
|
||||
for (c in info.name) {
|
||||
buf.writeChar(c.toInt())
|
||||
buf.writeChar(c.code)
|
||||
}
|
||||
buf.writeBoolean(info.output)
|
||||
buf.writeBoolean(info.hasChannel)
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.projecturanus.betterp2p.network.P2PInfo
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.util.EnumFacing
|
||||
import net.minecraftforge.common.util.ForgeDirection
|
||||
|
||||
fun linkP2P(player: EntityPlayer, inputIndex: Int, outputIndex: Int, status: P2PStatus) : Pair<PartP2PTunnel<*>, PartP2PTunnel<*>>? {
|
||||
@@ -60,7 +59,7 @@ fun updateP2P(tunnel: PartP2PTunnel<*>, frequency: Long, output: Boolean, player
|
||||
|
||||
val data = NBTTagCompound()
|
||||
val p2pItem: ItemStack = tunnel.getItemStack(PartItemStack.Wrench)
|
||||
val type: String = p2pItem.unlocalizedName
|
||||
p2pItem.unlocalizedName
|
||||
tunnel.outputProperty = output
|
||||
tunnel.customName = name
|
||||
|
||||
@@ -94,18 +93,8 @@ var PartP2PTunnel<*>.outputProperty
|
||||
field.setBoolean(this, value)
|
||||
}
|
||||
|
||||
fun ForgeDirection.getEnumIndex(): Int {
|
||||
if (this == ForgeDirection.WEST) {
|
||||
return 5
|
||||
}
|
||||
if (this == ForgeDirection.EAST) {
|
||||
return 4
|
||||
}
|
||||
return this.ordinal
|
||||
}
|
||||
|
||||
val PartP2PTunnel<*>.hasChannel
|
||||
get() = isPowered && isActive
|
||||
|
||||
fun PartP2PTunnel<*>.getInfo(index: Int)
|
||||
= P2PInfo(index, frequency, location.x, location.y, location.z,location.dimension,EnumFacing.getFront(side.getEnumIndex()), customName, isOutput, hasChannel)
|
||||
= P2PInfo(index, frequency, location.x, location.y, location.z, location.dimension, side, customName, isOutput, hasChannel)
|
||||
@@ -5,6 +5,8 @@ gui.advanced_memory_card.select=Select
|
||||
gui.advanced_memory_card.bind=Bind
|
||||
gui.advanced_memory_card.pos=Pos: %d, %d, %d Side: %s
|
||||
gui.advanced_memory_card.name=Name: %s
|
||||
gui.advanced_memory_card.extra.channel=Channels used: %s
|
||||
gui.advanced_memory_card.extra.none=No Extra Info
|
||||
gui.advanced_memory_card.mode.input=Mode: Bind Input
|
||||
gui.advanced_memory_card.mode.output=Mode: Bind Output
|
||||
gui.advanced_memory_card.mode.copy=Mode: Copy Output
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.2 KiB |
Reference in new issue
Block a user