mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-14 09:46:53 -04:00
Made Chamelium edible, closes #1001.
This commit is contained in:
parent
02b9c48603
commit
2ebced30eb
@ -1041,6 +1041,10 @@ opencomputers {
|
||||
# cost is multiplied with, so 1 is a full refund, 0 disables the
|
||||
# functionality (won't be able to put prints into the material input).
|
||||
printRecycleRate: 0.75
|
||||
|
||||
# Whether Chamelium is edible or not. When eaten, it gives a (short)
|
||||
# invisibility buff, and (slightly longer) blindness debuff.
|
||||
chameliumEdible: true
|
||||
}
|
||||
|
||||
# Settings for mod integration (the mod previously known as OpenComponents).
|
||||
|
@ -295,6 +295,7 @@ class Settings(val config: Config) {
|
||||
val threadPriority = config.getInt("misc.threadPriority")
|
||||
val maxPrintComplexity = config.getInt("misc.maxPrinterShapes")
|
||||
val printRecycleRate = config.getDouble("misc.printRecycleRate")
|
||||
val chameliumEdible = config.getBoolean("misc.chameliumEdible")
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
// integration
|
||||
|
@ -1,3 +1,32 @@
|
||||
package li.cil.oc.common.item
|
||||
|
||||
class Chamelium(val parent: Delegator) extends Delegate
|
||||
import li.cil.oc.Settings
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.item.EnumAction
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.potion.Potion
|
||||
import net.minecraft.potion.PotionEffect
|
||||
import net.minecraft.world.World
|
||||
|
||||
class Chamelium(val parent: Delegator) extends Delegate {
|
||||
override def onItemRightClick(stack: ItemStack, world: World, player: EntityPlayer): ItemStack = {
|
||||
if (Settings.get.chameliumEdible) {
|
||||
player.setItemInUse(stack, getMaxItemUseDuration(stack))
|
||||
}
|
||||
stack
|
||||
}
|
||||
|
||||
override def getItemUseAction(stack: ItemStack): EnumAction = EnumAction.eat
|
||||
|
||||
override def getMaxItemUseDuration(stack: ItemStack): Int = 32
|
||||
|
||||
override def onEaten(stack: ItemStack, world: World, player: EntityPlayer): ItemStack = {
|
||||
if (!world.isRemote) {
|
||||
player.addPotionEffect(new PotionEffect(Potion.invisibility.id, 100, 0))
|
||||
player.addPotionEffect(new PotionEffect(Potion.blindness.id, 200, 0))
|
||||
}
|
||||
stack.stackSize -= 1
|
||||
if (stack.stackSize > 0) stack
|
||||
else null
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ import li.cil.oc.util.Rarity
|
||||
import li.cil.oc.util.Tooltip
|
||||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.item.EnumAction
|
||||
import net.minecraft.item.ItemStack
|
||||
import net.minecraft.world.World
|
||||
|
||||
@ -55,8 +56,12 @@ trait Delegate {
|
||||
stack
|
||||
}
|
||||
|
||||
def getItemUseAction(stack: ItemStack): EnumAction = EnumAction.none
|
||||
|
||||
def getMaxItemUseDuration(stack: ItemStack) = 0
|
||||
|
||||
def onEaten(stack: ItemStack, world: World, player: EntityPlayer): ItemStack = stack
|
||||
|
||||
def onPlayerStoppedUsing(stack: ItemStack, player: EntityPlayer, duration: Int) {}
|
||||
|
||||
def update(stack: ItemStack, world: World, player: Entity, slot: Int, selected: Boolean) {}
|
||||
|
@ -14,6 +14,7 @@ import net.minecraft.client.renderer.texture.IIconRegister
|
||||
import net.minecraft.creativetab.CreativeTabs
|
||||
import net.minecraft.entity.Entity
|
||||
import net.minecraft.entity.player.EntityPlayer
|
||||
import net.minecraft.item.EnumAction
|
||||
import net.minecraft.item.EnumRarity
|
||||
import net.minecraft.item.Item
|
||||
import net.minecraft.item.ItemStack
|
||||
@ -124,6 +125,18 @@ class Delegator extends Item {
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
||||
override def onEaten(stack: ItemStack, world: World, player: EntityPlayer): ItemStack =
|
||||
subItem(stack) match {
|
||||
case Some(subItem) => subItem.onEaten(stack, world, player)
|
||||
case _ => super.onEaten(stack, world, player)
|
||||
}
|
||||
|
||||
override def getItemUseAction(stack: ItemStack): EnumAction =
|
||||
subItem(stack) match {
|
||||
case Some(subItem) => subItem.getItemUseAction(stack)
|
||||
case _ => super.getItemUseAction(stack)
|
||||
}
|
||||
|
||||
override def getMaxItemUseDuration(stack: ItemStack): Int =
|
||||
subItem(stack) match {
|
||||
case Some(subItem) => subItem.getMaxItemUseDuration(stack)
|
||||
|
Loading…
x
Reference in New Issue
Block a user