it: fuel slot

This commit is contained in:
Bixilon 2022-11-15 12:29:03 +01:00
parent 3119918641
commit e417671473
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
8 changed files with 155 additions and 9 deletions

View File

@ -0,0 +1,44 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.container.slots
import de.bixilon.minosoft.data.container.click.ContainerTestUtil
import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.data.registries.items.AppleTestO
import de.bixilon.minosoft.data.registries.items.CoalTest0
import de.bixilon.minosoft.data.registries.items.LavaBucketTest0
import de.bixilon.minosoft.data.registries.items.WaterBucketTest0
import org.testng.Assert.assertFalse
import org.testng.Assert.assertTrue
import org.testng.annotations.Test
@Test(groups = ["container"])
class FuelSlotTypeTest {
fun apple() {
assertFalse(FuelSlotType.canPut(ContainerTestUtil.createContainer(), 0, ItemStack(AppleTestO.item)))
}
fun lavaBucket() {
assertTrue(FuelSlotType.canPut(ContainerTestUtil.createContainer(), 0, ItemStack(LavaBucketTest0.item)))
}
fun waterBucket() {
assertFalse(FuelSlotType.canPut(ContainerTestUtil.createContainer(), 0, ItemStack(WaterBucketTest0.item)))
}
fun coal() {
assertTrue(FuelSlotType.canPut(ContainerTestUtil.createContainer(), 0, ItemStack(CoalTest0.item)))
}
}

View File

@ -0,0 +1,33 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.items
import de.bixilon.kutil.cast.CastUtil.unsafeNull
import de.bixilon.minosoft.data.registries.item.MinecraftItems
import de.bixilon.minosoft.data.registries.item.items.Item
import org.testng.annotations.Test
@Test(groups = ["item"])
class CoalTest : ItemTest<Item>() {
init {
CoalTest0 = this
}
fun getTorch() {
super.retrieveBlock(MinecraftItems.COAL)
}
}
var CoalTest0: CoalTest = unsafeNull()

View File

@ -26,7 +26,7 @@ class EggTest : ItemTest<Item>() {
} }
fun getTorch() { fun getTorch() {
super.retrieveBlock(MinecraftItems.APPLE) super.retrieveBlock(MinecraftItems.EGG)
} }
} }

View File

@ -0,0 +1,36 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.items
import de.bixilon.kutil.cast.CastUtil.unsafeNull
import de.bixilon.minosoft.data.registries.fluid.lava.LavaFluid
import de.bixilon.minosoft.data.registries.item.MinecraftItems
import de.bixilon.minosoft.data.registries.item.items.bucket.BucketItem
import org.testng.Assert.assertTrue
import org.testng.annotations.Test
@Test(groups = ["item"])
class LavaBucketTest : ItemTest<BucketItem>() {
init {
LavaBucketTest0 = this
assertTrue(item.fluid is LavaFluid)
}
fun getTorch() {
super.retrieveBlock(MinecraftItems.LAVA_BUCKET)
}
}
var LavaBucketTest0: LavaBucketTest = unsafeNull()

View File

@ -0,0 +1,36 @@
/*
* Minosoft
* Copyright (C) 2020-2022 Moritz Zwerger
*
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
*
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.data.registries.items
import de.bixilon.kutil.cast.CastUtil.unsafeNull
import de.bixilon.minosoft.data.registries.fluid.water.WaterFluid
import de.bixilon.minosoft.data.registries.item.MinecraftItems
import de.bixilon.minosoft.data.registries.item.items.bucket.BucketItem
import org.testng.Assert.assertTrue
import org.testng.annotations.Test
@Test(groups = ["item"])
class WaterBucketTest : ItemTest<BucketItem>() {
init {
WaterBucketTest0 = this
assertTrue(item.fluid is WaterFluid)
}
fun getTorch() {
super.retrieveBlock(MinecraftItems.WATER_BUCKET)
}
}
var WaterBucketTest0: WaterBucketTest = unsafeNull()

View File

@ -15,8 +15,6 @@ package de.bixilon.minosoft.data.container.slots
import de.bixilon.minosoft.data.container.Container import de.bixilon.minosoft.data.container.Container
import de.bixilon.minosoft.data.container.stack.ItemStack import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.data.registries.fluid.DefaultFluids
import de.bixilon.minosoft.data.registries.item.items.bucket.BucketItem
@Deprecated("ToDo") @Deprecated("ToDo")
object EnchantableSlotType : SlotType { object EnchantableSlotType : SlotType {
@ -24,10 +22,6 @@ object EnchantableSlotType : SlotType {
override fun canPut(container: Container, slot: Int, stack: ItemStack): Boolean { override fun canPut(container: Container, slot: Int, stack: ItemStack): Boolean {
val item = stack.item.item val item = stack.item.item
if (item is BucketItem && item.fluid.resourceLocation == DefaultFluids.LAVA) {
return true
}
// ToDo: get from registries (misc/fuel_time)
return super.canPut(container, slot, stack) return super.canPut(container, slot, stack)
} }
} }

View File

@ -15,7 +15,7 @@ package de.bixilon.minosoft.data.container.slots
import de.bixilon.minosoft.data.container.Container import de.bixilon.minosoft.data.container.Container
import de.bixilon.minosoft.data.container.stack.ItemStack import de.bixilon.minosoft.data.container.stack.ItemStack
import de.bixilon.minosoft.data.registries.fluid.DefaultFluids import de.bixilon.minosoft.data.registries.fluid.lava.LavaFluid
import de.bixilon.minosoft.data.registries.item.items.bucket.BucketItem import de.bixilon.minosoft.data.registries.item.items.bucket.BucketItem
@Deprecated("ToDo") @Deprecated("ToDo")
@ -24,7 +24,7 @@ object FuelSlotType : SlotType {
override fun canPut(container: Container, slot: Int, stack: ItemStack): Boolean { override fun canPut(container: Container, slot: Int, stack: ItemStack): Boolean {
val item = stack.item.item val item = stack.item.item
if (item is BucketItem && item.fluid.resourceLocation == DefaultFluids.LAVA) { if (item is BucketItem && item.fluid is LavaFluid) {
return true return true
} }
// ToDo: get from registries (misc/fuel_time) // ToDo: get from registries (misc/fuel_time)

View File

@ -20,4 +20,7 @@ object MinecraftItems {
val LAPISLAZULI = "minecraft:lapis_lazuli".toResourceLocation() val LAPISLAZULI = "minecraft:lapis_lazuli".toResourceLocation()
val APPLE = "minecraft:apple".toResourceLocation() val APPLE = "minecraft:apple".toResourceLocation()
val EGG = "minecraft:egg".toResourceLocation() val EGG = "minecraft:egg".toResourceLocation()
val LAVA_BUCKET = "minecraft:lava_bucket".toResourceLocation()
val WATER_BUCKET = "minecraft:water_bucket".toResourceLocation()
val COAL = "minecraft:coal".toResourceLocation()
} }