-
Notifications
You must be signed in to change notification settings - Fork 432
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
71a9abd
commit 362411c
Showing
7 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/scala/li/cil/oc/integration/enderio/EventHandlerEnderIO.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package li.cil.oc.integration.enderio | ||
|
||
import crazypants.enderio.api.tool.ITool | ||
import net.minecraft.entity.player.EntityPlayer | ||
import net.minecraft.item.ItemStack | ||
import net.minecraft.util.EnumHand | ||
import net.minecraft.util.math.BlockPos | ||
|
||
object EventHandlerEnderIO { | ||
def useWrench(player: EntityPlayer, pos: BlockPos, changeDurability: Boolean): Boolean = { | ||
player.getHeldItemMainhand.getItem match { | ||
case wrench: ITool => | ||
if (changeDurability) { | ||
wrench.used(EnumHand.MAIN_HAND, player, pos) | ||
true | ||
} | ||
else wrench.canUse(EnumHand.MAIN_HAND, player, pos) | ||
case _ => false | ||
} | ||
} | ||
|
||
def isWrench(stack: ItemStack): Boolean = stack.getItem.isInstanceOf[ITool] | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/scala/li/cil/oc/integration/enderio/ModEnderIO.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package li.cil.oc.integration.enderio | ||
|
||
import li.cil.oc.api | ||
import li.cil.oc.integration.ModProxy | ||
import li.cil.oc.integration.Mods | ||
|
||
object ModEnderIO extends ModProxy { | ||
override def getMod = Mods.EnderIO | ||
|
||
override def initialize(): Unit = { | ||
api.IMC.registerWrenchTool("li.cil.oc.integration.enderio.EventHandlerEnderIO.useWrench") | ||
api.IMC.registerWrenchToolCheck("li.cil.oc.integration.enderio.EventHandlerEnderIO.isWrench") | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
src/main/scala/li/cil/oc/integration/railcraft/DriverWorldspike.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package li.cil.oc.integration.railcraft | ||
|
||
|
||
import li.cil.oc.api.driver.NamedBlock | ||
import li.cil.oc.api.machine.{Arguments, Callback, Context} | ||
import li.cil.oc.api.network.ManagedEnvironment | ||
import li.cil.oc.api.prefab.DriverSidedTileEntity | ||
import li.cil.oc.integration.ManagedTileEntityEnvironment | ||
import li.cil.oc.util.ResultWrapper.result | ||
import mods.railcraft.common.blocks.machine.worldspike.{TileWorldspike, WorldspikeVariant} | ||
import net.minecraft.util.EnumFacing | ||
import net.minecraft.util.math.BlockPos | ||
import net.minecraft.world.World | ||
|
||
import java.util.Objects | ||
|
||
object DriverWorldspike extends DriverSidedTileEntity { | ||
def getTileEntityClass: Class[_] = classOf[TileWorldspike] | ||
|
||
def createEnvironment(world: World, pos: BlockPos, side: EnumFacing): ManagedEnvironment = | ||
new Environment(world.getTileEntity(pos).asInstanceOf[TileWorldspike]) | ||
|
||
final class Environment(val tile: TileWorldspike) extends ManagedTileEntityEnvironment[TileWorldspike](tile, "worldspike") with NamedBlock { | ||
override def preferredName = "worldspike" | ||
override def priority = 5 | ||
|
||
@Callback(doc = "function():int -- Get the amount of fuel.") | ||
def getFuel(context: Context, args: Arguments): Array[AnyRef] = result(tile.getFuelAmount) | ||
|
||
@Callback(doc = "function():string -- Get the anchor owner name.") | ||
def getOwner(context: Context, args: Arguments): Array[AnyRef] = | ||
if (tile.getOwner == null || tile.getOwner.getName == null || Objects.equals(tile.getOwner.getName, "[unknown]")) | ||
result() | ||
else | ||
result(tile.getOwner.getName) | ||
|
||
@Callback(doc = "function():string -- Get the anchor type.") | ||
def getType(context: Context, args: Arguments): Array[AnyRef] = tile.getMachineType match { | ||
case WorldspikeVariant.STANDARD => result("world") | ||
case WorldspikeVariant.ADMIN => result("admin") | ||
case WorldspikeVariant.PERSONAL => result("personal") | ||
case WorldspikeVariant.PASSIVE => result("passive") | ||
case _ => result("missing") | ||
} | ||
|
||
@Callback(doc = "function():table -- Get the anchor fuel slot's contents.") | ||
def getFuelSlotContents(context: Context, args: Arguments): Array[AnyRef] = { | ||
if (tile.needsFuel()) | ||
result(tile.getStackInSlot(0)) | ||
else | ||
result() | ||
} | ||
|
||
@Callback(doc = "function():boolean -- If the anchor is disabled (powered by redstone).") | ||
def isDisabled(context: Context, args: Arguments): Array[AnyRef] = result(tile.isPowered) | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/scala/li/cil/oc/integration/railcraft/EventHandlerRailcraft.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package li.cil.oc.integration.railcraft | ||
|
||
import mods.railcraft.api.items.IToolCrowbar | ||
import net.minecraft.entity.player.EntityPlayer | ||
import net.minecraft.item.ItemStack | ||
import net.minecraft.util.EnumHand | ||
import net.minecraft.util.math.BlockPos | ||
|
||
object EventHandlerRailcraft { | ||
def useWrench(player: EntityPlayer, pos: BlockPos, changeDurability: Boolean): Boolean = { | ||
player.getHeldItemMainhand.getItem match { | ||
case wrench: IToolCrowbar => | ||
if (changeDurability) { | ||
wrench.onWhack(player, EnumHand.MAIN_HAND, player.getHeldItemMainhand, pos) | ||
true | ||
} | ||
else wrench.canWhack(player, EnumHand.MAIN_HAND, player.getHeldItemMainhand, pos) | ||
case _ => false | ||
} | ||
} | ||
|
||
def isWrench(stack: ItemStack): Boolean = stack.getItem.isInstanceOf[IToolCrowbar] | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/scala/li/cil/oc/integration/railcraft/ModRailcraft.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package li.cil.oc.integration.railcraft | ||
|
||
import li.cil.oc.api | ||
import li.cil.oc.api.Driver | ||
import li.cil.oc.integration.ModProxy | ||
import li.cil.oc.integration.Mods | ||
|
||
object ModRailcraft extends ModProxy { | ||
override def getMod = Mods.Railcraft | ||
|
||
override def initialize() { | ||
api.IMC.registerWrenchTool("li.cil.oc.integration.railcraft.EventHandlerRailcraft.useWrench") | ||
api.IMC.registerWrenchToolCheck("li.cil.oc.integration.railcraft.EventHandlerRailcraft.isWrench") | ||
|
||
Driver.add(DriverWorldspike) | ||
} | ||
} |