mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 18:55:03 -04:00
Added hover boots. Because I can.
This commit is contained in:
parent
66203d8bd5
commit
4f804c39d4
BIN
assets/items.psd
BIN
assets/items.psd
Binary file not shown.
@ -556,6 +556,9 @@ opencomputers {
|
||||
|
||||
# The amount of energy an access point can store.
|
||||
accessPoint: 600.0
|
||||
|
||||
# The internal buffer size of the hover boots.
|
||||
hoverBoots: 15000.0
|
||||
}
|
||||
|
||||
# Default "costs", i.e. how much energy certain operations consume.
|
||||
@ -720,6 +723,20 @@ opencomputers {
|
||||
|
||||
# How much energy is required for a single 3D print.
|
||||
printerModel: 100
|
||||
|
||||
# The amount of energy consumed when jumping with the hover boots. Only
|
||||
# applies when the jump boost is applied, i.e. when not sneaking.
|
||||
hoverBootJump: 10
|
||||
|
||||
# The amount of energy consumed when the hover boots absorb some fall
|
||||
# velocity (i.e. when falling from something higher than three blocks).
|
||||
hoverBootAbsorb: 10
|
||||
|
||||
# The amount of energy consumed *per second* when moving around while
|
||||
# wearing the hover boots. This is compensate for the step assist, which
|
||||
# does not consume energy on a per-use basis. When standing still or
|
||||
# moving very slowly this also does not trigger.
|
||||
hoverBootMove: 1
|
||||
}
|
||||
|
||||
# The rate at which different blocks accept external power. All of these
|
||||
|
@ -0,0 +1,11 @@
|
||||
# Hover Boots
|
||||
|
||||

|
||||
|
||||
If you can't be bothered to program [drones](drone.md), here's an alternative use for them: stepping stones! Or glorified inline skates. Something like that.
|
||||
|
||||
Either way, these boots have a few useful properties: as long as they have power they will let you jump higher, and absorb some of the shock when landing after a particularly high jump. Specifically, they'll allow you to jump up to four blocks high and cut the impact down to one third.
|
||||
|
||||
Additionally, due to always being in kind of a hovering state anyway, they allow you to seamlessly walk up steps of up to one block height. This is particularly handy when sprinting up a mountain, for example, a very commonplace fitness routine amongst Minecrafters. Or so I hear.
|
||||
|
||||
The boots can be recharged in an OpenComptuers [charger](../block/charger.md) or any other such device, like the Applied Energistics 2 charger, an IndustrialCraft 2 battery box, or the Energetic Infuser from Thermal Expansion.
|
@ -83,3 +83,6 @@ Keep in mind that some of these may not be available, depending on the recipe se
|
||||
* [Drone Case](droneCase1.md)
|
||||
* [Microcontroller Case](microcontrollerCase1.md)
|
||||
* [Tablet Case](tabletCase1.md)
|
||||
|
||||
## Other
|
||||
* [Hover Boots](hoverBoots.md)
|
||||
|
@ -73,6 +73,7 @@ item.oc.GraphicsCard2.name=Graphics Card (Tier 3)
|
||||
item.oc.HardDiskDrive0.name=Hard Disk Drive (Tier 1)
|
||||
item.oc.HardDiskDrive1.name=Hard Disk Drive (Tier 2)
|
||||
item.oc.HardDiskDrive2.name=Hard Disk Drive (Tier 3)
|
||||
item.oc.hoverBoots.name=Hover Boots
|
||||
item.oc.InkCartridge.name=Ink Cartridge
|
||||
item.oc.InkCartridgeEmpty.name=Ink Cartridge (Empty)
|
||||
item.oc.InternetCard.name=Internet Card
|
||||
@ -268,6 +269,7 @@ oc:tooltip.EEPROM=Small, programmable storage that contains the BIOS computers u
|
||||
oc:tooltip.FakeEndstone=Almost as good as the real thing, even emulates its floatiness!
|
||||
oc:tooltip.Geolyzer=Allows scanning the surrounding area's blocks' hardness. This information can be useful for generating holograms of the area or for detecting ores.
|
||||
oc:tooltip.GraphicsCard=Used to change what's displayed on screens.[nl] Maximum resolution: §f%sx%s§7[nl] Maximum color depth: §f%s§7[nl] Operations/tick: §f%s§7
|
||||
oc:tooltip.HoverBoots=Jump higher, fall deeper, walk better. This and more, with the new and patented Hover Boots (TM).
|
||||
oc:tooltip.InkCartridge=Used to refill ink in 3D printers. For mysterious reasons it does not have to remain in the printer.
|
||||
oc:tooltip.InkCartridgeEmpty=This ink cartridge has been sucked dry. Refill it using dyes. Or throw it away. See if I care.
|
||||
oc:tooltip.InternetCard=This card allows making HTTP requests and using real TCP sockets.
|
||||
|
@ -6,15 +6,20 @@ analyzer {
|
||||
["oc:materialTransistor", nuggetGold, ""]
|
||||
["oc:materialCircuitBoardPrinted", nuggetGold, ""]]
|
||||
}
|
||||
texturePicker {
|
||||
input: [[dyeBlack, dyeRed, dyeGreen]
|
||||
[dyeBlue, "oc:analyzer", dyePurple]
|
||||
[dyeYellow, dyeMagenta, dyeWhite]]
|
||||
hoverBoots {
|
||||
input: [[nuggetIron, "oc:hoverUpgrade1", nuggetIron]
|
||||
[leather, "oc:droneCase1", leather]
|
||||
[nuggetIron, "oc:capacitor", nuggetIron]]
|
||||
}
|
||||
manual {
|
||||
type: shapeless
|
||||
input: [book, "oc:circuitChip1"]
|
||||
}
|
||||
texturePicker {
|
||||
input: [[dyeBlack, dyeRed, dyeGreen]
|
||||
[dyeBlue, "oc:analyzer", dyePurple]
|
||||
[dyeYellow, dyeMagenta, dyeWhite]]
|
||||
}
|
||||
wrench {
|
||||
input: [[ingotIron, "", ingotIron]
|
||||
["", "oc:circuitChip2", ""],
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 461 B |
@ -95,6 +95,7 @@ object Constants {
|
||||
final val HDDTier1 = "hdd1"
|
||||
final val HDDTier2 = "hdd2"
|
||||
final val HDDTier3 = "hdd3"
|
||||
final val HoverBoots = "hoverBoots"
|
||||
final val HoverUpgradeTier1 = "hoverUpgrade1"
|
||||
final val HoverUpgradeTier2 = "hoverUpgrade2"
|
||||
final val InkCartridgeEmpty = "inkCartridgeEmpty"
|
||||
|
@ -153,6 +153,7 @@ class Settings(val config: Config) {
|
||||
val bufferAccessPoint = config.getDouble("power.buffer.accessPoint") max 0
|
||||
val bufferDrone = config.getDouble("power.buffer.drone") max 0
|
||||
val bufferMicrocontroller = config.getDouble("power.buffer.mcu") max 0
|
||||
val bufferHoverBoots = config.getDouble("power.buffer.hoverBoots") max 1
|
||||
|
||||
// power.cost
|
||||
val computerCost = config.getDouble("power.cost.computer") max 0
|
||||
@ -187,6 +188,9 @@ class Settings(val config: Config) {
|
||||
val pistonCost = config.getDouble("power.cost.pistonPush") max 0
|
||||
val eepromWriteCost = config.getDouble("power.cost.eepromWrite") max 0
|
||||
val printCost = config.getDouble("power.cost.printerModel") max 0
|
||||
val hoverBootJump = config.getDouble("power.cost.hoverBootJump") max 0
|
||||
val hoverBootAbsorb = config.getDouble("power.cost.hoverBootAbsorb") max 0
|
||||
val hoverBootMove = config.getDouble("power.cost.hoverBootMove") max 0
|
||||
|
||||
// power.rate
|
||||
val accessPointRate = config.getDouble("power.rate.accessPoint") max 0
|
||||
|
@ -0,0 +1,109 @@
|
||||
package li.cil.oc.client.renderer.item
|
||||
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.util.RenderState
|
||||
import net.minecraft.client.model.ModelBase
|
||||
import net.minecraft.client.model.ModelBiped
|
||||
import net.minecraft.client.model.ModelRenderer
|
||||
import net.minecraft.util.ResourceLocation
|
||||
import org.lwjgl.opengl.GL11
|
||||
|
||||
object HoverBootRenderer extends ModelBiped {
|
||||
val texture = new ResourceLocation(Settings.resourceDomain, "textures/model/drone.png")
|
||||
|
||||
val bootLeft = new ModelRenderer(this, "bootLeft")
|
||||
val bootRight = new ModelRenderer(this, "bootRight")
|
||||
val body = new ModelRenderer(this, "body")
|
||||
val wing0 = new ModelRenderer(this, "wing0")
|
||||
val wing1 = new ModelRenderer(this, "wing1")
|
||||
val wing2 = new ModelRenderer(this, "wing2")
|
||||
val wing3 = new ModelRenderer(this, "wing3")
|
||||
val light0 = new LightModelRenderer(this, "light0")
|
||||
val light1 = new LightModelRenderer(this, "light1")
|
||||
val light2 = new LightModelRenderer(this, "light2")
|
||||
val light3 = new LightModelRenderer(this, "light3")
|
||||
|
||||
bootLeft.addChild(body)
|
||||
bootLeft.addChild(wing0)
|
||||
bootLeft.addChild(wing1)
|
||||
|
||||
bootRight.addChild(body)
|
||||
bootRight.addChild(wing2)
|
||||
bootRight.addChild(wing3)
|
||||
|
||||
wing0.addChild(light0)
|
||||
wing1.addChild(light1)
|
||||
wing2.addChild(light2)
|
||||
wing3.addChild(light3)
|
||||
|
||||
textureWidth = 64
|
||||
textureHeight = 32
|
||||
|
||||
setTextureOffset("body.middle", 0, 23)
|
||||
setTextureOffset("body.top", 0, 1)
|
||||
setTextureOffset("body.bottom", 0, 17)
|
||||
setTextureOffset("wing0.flap0", 0, 9)
|
||||
setTextureOffset("wing0.pin0", 0, 27)
|
||||
setTextureOffset("wing1.flap1", 0, 9)
|
||||
setTextureOffset("wing1.pin1", 0, 27)
|
||||
setTextureOffset("wing2.flap2", 0, 9)
|
||||
setTextureOffset("wing2.pin2", 0, 27)
|
||||
setTextureOffset("wing3.flap3", 0, 9)
|
||||
setTextureOffset("wing3.pin3", 0, 27)
|
||||
|
||||
setTextureOffset("light0.flap0", 24, 0)
|
||||
setTextureOffset("light1.flap1", 24, 0)
|
||||
setTextureOffset("light2.flap2", 24, 0)
|
||||
setTextureOffset("light3.flap3", 24, 0)
|
||||
|
||||
bootRight.offsetY = 10.1f / 16
|
||||
bootLeft.offsetY = 10.11f / 16f
|
||||
|
||||
body.addBox("top", -3, 1, -3, 6, 1, 6).rotateAngleY = math.toRadians(45).toFloat
|
||||
body.addBox("middle", -1, 0, -1, 2, 1, 2).rotateAngleY = math.toRadians(45).toFloat
|
||||
body.addBox("bottom", -2, -1, -2, 4, 1, 4).rotateAngleY = math.toRadians(45).toFloat
|
||||
wing0.addBox("flap0", -1, 0, -7, 6, 1, 6)
|
||||
wing0.addBox("pin0", 0, -1, -3, 1, 3, 1)
|
||||
wing1.addBox("flap1", -1, 0, 1, 6, 1, 6)
|
||||
wing1.addBox("pin1", 0, -1, 2, 1, 3, 1)
|
||||
wing2.addBox("flap2", -5, 0, 1, 6, 1, 6)
|
||||
wing2.addBox("pin2", -1, -1, 2, 1, 3, 1)
|
||||
wing3.addBox("flap3", -5, 0, -7, 6, 1, 6)
|
||||
wing3.addBox("pin3", -1, -1, -3, 1, 3, 1)
|
||||
|
||||
light0.addBox("flap0", -1, 0, -7, 6, 1, 6)
|
||||
light1.addBox("flap1", -1, 0, 1, 6, 1, 6)
|
||||
light2.addBox("flap2", -5, 0, 1, 6, 1, 6)
|
||||
light3.addBox("flap3", -5, 0, -7, 6, 1, 6)
|
||||
|
||||
// No drone textured legs, thank you very much.
|
||||
bipedLeftLeg.cubeList.clear()
|
||||
bipedRightLeg.cubeList.clear()
|
||||
|
||||
bipedLeftLeg.addChild(bootLeft)
|
||||
bipedRightLeg.addChild(bootRight)
|
||||
|
||||
bipedHead.isHidden = true
|
||||
bipedHeadwear.isHidden = true
|
||||
bipedBody.isHidden = true
|
||||
bipedRightArm.isHidden = true
|
||||
bipedLeftArm.isHidden = true
|
||||
bipedEars.isHidden = true
|
||||
bipedCloak.isHidden = true
|
||||
|
||||
class LightModelRenderer(modelBase: ModelBase, name: String) extends ModelRenderer(modelBase, name) {
|
||||
override def render(dt: Float): Unit = {
|
||||
RenderState.disableLighting()
|
||||
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS)
|
||||
GL11.glDepthFunc(GL11.GL_LEQUAL)
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE)
|
||||
GL11.glColor3ub(0x66.toByte, 0xDD.toByte, 0x55.toByte)
|
||||
|
||||
super.render(dt)
|
||||
|
||||
RenderState.enableLighting()
|
||||
GL11.glPopAttrib()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package li.cil.oc.common.event
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.common.item.HoverBoots
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraftforge.common.util.FakePlayer
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent
|
||||
|
||||
object HoverBootsHandler {
|
||||
@SubscribeEvent
|
||||
def onLivingUpdate(e: LivingUpdateEvent): Unit = e.entity match {
|
||||
case player: EntityPlayer if !player.isInstanceOf[FakePlayer] =>
|
||||
val nbt = player.getEntityData
|
||||
val hadHoverBoots = nbt.getBoolean(Settings.namespace + "hasHoverBoots")
|
||||
val hasHoverBoots = !player.isSneaking && equippedArmor(player).exists(stack => stack.getItem match {
|
||||
case boots: HoverBoots =>
|
||||
if (player.onGround && player.worldObj.getTotalWorldTime % 20 == 0) {
|
||||
val velocity = player.motionX * player.motionX + player.motionY * player.motionY + player.motionZ * player.motionZ
|
||||
if (velocity > 0.015f) {
|
||||
boots.charge(stack, -Settings.get.hoverBootMove, simulate = false)
|
||||
}
|
||||
}
|
||||
boots.getCharge(stack) > 0
|
||||
case _ => false
|
||||
})
|
||||
if (hasHoverBoots != hadHoverBoots) {
|
||||
nbt.setBoolean(Settings.namespace + "hasHoverBoots", hasHoverBoots)
|
||||
player.stepHeight = if (hasHoverBoots) 1f else 0.5f
|
||||
}
|
||||
if (hasHoverBoots && !player.onGround && player.fallDistance < 5 && player.motionY < 0) {
|
||||
player.motionY *= 0.9f
|
||||
}
|
||||
case _ => // Ignore.
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
def onLivingJump(e: LivingJumpEvent): Unit = e.entity match {
|
||||
case player: EntityPlayer if !player.isInstanceOf[FakePlayer] && !player.isSneaking =>
|
||||
equippedArmor(player).collectFirst {
|
||||
case stack if stack.getItem.isInstanceOf[HoverBoots] =>
|
||||
val boots = stack.getItem.asInstanceOf[HoverBoots]
|
||||
val hoverJumpCost = -Settings.get.hoverBootJump
|
||||
if (boots.charge(stack, hoverJumpCost, simulate = true) == 0) {
|
||||
boots.charge(stack, hoverJumpCost, simulate = false)
|
||||
if (player.isSprinting)
|
||||
player.addVelocity(player.motionX * 0.5, 0.4, player.motionZ * 0.5)
|
||||
else
|
||||
player.addVelocity(0, 0.4, 0)
|
||||
}
|
||||
}
|
||||
case _ => // Ignore.
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
def onLivingFall(e: LivingFallEvent): Unit = if (e.distance > 3) e.entity match {
|
||||
case player: EntityPlayer if !player.isInstanceOf[FakePlayer] =>
|
||||
equippedArmor(player).collectFirst {
|
||||
case stack if stack.getItem.isInstanceOf[HoverBoots] =>
|
||||
val boots = stack.getItem.asInstanceOf[HoverBoots]
|
||||
val hoverFallCost = -Settings.get.hoverBootAbsorb
|
||||
if (boots.charge(stack, hoverFallCost, simulate = true) == 0) {
|
||||
boots.charge(stack, hoverFallCost, simulate = false)
|
||||
e.distance *= 0.3f
|
||||
}
|
||||
}
|
||||
case _ => // Ignore.
|
||||
}
|
||||
|
||||
private def equippedArmor(player: EntityPlayer) = (1 to 4).map(player.getEquipmentInSlot).filter(_ != null)
|
||||
}
|
@ -18,6 +18,7 @@ import li.cil.oc.common.item.Delegator
|
||||
import li.cil.oc.common.item.SimpleItem
|
||||
import li.cil.oc.common.item.UpgradeLeash
|
||||
import li.cil.oc.common.item.data.DroneData
|
||||
import li.cil.oc.common.item.data.HoverBootsData
|
||||
import li.cil.oc.common.item.data.MicrocontrollerData
|
||||
import li.cil.oc.common.item.data.RobotData
|
||||
import li.cil.oc.common.item.data.TabletData
|
||||
@ -307,6 +308,16 @@ object Items extends ItemAPI {
|
||||
stack
|
||||
}
|
||||
|
||||
def createChargedHoverBoots() = {
|
||||
val data = new HoverBootsData()
|
||||
data.charge = Settings.get.bufferHoverBoots
|
||||
|
||||
val stack = get(Constants.ItemName.HoverBoots).createItemStack(1)
|
||||
data.save(stack)
|
||||
|
||||
stack
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
// Crafting
|
||||
|
||||
@ -316,7 +327,8 @@ object Items extends ItemAPI {
|
||||
createConfiguredDrone(),
|
||||
createConfiguredMicrocontroller(),
|
||||
createConfiguredRobot(),
|
||||
createConfiguredTablet()
|
||||
createConfiguredTablet(),
|
||||
createChargedHoverBoots()
|
||||
) ++ Loot.disksForClient ++ registeredItems
|
||||
|
||||
override def getSubItems(item: Item, tab: CreativeTabs, list: java.util.List[_]) {
|
||||
@ -517,5 +529,8 @@ object Items extends ItemAPI {
|
||||
// 1.5.10
|
||||
Recipes.addSubItem(new item.APU(multi, Tier.One), Constants.ItemName.APUTier1, "oc:apu1")
|
||||
Recipes.addSubItem(new item.APU(multi, Tier.Two), Constants.ItemName.APUTier2, "oc:apu2")
|
||||
|
||||
// 1.5.11
|
||||
Recipes.addItem(new item.HoverBoots(), Constants.ItemName.HoverBoots, "oc:hoverBoots")
|
||||
}
|
||||
}
|
||||
|
69
src/main/scala/li/cil/oc/common/item/HoverBoots.scala
Normal file
69
src/main/scala/li/cil/oc/common/item/HoverBoots.scala
Normal file
@ -0,0 +1,69 @@
|
||||
package li.cil.oc.common.item
|
||||
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.client.renderer.item.HoverBootRenderer
|
||||
import li.cil.oc.common.item.data.HoverBootsData
|
||||
import net.minecraft.client.model.ModelBiped
|
||||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.entity.EntityLivingBase
|
||||
import net.minecraft.item.EnumRarity
|
||||
import net.minecraft.item.ItemArmor
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
class HoverBoots extends ItemArmor(ItemArmor.ArmorMaterial.DIAMOND, 0, 3) with SimpleItem with traits.Chargeable {
|
||||
setNoRepair()
|
||||
|
||||
override def getRarity(stack: ItemStack): EnumRarity = EnumRarity.uncommon
|
||||
|
||||
override def maxCharge(stack: ItemStack) = Settings.get.bufferHoverBoots
|
||||
|
||||
override def getCharge(stack: ItemStack): Double =
|
||||
new HoverBootsData(stack).charge
|
||||
|
||||
override def setCharge(stack: ItemStack, amount: Double): Unit = {
|
||||
val data = new HoverBootsData(stack)
|
||||
data.charge = math.min(maxCharge(stack), math.max(0, amount))
|
||||
data.save(stack)
|
||||
}
|
||||
|
||||
override def canCharge(stack: ItemStack): Boolean = true
|
||||
|
||||
override def charge(stack: ItemStack, amount: Double, simulate: Boolean): Double = {
|
||||
val data = new HoverBootsData(stack)
|
||||
if (amount < 0) {
|
||||
val remainder = math.min(0, data.charge + amount)
|
||||
if (!simulate) {
|
||||
data.charge = math.max(0, data.charge + amount)
|
||||
data.save(stack)
|
||||
}
|
||||
remainder
|
||||
}
|
||||
else {
|
||||
val remainder = -math.min(0, Settings.get.bufferHoverBoots - (data.charge + amount))
|
||||
if (!simulate) {
|
||||
data.charge = math.min(Settings.get.bufferHoverBoots, data.charge + amount)
|
||||
data.save(stack)
|
||||
}
|
||||
remainder
|
||||
}
|
||||
}
|
||||
|
||||
override def getArmorModel(entityLiving: EntityLivingBase, itemStack: ItemStack, armorSlot: Int): ModelBiped = {
|
||||
if (armorSlot == armorType) HoverBootRenderer
|
||||
else super.getArmorModel(entityLiving, itemStack, armorSlot)
|
||||
}
|
||||
|
||||
override def getArmorTexture(stack: ItemStack, entity: Entity, slot: Int, subType: String): String = {
|
||||
HoverBootRenderer.texture.toString
|
||||
}
|
||||
|
||||
override def getDisplayDamage(stack: ItemStack): Int = {
|
||||
val data = new HoverBootsData(stack)
|
||||
(Settings.get.bufferHoverBoots * (1 - data.charge / Settings.get.bufferHoverBoots)).toInt
|
||||
}
|
||||
|
||||
override def getMaxDamage(stack: ItemStack): Int = Settings.get.bufferHoverBoots.toInt
|
||||
|
||||
// Always show energy bar.
|
||||
override def isDamaged(stack: ItemStack): Boolean = true
|
||||
}
|
11
src/main/scala/li/cil/oc/common/item/RemoteControl.scala
Normal file
11
src/main/scala/li/cil/oc/common/item/RemoteControl.scala
Normal file
@ -0,0 +1,11 @@
|
||||
package li.cil.oc.common.item
|
||||
|
||||
import li.cil.oc.util.BlockPosition
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
class RemoteControl(val parent: Delegator) extends Delegate {
|
||||
override def onItemUse(stack: ItemStack, player: EntityPlayer, position: BlockPosition, side: Int, hitX: Float, hitY: Float, hitZ: Float): Boolean = {
|
||||
super.onItemUse(stack, player, position, side, hitX, hitY, hitZ)
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package li.cil.oc.common.item.data
|
||||
|
||||
import li.cil.oc.Settings
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.nbt.NBTTagCompound
|
||||
|
||||
class HoverBootsData extends ItemData {
|
||||
def this(stack: ItemStack) {
|
||||
this()
|
||||
load(stack)
|
||||
}
|
||||
|
||||
var charge = 0.0
|
||||
|
||||
override def load(nbt: NBTTagCompound) {
|
||||
charge = nbt.getDouble(Settings.namespace + "charge")
|
||||
}
|
||||
|
||||
override def save(nbt: NBTTagCompound) {
|
||||
nbt.setDouble(Settings.namespace + "charge", charge)
|
||||
}
|
||||
}
|
96
src/main/scala/li/cil/oc/common/item/traits/Chargeable.scala
Normal file
96
src/main/scala/li/cil/oc/common/item/traits/Chargeable.scala
Normal file
@ -0,0 +1,96 @@
|
||||
package li.cil.oc.common.item.traits
|
||||
|
||||
import appeng.api.config.AccessRestriction
|
||||
import cpw.mods.fml.common.Optional
|
||||
import ic2.api.item.IElectricItemManager
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.api
|
||||
import li.cil.oc.common.asm.Injectable
|
||||
import li.cil.oc.integration.Mods
|
||||
import li.cil.oc.integration.ic2.ElectricItemManager
|
||||
import net.minecraft.item.Item
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
@Injectable.InterfaceList(Array(
|
||||
new Injectable.Interface(value = "appeng.api.implementations.items.IAEItemPowerStorage", modid = Mods.IDs.AppliedEnergistics2),
|
||||
new Injectable.Interface(value = "cofh.api.energy.IEnergyContainerItem", modid = Mods.IDs.CoFHEnergy),
|
||||
new Injectable.Interface(value = "ic2.api.item.ISpecialElectricItem", modid = Mods.IDs.IndustrialCraft2),
|
||||
new Injectable.Interface(value = "mekanism.api.energy.IEnergizedItem", modid = Mods.IDs.Mekanism)
|
||||
))
|
||||
trait Chargeable extends api.driver.item.Chargeable {
|
||||
def maxCharge(stack: ItemStack): Double
|
||||
|
||||
def getCharge(stack: ItemStack): Double
|
||||
|
||||
def setCharge(stack: ItemStack, amount: Double): Unit
|
||||
|
||||
// Applied Energistics 2
|
||||
|
||||
def getAECurrentPower(stack: ItemStack): Double =
|
||||
getCharge(stack) / Settings.get.ratioAppliedEnergistics2
|
||||
|
||||
def getAEMaxPower(stack: ItemStack): Double =
|
||||
maxCharge(stack) / Settings.get.ratioAppliedEnergistics2
|
||||
|
||||
def injectAEPower(stack: ItemStack, value: Double): Double =
|
||||
(charge(stack, value * Settings.get.ratioAppliedEnergistics2, false) / Settings.get.ratioAppliedEnergistics2).toInt
|
||||
|
||||
def extractAEPower(stack: ItemStack, value: Double): Double =
|
||||
value - (charge(stack, -value * Settings.get.ratioAppliedEnergistics2, false) / Settings.get.ratioAppliedEnergistics2).toInt
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.AppliedEnergistics2)
|
||||
def getPowerFlow(stack: ItemStack): AccessRestriction = AccessRestriction.WRITE
|
||||
|
||||
// IndustrialCraft 2
|
||||
|
||||
@Optional.Method(modid = Mods.IDs.IndustrialCraft2)
|
||||
def getManager(stack: ItemStack): IElectricItemManager = ElectricItemManager
|
||||
|
||||
def getMaxCharge(stack: ItemStack): Double =
|
||||
maxCharge(stack) / Settings.get.ratioIndustrialCraft2
|
||||
|
||||
def getTransferLimit(stack: ItemStack): Double =
|
||||
Settings.get.chargeRateTablet / Settings.get.ratioIndustrialCraft2
|
||||
|
||||
def getTier(stack: ItemStack): Int = 1
|
||||
|
||||
def canProvideEnergy(stack: ItemStack): Boolean = false
|
||||
|
||||
def getEmptyItem(stack: ItemStack): Item = stack.getItem
|
||||
|
||||
def getChargedItem(stack: ItemStack): Item = stack.getItem
|
||||
|
||||
// Mekanism
|
||||
|
||||
def getEnergy(stack: ItemStack): Double =
|
||||
getCharge(stack) / Settings.get.ratioMekanism
|
||||
|
||||
def setEnergy(stack: ItemStack, amount: Double): Unit =
|
||||
setCharge(stack, amount * Settings.get.ratioMekanism)
|
||||
|
||||
def getMaxEnergy(stack: ItemStack): Double =
|
||||
maxCharge(stack) / Settings.get.ratioMekanism
|
||||
|
||||
def canSend(stack: ItemStack): Boolean = false
|
||||
|
||||
def canReceive(stack: ItemStack): Boolean = true
|
||||
|
||||
def isMetadataSpecific(stack: ItemStack): Boolean = false
|
||||
|
||||
def getMaxTransfer(stack: ItemStack): Double =
|
||||
Settings.get.chargeRateTablet / Settings.get.ratioMekanism
|
||||
|
||||
// Redstone Flux
|
||||
|
||||
def getEnergyStored(stack: ItemStack): Int =
|
||||
(getCharge(stack) / Settings.get.ratioRedstoneFlux).toInt
|
||||
|
||||
def getMaxEnergyStored(stack: ItemStack): Int =
|
||||
(maxCharge(stack) / Settings.get.ratioRedstoneFlux).toInt
|
||||
|
||||
def receiveEnergy(stack: ItemStack, maxReceive: Int, simulate: Boolean): Int =
|
||||
maxReceive - (charge(stack, maxReceive * Settings.get.ratioRedstoneFlux, simulate) / Settings.get.ratioRedstoneFlux).toInt
|
||||
|
||||
def extractEnergy(stack: ItemStack, maxExtract: Int, simulate: Boolean): Int =
|
||||
maxExtract - (charge(stack, -maxExtract * Settings.get.ratioRedstoneFlux, simulate) / Settings.get.ratioRedstoneFlux).toInt
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package li.cil.oc.integration.ic2
|
||||
|
||||
import ic2.api.item.IElectricItemManager
|
||||
import li.cil.oc.Settings
|
||||
import li.cil.oc.api.driver.item.Chargeable
|
||||
import li.cil.oc.common.item.HoverBoots
|
||||
import li.cil.oc.common.item.data.HoverBootsData
|
||||
import net.minecraft.entity.EntityLivingBase
|
||||
import net.minecraft.item.ItemStack
|
||||
|
||||
object ElectricItemManager extends IElectricItemManager {
|
||||
override def getCharge(stack: ItemStack): Double = {
|
||||
if (stack == null) 0
|
||||
else stack.getItem match {
|
||||
// TODO in OC 1.6, add a getCharge method to Chargeable and use that instead.
|
||||
case hoverBoots: HoverBoots => new HoverBootsData(stack).charge
|
||||
case _ => 0
|
||||
}
|
||||
}
|
||||
|
||||
override def charge(stack: ItemStack, amount: Double, tier: Int, ignoreTransferLimit: Boolean, simulate: Boolean): Double = {
|
||||
if (stack == null) 0
|
||||
else stack.getItem match {
|
||||
case chargeable: Chargeable =>
|
||||
val limitedAmount = if (ignoreTransferLimit) math.min(Int.MaxValue, amount) else math.min(amount, Settings.get.chargeRateTablet)
|
||||
limitedAmount - chargeable.charge(stack, limitedAmount * Settings.get.ratioIndustrialCraft2, simulate) / Settings.get.ratioIndustrialCraft2
|
||||
case _ => 0
|
||||
}
|
||||
}
|
||||
|
||||
override def discharge(stack: ItemStack, amount: Double, tier: Int, ignoreTransferLimit: Boolean, externally: Boolean, simulate: Boolean): Double = {
|
||||
0.0 // TODO if we ever need it...
|
||||
}
|
||||
|
||||
override def chargeFromArmor(stack: ItemStack, entity: EntityLivingBase): Unit = {}
|
||||
|
||||
override def canUse(stack: ItemStack, amount: Double): Boolean = getCharge(stack) >= amount
|
||||
|
||||
override def use(stack: ItemStack, amount: Double, entity: EntityLivingBase): Boolean = canUse(stack, amount) && {
|
||||
false // TODO if we ever need it...
|
||||
}
|
||||
|
||||
override def getToolTip(stack: ItemStack): String = null
|
||||
}
|
@ -75,6 +75,7 @@ object ModOpenComputers extends ModProxy {
|
||||
MinecraftForge.EVENT_BUS.register(ExperienceUpgradeHandler)
|
||||
MinecraftForge.EVENT_BUS.register(FileSystemAccessHandler)
|
||||
MinecraftForge.EVENT_BUS.register(GeolyzerHandler)
|
||||
MinecraftForge.EVENT_BUS.register(HoverBootsHandler)
|
||||
MinecraftForge.EVENT_BUS.register(Loot)
|
||||
MinecraftForge.EVENT_BUS.register(RobotCommonHandler)
|
||||
MinecraftForge.EVENT_BUS.register(SaveHandler)
|
||||
|
Loading…
x
Reference in New Issue
Block a user