diff --git a/src/net/torvald/terrarum/gameworld/BlockLayer.kt b/src/net/torvald/terrarum/gameworld/BlockLayer.kt index ab4c6a015..17ba29026 100644 --- a/src/net/torvald/terrarum/gameworld/BlockLayer.kt +++ b/src/net/torvald/terrarum/gameworld/BlockLayer.kt @@ -18,10 +18,12 @@ open class BlockLayer(val width: Int, val height: Int) : Disposable { unsafeConstructor.isAccessible = true unsafe = unsafeConstructor.newInstance() } - private var unsafeArrayInitialised = false private var unsafeArrayDestroyed = false private var layerPtr = unsafe.allocateMemory(width * height * BYTES_PER_BLOCK.toLong()) + init { + unsafe.setMemory(layerPtr, width * height * BYTES_PER_BLOCK.toLong(), 0) // sometimes does not work?! + } /** * @param data Byte array representation of the layer, where: @@ -39,18 +41,8 @@ open class BlockLayer(val width: Int, val height: Int) : Disposable { */ constructor(width: Int, height: Int, data: ByteArray) : this(width, height) { data.forEachIndexed { index, byte -> unsafe.putByte(layerPtr + index, byte) } - unsafeArrayInitialised = true } - init { - if (!unsafeArrayInitialised) { - //unsafe.setMemory(layerPtr, width * height * BYTES_PER_BLOCK.toLong(), 0) // sometimes does not work?! - for (i in 0 until width * height * BYTES_PER_BLOCK.toLong()) { - unsafe.putByte(layerPtr + i, 0) - } - unsafeArrayInitialised = true - } - } /** * Returns an iterator over blocks of type `Int`. diff --git a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureTikiTorch.kt b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureTikiTorch.kt index 8678c9e40..f91344fec 100644 --- a/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureTikiTorch.kt +++ b/src/net/torvald/terrarum/modulebasegame/gameactors/FixtureTikiTorch.kt @@ -31,7 +31,7 @@ internal class FixtureTikiTorch : FixtureBase(BlockBox(BlockBox.NO_COLLISION, 1, lightBoxList = ArrayList(1) lightBoxList.add(Hitbox(6.0, 5.0, 4.0, 3.0)) - makeNewSprite(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/fixtures/tiki_torch.tga"), 10, 27)) + makeNewSprite(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/fixtures/tiki_torch.tga"), 16, 32)) sprite!!.setRowsAndFrames(1, 1) actorValue[AVKey.BASEMASS] = 1.0