From e417671473f3c36d18f17904ed7be658b4284ee3 Mon Sep 17 00:00:00 2001 From: Bixilon Date: Tue, 15 Nov 2022 12:29:03 +0100 Subject: [PATCH] it: fuel slot --- .../data/container/slots/FuelSlotTypeTest.kt | 44 +++++++++++++++++++ .../data/registries/items/CoalTest.kt | 33 ++++++++++++++ .../minosoft/data/registries/items/EggTest.kt | 2 +- .../data/registries/items/LavaBucketTest.kt | 36 +++++++++++++++ .../data/registries/items/WaterBucketTest.kt | 36 +++++++++++++++ .../container/slots/EnchantableSlotType.kt | 6 --- .../data/container/slots/FuelSlotType.kt | 4 +- .../data/registries/item/MinecraftItems.kt | 3 ++ 8 files changed, 155 insertions(+), 9 deletions(-) create mode 100644 src/integration-test/kotlin/de/bixilon/minosoft/data/container/slots/FuelSlotTypeTest.kt create mode 100644 src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/CoalTest.kt create mode 100644 src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/LavaBucketTest.kt create mode 100644 src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/WaterBucketTest.kt diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/container/slots/FuelSlotTypeTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/container/slots/FuelSlotTypeTest.kt new file mode 100644 index 000000000..175fd18f7 --- /dev/null +++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/container/slots/FuelSlotTypeTest.kt @@ -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 . + * + * 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))) + } +} diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/CoalTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/CoalTest.kt new file mode 100644 index 000000000..04c79c4eb --- /dev/null +++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/CoalTest.kt @@ -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 . + * + * 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() { + + init { + CoalTest0 = this + } + + fun getTorch() { + super.retrieveBlock(MinecraftItems.COAL) + } +} + +var CoalTest0: CoalTest = unsafeNull() diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/EggTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/EggTest.kt index d13708190..54c03b2b1 100644 --- a/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/EggTest.kt +++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/EggTest.kt @@ -26,7 +26,7 @@ class EggTest : ItemTest() { } fun getTorch() { - super.retrieveBlock(MinecraftItems.APPLE) + super.retrieveBlock(MinecraftItems.EGG) } } diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/LavaBucketTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/LavaBucketTest.kt new file mode 100644 index 000000000..feeb1e25c --- /dev/null +++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/LavaBucketTest.kt @@ -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 . + * + * 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() { + + init { + LavaBucketTest0 = this + assertTrue(item.fluid is LavaFluid) + } + + fun getTorch() { + super.retrieveBlock(MinecraftItems.LAVA_BUCKET) + } +} + +var LavaBucketTest0: LavaBucketTest = unsafeNull() diff --git a/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/WaterBucketTest.kt b/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/WaterBucketTest.kt new file mode 100644 index 000000000..936378fc1 --- /dev/null +++ b/src/integration-test/kotlin/de/bixilon/minosoft/data/registries/items/WaterBucketTest.kt @@ -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 . + * + * 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() { + + init { + WaterBucketTest0 = this + assertTrue(item.fluid is WaterFluid) + } + + fun getTorch() { + super.retrieveBlock(MinecraftItems.WATER_BUCKET) + } +} + +var WaterBucketTest0: WaterBucketTest = unsafeNull() diff --git a/src/main/java/de/bixilon/minosoft/data/container/slots/EnchantableSlotType.kt b/src/main/java/de/bixilon/minosoft/data/container/slots/EnchantableSlotType.kt index cf8133eac..a1cb6e109 100644 --- a/src/main/java/de/bixilon/minosoft/data/container/slots/EnchantableSlotType.kt +++ b/src/main/java/de/bixilon/minosoft/data/container/slots/EnchantableSlotType.kt @@ -15,8 +15,6 @@ package de.bixilon.minosoft.data.container.slots import de.bixilon.minosoft.data.container.Container 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") object EnchantableSlotType : SlotType { @@ -24,10 +22,6 @@ object EnchantableSlotType : SlotType { override fun canPut(container: Container, slot: Int, stack: ItemStack): Boolean { 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) } } diff --git a/src/main/java/de/bixilon/minosoft/data/container/slots/FuelSlotType.kt b/src/main/java/de/bixilon/minosoft/data/container/slots/FuelSlotType.kt index b868c80b2..d523ffaef 100644 --- a/src/main/java/de/bixilon/minosoft/data/container/slots/FuelSlotType.kt +++ b/src/main/java/de/bixilon/minosoft/data/container/slots/FuelSlotType.kt @@ -15,7 +15,7 @@ package de.bixilon.minosoft.data.container.slots import de.bixilon.minosoft.data.container.Container 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 @Deprecated("ToDo") @@ -24,7 +24,7 @@ object FuelSlotType : SlotType { override fun canPut(container: Container, slot: Int, stack: ItemStack): Boolean { val item = stack.item.item - if (item is BucketItem && item.fluid.resourceLocation == DefaultFluids.LAVA) { + if (item is BucketItem && item.fluid is LavaFluid) { return true } // ToDo: get from registries (misc/fuel_time) diff --git a/src/main/java/de/bixilon/minosoft/data/registries/item/MinecraftItems.kt b/src/main/java/de/bixilon/minosoft/data/registries/item/MinecraftItems.kt index ed816773f..d544cec39 100644 --- a/src/main/java/de/bixilon/minosoft/data/registries/item/MinecraftItems.kt +++ b/src/main/java/de/bixilon/minosoft/data/registries/item/MinecraftItems.kt @@ -20,4 +20,7 @@ object MinecraftItems { val LAPISLAZULI = "minecraft:lapis_lazuli".toResourceLocation() val APPLE = "minecraft:apple".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() }