Removed use of a few remaining reflection thingers, since we have an oc_at.cfg now anyway.

This commit is contained in:
Florian Nücke 2015-04-21 11:36:23 +02:00
parent 61ff63257b
commit 8a31eba5c3
4 changed files with 8 additions and 13 deletions

View File

@ -2,4 +2,8 @@
public net.minecraft.client.gui.inventory.GuiContainer field_146999_f #xSize
public net.minecraft.client.gui.inventory.GuiContainer field_147000_g #ySize
public net.minecraft.client.gui.inventory.GuiContainer field_147003_i #guiLeft
public net.minecraft.client.gui.inventory.GuiContainer field_147009_r #guiTop
public net.minecraft.client.gui.inventory.GuiContainer field_147009_r #guiTop
public net.minecraft.block.BlockPistonBase func_150079_i(Lnet/minecraft/world/World;IIII)Z #tryExtend
public net.minecraft.tileentity.TileEntity field_145853_j #classToNameMap
public net.minecraft.client.audio.SoundManager field_148620_e #sndSystem
public net.minecraft.client.audio.SoundManager$SoundSystemStarterThread

View File

@ -12,7 +12,6 @@ import com.google.common.base.Charsets
import cpw.mods.fml.client.FMLClientHandler
import cpw.mods.fml.common.eventhandler.SubscribeEvent
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent
import cpw.mods.fml.relauncher.ReflectionHelper
import li.cil.oc.OpenComputers
import li.cil.oc.Settings
import net.minecraft.client.Minecraft
@ -25,7 +24,6 @@ import net.minecraft.tileentity.TileEntity
import net.minecraft.util.ResourceLocation
import net.minecraftforge.client.event.sound.SoundLoadEvent
import net.minecraftforge.event.world.WorldEvent
import paulscode.sound.SoundSystem
import paulscode.sound.SoundSystemConfig
import scala.collection.mutable
@ -51,7 +49,7 @@ object Sound {
// Set in init event.
var manager: SoundManager = _
def soundSystem: SoundSystem = ReflectionHelper.getPrivateValue(classOf[SoundManager], manager, "sndSystem", "field_148620_e", "e")
def soundSystem = manager.sndSystem
private def updateVolume() {
val volume =

View File

@ -1,6 +1,5 @@
package li.cil.oc.server.component
import cpw.mods.fml.relauncher.ReflectionHelper
import li.cil.oc.Settings
import li.cil.oc.api.Network
import li.cil.oc.api.driver.EnvironmentHost
@ -12,9 +11,7 @@ import li.cil.oc.api.network.Visibility
import li.cil.oc.api.prefab
import li.cil.oc.util.BlockPosition
import li.cil.oc.util.ExtendedWorld._
import net.minecraft.block.BlockPistonBase
import net.minecraft.init.Blocks
import net.minecraft.world.World
class UpgradePiston(val host: Rotatable with EnvironmentHost) extends prefab.ManagedEnvironment {
override val node = Network.newNode(this, Visibility.Network).
@ -22,13 +19,11 @@ class UpgradePiston(val host: Rotatable with EnvironmentHost) extends prefab.Man
withConnector().
create()
private lazy val tryExtend = ReflectionHelper.findMethod(classOf[BlockPistonBase], null, Array("tryExtend", "func_150079_i", "i"), classOf[World], classOf[Int], classOf[Int], classOf[Int], classOf[Int])
@Callback(doc = """function():boolean -- Tries to push the block in front of the container of the upgrade.""")
def push(context: Context, args: Arguments): Array[AnyRef] = {
val hostPos = BlockPosition(host)
val blockPos = hostPos.offset(host.facing)
if (!host.world.isAirBlock(blockPos) && node.tryChangeBuffer(-Settings.get.pistonCost) && tryExtend.invoke(Blocks.piston, host.world, int2Integer(hostPos.x), int2Integer(hostPos.y), int2Integer(hostPos.z), int2Integer(host.facing.ordinal)).asInstanceOf[Boolean]) {
if (!host.world.isAirBlock(blockPos) && node.tryChangeBuffer(-Settings.get.pistonCost) && Blocks.piston.tryExtend(host.world, hostPos.x, hostPos.y, hostPos.z, host.facing.ordinal)) {
host.world.setBlockToAir(blockPos)
host.world.playSoundEffect(host.xPosition, host.yPosition, host.zPosition, "tile.piston.out", 0.5f, host.world.rand.nextFloat() * 0.25f + 0.6f)
context.pause(0.5)

View File

@ -1,7 +1,6 @@
package li.cil.oc.server.driver
import com.google.common.base.Strings
import cpw.mods.fml.relauncher.ReflectionHelper
import li.cil.oc.api.driver
import li.cil.oc.api.driver.NamedBlock
import li.cil.oc.api.network.ManagedEnvironment
@ -59,8 +58,7 @@ class CompoundBlockDriver(val blocks: driver.Block*) extends driver.Block {
}
try world.getTileEntity(x, y, z) match {
case tileEntity: TileEntity =>
val map = ReflectionHelper.getPrivateValue[java.util.Map[Class[_], String], TileEntity](classOf[TileEntity], tileEntity, "classToNameMap", "field_145853_j")
return map.get(tileEntity.getClass)
return TileEntity.classToNameMap.get(tileEntity.getClass).asInstanceOf[String]
} catch {
case _: Throwable =>
}