From 42680199357ab82c4e94ee3e7594d9dcefbe4f8c Mon Sep 17 00:00:00 2001 From: bdew Date: Mon, 10 Feb 2014 14:14:06 +0200 Subject: [PATCH] Initial port to MC 1.7.2 --- build.gradle | 15 +++- src/net/bdew/lib/BdLib.scala | 10 ++- src/net/bdew/lib/Misc.scala | 10 ++- src/net/bdew/lib/block/HasTE.scala | 8 +- src/net/bdew/lib/config/BlockManager.scala | 4 +- src/net/bdew/lib/config/FluidManager.scala | 2 +- src/net/bdew/lib/config/IdManager.scala | 46 ------------ src/net/bdew/lib/config/ItemManager.scala | 6 +- src/net/bdew/lib/config/MachineManager.scala | 4 +- src/net/bdew/lib/data/DataSlotDirection.scala | 2 +- src/net/bdew/lib/data/DataSlotItemStack.scala | 2 +- src/net/bdew/lib/data/DataSlotTank.scala | 2 +- .../lib/data/base/ContainerDataSlots.scala | 6 +- .../bdew/lib/data/base/TileDataSlots.scala | 17 +++-- src/net/bdew/lib/gui/BaseScreen.scala | 5 +- src/net/bdew/lib/gui/GuiHandler.scala | 4 +- src/net/bdew/lib/gui/WidgetContainer.scala | 6 +- .../bdew/lib/gui/widgets/WidgetButton.scala | 4 +- .../lib/gui/widgets/WidgetSubcontainer.scala | 4 +- src/net/bdew/lib/items/ItemUtils.scala | 6 +- src/net/bdew/lib/items/SimpleItem.scala | 6 +- src/net/bdew/lib/machine/Machine.scala | 7 +- src/net/bdew/lib/power/DataSlotPower.scala | 2 +- src/net/bdew/lib/recipes/RecipeLoader.scala | 75 ++++++++----------- .../recipes/gencfg/GenericConfigLoader.scala | 5 +- .../bdew/lib/rotate/BaseRotateableBlock.scala | 13 ++-- src/net/bdew/lib/rotate/IconType.scala | 2 +- .../bdew/lib/rotate/RotateableTileBlock.scala | 8 +- src/net/bdew/lib/tile/ExposeTank.scala | 2 +- src/net/bdew/lib/tile/TileExtended.scala | 16 ++-- .../lib/tile/inventory/BaseInventory.scala | 8 +- .../inventory/BreakableInventoryBlock.scala | 6 +- .../inventory/BreakableInventoryTile.scala | 4 +- .../inventory/PersistentInventoryTile.scala | 2 +- 34 files changed, 141 insertions(+), 178 deletions(-) delete mode 100644 src/net/bdew/lib/config/IdManager.scala diff --git a/build.gradle b/build.gradle index 0a025ee..e7cb657 100644 --- a/build.gradle +++ b/build.gradle @@ -1,20 +1,27 @@ buildscript { + configurations.all { + resolutionStrategy.cacheChangingModulesFor 0, 'seconds' + } repositories { mavenCentral() maven { name = "forge" url = "http://files.minecraftforge.net/maven" } + maven { + name = "sonatype" + url = "https://oss.sonatype.org/content/repositories/snapshots/" + } } dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:1.0-SNAPSHOT' + classpath 'net.minecraftforge.gradle:ForgeGradle:1.1-SNAPSHOT' } } apply plugin: 'forge' apply plugin: 'scala' -version = "1.2.0" +version = "2.0.0" if (project.hasProperty('buildnum')) { project.version = project.version + '.' + project.buildnum @@ -24,10 +31,10 @@ if (project.hasProperty('buildnum')) { group = "net.bdew" archivesBaseName = "bdlib" -ext.versuffix = "mc164" +ext.versuffix = "mc172" minecraft { - version = "1.6.4-9.11.1.964" + version = "1.7.2-10.12.0.1024" replace("BDLIB_VER", project.version) } diff --git a/src/net/bdew/lib/BdLib.scala b/src/net/bdew/lib/BdLib.scala index c186165..8483d65 100644 --- a/src/net/bdew/lib/BdLib.scala +++ b/src/net/bdew/lib/BdLib.scala @@ -11,10 +11,18 @@ package net.bdew.lib import cpw.mods.fml.common.Mod import cpw.mods.fml.common.event.FMLPreInitializationEvent +import org.apache.logging.log4j.Logger @Mod(modid = "bdlib", name = "BD lib", version = "BDLIB_VER", modLanguage = "scala") object BdLib { + var log: Logger = null + + def logInfo(msg: String, args: Any*) = log.info(msg.format(args: _*)) + def logWarn(msg: String, args: Any*) = log.warn(msg.format(args: _*)) + def logError(msg: String, args: Any*) = log.error(msg.format(args: _*)) + def preInit(ev: FMLPreInitializationEvent) { - ev.getModLog.info("bdlib BDLIB_VER loaded") + log = ev.getModLog + log.info("bdlib BDLIB_VER loaded") } } diff --git a/src/net/bdew/lib/Misc.scala b/src/net/bdew/lib/Misc.scala index a9a3a66..1c34475 100644 --- a/src/net/bdew/lib/Misc.scala +++ b/src/net/bdew/lib/Misc.scala @@ -10,7 +10,7 @@ package net.bdew.lib import cpw.mods.fml.common.registry.GameRegistry -import net.minecraft.nbt.{NBTTagCompound, NBTTagList} +import net.minecraft.nbt.NBTTagCompound import net.minecraft.util.StatCollector import net.minecraft.item.ItemStack import cpw.mods.fml.common.versioning.{ArtifactVersion, VersionParser} @@ -18,8 +18,10 @@ import cpw.mods.fml.common.Loader import net.minecraftforge.oredict.ShapedOreRecipe object Misc { - def iterNbtList[X](list: NBTTagList) = - for (i <- 0 until list.tagCount()) yield list.tagAt(i).asInstanceOf[X] + def iterNbtCompoundList(parent: NBTTagCompound, name: String): Iterable[NBTTagCompound] = { + val list = parent.getTagList(name, 10) + for (i <- 0 until list.tagCount()) yield list.getCompoundTagAt(i) + } def getActiveModId = Loader.instance().activeModContainer().getModId @@ -34,7 +36,7 @@ object Misc { def wrapTag(n: String, f: (NBTTagCompound) => Any)(t: NBTTagCompound) { val p = t.getCompoundTag(n) f(p) - t.setCompoundTag(n, p) + t.setTag(n, p) } def addRecipe(result: ItemStack, pattern: Seq[String], items: Map[Char, AnyRef]) = diff --git a/src/net/bdew/lib/block/HasTE.scala b/src/net/bdew/lib/block/HasTE.scala index 34d9aa8..caa844c 100644 --- a/src/net/bdew/lib/block/HasTE.scala +++ b/src/net/bdew/lib/block/HasTE.scala @@ -12,19 +12,19 @@ package net.bdew.lib.block import net.minecraft.block.{ITileEntityProvider, Block} import net.minecraft.world.{IBlockAccess, World} import net.minecraft.tileentity.TileEntity -import cpw.mods.fml.common.FMLCommonHandler +import net.bdew.lib.BdLib trait HasTE[T] extends Block with ITileEntityProvider { val TEClass: Class[_ <: TileEntity] def createNewTileEntity(world: World): TileEntity = TEClass.newInstance() def getTE(w: IBlockAccess, x: Int, y: Int, z: Int): T = { - var t = w.getBlockTileEntity(x, y, z) + var t = w.getTileEntity(x, y, z) if ((t == null) || !TEClass.isInstance(t)) { - FMLCommonHandler.instance().getFMLLogger.severe("Tile entity for block %s at (%d,%d,%d) is corrupt or missing - recreating".format(this, x, y, z)) + BdLib.logError("Tile entity for block %s at (%d,%d,%d) is corrupt or missing - recreating", this, x, y, z) w match { case ww: World => t = createNewTileEntity(ww) - ww.setBlockTileEntity(x, y, z, t) + ww.setTileEntity(x, y, z, t) case _ => sys.error("Unable to recreate TE") } diff --git a/src/net/bdew/lib/config/BlockManager.scala b/src/net/bdew/lib/config/BlockManager.scala index aa3e05d..24d022a 100644 --- a/src/net/bdew/lib/config/BlockManager.scala +++ b/src/net/bdew/lib/config/BlockManager.scala @@ -14,10 +14,10 @@ import net.minecraft.block.Block import cpw.mods.fml.common.registry.GameRegistry import net.bdew.lib.block.HasTE -class BlockManager(val ids: IdManager) { +class BlockManager() { def regBlockCls[T <: Block](blockCls: Class[T], name: String, addStack: Boolean = true): T = { - val block = blockCls.getConstructor(classOf[Int]).newInstance(ids.getBlockId(name): Integer) + val block = blockCls.getConstructor(classOf[Int]).newInstance() regBlock[T](block, name, addStack) } diff --git a/src/net/bdew/lib/config/FluidManager.scala b/src/net/bdew/lib/config/FluidManager.scala index 6ccb8ad..7a6d671 100644 --- a/src/net/bdew/lib/config/FluidManager.scala +++ b/src/net/bdew/lib/config/FluidManager.scala @@ -11,7 +11,7 @@ package net.bdew.lib.config import net.minecraftforge.fluids.{FluidRegistry, Fluid} -class FluidManager(val ids: IdManager) { +class FluidManager() { def regFluid[T <: Fluid](fluid: T): T = { FluidRegistry.registerFluid(fluid) return fluid diff --git a/src/net/bdew/lib/config/IdManager.scala b/src/net/bdew/lib/config/IdManager.scala deleted file mode 100644 index 671c33a..0000000 --- a/src/net/bdew/lib/config/IdManager.scala +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) bdew, 2013 - 2014 - * https://github.com/bdew/bdlib - * - * This mod is distributed under the terms of the Minecraft Mod Public - * License 1.0, or MMPL. Please check the contents of the license located in - * https://raw.github.com/bdew/bdlib/master/MMPL-1.0.txt - */ - -package net.bdew.lib.config - -import net.minecraft.block.Block -import net.minecraft.item.Item -import net.minecraftforge.common.Configuration - -class IdManager(cfg: Configuration, itemStart: Int, blockStart: Int) { - - class MyIter(start: Int, check: Array[_], offset: Int = 0) { - var now = start - def next(): Int = { - while (check(now + offset) != null) now += 1 - return now - } - } - - def getBlockId(name: String, comment: String) = cfg.getBlock(name, blockIds.next(), comment).getInt - def getBlockId(name: String) = cfg.getBlock(name, blockIds.next()).getInt - - def getItemId(name: String, comment: String) = cfg.getItem(name, itemIds.next(), comment).getInt - def getItemId(name: String) = cfg.getItem(name, itemIds.next()).getInt - - val blockIds = new MyIter(blockStart, Block.blocksList) - val itemIds = new MyIter(itemStart, Item.itemsList, 256) - - // figure out what's the max id we already use, because forge is stupid - // ignore ids in the top slots as they were probably assigned to resolve conflicts - - import scala.collection.JavaConverters._ - - val maxBlock = (cfg.getCategory(Configuration.CATEGORY_BLOCK).values().asScala.map(_.getInt).filter(_ < Block.blocksList.length - 100) ++ Seq(0)).max + 1 - val maxItem = (cfg.getCategory(Configuration.CATEGORY_ITEM).values().asScala.map(_.getInt).filter(_ < Item.itemsList.length - 1000) ++ Seq(0)).max + 1 - - if (maxBlock > blockIds.now) blockIds.now = maxBlock - if (maxItem > itemIds.now) itemIds.now = maxItem -} - diff --git a/src/net/bdew/lib/config/ItemManager.scala b/src/net/bdew/lib/config/ItemManager.scala index 3a984f4..14db44a 100644 --- a/src/net/bdew/lib/config/ItemManager.scala +++ b/src/net/bdew/lib/config/ItemManager.scala @@ -13,13 +13,13 @@ import net.minecraft.item.{ItemStack, Item} import cpw.mods.fml.common.registry.GameRegistry import net.bdew.lib.items.SimpleItem -class ItemManager(val ids: IdManager) { - def regSimpleItem(name: String): SimpleItem = regItem(new SimpleItem(ids.getItemId(name), name), name) +class ItemManager() { + def regSimpleItem(name: String): SimpleItem = regItem(new SimpleItem(name), name) def regItem[T <: SimpleItem](item: T): T = regItem[T](item, item.name) def regItemCls[T <: Item](itemCls: Class[T], name: String, addStack: Boolean = true): T = { - val item = itemCls.getConstructor(classOf[Int]).newInstance(ids.getItemId(name): Integer) + val item = itemCls.getConstructor(classOf[Int]).newInstance() regItem[T](item, name, addStack) } diff --git a/src/net/bdew/lib/config/MachineManager.scala b/src/net/bdew/lib/config/MachineManager.scala index a439a73..1bad32d 100644 --- a/src/net/bdew/lib/config/MachineManager.scala +++ b/src/net/bdew/lib/config/MachineManager.scala @@ -13,12 +13,12 @@ import net.bdew.lib.recipes.gencfg.ConfigSection import net.bdew.lib.machine.Machine import net.bdew.lib.gui.{GuiProvider, GuiHandler} -class MachineManager(ids: IdManager, val tuning: ConfigSection, guiHandler: GuiHandler) { +class MachineManager(val tuning: ConfigSection, guiHandler: GuiHandler) { def registerMachine[R <: Machine[_]](machine: R): R = { machine.tuning = tuning.getSection(machine.name) if (machine.tuning.getBoolean("Enabled")) { machine.enabled = true - machine.regBlock(ids) + machine.regBlock() if (machine.isInstanceOf[GuiProvider]) guiHandler.register(machine.asInstanceOf[GuiProvider]) } diff --git a/src/net/bdew/lib/data/DataSlotDirection.scala b/src/net/bdew/lib/data/DataSlotDirection.scala index 4afd022..5c7bb2e 100644 --- a/src/net/bdew/lib/data/DataSlotDirection.scala +++ b/src/net/bdew/lib/data/DataSlotDirection.scala @@ -10,8 +10,8 @@ package net.bdew.lib.data import net.bdew.lib.data.base.{TileDataSlots, UpdateKind, DataSlotVal} -import net.minecraftforge.common.ForgeDirection import net.minecraft.nbt.NBTTagCompound +import net.minecraftforge.common.util.ForgeDirection case class DataSlotDirection(name: String, parent: TileDataSlots) extends DataSlotVal[ForgeDirection] { var cval = ForgeDirection.UP diff --git a/src/net/bdew/lib/data/DataSlotItemStack.scala b/src/net/bdew/lib/data/DataSlotItemStack.scala index 49d809e..da61284 100644 --- a/src/net/bdew/lib/data/DataSlotItemStack.scala +++ b/src/net/bdew/lib/data/DataSlotItemStack.scala @@ -26,7 +26,7 @@ case class DataSlotItemStack(name: String, parent: TileDataSlots) extends DataSl def save(t: NBTTagCompound, kind: UpdateKind.Value) = { val tag = new NBTTagCompound() if (cval != null) cval.writeToNBT(tag) - t.setCompoundTag(name, tag) + t.setTag(name, tag) } def load(t: NBTTagCompound, kind: UpdateKind.Value) = cval = ItemStack.loadItemStackFromNBT(t.getCompoundTag(name)) } diff --git a/src/net/bdew/lib/data/DataSlotTank.scala b/src/net/bdew/lib/data/DataSlotTank.scala index ee928f2..048247d 100644 --- a/src/net/bdew/lib/data/DataSlotTank.scala +++ b/src/net/bdew/lib/data/DataSlotTank.scala @@ -38,7 +38,7 @@ abstract class DataSlotTankBase(sz: Int) extends FluidTank(sz) with IFluidTank w writeToNBT(tag) if (k == UpdateKind.GUI) tag.setInteger("size", getCapacity) - t.setCompoundTag(name, tag) + t.setTag(name, tag) } def load(t: NBTTagCompound, k: UpdateKind.Value) { diff --git a/src/net/bdew/lib/data/base/ContainerDataSlots.scala b/src/net/bdew/lib/data/base/ContainerDataSlots.scala index a9aa2f5..6ea2aef 100644 --- a/src/net/bdew/lib/data/base/ContainerDataSlots.scala +++ b/src/net/bdew/lib/data/base/ContainerDataSlots.scala @@ -21,19 +21,19 @@ trait ContainerDataSlots extends NoInvContainer { super.addCraftingToCrafters(crafter) if (crafter.isInstanceOf[EntityPlayerMP]) { val pkt = dataSource.getDataSlotPacket - crafter.asInstanceOf[EntityPlayerMP].playerNetServerHandler.sendPacketToPlayer(pkt) + crafter.asInstanceOf[EntityPlayerMP].playerNetServerHandler.sendPacket(pkt) } } override def detectAndSendChanges() { super.detectAndSendChanges() // only send updates every 10 ticks - if (dataSource.lastChange >= lastSentChange + 10 || (dataSource.lastChange > lastSentChange && lastSentChange + 10 < dataSource.worldObj.getTotalWorldTime)) { + if (dataSource.lastChange >= lastSentChange + 10 || (dataSource.lastChange > lastSentChange && lastSentChange + 10 < dataSource.getWorldObj.getTotalWorldTime)) { lastSentChange = dataSource.lastChange val pkt = dataSource.getDataSlotPacket for (player <- players) - player.playerNetServerHandler.sendPacketToPlayer(pkt) + player.playerNetServerHandler.sendPacket(pkt) } } } diff --git a/src/net/bdew/lib/data/base/TileDataSlots.scala b/src/net/bdew/lib/data/base/TileDataSlots.scala index fa4667c..21e923e 100644 --- a/src/net/bdew/lib/data/base/TileDataSlots.scala +++ b/src/net/bdew/lib/data/base/TileDataSlots.scala @@ -9,10 +9,11 @@ package net.bdew.lib.data.base -import net.minecraft.network.packet.Packet132TileEntityData import scala.collection.mutable import net.minecraft.nbt.NBTTagCompound import net.bdew.lib.tile.TileExtended +import net.minecraft.network.play.server.S35PacketUpdateTileEntity +import net.minecraft.network.Packet trait TileDataSlots extends TileExtended { val dataSlots = mutable.HashMap.empty[String, DataSlot] @@ -32,7 +33,7 @@ trait TileDataSlots extends TileExtended { if (TRACE) printf("%s: %s L<= %s\n".format(kind, n, t.getTag(n))) s.load(t, kind) if (kind == UpdateKind.WORLD && s.updateKind.contains(UpdateKind.RENDER)) - worldObj.markBlockForRenderUpdate(xCoord, yCoord, zCoord) + getWorldObj.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord) } } @@ -42,20 +43,20 @@ trait TileDataSlots extends TileExtended { handleClientUpdate.listen(doLoad(UpdateKind.WORLD, _)) def dataSlotChanged(slot: DataSlot) { - if (worldObj != null) { + if (getWorldObj != null) { if (slot.updateKind.contains(UpdateKind.GUI)) - lastChange = worldObj.getTotalWorldTime + lastChange = getWorldObj.getTotalWorldTime if (slot.updateKind.contains(UpdateKind.WORLD)) - worldObj.markBlockForUpdate(xCoord, yCoord, zCoord) + getWorldObj.markBlockForUpdate(xCoord, yCoord, zCoord) if (slot.updateKind.contains(UpdateKind.SAVE)) - worldObj.markTileEntityChunkModified(xCoord, yCoord, zCoord, this) + getWorldObj.markTileEntityChunkModified(xCoord, yCoord, zCoord, this) } } - def getDataSlotPacket: Packet132TileEntityData = { + def getDataSlotPacket: Packet = { val tag = new NBTTagCompound() doSave(UpdateKind.GUI, tag) - return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, ACT_GUI, tag) + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, ACT_GUI, tag) } override protected def extDataPacket(id: Int, data: NBTTagCompound) { diff --git a/src/net/bdew/lib/gui/BaseScreen.scala b/src/net/bdew/lib/gui/BaseScreen.scala index adb6485..43038bf 100644 --- a/src/net/bdew/lib/gui/BaseScreen.scala +++ b/src/net/bdew/lib/gui/BaseScreen.scala @@ -14,6 +14,7 @@ import net.minecraft.inventory.Container import scala.collection.mutable import net.minecraft.util.ResourceLocation import org.lwjgl.opengl.GL11 +import net.minecraft.client.Minecraft abstract class BaseScreen(cont: Container, xSz: Int, ySz: Int) extends GuiContainer(cont) { xSize = xSz @@ -25,7 +26,7 @@ abstract class BaseScreen(cont: Container, xSz: Int, ySz: Int) extends GuiContai def rect = new Rect(guiLeft, guiTop, xSize, ySize) - def getFontRenderer = fontRenderer + def getFontRenderer = Minecraft.getMinecraft.fontRenderer def getZLevel = zLevel override def initGui() { @@ -56,7 +57,7 @@ abstract class BaseScreen(cont: Container, xSz: Int, ySz: Int) extends GuiContai import collection.JavaConversions._ if (tip.size > 0) - drawHoveringText(tip, x, y, fontRenderer) + drawHoveringText(tip, x, y, getFontRenderer) } protected def drawGuiContainerBackgroundLayer(f: Float, i: Int, j: Int) { diff --git a/src/net/bdew/lib/gui/GuiHandler.scala b/src/net/bdew/lib/gui/GuiHandler.scala index 290aeff..c6b8326 100644 --- a/src/net/bdew/lib/gui/GuiHandler.scala +++ b/src/net/bdew/lib/gui/GuiHandler.scala @@ -24,8 +24,8 @@ class GuiHandler extends IGuiHandler { } def getServerGuiElement(ID: Int, player: EntityPlayer, world: World, x: Int, y: Int, z: Int): AnyRef = - guis(ID).getContainer(world.getBlockTileEntity(x, y, z), player) + guis(ID).getContainer(world.getTileEntity(x, y, z), player) def getClientGuiElement(ID: Int, player: EntityPlayer, world: World, x: Int, y: Int, z: Int): AnyRef = - guis(ID).getGui(world.getBlockTileEntity(x, y, z), player) + guis(ID).getGui(world.getTileEntity(x, y, z), player) } diff --git a/src/net/bdew/lib/gui/WidgetContainer.scala b/src/net/bdew/lib/gui/WidgetContainer.scala index fa5f34c..0a8e1a3 100644 --- a/src/net/bdew/lib/gui/WidgetContainer.scala +++ b/src/net/bdew/lib/gui/WidgetContainer.scala @@ -11,11 +11,11 @@ package net.bdew.lib.gui import scala.collection.mutable import net.bdew.lib.gui.widgets.BaseWidget -import net.minecraft.util.Icon import net.minecraft.client.gui.FontRenderer import net.minecraft.client.Minecraft import org.lwjgl.opengl.GL11 import net.minecraft.client.renderer.Tessellator +import net.minecraft.util.IIcon trait WidgetContainer { val rect: Rect @@ -76,7 +76,7 @@ trait WidgetContainer { def getOffsetFromWindow: Point def drawTexture(r: Rect, uv: Point, color: Color = Color.white): Unit - def drawIcon(r: Rect, i: Icon, color: Color = Color.white) + def drawIcon(r: Rect, i: IIcon, color: Color = Color.white) def drawTextureScaled(r: Rect, t: TextureLocationScaled, color: Color = Color.white) } @@ -110,7 +110,7 @@ class WidgetContainerWindow(val parent: BaseScreen, xSz: Int, ySz: Int) extends parent.drawTexturedModalRect(r.x, r.y, uv.x, uv.y, r.w, r.h) } - def drawIcon(r: Rect, i: Icon, color: Color = Color.white) { + def drawIcon(r: Rect, i: IIcon, color: Color = Color.white) { color.activate() parent.drawTexturedModelRectFromIcon(r.x, r.y, i, r.w, r.h) } diff --git a/src/net/bdew/lib/gui/widgets/WidgetButton.scala b/src/net/bdew/lib/gui/widgets/WidgetButton.scala index 94e2d49..e10ed28 100644 --- a/src/net/bdew/lib/gui/widgets/WidgetButton.scala +++ b/src/net/bdew/lib/gui/widgets/WidgetButton.scala @@ -12,12 +12,14 @@ package net.bdew.lib.gui.widgets import net.minecraft.client.gui.GuiButton import net.bdew.lib.gui.{Point, Rect} import net.minecraft.client.Minecraft +import net.minecraft.client.audio.PositionedSoundRecord +import net.minecraft.util.ResourceLocation class WidgetButton(val rect: Rect, text: String, clicked: WidgetButton => Unit) extends GuiButton(0, rect.x, rect.y, rect.w, rect.h, text) with Widget { override def mouseClicked(p: Point, button: Int) { - Minecraft.getMinecraft.sndManager.playSoundFX("random.click", 1.0F, 1.0F) + Minecraft.getMinecraft.getSoundHandler.playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)) clicked(this) } diff --git a/src/net/bdew/lib/gui/widgets/WidgetSubcontainer.scala b/src/net/bdew/lib/gui/widgets/WidgetSubcontainer.scala index 54fc8ce..7549aab 100644 --- a/src/net/bdew/lib/gui/widgets/WidgetSubcontainer.scala +++ b/src/net/bdew/lib/gui/widgets/WidgetSubcontainer.scala @@ -10,13 +10,13 @@ package net.bdew.lib.gui.widgets import net.bdew.lib.gui._ -import net.minecraft.util.Icon +import net.minecraft.util.IIcon import net.bdew.lib.gui.Rect class WidgetSubcontainer(val rect: Rect) extends BaseWidget with WidgetContainer { def getFontRenderer = parent.getFontRenderer def getOffsetFromWindow = parent.getOffsetFromWindow + rect.origin def drawTexture(r: Rect, uv: Point, color: Color = Color.white) = parent.drawTexture(r, uv, color) - def drawIcon(r: Rect, i: Icon, color: Color = Color.white) = parent.drawIcon(r, i, color) + def drawIcon(r: Rect, i: IIcon, color: Color = Color.white) = parent.drawIcon(r, i, color) def drawTextureScaled(r: Rect, t: TextureLocationScaled, color: Color = Color.white) = parent.drawTextureScaled(r, t, color) } diff --git a/src/net/bdew/lib/items/ItemUtils.scala b/src/net/bdew/lib/items/ItemUtils.scala index 804684e..c04c3bd 100644 --- a/src/net/bdew/lib/items/ItemUtils.scala +++ b/src/net/bdew/lib/items/ItemUtils.scala @@ -37,7 +37,7 @@ object ItemUtils { def isSameItem(stack1: ItemStack, stack2: ItemStack): Boolean = { if (stack1 == null || stack2 == null) return stack1 == stack2 - if (stack1.itemID != stack2.itemID) + if (stack1.getItem != stack2.getItem) return false if (stack1.getHasSubtypes && stack2.getItemDamage != stack1.getItemDamage) return false @@ -54,12 +54,12 @@ object ItemUtils { if (toAdd >= stack.stackSize) { target.stackSize += stack.stackSize stack.stackSize = 0 - inv.onInventoryChanged() + inv.markDirty() return null } else if (toAdd > 0) { target.stackSize += toAdd stack.stackSize -= toAdd - inv.onInventoryChanged() + inv.markDirty() } } diff --git a/src/net/bdew/lib/items/SimpleItem.scala b/src/net/bdew/lib/items/SimpleItem.scala index 9f73bd7..e062057 100644 --- a/src/net/bdew/lib/items/SimpleItem.scala +++ b/src/net/bdew/lib/items/SimpleItem.scala @@ -10,16 +10,16 @@ package net.bdew.lib.items import net.minecraft.item.Item -import net.minecraft.client.renderer.texture.IconRegister +import net.minecraft.client.renderer.texture.IIconRegister import cpw.mods.fml.relauncher.{Side, SideOnly} import net.bdew.lib.Misc -class SimpleItem(id: Int, val name: String) extends Item(id) { +class SimpleItem(val name: String) extends Item() { val modId = Misc.getActiveModId setUnlocalizedName(modId + "." + name) @SideOnly(Side.CLIENT) - override def registerIcons(reg: IconRegister) { + override def registerIcons(reg: IIconRegister) { itemIcon = reg.registerIcon(modId + ":" + name.toLowerCase) } } diff --git a/src/net/bdew/lib/machine/Machine.scala b/src/net/bdew/lib/machine/Machine.scala index 77abaae..722cf31 100644 --- a/src/net/bdew/lib/machine/Machine.scala +++ b/src/net/bdew/lib/machine/Machine.scala @@ -14,17 +14,16 @@ import net.minecraft.block.Block import cpw.mods.fml.common.registry.GameRegistry import net.minecraft.item.ItemStack import net.bdew.lib.block.HasTE -import net.bdew.lib.config.IdManager import net.bdew.lib.Misc -abstract class Machine[T <: Block](val name: String, val blockConstruct: (Int) => T) { +abstract class Machine[T <: Block](val name: String, blockConstruct: => T) { var block: T = null.asInstanceOf[T] var tuning: ConfigSection = null var enabled = false val modId = Misc.getActiveModId - def regBlock(ids: IdManager) { - block = blockConstruct(ids.getBlockId(name)) + def regBlock() { + block = blockConstruct GameRegistry.registerBlock(block, name) GameRegistry.registerCustomItemStack(name, new ItemStack(block)) if (block.isInstanceOf[HasTE[_]]) { diff --git a/src/net/bdew/lib/power/DataSlotPower.scala b/src/net/bdew/lib/power/DataSlotPower.scala index f6801e2..5467593 100644 --- a/src/net/bdew/lib/power/DataSlotPower.scala +++ b/src/net/bdew/lib/power/DataSlotPower.scala @@ -49,7 +49,7 @@ case class DataSlotPower(name: String, parent: TileDataSlots) extends DataSlot { tag.setFloat("stored", stored) if (kind == UpdateKind.GUI) tag.setFloat("capacity", capacity) - t.setCompoundTag(name, tag) + t.setTag(name, tag) } def load(t: NBTTagCompound, kind: UpdateKind.Value) { diff --git a/src/net/bdew/lib/recipes/RecipeLoader.scala b/src/net/bdew/lib/recipes/RecipeLoader.scala index 84da605..6656aa6 100644 --- a/src/net/bdew/lib/recipes/RecipeLoader.scala +++ b/src/net/bdew/lib/recipes/RecipeLoader.scala @@ -11,13 +11,10 @@ package net.bdew.lib.recipes import java.io.Reader import net.minecraft.item.{Item, ItemStack} -import net.bdew.lib.Misc +import net.bdew.lib.{BdLib, Misc} import net.minecraft.block.Block import cpw.mods.fml.common.registry.GameRegistry import net.minecraftforge.oredict.{ShapelessOreRecipe, OreDictionary} -import java.util.logging.Logger -import cpw.mods.fml.common.FMLLog -import net.minecraft.item.crafting.FurnaceRecipes /** * Main recipe loader class @@ -34,9 +31,6 @@ class RecipeLoader { */ def newParser() = new RecipeParser() - val log: Logger = Logger.getLogger("RecipeLoader") - log.setParent(FMLLog.getLogger) - /** * Current map of recipe characters to parser item references */ @@ -90,7 +84,7 @@ class RecipeLoader { val l = x.copy() l.stackSize = cnt if (meta != OreDictionary.WILDCARD_VALUE && meta != l.getItemDamage) { - log.warning("%s requested with meta %d but specifies %d".format(source, meta, l.getItemDamage)) + BdLib.logWarn("%s requested with meta %d but specifies %d", source, meta, l.getItemDamage) l.setItemDamage(meta) } return l @@ -178,7 +172,7 @@ class RecipeLoader { if (l.size == 0) error("Concrete ItemStack requested for OD entry '%s' that is empty", id) val s = l.get(0).copy() s.stackSize = cnt - log.info("Concrete ItemStack for OD entry '%s' -> %s".format(id, s)) + BdLib.logInfo("Concrete ItemStack for OD entry '%s' -> %s", id, s) return s case StackMacro(ch) => getConcreteStack(currCharMap(ch), cnt) case StackMod(mod, id) => @@ -203,7 +197,7 @@ class RecipeLoader { if (!currCharMap.contains(x)) error("Character %s is undefined", x) val r = getRecipeComponent(currCharMap(x)) if (r.isInstanceOf[String]) needOd = true - log.info("%s -> %s".format(x, r)) + BdLib.logInfo("%s -> %s", x, r) comp += (x -> r) } return (comp, needOd) @@ -216,29 +210,29 @@ class RecipeLoader { def processStatement(s: Statement): Unit = s match { case StIfHaveMod(mod, thn, els) => if (Misc.haveModVersion(mod)) { - log.info("ifMod: %s found".format(mod)) + BdLib.logInfo("ifMod: %s found", mod) processStatementsSafe(thn) } else { - log.info("ifMod: %s not found".format(mod)) + BdLib.logInfo("ifMod: %s not found", mod) processStatementsSafe(els) } case StIfHaveOD(od, thn, els) => if (OreDictionary.getOres(od).size() > 0) { - log.info("ifOreDict: %s found".format(od)) + BdLib.logInfo("ifOreDict: %s found", od) processStatementsSafe(thn) } else { - log.info("ifOreDict: %s not found".format(od)) + BdLib.logInfo("ifOreDict: %s not found", od) processStatementsSafe(els) } case StClearRecipes(res) => - log.info("Clearing recipes that produce %s".format(res)) + BdLib.logInfo("Clearing recipes that produce %s", res) delayedStatements = delayedStatements.filter({ x => if (x.isInstanceOf[CraftingStatement]) if (x.asInstanceOf[CraftingStatement].result == res) { - log.info("Removing recipe %s".format(x)) + BdLib.logInfo("Removing recipe %s", x) false } else true else true @@ -248,7 +242,7 @@ class RecipeLoader { delayedStatements :+= x case x => - log.severe("Can't process %s - this is a programing bug!".format(x)) + BdLib.logError("Can't process %s - this is a programing bug!", x) } /** @@ -258,19 +252,19 @@ class RecipeLoader { def processDelayedStatement(st: DelayedStatement) = st match { case StCharAssign(c, r) => currCharMap += (c -> r) - log.info("Added %s = %s".format(c, r)) + BdLib.logInfo("Added %s = %s", c, r) case StClassMacro(id, cls) => currClassMacros += (id -> cls) - log.info("Added def %s = %s".format(id, cls)) + BdLib.logInfo("Added def %s = %s", id, cls) case StRecipeShaped(rec, res, cnt) => - log.info("Adding shaped recipe %s => %s * %d".format(rec, res, cnt)) + BdLib.logInfo("Adding shaped recipe %s => %s * %d", rec, res, cnt) val (comp, needOd) = resolveRecipeComponents(rec.mkString("")) val resStack = getConcreteStack(res, cnt) if (resStack.getItemDamage == OreDictionary.WILDCARD_VALUE) { - log.info("Result meta is unset, defaulting to 0") + BdLib.logInfo("Result meta is unset, defaulting to 0") resStack.setItemDamage(0) } @@ -279,16 +273,16 @@ class RecipeLoader { else Misc.addRecipe(resStack, rec, comp) - log.info("Done... result=%s, od=%s".format(resStack, needOd)) + BdLib.logInfo("Done... result=%s, od=%s", resStack, needOd) case StRecipeShapeless(rec, res, cnt) => - log.info("Adding shapeless recipe %s => %s * %d".format(rec, res, cnt)) + BdLib.logInfo("Adding shapeless recipe %s => %s * %d", rec, res, cnt) val (comp, needOd) = resolveRecipeComponents(rec) val resStack = getConcreteStack(res, cnt) val recTrans = rec.toCharArray.map(comp(_)) if (resStack.getItemDamage == OreDictionary.WILDCARD_VALUE) { - log.info("Result meta is unset, defaulting to 0") + BdLib.logInfo("Result meta is unset, defaulting to 0") resStack.setItemDamage(0) } @@ -297,42 +291,37 @@ class RecipeLoader { else GameRegistry.addShapelessRecipe(resStack, recTrans: _*) - log.info("Done... result=%s, od=%s".format(resStack, needOd)) + BdLib.logInfo("Done... result=%s, od=%s", resStack, needOd) case StSmeltRecipe(in, out, cnt, xp) => - log.info("Adding smelting recipe %s => %s * %d (%f xp)".format(in, out, cnt, xp)) + BdLib.logInfo("Adding smelting recipe %s => %s * %d (%f xp)", in, out, cnt, xp) val outStack = getConcreteStack(out, cnt) if (outStack.getItemDamage == OreDictionary.WILDCARD_VALUE) { - log.info("Result meta is unset, defaulting to 0") + BdLib.logInfo("Result meta is unset, defaulting to 0") outStack.setItemDamage(0) } for (inStack <- getAllConcreteStacks(in, 1)) { - if (inStack.getItemDamage == OreDictionary.WILDCARD_VALUE) { - FurnaceRecipes.smelting.addSmelting(inStack.itemID, outStack, xp) - log.info("added %d -> %s".format(inStack.itemID, outStack)) - } else { - FurnaceRecipes.smelting.addSmelting(inStack.itemID, inStack.getItemDamage, outStack, xp) - log.info("added %d@%d -> %s".format(inStack.itemID, inStack.getItemDamage, outStack)) - } + GameRegistry.addSmelting(inStack, outStack, xp) + BdLib.logInfo("added %d -> %s", inStack, outStack) } case x => - log.severe("Can't process %s - this is a programing bug!".format(x)) + BdLib.logError("Can't process %s - this is a programing bug!", x) } /** * Process delayed statements, clear the list afterwards */ def processDelayedStatements() { - log.info("Processing %d delayed statements".format(delayedStatements.size)) + BdLib.logInfo("Processing %d delayed statements", delayedStatements.size) for (s <- delayedStatements) { try { processDelayedStatement(s) } catch { case e: StatementError => - log.severe("Error while processing %s: %s".format(s, e.getMessage)) + BdLib.logError("Error while processing %s: %s", s, e.getMessage) case e: Throwable => - log.severe("Error while processing %s: %s".format(s, e)) + BdLib.logError("Error while processing %s: %s", s, e) e.printStackTrace() } } @@ -349,19 +338,19 @@ class RecipeLoader { processStatement(s) } catch { case e: StatementError => - log.severe("Error while processing %s: %s".format(s, e.getMessage)) + BdLib.logError("Error while processing %s: %s", s, e.getMessage) case e: Throwable => - log.severe("Error while processing %s: %s".format(s, e)) + BdLib.logError("Error while processing %s: %s", s, e) e.printStackTrace() } } } def load(f: Reader) { - log.info("Starting parsing") + BdLib.logInfo("Starting parsing") val r = newParser().doParse(f) - log.info("Processing %d statements".format(r.size)) + BdLib.logInfo("Processing %d statements", r.size) processStatementsSafe(r) - log.info("Done") + BdLib.logInfo("Done") } } diff --git a/src/net/bdew/lib/recipes/gencfg/GenericConfigLoader.scala b/src/net/bdew/lib/recipes/gencfg/GenericConfigLoader.scala index 95bff65..dc78717 100644 --- a/src/net/bdew/lib/recipes/gencfg/GenericConfigLoader.scala +++ b/src/net/bdew/lib/recipes/gencfg/GenericConfigLoader.scala @@ -10,17 +10,18 @@ package net.bdew.lib.recipes.gencfg import net.bdew.lib.recipes.{Statement, RecipeLoader} +import net.bdew.lib.BdLib trait GenericConfigLoader extends RecipeLoader { val cfgStore: ConfigSection def processConfigStatement(section: ConfigSection, s: CfgStatement): Unit = s match { case CfgVal(id, v) => - log.info("Config: %s%s = %s".format(section.pfx, id, v)) + BdLib.logInfo("Config: %s%s = %s", section.pfx, id, v) section.set(id, v) case CfgSub(id, st) => processConfigBlock(section.getOrAddSection(id), st) case x => - log.severe("Can't process %s - this is a programing bug!".format(x)) + BdLib.logError("Can't process %s - this is a programing bug!", x) } def processConfigBlock(view: ConfigSection, block: List[CfgStatement]) = for (s <- block) processConfigStatement(view, s) diff --git a/src/net/bdew/lib/rotate/BaseRotateableBlock.scala b/src/net/bdew/lib/rotate/BaseRotateableBlock.scala index a7f2d46..49f4616 100644 --- a/src/net/bdew/lib/rotate/BaseRotateableBlock.scala +++ b/src/net/bdew/lib/rotate/BaseRotateableBlock.scala @@ -14,12 +14,11 @@ import cpw.mods.fml.relauncher.SideOnly import net.minecraft.block.Block import net.minecraft.entity.EntityLivingBase import net.minecraft.item.ItemStack -import net.minecraft.util.Icon -import net.minecraft.util.MathHelper +import net.minecraft.util.{IIcon, MathHelper} import net.minecraft.world.IBlockAccess import net.minecraft.world.World -import net.minecraftforge.common.ForgeDirection import java.util.EnumSet +import net.minecraftforge.common.util.ForgeDirection /** * Basic logic for block rotatation @@ -29,12 +28,12 @@ trait BaseRotateableBlock extends Block { /** * Override this method to provide your textures, also called when rendering as item */ - def getIcon(meta: Int, kind: IconType.Value): Icon + def getIcon(meta: Int, kind: IconType.Value): IIcon /** * Override this method to provide your textures, if you need to check other state */ - def getIcon(world: IBlockAccess, x: Int, y: Int, z: Int, kind: IconType.Value): Icon = getIcon(world.getBlockMetadata(x, y, z), kind) + def getIcon(world: IBlockAccess, x: Int, y: Int, z: Int, kind: IconType.Value): IIcon = getIcon(world.getBlockMetadata(x, y, z), kind) /** * Set of valid rotations, default is all of them @@ -63,10 +62,10 @@ trait BaseRotateableBlock extends Block { } @SideOnly(Side.CLIENT) - override def getIcon(side: Int, meta: Int): Icon = getIcon(meta, IconType.fromSideAndDir(side, getDefaultFacing)) + override def getIcon(side: Int, meta: Int): IIcon = getIcon(meta, IconType.fromSideAndDir(side, getDefaultFacing)) @SideOnly(Side.CLIENT) - override def getBlockTexture(world: IBlockAccess, x: Int, y: Int, z: Int, side: Int): Icon = getIcon(world, x, y, z, IconType.fromSideAndDir(side, getFacing(world, x, y, z))) + override def getIcon(world: IBlockAccess, x: Int, y: Int, z: Int, side: Int): IIcon = getIcon(world, x, y, z, IconType.fromSideAndDir(side, getFacing(world, x, y, z))) override def getValidRotations(worldObj: World, x: Int, y: Int, z: Int): Array[ForgeDirection] = getValidFacings.toArray(Array.empty[ForgeDirection]) diff --git a/src/net/bdew/lib/rotate/IconType.scala b/src/net/bdew/lib/rotate/IconType.scala index 00349a1..941cf3b 100644 --- a/src/net/bdew/lib/rotate/IconType.scala +++ b/src/net/bdew/lib/rotate/IconType.scala @@ -9,7 +9,7 @@ package net.bdew.lib.rotate -import net.minecraftforge.common.ForgeDirection +import net.minecraftforge.common.util.ForgeDirection object IconType extends Enumeration { val BACK = Value(0, "BACK") diff --git a/src/net/bdew/lib/rotate/RotateableTileBlock.scala b/src/net/bdew/lib/rotate/RotateableTileBlock.scala index 593e075..6e7f3d9 100644 --- a/src/net/bdew/lib/rotate/RotateableTileBlock.scala +++ b/src/net/bdew/lib/rotate/RotateableTileBlock.scala @@ -12,21 +12,21 @@ package net.bdew.lib.rotate import net.minecraft.block.ITileEntityProvider import net.minecraft.world.IBlockAccess import net.minecraft.world.World -import net.minecraftforge.common.ForgeDirection import cpw.mods.fml.common.FMLCommonHandler +import net.minecraftforge.common.util.ForgeDirection /** * Stores rotation data in tile entity. The TE should implement {@link RotateableTile} */ trait RotateableTileBlock extends BaseRotateableBlock with ITileEntityProvider { def setFacing(world: World, x: Int, y: Int, z: Int, facing: ForgeDirection) { - world.getBlockTileEntity(x, y, z).asInstanceOf[RotateableTile].rotation := facing + world.getTileEntity(x, y, z).asInstanceOf[RotateableTile].rotation := facing } def getFacing(world: IBlockAccess, x: Int, y: Int, z: Int): ForgeDirection = { - val te: RotateableTile = world.getBlockTileEntity(x, y, z).asInstanceOf[RotateableTile] + val te: RotateableTile = world.getTileEntity(x, y, z).asInstanceOf[RotateableTile] if (te == null || te.rotation == null) { - FMLCommonHandler.instance().getFMLLogger.warning("Failed gettig rocation for block at %d, %d, %d".format(x, y, z)) + FMLCommonHandler.instance().getFMLLogger.warn("Failed getting rocation for block at %d, %d, %d".format(x, y, z)) return getDefaultFacing } return te.rotation diff --git a/src/net/bdew/lib/tile/ExposeTank.scala b/src/net/bdew/lib/tile/ExposeTank.scala index 70c2f4d..4d9e228 100644 --- a/src/net/bdew/lib/tile/ExposeTank.scala +++ b/src/net/bdew/lib/tile/ExposeTank.scala @@ -11,7 +11,7 @@ package net.bdew.lib.tile import net.minecraft.tileentity.TileEntity import net.minecraftforge.fluids._ -import net.minecraftforge.common.ForgeDirection +import net.minecraftforge.common.util.ForgeDirection trait ExposeTank extends TileEntity with IFluidHandler { def getTankFromDirection(dir: ForgeDirection): IFluidTank diff --git a/src/net/bdew/lib/tile/TileExtended.scala b/src/net/bdew/lib/tile/TileExtended.scala index d1186ef..e2efac9 100644 --- a/src/net/bdew/lib/tile/TileExtended.scala +++ b/src/net/bdew/lib/tile/TileExtended.scala @@ -11,9 +11,9 @@ package net.bdew.lib.tile import net.minecraft.tileentity.TileEntity import net.minecraft.nbt.NBTTagCompound -import net.minecraft.network.INetworkManager -import net.minecraft.network.packet.Packet132TileEntityData +import net.minecraft.network.{NetworkManager, Packet} import net.bdew.lib.Event +import net.minecraft.network.play.server.S35PacketUpdateTileEntity class TileExtended extends TileEntity { final val ACT_CLIENT = 1 @@ -39,18 +39,18 @@ class TileExtended extends TileEntity { persistLoad.trigger(tag) } - override final def getDescriptionPacket: Packet132TileEntityData = { + override final def getDescriptionPacket: Packet = { if (!sendClientUpdate.hasListeners) return null val tag = new NBTTagCompound sendClientUpdate.trigger(tag) - return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, ACT_CLIENT, tag) + return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, ACT_CLIENT, tag) } - override final def onDataPacket(net: INetworkManager, pkt: Packet132TileEntityData) { - if (pkt.actionType == ACT_CLIENT) - handleClientUpdate.trigger(pkt.data) + override final def onDataPacket(net: NetworkManager, pkt: S35PacketUpdateTileEntity) { + if (pkt.func_148853_f == ACT_CLIENT) + handleClientUpdate.trigger(pkt.func_148857_g) else - extDataPacket(pkt.actionType, pkt.data) + extDataPacket(pkt.func_148853_f, pkt.func_148857_g) } override final def updateEntity() { diff --git a/src/net/bdew/lib/tile/inventory/BaseInventory.scala b/src/net/bdew/lib/tile/inventory/BaseInventory.scala index 4956448..389af40 100644 --- a/src/net/bdew/lib/tile/inventory/BaseInventory.scala +++ b/src/net/bdew/lib/tile/inventory/BaseInventory.scala @@ -37,14 +37,14 @@ trait BaseInventory extends IInventory { if (item != null) { if (item.stackSize <= n) { inv(slot) = null - onInventoryChanged() + markDirty() return item } else { var newstack = item.splitStack(n) if (item.stackSize == 0) { inv(slot) = null } - onInventoryChanged() + markDirty() return newstack } } else { @@ -55,12 +55,12 @@ trait BaseInventory extends IInventory { def getStackInSlotOnClosing(slot: Int): ItemStack = { var tmp = inv(slot) inv(slot) = null - onInventoryChanged() + markDirty() return tmp } def setInventorySlotContents(slot: Int, stack: ItemStack) = { inv(slot) = stack - onInventoryChanged() + markDirty() } } diff --git a/src/net/bdew/lib/tile/inventory/BreakableInventoryBlock.scala b/src/net/bdew/lib/tile/inventory/BreakableInventoryBlock.scala index c564310..d0c7f86 100644 --- a/src/net/bdew/lib/tile/inventory/BreakableInventoryBlock.scala +++ b/src/net/bdew/lib/tile/inventory/BreakableInventoryBlock.scala @@ -13,13 +13,13 @@ import net.minecraft.block.Block import net.minecraft.world.World trait BreakableInventoryBlock extends Block { - override def breakBlock(world: World, x: Int, y: Int, z: Int, blockId: Int, meta: Int) { + override def breakBlock(world: World, x: Int, y: Int, z: Int, block: Block, meta: Int) { if (!world.isRemote) { - val te = world.getBlockTileEntity(x, y, z).asInstanceOf[BreakableInventoryTile] + val te = world.getTileEntity(x, y, z).asInstanceOf[BreakableInventoryTile] if (te != null) { te.dropItems() } } - super.breakBlock(world, x, y, z, blockId, meta) + super.breakBlock(world, x, y, z, block, meta) } } diff --git a/src/net/bdew/lib/tile/inventory/BreakableInventoryTile.scala b/src/net/bdew/lib/tile/inventory/BreakableInventoryTile.scala index 261dfc6..6bc4f93 100644 --- a/src/net/bdew/lib/tile/inventory/BreakableInventoryTile.scala +++ b/src/net/bdew/lib/tile/inventory/BreakableInventoryTile.scala @@ -15,9 +15,9 @@ import net.bdew.lib.items.ItemUtils trait BreakableInventoryTile extends TileEntity with BaseInventory { def dropItems() { - if (worldObj != null && !worldObj.isRemote) { + if (getWorldObj != null && !getWorldObj.isRemote) { for (stack <- inv if stack != null) { - ItemUtils.throwItemAt(worldObj, xCoord, yCoord, zCoord, stack) + ItemUtils.throwItemAt(getWorldObj, xCoord, yCoord, zCoord, stack) } inv = new Array[ItemStack](inv.size) } diff --git a/src/net/bdew/lib/tile/inventory/PersistentInventoryTile.scala b/src/net/bdew/lib/tile/inventory/PersistentInventoryTile.scala index e883df3..1a5f035 100644 --- a/src/net/bdew/lib/tile/inventory/PersistentInventoryTile.scala +++ b/src/net/bdew/lib/tile/inventory/PersistentInventoryTile.scala @@ -17,7 +17,7 @@ import net.bdew.lib.tile.TileExtended trait PersistentInventoryTile extends TileExtended with BaseInventory { persistLoad.listen((tag: NBTTagCompound) => { inv = new Array[ItemStack](getSizeInventory) - for (nbtItem <- Misc.iterNbtList[NBTTagCompound](tag.getTagList("Items"))) { + for (nbtItem <- Misc.iterNbtCompoundList(tag, "Items")) { val slot = nbtItem.getByte("Slot") if (slot >= 0 && slot < inv.size) { inv(slot) = ItemStack.loadItemStackFromNBT(nbtItem)