From b99726610fd2b13cd264414a8f5c56391b4ce883 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 17 Jun 2017 18:47:56 -0400 Subject: [PATCH] Initial port to 1.12 --- build.gradle | 5 +-- gradle.properties | 14 ++++---- .../shadowfacts/extrahoppers/ExtraHoppers.kt | 2 -- .../shadowfacts/extrahoppers/ModRecipes.kt | 32 ------------------- .../block/fluid/BlockFluidHopper.kt | 12 +++---- .../block/fluid/TESRFluidHopper.kt | 2 +- .../block/fluid/TileEntityFluidHopper.kt | 2 +- .../inverted/TileEntityInvertedHopper.kt | 8 ++--- .../block/wooden/TileEntityWoodenHopper.kt | 8 ++--- .../wooden_fluid/BlockWoodenFluidHopper.kt | 3 +- .../extrahoppers/gui/EHGUIFactory.kt | 19 +++++------ .../extrahoppers/recipes/fluid_hopper.json | 20 ++++++++++++ .../recipes/invert_fluid_hopper.json | 11 +++++++ .../extrahoppers/recipes/invert_hopper.json | 11 +++++++ .../recipes/invert_wooden_fluid_hopper.json | 11 +++++++ .../recipes/invert_wooden_hopper.json | 11 +++++++ .../recipes/uninvert_fluid_hopper.json | 11 +++++++ .../extrahoppers/recipes/uninvert_hopper.json | 11 +++++++ .../recipes/uninvert_wooden_fluid_hopper.json | 11 +++++++ .../recipes/uninvert_wooden_hopper.json | 11 +++++++ .../recipes/wooden_fluid_hopper.json | 20 ++++++++++++ .../extrahoppers/recipes/wooden_hopper.json | 17 ++++++++++ 22 files changed, 180 insertions(+), 72 deletions(-) delete mode 100644 src/main/kotlin/net/shadowfacts/extrahoppers/ModRecipes.kt create mode 100644 src/main/resources/assets/extrahoppers/recipes/fluid_hopper.json create mode 100644 src/main/resources/assets/extrahoppers/recipes/invert_fluid_hopper.json create mode 100644 src/main/resources/assets/extrahoppers/recipes/invert_hopper.json create mode 100644 src/main/resources/assets/extrahoppers/recipes/invert_wooden_fluid_hopper.json create mode 100644 src/main/resources/assets/extrahoppers/recipes/invert_wooden_hopper.json create mode 100644 src/main/resources/assets/extrahoppers/recipes/uninvert_fluid_hopper.json create mode 100644 src/main/resources/assets/extrahoppers/recipes/uninvert_hopper.json create mode 100644 src/main/resources/assets/extrahoppers/recipes/uninvert_wooden_fluid_hopper.json create mode 100644 src/main/resources/assets/extrahoppers/recipes/uninvert_wooden_hopper.json create mode 100644 src/main/resources/assets/extrahoppers/recipes/wooden_fluid_hopper.json create mode 100644 src/main/resources/assets/extrahoppers/recipes/wooden_hopper.json diff --git a/build.gradle b/build.gradle index 62c48ad..cf30c39 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { } } dependencies { - classpath "net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT" + classpath "net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlin_version}" } } @@ -51,6 +51,7 @@ processResources { } repositories { + jcenter() maven { name "shadowfacts" url "http://mvn.rx14.co.uk/shadowfacts/" @@ -72,7 +73,7 @@ curseforge { project { id = "246215" - addGameVersion "1.11" + addGameVersion "1.12" addGameVersion "Java 8" mainArtifact(jar) { diff --git a/gradle.properties b/gradle.properties index f58e053..8cba262 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,12 +2,12 @@ mod_version = 2.0.0 group = net.shadowfacts archivesBaseName = ExtraHoppers -mc_version = 1.11.2 -mcp_mappings = snapshot_20170327 -forge_version = 13.20.0.2260 +mc_version = 1.12 +mcp_mappings = snapshot_20170615 +forge_version = 14.21.0.2333 -kotlin_version = 1.1.1 +kotlin_version = 1.1.2-4 -shadowmc_version = 3.7.6-SNAPSHOT -forgelin_version = 1.4.1 -jei_version = 4.2.10.250 +shadowmc_version = 3.8.0-SNAPSHOT +forgelin_version = 1.5.0 +jei_version = 4.6.0.61 diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/ExtraHoppers.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/ExtraHoppers.kt index 97b07fa..501f403 100644 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/ExtraHoppers.kt +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/ExtraHoppers.kt @@ -33,8 +33,6 @@ object ExtraHoppers { blocks.init() - ModRecipes.init() - NetworkRegistry.INSTANCE.registerGuiHandler(ExtraHoppers, GUIHandler) } diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/ModRecipes.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/ModRecipes.kt deleted file mode 100644 index b315e35..0000000 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/ModRecipes.kt +++ /dev/null @@ -1,32 +0,0 @@ -package net.shadowfacts.extrahoppers - -import net.minecraft.init.Blocks -import net.minecraft.init.Items -import net.minecraft.item.ItemStack -import net.minecraftforge.fml.common.registry.GameRegistry -import net.minecraftforge.oredict.ShapedOreRecipe - -/** - * @author shadowfacts - */ -object ModRecipes { - - fun init() { - GameRegistry.addRecipe(ShapedOreRecipe(ExtraHoppers.blocks.fluidHopper, "I I", "I I", " B ", 'I', "ingotIron", 'B', Items.BUCKET)) - GameRegistry.addRecipe(ShapedOreRecipe(ExtraHoppers.blocks.woodenHopper, "W W", "W W", " W ", 'W', "plankWood")) - GameRegistry.addRecipe(ShapedOreRecipe(ExtraHoppers.blocks.woodenFluidHopper, "W W", "W W", " B ", 'W', "plankWood", 'B', Items.BUCKET)) - - GameRegistry.addShapelessRecipe(ItemStack(ExtraHoppers.blocks.invertedHopper), Blocks.HOPPER) - GameRegistry.addShapelessRecipe(ItemStack(Blocks.HOPPER), ExtraHoppers.blocks.invertedHopper) - - GameRegistry.addShapelessRecipe(ItemStack(ExtraHoppers.blocks.invertedFluidHopper), ExtraHoppers.blocks.fluidHopper) - GameRegistry.addShapelessRecipe(ItemStack(ExtraHoppers.blocks.fluidHopper), ExtraHoppers.blocks.invertedFluidHopper) - - GameRegistry.addShapelessRecipe(ItemStack(ExtraHoppers.blocks.invertedWoodenHopper), ExtraHoppers.blocks.woodenHopper) - GameRegistry.addShapelessRecipe(ItemStack(ExtraHoppers.blocks.woodenHopper), ExtraHoppers.blocks.invertedWoodenHopper) - - GameRegistry.addShapelessRecipe(ItemStack(ExtraHoppers.blocks.invertedWoodenFluidHopper), ExtraHoppers.blocks.woodenFluidHopper) - GameRegistry.addShapelessRecipe(ItemStack(ExtraHoppers.blocks.woodenFluidHopper), ExtraHoppers.blocks.invertedWoodenFluidHopper) - } - -} \ No newline at end of file diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/block/fluid/BlockFluidHopper.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/block/fluid/BlockFluidHopper.kt index f2bc6b2..a974db1 100644 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/block/fluid/BlockFluidHopper.kt +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/block/fluid/BlockFluidHopper.kt @@ -4,6 +4,7 @@ import net.minecraft.block.SoundType import net.minecraft.block.material.Material import net.minecraft.block.state.IBlockState import net.minecraft.client.resources.I18n +import net.minecraft.client.util.ITooltipFlag import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack import net.minecraft.util.EnumFacing @@ -47,18 +48,15 @@ open class BlockFluidHopper(inverted: Boolean, name: String = "fluid_hopper", ma if (player.isSneaking) { player.openGui(ExtraHoppers, GUIHandler.FLUID_HOPPER, world, pos.x, pos.y, pos.z) } else { - val te = getTileEntity(world, pos) - val stack = player.getHeldItem(hand) - val result = FluidUtil.interactWithFluidHandler(stack, te.getCapability(FLUID_HANDLER_CAPABILITY, EnumFacing.NORTH), player) - if (result.isSuccess) { - player.setHeldItem(hand, result.getResult()) - te.save() + val res = FluidUtil.interactWithFluidHandler(player, hand, world, pos, side) + if (res) { + getTileEntity(world, pos).save() } } return true } - override fun addInformation(stack: ItemStack, player: EntityPlayer, tooltip: MutableList, advanced: Boolean) { + override fun addInformation(stack: ItemStack, world: World?, tooltip: MutableList, flag: ITooltipFlag) { tooltip.add(I18n.format("tile.extrahoppers:fluid_hopper.tooltip")) } diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/block/fluid/TESRFluidHopper.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/block/fluid/TESRFluidHopper.kt index 28f57cb..36183a5 100644 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/block/fluid/TESRFluidHopper.kt +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/block/fluid/TESRFluidHopper.kt @@ -15,7 +15,7 @@ import org.lwjgl.opengl.GL11 */ object TESRFluidHopper: TileEntitySpecialRenderer() { - override fun renderTileEntityAt(te: TileEntityFluidHopper, x: Double, y: Double, z: Double, partialTicks: Float, destroyStage: Int) { + override fun renderTileEntityAt(te: TileEntityFluidHopper, x: Double, y: Double, z: Double, partialTicks: Float, destroyStage: Int, alpha: Float) { val pos = if (te.inverted) te.pos.down() else te.pos.up() if (te.tank.fluid != null && !te.world.getBlockState(pos).isSideSolid(te.world, pos, EnumFacing.DOWN)) { diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/block/fluid/TileEntityFluidHopper.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/block/fluid/TileEntityFluidHopper.kt index 7b8f231..15006da 100644 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/block/fluid/TileEntityFluidHopper.kt +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/block/fluid/TileEntityFluidHopper.kt @@ -123,7 +123,7 @@ open class TileEntityFluidHopper(inverted: Boolean): TileEntityHopperBase(invert val pickupPos = if (inverted) pos.down() else pos.up() if (FluidUtils.isFluidBlock(world, pickupPos)) { val toDrain = FluidUtils.drainFluidBlock(world, pickupPos, false)!! - if (toDrain.amount <= tank.capacity - tank.fluidAmount && tank.fill(toDrain, false) === 1000) { + if (toDrain.amount <= tank.capacity - tank.fluidAmount && tank.fill(toDrain, false) == 1000) { tank.fill(FluidUtils.drainFluidBlock(world, pickupPos, true), true) return true } diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/block/inverted/TileEntityInvertedHopper.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/block/inverted/TileEntityInvertedHopper.kt index 75b2edc..e90db01 100644 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/block/inverted/TileEntityInvertedHopper.kt +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/block/inverted/TileEntityInvertedHopper.kt @@ -91,13 +91,13 @@ class TileEntityInvertedHopper: TileEntityHopperBase(true), ITickable { val items = world.getEntitiesWithinAABB(EntityItem::class.java, AxisAlignedBB(pos.x.toDouble(), pos.y - 0.5, pos.z.toDouble(), pos.x + 1.0, pos.y + 0.5, pos.z + 1.0)) for (item in items) { for (slot in 0.until(inventory.slots)) { - val result = inventory.insertItem(slot, item.entityItem, true) - if (result.count != item.entityItem.count) { - inventory.insertItem(slot, item.entityItem, false) + val result = inventory.insertItem(slot, item.item, true) + if (result.count != item.item.count) { + inventory.insertItem(slot, item.item, false) if (result.isEmpty) { item.setDead() } else { - item.setEntityItemStack(result) + item.item = result } return true } diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/block/wooden/TileEntityWoodenHopper.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/block/wooden/TileEntityWoodenHopper.kt index 9c7aef8..b9cd3a1 100644 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/block/wooden/TileEntityWoodenHopper.kt +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/block/wooden/TileEntityWoodenHopper.kt @@ -86,13 +86,13 @@ class TileEntityWoodenHopper(inverted: Boolean): TileEntityHopperBase(inverted), val yOffset = if (inverted) -1 else 0 val items = world.getEntitiesWithinAABB(EntityItem::class.java, AxisAlignedBB(pos.x.toDouble(), pos.y + 0.5 + yOffset, pos.z.toDouble(), pos.x + 1.0, pos.y + 1.5 + yOffset, pos.z + 1.0)) for (item in items) { - val result = inventory.insertItem(0, item.entityItem, true) - if (result.count != item.entityItem.count) { - inventory.insertItem(0, item.entityItem, false) + val result = inventory.insertItem(0, item.item, true) + if (result.count != item.item.count) { + inventory.insertItem(0, item.item, false) if (result.isEmpty) { item.setDead() } else { - item.setEntityItemStack(result) + item.item = result } return true } diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/block/wooden_fluid/BlockWoodenFluidHopper.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/block/wooden_fluid/BlockWoodenFluidHopper.kt index 8c4daa8..f78e579 100644 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/block/wooden_fluid/BlockWoodenFluidHopper.kt +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/block/wooden_fluid/BlockWoodenFluidHopper.kt @@ -3,6 +3,7 @@ package net.shadowfacts.extrahoppers.block.wooden_fluid import net.minecraft.block.SoundType import net.minecraft.block.material.Material import net.minecraft.block.state.IBlockState +import net.minecraft.client.util.ITooltipFlag import net.minecraft.entity.player.EntityPlayer import net.minecraft.item.ItemStack import net.minecraft.util.EnumFacing @@ -35,7 +36,7 @@ class BlockWoodenFluidHopper(inverted: Boolean): BlockFluidHopper(inverted, name } } - override fun addInformation(stack: ItemStack, player: EntityPlayer, tooltip: MutableList, advanced: Boolean) { + override fun addInformation(stack: ItemStack, world: World?, tooltip: MutableList, flag: ITooltipFlag) { } override fun createTileEntity(world: World, state: IBlockState): TileEntityFluidHopper { diff --git a/src/main/kotlin/net/shadowfacts/extrahoppers/gui/EHGUIFactory.kt b/src/main/kotlin/net/shadowfacts/extrahoppers/gui/EHGUIFactory.kt index 826774d..eeb8400 100644 --- a/src/main/kotlin/net/shadowfacts/extrahoppers/gui/EHGUIFactory.kt +++ b/src/main/kotlin/net/shadowfacts/extrahoppers/gui/EHGUIFactory.kt @@ -9,20 +9,17 @@ import net.minecraftforge.fml.client.IModGuiFactory */ class EHGUIFactory: IModGuiFactory { - override fun initialize(minecraftInstance: Minecraft) { + override fun initialize(minecraftInstance: Minecraft) {} - } + override fun hasConfigGui() = true - override fun mainConfigGuiClass(): Class { - return EHConfigGUI::class.java - } + override fun createConfigGui(parentScreen: GuiScreen) = EHConfigGUI(parentScreen) - override fun runtimeGuiCategories(): Set? { - return null - } + @Deprecated("") + override fun mainConfigGuiClass() = EHConfigGUI::class.java - override fun getHandlerFor(element: IModGuiFactory.RuntimeOptionCategoryElement): IModGuiFactory.RuntimeOptionGuiHandler? { - return null - } + override fun runtimeGuiCategories() = null + + override fun getHandlerFor(element: IModGuiFactory.RuntimeOptionCategoryElement) = null } diff --git a/src/main/resources/assets/extrahoppers/recipes/fluid_hopper.json b/src/main/resources/assets/extrahoppers/recipes/fluid_hopper.json new file mode 100644 index 0000000..029d427 --- /dev/null +++ b/src/main/resources/assets/extrahoppers/recipes/fluid_hopper.json @@ -0,0 +1,20 @@ +{ + "type": "forge:ore_shaped", + "pattern": [ + "I I", + "I I", + " B " + ], + "key": { + "I": { + "type": "forge:ore_dict", + "ore": "ingotIron" + }, + "B": { + "item": "minecraft:bucket" + } + }, + "result": { + "item": "extrahoppers:fluid_hopper" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/extrahoppers/recipes/invert_fluid_hopper.json b/src/main/resources/assets/extrahoppers/recipes/invert_fluid_hopper.json new file mode 100644 index 0000000..699ead9 --- /dev/null +++ b/src/main/resources/assets/extrahoppers/recipes/invert_fluid_hopper.json @@ -0,0 +1,11 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "extrahoppers:fluid_hopper" + } + ], + "result": { + "item": "extrahoppers:inverted_fluid_hopper" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/extrahoppers/recipes/invert_hopper.json b/src/main/resources/assets/extrahoppers/recipes/invert_hopper.json new file mode 100644 index 0000000..d696220 --- /dev/null +++ b/src/main/resources/assets/extrahoppers/recipes/invert_hopper.json @@ -0,0 +1,11 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "minecraft:hopper" + } + ], + "result": { + "item": "extrahoppers:inverted_hopper" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/extrahoppers/recipes/invert_wooden_fluid_hopper.json b/src/main/resources/assets/extrahoppers/recipes/invert_wooden_fluid_hopper.json new file mode 100644 index 0000000..2e5b37c --- /dev/null +++ b/src/main/resources/assets/extrahoppers/recipes/invert_wooden_fluid_hopper.json @@ -0,0 +1,11 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "extrahoppers:wooden_fluid_hopper" + } + ], + "result": { + "item": "extrahoppers:inverted_wooden_fluid_hopper" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/extrahoppers/recipes/invert_wooden_hopper.json b/src/main/resources/assets/extrahoppers/recipes/invert_wooden_hopper.json new file mode 100644 index 0000000..5354ec9 --- /dev/null +++ b/src/main/resources/assets/extrahoppers/recipes/invert_wooden_hopper.json @@ -0,0 +1,11 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "extrahoppers:wooden_hopper" + } + ], + "result": { + "item": "extrahoppers:inverted_wooden_hopper" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/extrahoppers/recipes/uninvert_fluid_hopper.json b/src/main/resources/assets/extrahoppers/recipes/uninvert_fluid_hopper.json new file mode 100644 index 0000000..7082eb7 --- /dev/null +++ b/src/main/resources/assets/extrahoppers/recipes/uninvert_fluid_hopper.json @@ -0,0 +1,11 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "extrahoppers:inverted_fluid_hopper" + } + ], + "result": { + "item": "extrahoppers:fluid_hopper" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/extrahoppers/recipes/uninvert_hopper.json b/src/main/resources/assets/extrahoppers/recipes/uninvert_hopper.json new file mode 100644 index 0000000..c0c569e --- /dev/null +++ b/src/main/resources/assets/extrahoppers/recipes/uninvert_hopper.json @@ -0,0 +1,11 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "extrahoppers:inverted_hopper" + } + ], + "result": { + "item": "minecraft:hopper" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/extrahoppers/recipes/uninvert_wooden_fluid_hopper.json b/src/main/resources/assets/extrahoppers/recipes/uninvert_wooden_fluid_hopper.json new file mode 100644 index 0000000..7c6065d --- /dev/null +++ b/src/main/resources/assets/extrahoppers/recipes/uninvert_wooden_fluid_hopper.json @@ -0,0 +1,11 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "extrahoppers:inverted_wooden_fluid_hopper" + } + ], + "result": { + "item": "extrahoppers:wooden_fluid_hopper" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/extrahoppers/recipes/uninvert_wooden_hopper.json b/src/main/resources/assets/extrahoppers/recipes/uninvert_wooden_hopper.json new file mode 100644 index 0000000..339c6f8 --- /dev/null +++ b/src/main/resources/assets/extrahoppers/recipes/uninvert_wooden_hopper.json @@ -0,0 +1,11 @@ +{ + "type": "minecraft:crafting_shapeless", + "ingredients": [ + { + "item": "extrahoppers:inverted_wooden_hopper" + } + ], + "result": { + "item": "extrahoppers:wooden_hopper" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/extrahoppers/recipes/wooden_fluid_hopper.json b/src/main/resources/assets/extrahoppers/recipes/wooden_fluid_hopper.json new file mode 100644 index 0000000..33a6d72 --- /dev/null +++ b/src/main/resources/assets/extrahoppers/recipes/wooden_fluid_hopper.json @@ -0,0 +1,20 @@ +{ + "type": "forge:ore_shaped", + "pattern": [ + "W W", + "W W", + " B " + ], + "key": { + "W": { + "type": "forge:ore_dict", + "ore": "plankWood" + }, + "B": { + "item": "minecraft:bucket" + } + }, + "result": { + "item": "extrahoppers:wooden_fluid_hopper" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/extrahoppers/recipes/wooden_hopper.json b/src/main/resources/assets/extrahoppers/recipes/wooden_hopper.json new file mode 100644 index 0000000..7202ec2 --- /dev/null +++ b/src/main/resources/assets/extrahoppers/recipes/wooden_hopper.json @@ -0,0 +1,17 @@ +{ + "type": "forge:ore_shaped", + "pattern": [ + "W W", + "W W", + " W " + ], + "key": { + "W": { + "type": "forge:ore_dict", + "ore": "plankWood" + } + }, + "result": { + "item": "extrahoppers:wooden_hopper" + } +} \ No newline at end of file