fixed nullpointer in serialization of broadcast packets in switch/access point; reworked a couple of textures
Before Width: | Height: | Size: 494 B After Width: | Height: | Size: 525 B |
Before Width: | Height: | Size: 399 B After Width: | Height: | Size: 490 B |
Before Width: | Height: | Size: 699 B After Width: | Height: | Size: 634 B |
Before Width: | Height: | Size: 721 B After Width: | Height: | Size: 652 B |
Before Width: | Height: | Size: 689 B After Width: | Height: | Size: 624 B |
Before Width: | Height: | Size: 657 B After Width: | Height: | Size: 595 B |
Before Width: | Height: | Size: 688 B After Width: | Height: | Size: 570 B |
Before Width: | Height: | Size: 430 B After Width: | Height: | Size: 339 B |
Before Width: | Height: | Size: 545 B |
After Width: | Height: | Size: 523 B |
After Width: | Height: | Size: 149 B |
Before Width: | Height: | Size: 559 B |
After Width: | Height: | Size: 572 B |
After Width: | Height: | Size: 427 B |
@ -0,0 +1,6 @@
|
||||
{
|
||||
"animation": {
|
||||
"frametime": 2,
|
||||
"frames": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ]
|
||||
}
|
||||
}
|
Before Width: | Height: | Size: 514 B After Width: | Height: | Size: 613 B |
Before Width: | Height: | Size: 579 B |
Before Width: | Height: | Size: 178 B |
After Width: | Height: | Size: 586 B |
After Width: | Height: | Size: 448 B |
@ -0,0 +1,6 @@
|
||||
{
|
||||
"animation": {
|
||||
"frametime": 2,
|
||||
"frames": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13 ]
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 491 B |
After Width: | Height: | Size: 203 B |
Before Width: | Height: | Size: 542 B After Width: | Height: | Size: 595 B |
After Width: | Height: | Size: 157 B |
@ -42,6 +42,7 @@ class PacketHandler extends CommonPacketHandler {
|
||||
case PacketType.RobotSelectedSlotChange => onRobotSelectedSlotChange(p)
|
||||
case PacketType.RobotXp => onRobotXp(p)
|
||||
case PacketType.RotatableState => onRotatableState(p)
|
||||
case PacketType.RouterActivity => onRouterActivity(p)
|
||||
case PacketType.ScreenColorChange => onScreenColorChange(p)
|
||||
case PacketType.ScreenCopy => onScreenCopy(p)
|
||||
case PacketType.ScreenDepthChange => onScreenDepthChange(p)
|
||||
@ -222,6 +223,12 @@ class PacketHandler extends CommonPacketHandler {
|
||||
case _ => // Invalid packet.
|
||||
}
|
||||
|
||||
def onRouterActivity(p: PacketParser) =
|
||||
p.readTileEntity[Router]() match {
|
||||
case Some(t) => t.lastMessage = System.currentTimeMillis()
|
||||
case _ => // Invalid packet.
|
||||
}
|
||||
|
||||
def onScreenColorChange(p: PacketParser) {
|
||||
val buffer = p.readTileEntity[TileEntity]() match {
|
||||
case Some(t: TextBuffer) => t.buffer
|
||||
|
@ -33,9 +33,12 @@ private[oc] class Proxy extends CommonProxy {
|
||||
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[tileentity.Cable], CableRenderer)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[tileentity.Case], CaseRenderer)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[tileentity.Charger], ChargerRenderer)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[tileentity.Hologram], HologramRenderer)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[tileentity.PowerDistributor], PowerDistributorRenderer)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[tileentity.Rack], RackRenderer)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[tileentity.Router], RouterRenderer)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[tileentity.WirelessRouter], RouterRenderer)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[tileentity.RobotProxy], RobotRenderer)
|
||||
ClientRegistry.bindTileEntitySpecialRenderer(classOf[tileentity.Screen], ScreenRenderer)
|
||||
|
||||
|
@ -23,7 +23,6 @@ object TexturePreloader extends ResourceManagerReloadListener {
|
||||
val blockCable = new ResourceLocation(Settings.resourceDomain, "textures/blocks/cable.png")
|
||||
val blockCaseFrontOn = new ResourceLocation(Settings.resourceDomain, "textures/blocks/case_front_on.png")
|
||||
val blockHologram = new ResourceLocation(Settings.resourceDomain, "textures/blocks/hologram_effect.png")
|
||||
val blockPowerDistributorOn = new ResourceLocation(Settings.resourceDomain, "textures/blocks/power_distributor_on.png")
|
||||
val blockRackFrontOn = new ResourceLocation(Settings.resourceDomain, "textures/blocks/rack_front_on.png")
|
||||
val blockRobot = new ResourceLocation(Settings.resourceDomain, "textures/blocks/robot.png")
|
||||
val blockScreenUpIndicator = new ResourceLocation(Settings.resourceDomain, "textures/blocks/screen/up_indicator.png")
|
||||
@ -49,7 +48,6 @@ object TexturePreloader extends ResourceManagerReloadListener {
|
||||
|
||||
manager.getResource(blockCable)
|
||||
manager.getResource(blockCaseFrontOn)
|
||||
manager.getResource(blockPowerDistributorOn)
|
||||
manager.getResource(blockRackFrontOn)
|
||||
manager.getResource(blockRobot)
|
||||
manager.getResource(blockScreenUpIndicator)
|
||||
|
@ -10,7 +10,7 @@ import net.minecraftforge.common.ForgeDirection
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
object CaseRenderer extends TileEntitySpecialRenderer {
|
||||
override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) = {
|
||||
override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) {
|
||||
val computer = tileEntity.asInstanceOf[Case]
|
||||
if (computer.isRunning) {
|
||||
GL11.glPushAttrib(0xFFFFFF)
|
||||
|
@ -0,0 +1,70 @@
|
||||
package li.cil.oc.client.renderer.tileentity
|
||||
|
||||
import li.cil.oc.Blocks
|
||||
import li.cil.oc.common.tileentity.Charger
|
||||
import li.cil.oc.util.RenderState
|
||||
import net.minecraft.client.renderer.Tessellator
|
||||
import net.minecraft.client.renderer.texture.TextureMap
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import net.minecraftforge.common.ForgeDirection
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
object ChargerRenderer extends TileEntitySpecialRenderer {
|
||||
override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) {
|
||||
val charger = tileEntity.asInstanceOf[Charger]
|
||||
if (charger.chargeSpeed > 0) {
|
||||
GL11.glPushAttrib(0xFFFFFF)
|
||||
|
||||
RenderState.disableLighting()
|
||||
RenderState.makeItBlend()
|
||||
|
||||
GL11.glPushMatrix()
|
||||
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
|
||||
|
||||
charger.yaw match {
|
||||
case ForgeDirection.WEST => GL11.glRotatef(-90, 0, 1, 0)
|
||||
case ForgeDirection.NORTH => GL11.glRotatef(180, 0, 1, 0)
|
||||
case ForgeDirection.EAST => GL11.glRotatef(90, 0, 1, 0)
|
||||
case _ => // No yaw.
|
||||
}
|
||||
|
||||
GL11.glTranslatef(-0.5f, 0.5f, 0.5f)
|
||||
GL11.glScalef(1, -1, 1)
|
||||
|
||||
val t = Tessellator.instance
|
||||
|
||||
val frontIcon = Blocks.charger.iconFrontCharging
|
||||
bindTexture(TextureMap.locationBlocksTexture)
|
||||
t.startDrawingQuads()
|
||||
|
||||
val inverse = 1 - charger.chargeSpeed
|
||||
t.addVertexWithUV(0, 1, 0.005, frontIcon.getMinU, frontIcon.getMaxV)
|
||||
t.addVertexWithUV(1, 1, 0.005, frontIcon.getMaxU, frontIcon.getMaxV)
|
||||
t.addVertexWithUV(1, inverse, 0.005, frontIcon.getMaxU, frontIcon.getInterpolatedV(inverse * 16))
|
||||
t.addVertexWithUV(0, inverse, 0.005, frontIcon.getMinU, frontIcon.getInterpolatedV(inverse * 16))
|
||||
|
||||
val sideIcon = Blocks.charger.iconSideCharging
|
||||
t.addVertexWithUV(-0.005, 1, -1, sideIcon.getMinU, sideIcon.getMaxV)
|
||||
t.addVertexWithUV(-0.005, 1, 0, sideIcon.getMaxU, sideIcon.getMaxV)
|
||||
t.addVertexWithUV(-0.005, 0, 0, sideIcon.getMaxU, sideIcon.getMinV)
|
||||
t.addVertexWithUV(-0.005, 0, -1, sideIcon.getMinU, sideIcon.getMinV)
|
||||
|
||||
t.addVertexWithUV(1, 1, -1.005, sideIcon.getMinU, sideIcon.getMaxV)
|
||||
t.addVertexWithUV(0, 1, -1.005, sideIcon.getMaxU, sideIcon.getMaxV)
|
||||
t.addVertexWithUV(0, 0, -1.005, sideIcon.getMaxU, sideIcon.getMinV)
|
||||
t.addVertexWithUV(1, 0, -1.005, sideIcon.getMinU, sideIcon.getMinV)
|
||||
|
||||
t.addVertexWithUV(1.005, 1, 0, sideIcon.getMinU, sideIcon.getMaxV)
|
||||
t.addVertexWithUV(1.005, 1, -1, sideIcon.getMaxU, sideIcon.getMaxV)
|
||||
t.addVertexWithUV(1.005, 0, -1, sideIcon.getMaxU, sideIcon.getMinV)
|
||||
t.addVertexWithUV(1.005, 0, 0, sideIcon.getMinU, sideIcon.getMinV)
|
||||
|
||||
t.draw()
|
||||
|
||||
GL11.glPopMatrix()
|
||||
GL11.glPopAttrib()
|
||||
}
|
||||
}
|
||||
}
|
@ -1,15 +1,16 @@
|
||||
package li.cil.oc.client.renderer.tileentity
|
||||
|
||||
import li.cil.oc.client.TexturePreloader
|
||||
import li.cil.oc.Blocks
|
||||
import li.cil.oc.common.tileentity
|
||||
import li.cil.oc.util.RenderState
|
||||
import net.minecraft.client.renderer.Tessellator
|
||||
import net.minecraft.client.renderer.texture.TextureMap
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
object PowerDistributorRenderer extends TileEntitySpecialRenderer {
|
||||
override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) = {
|
||||
override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) {
|
||||
val distributor = tileEntity.asInstanceOf[tileentity.PowerDistributor]
|
||||
if (distributor.globalBuffer > 0) {
|
||||
GL11.glPushAttrib(0xFFFFFF)
|
||||
@ -24,30 +25,36 @@ object PowerDistributorRenderer extends TileEntitySpecialRenderer {
|
||||
GL11.glScalef(1.002f, -1.002f, 1.002f)
|
||||
GL11.glTranslatef(-0.5f, -0.5f, -0.5f)
|
||||
|
||||
bindTexture(TexturePreloader.blockPowerDistributorOn)
|
||||
|
||||
bindTexture(TextureMap.locationBlocksTexture)
|
||||
val t = Tessellator.instance
|
||||
t.startDrawingQuads()
|
||||
|
||||
t.addVertexWithUV(1, 1, 0, 0, 1)
|
||||
t.addVertexWithUV(0, 1, 0, 1, 1)
|
||||
t.addVertexWithUV(0, 0, 0, 1, 0)
|
||||
t.addVertexWithUV(1, 0, 0, 0, 0)
|
||||
val topOn = Blocks.powerDistributor.iconTopOn
|
||||
t.addVertexWithUV(0, 0, 1, topOn.getMinU, topOn.getMaxV)
|
||||
t.addVertexWithUV(1, 0, 1, topOn.getMaxU, topOn.getMaxV)
|
||||
t.addVertexWithUV(1, 0, 0, topOn.getMaxU, topOn.getMinV)
|
||||
t.addVertexWithUV(0, 0, 0, topOn.getMinU, topOn.getMinV)
|
||||
|
||||
t.addVertexWithUV(0, 1, 1, 0, 1)
|
||||
t.addVertexWithUV(1, 1, 1, 1, 1)
|
||||
t.addVertexWithUV(1, 0, 1, 1, 0)
|
||||
t.addVertexWithUV(0, 0, 1, 0, 0)
|
||||
val sideOn = Blocks.powerDistributor.iconSideOn
|
||||
t.addVertexWithUV(1, 1, 0, sideOn.getMinU, sideOn.getMaxV)
|
||||
t.addVertexWithUV(0, 1, 0, sideOn.getMaxU, sideOn.getMaxV)
|
||||
t.addVertexWithUV(0, 0, 0, sideOn.getMaxU, sideOn.getMinV)
|
||||
t.addVertexWithUV(1, 0, 0, sideOn.getMinU, sideOn.getMinV)
|
||||
|
||||
t.addVertexWithUV(1, 1, 1, 0, 1)
|
||||
t.addVertexWithUV(1, 1, 0, 1, 1)
|
||||
t.addVertexWithUV(1, 0, 0, 1, 0)
|
||||
t.addVertexWithUV(1, 0, 1, 0, 0)
|
||||
t.addVertexWithUV(0, 1, 1, sideOn.getMinU, sideOn.getMaxV)
|
||||
t.addVertexWithUV(1, 1, 1, sideOn.getMaxU, sideOn.getMaxV)
|
||||
t.addVertexWithUV(1, 0, 1, sideOn.getMaxU, sideOn.getMinV)
|
||||
t.addVertexWithUV(0, 0, 1, sideOn.getMinU, sideOn.getMinV)
|
||||
|
||||
t.addVertexWithUV(0, 1, 0, 0, 1)
|
||||
t.addVertexWithUV(0, 1, 1, 1, 1)
|
||||
t.addVertexWithUV(0, 0, 1, 1, 0)
|
||||
t.addVertexWithUV(0, 0, 0, 0, 0)
|
||||
t.addVertexWithUV(1, 1, 1, sideOn.getMinU, sideOn.getMaxV)
|
||||
t.addVertexWithUV(1, 1, 0, sideOn.getMaxU, sideOn.getMaxV)
|
||||
t.addVertexWithUV(1, 0, 0, sideOn.getMaxU, sideOn.getMinV)
|
||||
t.addVertexWithUV(1, 0, 1, sideOn.getMinU, sideOn.getMinV)
|
||||
|
||||
t.addVertexWithUV(0, 1, 0, sideOn.getMinU, sideOn.getMaxV)
|
||||
t.addVertexWithUV(0, 1, 1, sideOn.getMaxU, sideOn.getMaxV)
|
||||
t.addVertexWithUV(0, 0, 1, sideOn.getMaxU, sideOn.getMinV)
|
||||
t.addVertexWithUV(0, 0, 0, sideOn.getMinU, sideOn.getMinV)
|
||||
|
||||
t.draw()
|
||||
|
||||
|
@ -0,0 +1,60 @@
|
||||
package li.cil.oc.client.renderer.tileentity
|
||||
|
||||
import li.cil.oc.Blocks
|
||||
import li.cil.oc.common.tileentity
|
||||
import li.cil.oc.util.RenderState
|
||||
import net.minecraft.client.renderer.Tessellator
|
||||
import net.minecraft.client.renderer.texture.TextureMap
|
||||
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer
|
||||
import net.minecraft.tileentity.TileEntity
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
object RouterRenderer extends TileEntitySpecialRenderer {
|
||||
override def renderTileEntityAt(tileEntity: TileEntity, x: Double, y: Double, z: Double, f: Float) {
|
||||
val router = tileEntity.asInstanceOf[tileentity.Router]
|
||||
val activity = math.max(0, 1 - (System.currentTimeMillis() - router.lastMessage) / 1000.0)
|
||||
if (activity > 0) {
|
||||
GL11.glPushAttrib(0xFFFFFF)
|
||||
|
||||
RenderState.disableLighting()
|
||||
RenderState.makeItBlend()
|
||||
RenderState.setBlendAlpha(activity.toFloat)
|
||||
|
||||
GL11.glPushMatrix()
|
||||
|
||||
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5)
|
||||
GL11.glScalef(1.002f, -1.002f, 1.002f)
|
||||
GL11.glTranslatef(-0.5f, -0.5f, -0.5f)
|
||||
|
||||
bindTexture(TextureMap.locationBlocksTexture)
|
||||
val t = Tessellator.instance
|
||||
t.startDrawingQuads()
|
||||
|
||||
val sideActivity = Blocks.router.iconSideActivity
|
||||
t.addVertexWithUV(1, 1, 0, sideActivity.getMinU, sideActivity.getMaxV)
|
||||
t.addVertexWithUV(0, 1, 0, sideActivity.getMaxU, sideActivity.getMaxV)
|
||||
t.addVertexWithUV(0, 0, 0, sideActivity.getMaxU, sideActivity.getMinV)
|
||||
t.addVertexWithUV(1, 0, 0, sideActivity.getMinU, sideActivity.getMinV)
|
||||
|
||||
t.addVertexWithUV(0, 1, 1, sideActivity.getMinU, sideActivity.getMaxV)
|
||||
t.addVertexWithUV(1, 1, 1, sideActivity.getMaxU, sideActivity.getMaxV)
|
||||
t.addVertexWithUV(1, 0, 1, sideActivity.getMaxU, sideActivity.getMinV)
|
||||
t.addVertexWithUV(0, 0, 1, sideActivity.getMinU, sideActivity.getMinV)
|
||||
|
||||
t.addVertexWithUV(1, 1, 1, sideActivity.getMinU, sideActivity.getMaxV)
|
||||
t.addVertexWithUV(1, 1, 0, sideActivity.getMaxU, sideActivity.getMaxV)
|
||||
t.addVertexWithUV(1, 0, 0, sideActivity.getMaxU, sideActivity.getMinV)
|
||||
t.addVertexWithUV(1, 0, 1, sideActivity.getMinU, sideActivity.getMinV)
|
||||
|
||||
t.addVertexWithUV(0, 1, 0, sideActivity.getMinU, sideActivity.getMaxV)
|
||||
t.addVertexWithUV(0, 1, 1, sideActivity.getMaxU, sideActivity.getMaxV)
|
||||
t.addVertexWithUV(0, 0, 1, sideActivity.getMaxU, sideActivity.getMinV)
|
||||
t.addVertexWithUV(0, 0, 0, sideActivity.getMinU, sideActivity.getMinV)
|
||||
|
||||
t.draw()
|
||||
|
||||
GL11.glPopMatrix()
|
||||
GL11.glPopAttrib()
|
||||
}
|
||||
}
|
||||
}
|
@ -22,6 +22,7 @@ object PacketType extends Enumeration {
|
||||
RobotSelectedSlotChange,
|
||||
RobotXp,
|
||||
RotatableState,
|
||||
RouterActivity,
|
||||
ScreenColorChange,
|
||||
ScreenCopy,
|
||||
ScreenDepthChange,
|
||||
|
@ -9,7 +9,7 @@ import li.cil.oc.{OpenComputers, Settings}
|
||||
import mcp.mobius.waila.api.{IWailaConfigHandler, IWailaDataAccessor}
|
||||
import net.minecraft.client.renderer.texture.IconRegister
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.item.{EnumRarity, ItemStack}
|
||||
import net.minecraft.item.{ItemDye, EnumRarity, ItemStack}
|
||||
import net.minecraft.util.{StatCollector, Icon}
|
||||
import net.minecraft.world.IBlockAccess
|
||||
import net.minecraft.world.World
|
||||
@ -105,19 +105,19 @@ object Case {
|
||||
class Tier1(parent: SimpleDelegator) extends Case(parent) {
|
||||
def tier = 0
|
||||
|
||||
override def color = 0x7F7F7F
|
||||
override def color = ItemDye.dyeColors(ItemDye.dyeColorNames.indexOf("silver"))
|
||||
}
|
||||
|
||||
class Tier2(parent: SimpleDelegator) extends Case(parent) {
|
||||
def tier = 1
|
||||
|
||||
override def color = 0xFFFF66
|
||||
override def color = 0xFFFF66 // ItemDye.dyeColors(ItemDye.dyeColorNames.indexOf("yellow"))
|
||||
}
|
||||
|
||||
class Tier3(parent: SimpleDelegator) extends Case(parent) {
|
||||
def tier = 2
|
||||
|
||||
override def color = 0x66FFFF
|
||||
override def color = 0x66FFFF // ItemDye.dyeColors(ItemDye.dyeColorNames.indexOf("lightBlue"))
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,7 +20,8 @@ class Charger(val parent: SimpleDelegator) extends RedstoneAware with SimpleDele
|
||||
val unlocalizedName = "Charger"
|
||||
|
||||
private val icons = Array.fill[Icon](6)(null)
|
||||
private val iconsCharging = Array.fill[Icon](6)(null)
|
||||
var iconFrontCharging: Icon = _
|
||||
var iconSideCharging: Icon = _
|
||||
|
||||
override def tooltipLines(stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) {
|
||||
tooltip.addAll(Tooltip.get(unlocalizedName))
|
||||
@ -40,28 +41,19 @@ class Charger(val parent: SimpleDelegator) extends RedstoneAware with SimpleDele
|
||||
override def icon(side: ForgeDirection) = Some(icons(side.ordinal()))
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
override def icon(world: IBlockAccess, x: Int, y: Int, z: Int, worldSide: ForgeDirection, localSide: ForgeDirection) =
|
||||
world.getBlockTileEntity(x, y, z) match {
|
||||
case charger: tileentity.Charger if charger.chargeSpeed > 0 => Some(iconsCharging(localSide.ordinal()))
|
||||
case _ => Some(icons(localSide.ordinal()))
|
||||
}
|
||||
override def icon(world: IBlockAccess, x: Int, y: Int, z: Int, worldSide: ForgeDirection, localSide: ForgeDirection) = Some(icons(localSide.ordinal()))
|
||||
|
||||
override def registerIcons(iconRegister: IconRegister) = {
|
||||
icons(ForgeDirection.DOWN.ordinal) = iconRegister.registerIcon(Settings.resourceDomain + ":generic_top")
|
||||
icons(ForgeDirection.UP.ordinal) = icons(ForgeDirection.DOWN.ordinal)
|
||||
|
||||
icons(ForgeDirection.NORTH.ordinal) = iconRegister.registerIcon(Settings.resourceDomain + ":charger")
|
||||
icons(ForgeDirection.SOUTH.ordinal) = icons(ForgeDirection.NORTH.ordinal)
|
||||
icons(ForgeDirection.NORTH.ordinal) = iconRegister.registerIcon(Settings.resourceDomain + ":charger_side")
|
||||
icons(ForgeDirection.SOUTH.ordinal) = iconRegister.registerIcon(Settings.resourceDomain + ":charger_front")
|
||||
icons(ForgeDirection.WEST.ordinal) = icons(ForgeDirection.NORTH.ordinal)
|
||||
icons(ForgeDirection.EAST.ordinal) = icons(ForgeDirection.NORTH.ordinal)
|
||||
|
||||
iconsCharging(ForgeDirection.DOWN.ordinal) = icons(ForgeDirection.DOWN.ordinal)
|
||||
iconsCharging(ForgeDirection.UP.ordinal) = icons(ForgeDirection.UP.ordinal)
|
||||
|
||||
iconsCharging(ForgeDirection.NORTH.ordinal) = iconRegister.registerIcon(Settings.resourceDomain + ":charger_on")
|
||||
iconsCharging(ForgeDirection.SOUTH.ordinal) = iconsCharging(ForgeDirection.NORTH.ordinal)
|
||||
iconsCharging(ForgeDirection.WEST.ordinal) = iconsCharging(ForgeDirection.NORTH.ordinal)
|
||||
iconsCharging(ForgeDirection.EAST.ordinal) = iconsCharging(ForgeDirection.NORTH.ordinal)
|
||||
iconFrontCharging = iconRegister.registerIcon(Settings.resourceDomain + ":charger_front_on")
|
||||
iconSideCharging = iconRegister.registerIcon(Settings.resourceDomain + ":charger_side_on")
|
||||
}
|
||||
|
||||
override def createTileEntity(world: World) = Some(new tileentity.Charger())
|
||||
|
@ -46,10 +46,8 @@ class Item(id: Int) extends ItemBlock(id) {
|
||||
keyboard.setFromFacing(ForgeDirection.getOrientation(side))
|
||||
case rotatable: tileentity.traits.Rotatable =>
|
||||
rotatable.setFromEntityPitchAndYaw(player)
|
||||
rotatable match {
|
||||
case _@(_: tileentity.traits.Computer | _: tileentity.DiskDrive | _: tileentity.Rack) =>
|
||||
rotatable.pitch = ForgeDirection.NORTH
|
||||
case _ =>
|
||||
if (!rotatable.validFacings.contains(rotatable.pitch)) {
|
||||
rotatable.pitch = rotatable.validFacings.headOption.getOrElse(ForgeDirection.NORTH)
|
||||
}
|
||||
if (!rotatable.isInstanceOf[tileentity.RobotProxy]) {
|
||||
rotatable.invertRotation()
|
||||
|
@ -15,6 +15,8 @@ class PowerDistributor(val parent: SimpleDelegator) extends SimpleDelegate {
|
||||
val unlocalizedName = "PowerDistributor"
|
||||
|
||||
private val icons = Array.fill[Icon](6)(null)
|
||||
var iconSideOn: Icon = _
|
||||
var iconTopOn: Icon = _
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
@ -26,12 +28,15 @@ class PowerDistributor(val parent: SimpleDelegator) extends SimpleDelegate {
|
||||
|
||||
override def registerIcons(iconRegister: IconRegister) = {
|
||||
icons(ForgeDirection.DOWN.ordinal) = iconRegister.registerIcon(Settings.resourceDomain + ":generic_top")
|
||||
icons(ForgeDirection.UP.ordinal) = icons(ForgeDirection.DOWN.ordinal)
|
||||
icons(ForgeDirection.UP.ordinal) = iconRegister.registerIcon(Settings.resourceDomain + ":power_distributor_top")
|
||||
|
||||
icons(ForgeDirection.NORTH.ordinal) = iconRegister.registerIcon(Settings.resourceDomain + ":power_distributor")
|
||||
icons(ForgeDirection.NORTH.ordinal) = iconRegister.registerIcon(Settings.resourceDomain + ":power_distributor_side")
|
||||
icons(ForgeDirection.SOUTH.ordinal) = icons(ForgeDirection.NORTH.ordinal)
|
||||
icons(ForgeDirection.WEST.ordinal) = icons(ForgeDirection.NORTH.ordinal)
|
||||
icons(ForgeDirection.EAST.ordinal) = icons(ForgeDirection.NORTH.ordinal)
|
||||
|
||||
iconSideOn = iconRegister.registerIcon(Settings.resourceDomain + ":power_distributor_side_on")
|
||||
iconTopOn = iconRegister.registerIcon(Settings.resourceDomain + ":power_distributor_top_on")
|
||||
}
|
||||
|
||||
override def luminance(world: IBlockAccess, x: Int, y: Int, z: Int) = 5
|
||||
|
@ -16,6 +16,8 @@ class Router(val parent: SimpleDelegator) extends SimpleDelegate {
|
||||
|
||||
private val icons = Array.fill[Icon](6)(null)
|
||||
|
||||
var iconSideActivity: Icon = _
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def tooltipLines(stack: ItemStack, player: EntityPlayer, tooltip: util.List[String], advanced: Boolean) {
|
||||
@ -32,6 +34,8 @@ class Router(val parent: SimpleDelegator) extends SimpleDelegate {
|
||||
icons(ForgeDirection.SOUTH.ordinal) = icons(ForgeDirection.NORTH.ordinal)
|
||||
icons(ForgeDirection.WEST.ordinal) = icons(ForgeDirection.NORTH.ordinal)
|
||||
icons(ForgeDirection.EAST.ordinal) = icons(ForgeDirection.NORTH.ordinal)
|
||||
|
||||
iconSideActivity = iconRegister.registerIcon(Settings.resourceDomain + ":router_side_active")
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
@ -9,7 +9,7 @@ import net.minecraft.nbt.NBTTagCompound
|
||||
import net.minecraft.util.ChatMessageComponent
|
||||
import net.minecraftforge.common.ForgeDirection
|
||||
|
||||
class Charger extends traits.Environment with traits.RedstoneAware with Analyzable {
|
||||
class Charger extends traits.Environment with traits.RedstoneAware with traits.Rotatable with Analyzable {
|
||||
val node = api.Network.newNode(this, Visibility.None).
|
||||
withConnector().
|
||||
create()
|
||||
|
@ -12,6 +12,8 @@ import net.minecraftforge.common.ForgeDirection
|
||||
class Keyboard(isRemote: Boolean) extends traits.Environment with traits.Rotatable with SidedEnvironment with Analyzable {
|
||||
def this() = this(false)
|
||||
|
||||
override def validFacings = ForgeDirection.VALID_DIRECTIONS
|
||||
|
||||
val keyboard = if (isRemote) null
|
||||
else new component.Keyboard {
|
||||
override def isUseableByPlayer(p: EntityPlayer) =
|
||||
|
@ -4,10 +4,14 @@ import cpw.mods.fml.common.{Loader, Optional}
|
||||
import dan200.computer.api.{ILuaContext, IComputerAccess, IPeripheral}
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.api.network.{Packet, Message}
|
||||
import li.cil.oc.server.PacketSender
|
||||
import net.minecraftforge.common.ForgeDirection
|
||||
import scala.collection.mutable
|
||||
|
||||
@Optional.Interface(iface = "dan200.computer.api.IPeripheral", modid = "ComputerCraft")
|
||||
class Router extends traits.Hub with traits.NotAnalyzable with IPeripheral {
|
||||
var lastMessage = 0L
|
||||
|
||||
private val computers = mutable.ArrayBuffer.empty[AnyRef]
|
||||
|
||||
private val openPorts = mutable.Map.empty[AnyRef, mutable.Set[Int]]
|
||||
@ -86,6 +90,15 @@ class Router extends traits.Hub with traits.NotAnalyzable with IPeripheral {
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override protected def relayPacket(sourceSide: ForgeDirection, packet: Packet) {
|
||||
super.relayPacket(sourceSide, packet)
|
||||
val now = System.currentTimeMillis()
|
||||
if (now - lastMessage > 250) {
|
||||
lastMessage = now
|
||||
PacketSender.sendRouterActivity(this)
|
||||
}
|
||||
}
|
||||
|
||||
override protected def onPlugMessage(plug: Plug, message: Message) {
|
||||
super.onPlugMessage(plug, message)
|
||||
if (message.name == "network.message" && Loader.isModLoaded("ComputerCraft")) {
|
||||
|
@ -22,6 +22,8 @@ class Screen(var tier: Int) extends traits.TextBuffer with SidedEnvironment with
|
||||
|
||||
_isOutputEnabled = true
|
||||
|
||||
override def validFacings = ForgeDirection.VALID_DIRECTIONS
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override protected val _buffer = new component.Buffer(this) {
|
||||
|
@ -149,6 +149,8 @@ trait Rotatable extends RotationAware with api.Rotatable {
|
||||
|
||||
override def toGlobal(value: ForgeDirection) = cachedInverseTranslation(value.ordinal)
|
||||
|
||||
def validFacings = Array(ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.WEST, ForgeDirection.EAST)
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
protected def onRotationChanged() {
|
||||
@ -165,8 +167,12 @@ trait Rotatable extends RotationAware with api.Rotatable {
|
||||
|
||||
override def readFromNBT(nbt: NBTTagCompound) = {
|
||||
super.readFromNBT(nbt)
|
||||
pitch = ForgeDirection.getOrientation(nbt.getInteger(Settings.namespace + "pitch"))
|
||||
yaw = ForgeDirection.getOrientation(nbt.getInteger(Settings.namespace + "yaw"))
|
||||
if (nbt.hasKey(Settings.namespace + "pitch")) {
|
||||
pitch = ForgeDirection.getOrientation(nbt.getInteger(Settings.namespace + "pitch"))
|
||||
}
|
||||
if (nbt.hasKey(Settings.namespace + "yaw")) {
|
||||
yaw = ForgeDirection.getOrientation(nbt.getInteger(Settings.namespace + "yaw"))
|
||||
}
|
||||
validatePitchAndYaw()
|
||||
updateTranslation()
|
||||
}
|
||||
|
@ -198,6 +198,14 @@ object PacketSender {
|
||||
pb.sendToNearbyPlayers(t)
|
||||
}
|
||||
|
||||
def sendRouterActivity(t: tileentity.Router) {
|
||||
val pb = new PacketBuilder(PacketType.RouterActivity)
|
||||
|
||||
pb.writeTileEntity(t)
|
||||
|
||||
pb.sendToNearbyPlayers(t, 64)
|
||||
}
|
||||
|
||||
def sendScreenColorChange(b: common.component.Buffer, foreground: Int, background: Int) {
|
||||
val pb = new PacketBuilder(PacketType.ScreenColorChange)
|
||||
|
||||
|
@ -465,7 +465,7 @@ object Network extends api.detail.NetworkAPI {
|
||||
override def newPacket(nbt: NBTTagCompound) = {
|
||||
val source = nbt.getString("source")
|
||||
val destination =
|
||||
if (nbt.getBoolean("broadcast")) null
|
||||
if (nbt.hasKey("dest")) null
|
||||
else nbt.getString("dest")
|
||||
val port = nbt.getInteger("port")
|
||||
val ttl = nbt.getInteger("ttl")
|
||||
@ -596,8 +596,7 @@ object Network extends api.detail.NetworkAPI {
|
||||
|
||||
override def save(nbt: NBTTagCompound) {
|
||||
nbt.setString("source", source)
|
||||
nbt.setBoolean("broadcast", destination.isEmpty)
|
||||
if (destination != null) {
|
||||
if (destination != null && !destination.isEmpty) {
|
||||
nbt.setString("dest", destination)
|
||||
}
|
||||
nbt.setInteger("port", port)
|
||||
|