Merge branch 'master' of github.com:MightyPirates/OpenComputers into MC1.7

Conflicts:
	src/main/scala/li/cil/oc/server/component/robot/Player.scala
	src/main/scala/li/cil/oc/server/component/robot/Robot.scala
This commit is contained in:
Florian Nücke 2014-03-20 22:23:14 +01:00
commit 6c3a883624
3 changed files with 24 additions and 12 deletions

View File

@ -1,6 +1,8 @@
# Do not change this file, it is rewritten each time you start the game.
# Instead, use the user.recipes file to edit recipes by redefining them there.
include file("default.recipes")
analyzer {
input: [["", torchRedstoneActive, ""]
["oc:craftingTransistor", "oc:circuitTier1", nuggetGold]

View File

@ -1,13 +1,12 @@
package li.cil.oc.server.component.robot
import cpw.mods.fml.common.Loader
import com.mojang.authlib.GameProfile
import cpw.mods.fml.common.eventhandler.Event
import cpw.mods.fml.common.Loader
import li.cil.oc.common.tileentity
import li.cil.oc.Settings
import li.cil.oc.util.mods.{UniversalElectricity, TinkersConstruct, PortalGun}
import net.minecraft.block.{BlockPistonBase, Block}
import net.minecraft.enchantment.EnchantmentHelper
import net.minecraft.entity.item.EntityItem
import net.minecraft.entity.player.EntityPlayer
import net.minecraft.entity.player.EntityPlayer.EnumStatus
@ -19,9 +18,11 @@ import net.minecraft.server.MinecraftServer
import net.minecraft.util._
import net.minecraft.world.World
import net.minecraftforge.common.ForgeHooks
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action
import net.minecraftforge.event.ForgeEventFactory
import net.minecraftforge.event.world.BlockEvent
import net.minecraftforge.fluids.FluidRegistry
import scala.collection.convert.WrapAsScala._
import scala.reflect._
@ -197,7 +198,7 @@ class Player(val robot: tileentity.Robot) extends EntityPlayer(robot.world, Play
def placeBlock(slot: Int, x: Int, y: Int, z: Int, side: Int, hitX: Float, hitY: Float, hitZ: Float): Boolean = {
callUsingItemInSlot(slot, stack => {
val event = ForgeEventFactory.onPlayerInteract(this, Action.RIGHT_CLICK_BLOCK, x, y, z, side)
if (event.isCanceled || event.useBlock == Event.Result.DENY) {
if (event.isCanceled || event.useBlock == Event.Result.DENY || event.useItem == Event.Result.DENY) {
return false
}
@ -208,7 +209,7 @@ class Player(val robot: tileentity.Robot) extends EntityPlayer(robot.world, Play
def clickBlock(x: Int, y: Int, z: Int, side: Int): Double = {
callUsingItemInSlot(0, stack => {
val event = ForgeEventFactory.onPlayerInteract(this, Action.LEFT_CLICK_BLOCK, x, y, z, side)
if (event.isCanceled) {
if (event.isCanceled || event.useBlock == Event.Result.DENY || event.useItem == Event.Result.DENY) {
return 0
}
@ -219,7 +220,7 @@ class Player(val robot: tileentity.Robot) extends EntityPlayer(robot.world, Play
val block = world.getBlock(x, y, z)
val metadata = world.getBlockMetadata(x, y, z)
val mayClickBlock = event.useBlock != Event.Result.DENY && block != null
val mayClickBlock = block != null
val canClickBlock = mayClickBlock &&
!block.isAir(world, x, y, z) &&
FluidRegistry.lookupFluidForBlock(block) == null
@ -227,6 +228,12 @@ class Player(val robot: tileentity.Robot) extends EntityPlayer(robot.world, Play
return 0
}
val breakEvent = new BlockEvent.BreakEvent(x, y, z, world, block, metadata, this)
MinecraftForge.EVENT_BUS.post(breakEvent)
if (breakEvent.isCanceled) {
return 0
}
block.onBlockClicked(world, x, y, z, this)
world.extinguishFire(this, x, y, z, side)
@ -284,11 +291,7 @@ class Player(val robot: tileentity.Robot) extends EntityPlayer(robot.world, Play
// check only serves to test whether the block can drop anything at all.
if (block.canHarvestBlock(this, metadata)) {
block.harvestBlock(world, this, x, y, z, metadata)
if (!EnchantmentHelper.getSilkTouchModifier(this)) {
val fortune = EnchantmentHelper.getFortuneModifier(this)
val xp = block.getExpDrop(world, metadata, fortune)
robot.addXp(xp * Settings.get.robotOreXpRate)
}
robot.addXp(breakEvent.getExpToDrop * Settings.get.robotOreXpRate)
}
if (stack != null) {
robot.addXp(Settings.get.robotActionXp)

View File

@ -16,7 +16,9 @@ import net.minecraft.nbt.NBTTagCompound
import net.minecraft.tileentity.TileEntityChest
import net.minecraft.util.MovingObjectPosition
import net.minecraft.util.MovingObjectPosition.MovingObjectType
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.common.util.ForgeDirection
import net.minecraftforge.event.world.BlockEvent
import net.minecraftforge.fluids.FluidRegistry
import scala.collection.convert.WrapAsScala._
@ -590,14 +592,19 @@ class Robot(val robot: tileentity.Robot) extends ManagedComponent {
case _ =>
val (bx, by, bz) = (x + side.offsetX, y + side.offsetY, z + side.offsetZ)
val block = world.getBlock(bx, by, bz)
val metadata = world.getBlockMetadata(bx, by, bz)
if (block == null || block.isAir(world, bx, by, bz)) {
(false, "air")
}
else if (FluidRegistry.lookupFluidForBlock(block) != null) {
(false, "liquid")
val event = new BlockEvent.BreakEvent(bx, by, bz, world, block, metadata, player)
MinecraftForge.EVENT_BUS.post(event)
(event.isCanceled, "liquid")
}
else if (block.isReplaceable(world, bx, by, bz)) {
(false, "replaceable")
val event = new BlockEvent.BreakEvent(bx, by, bz, world, block, metadata, player)
MinecraftForge.EVENT_BUS.post(event)
(event.isCanceled, "replaceable")
}
else {
(true, "solid")