diff --git a/src/main/kotlin/org/kotobank/kuarry/block/KuarryBlock.kt b/src/main/kotlin/org/kotobank/kuarry/block/KuarryBlock.kt index e67c302..06f4bb3 100644 --- a/src/main/kotlin/org/kotobank/kuarry/block/KuarryBlock.kt +++ b/src/main/kotlin/org/kotobank/kuarry/block/KuarryBlock.kt @@ -18,17 +18,20 @@ import net.minecraft.util.NonNullList import net.minecraft.util.math.BlockPos import net.minecraft.world.IBlockAccess import net.minecraft.world.World -import org.kotobank.kuarry.KuarryMod -import org.kotobank.kuarry.KuarryModGUIHandler -import org.kotobank.kuarry.tile_entity.KuarryTileEntity import net.minecraft.nbt.NBTTagCompound import net.minecraft.util.text.TextFormatting +import net.minecraftforge.fml.common.Optional import net.minecraftforge.fml.relauncher.Side import net.minecraftforge.fml.relauncher.SideOnly import net.minecraftforge.items.ItemStackHandler import org.kotobank.kuarry.helper.TranslationHelper +import org.kotobank.kuarry.KuarryMod +import org.kotobank.kuarry.KuarryModGUIHandler +import org.kotobank.kuarry.tile_entity.KuarryTileEntity +import cofh.api.block.IDismantleable -class KuarryBlock(material: Material, registryName: String) : Block(material) { +@Optional.Interface(iface = "cofh.api.block.IDismantleable", modid = "cofhcore") +class KuarryBlock(material: Material, registryName: String) : Block(material), IDismantleable { companion object { val FACING: PropertyDirection = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL) @@ -152,4 +155,22 @@ class KuarryBlock(material: Material, registryName: String) : Block(material) { )) } } + + // region IDismantleable implementation + + @Optional.Method(modid = "cofhcore") + override fun canDismantle(world: World?, pos: BlockPos?, state: IBlockState?, player: EntityPlayer?) = true + + @Optional.Method(modid = "cofhcore") + override fun dismantleBlock(world: World, pos: BlockPos, state: IBlockState, player: EntityPlayer, returnDrops: Boolean): ArrayList { + val res = ItemStack.EMPTY + val te = world.getTileEntity(pos) + if (te != null) { + harvestBlock(world, player, pos, state, te, res) + } + + return arrayListOf(res) + } + + // endregion } diff --git a/src/main/kotlin/org/kotobank/kuarry/tile_entity/KuarryTileEntity.kt b/src/main/kotlin/org/kotobank/kuarry/tile_entity/KuarryTileEntity.kt index 2d8a395..606f608 100644 --- a/src/main/kotlin/org/kotobank/kuarry/tile_entity/KuarryTileEntity.kt +++ b/src/main/kotlin/org/kotobank/kuarry/tile_entity/KuarryTileEntity.kt @@ -655,6 +655,6 @@ class KuarryTileEntity : TileEntity(), ITickable { return originalBB } - // Overriden to make it not reset the TE on block rotation - override fun shouldRefresh(world: World, pos: BlockPos, oldState: IBlockState, newSate: IBlockState) = false + // Overriden to make it not reset the TE on block rotation, but update when the block actually changes + override fun shouldRefresh(world: World, pos: BlockPos, oldState: IBlockState, newSate: IBlockState) = oldState.block != newSate.block } \ No newline at end of file